1 /* tcp_stream_dialog.h 2 * 3 * Wireshark - Network traffic analyzer 4 * By Gerald Combs <gerald@wireshark.org> 5 * Copyright 1998 Gerald Combs 6 * 7 * SPDX-License-Identifier: GPL-2.0-or-later 8 */ 9 10 #ifndef TCP_STREAM_DIALOG_H 11 #define TCP_STREAM_DIALOG_H 12 13 #include <config.h> 14 15 #include <glib.h> 16 17 #include <file.h> 18 19 #include <epan/dissectors/packet-tcp.h> 20 21 #include "ui/tap-tcp-stream.h" 22 23 #include "geometry_state_dialog.h" 24 25 #include <ui/qt/widgets/qcustomplot.h> 26 #include <QMenu> 27 #include <QRubberBand> 28 #include <QTimer> 29 30 namespace Ui { 31 class TCPStreamDialog; 32 class QCPErrorBarsNotSelectable; 33 } 34 35 class QCPErrorBarsNotSelectable : public QCPErrorBars 36 { 37 Q_OBJECT 38 39 public: 40 explicit QCPErrorBarsNotSelectable(QCPAxis *keyAxis, QCPAxis *valueAxis); 41 virtual ~QCPErrorBarsNotSelectable(); 42 43 virtual double selectTest(const QPointF &pos, bool onlySelectable, QVariant *details = 0) const Q_DECL_OVERRIDE; 44 }; 45 46 class TCPStreamDialog : public GeometryStateDialog 47 { 48 Q_OBJECT 49 50 public: 51 explicit TCPStreamDialog(QWidget *parent = 0, capture_file *cf = NULL, tcp_graph_type graph_type = GRAPH_TSEQ_TCPTRACE); 52 ~TCPStreamDialog(); 53 54 signals: 55 void goToPacket(int packet_num); 56 57 public slots: 58 void setCaptureFile(capture_file *cf); 59 void updateGraph(); 60 61 protected: 62 void showEvent(QShowEvent *event); 63 void keyPressEvent(QKeyEvent *event); 64 void mousePressEvent(QMouseEvent *event); 65 void mouseReleaseEvent(QMouseEvent *event); 66 67 private: 68 Ui::TCPStreamDialog *ui; 69 capture_file *cap_file_; 70 QMultiMap<double, struct segment *> time_stamp_map_; 71 double ts_offset_; 72 bool ts_origin_conn_; 73 QMap<double, struct segment *> sequence_num_map_; 74 double seq_offset_; 75 bool seq_origin_zero_; 76 struct tcp_graph graph_; 77 QCPTextElement *title_; 78 QString stream_desc_; 79 QCPGraph *base_graph_; // Clickable packets 80 QCPGraph *tput_graph_; 81 QCPGraph *goodput_graph_; 82 QCPGraph *seg_graph_; 83 QCPErrorBars *seg_eb_; 84 QCPGraph *ack_graph_; 85 QCPGraph *sack_graph_; 86 QCPErrorBars *sack_eb_; 87 QCPGraph *sack2_graph_; 88 QCPErrorBars *sack2_eb_; 89 QCPGraph *rwin_graph_; 90 QCPGraph *dup_ack_graph_; 91 QCPGraph *zero_win_graph_; 92 QCPItemTracer *tracer_; 93 QRectF axis_bounds_; 94 guint32 packet_num_; 95 QTransform y_axis_xfrm_; 96 bool mouse_drags_; 97 QRubberBand *rubber_band_; 98 QPoint rb_origin_; 99 QMenu ctx_menu_; 100 101 class GraphUpdater { 102 public: 103 GraphUpdater(TCPStreamDialog *dialog) : 104 dialog_(dialog), 105 graph_update_timer_(NULL), 106 reset_axes_(false) {} 107 void triggerUpdate(int timeout, bool reset_axes = false); 108 void clearPendingUpdate(); 109 void doUpdate(); 110 bool hasPendingUpdate() { return graph_update_timer_ != NULL; } 111 private: 112 TCPStreamDialog *dialog_; 113 QTimer *graph_update_timer_; 114 bool reset_axes_; 115 }; 116 friend class GraphUpdater; 117 GraphUpdater graph_updater_; 118 119 int num_dsegs_; 120 int num_acks_; 121 int num_sack_ranges_; 122 123 double ma_window_size_; 124 125 void findStream(); 126 void fillGraph(bool reset_axes = true, bool set_focus = true); 127 void showWidgetsForGraphType(); 128 void zoomAxes(bool in); 129 void zoomXAxis(bool in); 130 void zoomYAxis(bool in); 131 void panAxes(int x_pixels, int y_pixels); 132 void resetAxes(); 133 void fillStevens(); 134 void fillTcptrace(); 135 void fillThroughput(); 136 void fillRoundTripTime(); 137 void fillWindowScale(); 138 QString streamDescription(); 139 bool compareHeaders(struct segment *seg); 140 void toggleTracerStyle(bool force_default = false); 141 QRectF getZoomRanges(QRect zoom_rect); 142 143 private slots: 144 void graphClicked(QMouseEvent *event); 145 void axisClicked(QCPAxis *axis, QCPAxis::SelectablePart part, QMouseEvent *event); 146 void mouseMoved(QMouseEvent *event); 147 void mouseReleased(QMouseEvent *event); 148 void transformYRange(const QCPRange &y_range1); 149 void on_buttonBox_accepted(); 150 void on_graphTypeComboBox_currentIndexChanged(int index); 151 void on_resetButton_clicked(); 152 void on_streamNumberSpinBox_valueChanged(int new_stream); 153 void on_streamNumberSpinBox_editingFinished(); 154 void on_maWindowSizeSpinBox_valueChanged(double new_ma_size); 155 void on_maWindowSizeSpinBox_editingFinished(); 156 void on_selectSACKsCheckBox_stateChanged(int state); 157 void on_otherDirectionButton_clicked(); 158 void on_dragRadioButton_toggled(bool checked); 159 void on_zoomRadioButton_toggled(bool checked); 160 void on_bySeqNumberCheckBox_stateChanged(int state); 161 void on_showSegLengthCheckBox_stateChanged(int state); 162 void on_showThroughputCheckBox_stateChanged(int state); 163 void on_showGoodputCheckBox_stateChanged(int state); 164 void on_showRcvWinCheckBox_stateChanged(int state); 165 void on_showBytesOutCheckBox_stateChanged(int state); 166 void on_actionZoomIn_triggered(); 167 void on_actionZoomInX_triggered(); 168 void on_actionZoomInY_triggered(); 169 void on_actionZoomOut_triggered(); 170 void on_actionZoomOutX_triggered(); 171 void on_actionZoomOutY_triggered(); 172 void on_actionReset_triggered(); 173 void on_actionMoveRight10_triggered(); 174 void on_actionMoveLeft10_triggered(); 175 void on_actionMoveUp10_triggered(); 176 void on_actionMoveDown10_triggered(); 177 void on_actionMoveRight1_triggered(); 178 void on_actionMoveLeft1_triggered(); 179 void on_actionMoveUp1_triggered(); 180 void on_actionMoveDown1_triggered(); 181 void on_actionNextStream_triggered(); 182 void on_actionPreviousStream_triggered(); 183 void on_actionSwitchDirection_triggered(); 184 void on_actionGoToPacket_triggered(); 185 void on_actionDragZoom_triggered(); 186 void on_actionToggleSequenceNumbers_triggered(); 187 void on_actionToggleTimeOrigin_triggered(); 188 void on_actionRoundTripTime_triggered(); 189 void on_actionThroughput_triggered(); 190 void on_actionStevens_triggered(); 191 void on_actionTcptrace_triggered(); 192 void on_actionWindowScaling_triggered(); 193 void on_buttonBox_helpRequested(); 194 }; 195 196 #endif // TCP_STREAM_DIALOG_H 197