Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
io_graph.h
Go to the documentation of this file.
1
10#ifndef IO_GRAPH_H
11#define IO_GRAPH_H
12
13#include <config.h>
14
15#include "graph.h"
16
17#include <wsutil/str_util.h>
18#include <ui/io_graph_item.h>
19
20#include "wireshark_dialog.h"
21
22#include <vector>
23
24class QCPBars;
25class QCPGraph;
26class QCustomPlot;
27
28// Scale factor to convert the units the interval is stored in to seconds.
29// Must match what get_io_graph_index() in io_graph_item expects.
30// Increase this in order to make smaller intervals possible.
31const int SCALE = 1000000;
32const double SCALE_F = (double)SCALE;
33
34static const value_string y_axis_packet_vs[] = {
35 { IOG_ITEM_UNIT_PACKETS, "Packets" },
36 { IOG_ITEM_UNIT_BYTES, "Bytes" },
37 { IOG_ITEM_UNIT_BITS, "Bits" },
38 { IOG_ITEM_UNIT_CALC_SUM, "SUM(Y Field)" },
39 { IOG_ITEM_UNIT_CALC_FRAMES, "COUNT FRAMES(Y Field)" },
40 { IOG_ITEM_UNIT_CALC_FIELDS, "COUNT FIELDS(Y Field)" },
41 { IOG_ITEM_UNIT_CALC_MAX, "MAX(Y Field)" },
42 { IOG_ITEM_UNIT_CALC_MIN, "MIN(Y Field)" },
43 { IOG_ITEM_UNIT_CALC_AVERAGE, "AVG(Y Field)" },
44 { IOG_ITEM_UNIT_CALC_THROUGHPUT, "THROUGHPUT(Y Field)" },
45 { IOG_ITEM_UNIT_CALC_LOAD, "LOAD(Y Field)" },
46 { 0, NULL }
47};
48
49static const value_string y_axis_event_vs[] = {
50 { IOG_ITEM_UNIT_PACKETS, "Events" },
51 y_axis_packet_vs[1],
52 y_axis_packet_vs[2],
53 y_axis_packet_vs[3],
54 y_axis_packet_vs[4],
55 y_axis_packet_vs[5],
56 y_axis_packet_vs[6],
57 y_axis_packet_vs[7],
58 y_axis_packet_vs[8],
59 y_axis_packet_vs[9],
60 { 0, NULL }
61};
62
63class IOGraph : public Graph {
64 Q_OBJECT
65public:
66 explicit IOGraph(QCustomPlot* parent);
67 ~IOGraph();
68 QString configError() const { return config_err_; }
69 void setAOT(bool asAOT);
70 bool getAOT() const { return asAOT_; }
71 QString filter() const { return filter_; }
72 bool setFilter(const QString& filter);
73 void setVisible(bool visible);
74 bool needRetap() const { return need_retap_; }
75 void setNeedRetap(bool retap);
76 void setPlotStyle(PlotStyles style);
77 QString valueUnitLabel() const;
78 format_size_units_e formatUnits() const;
79 io_graph_item_unit_t valueUnits() const { return val_units_; }
80 void setValueUnits(int val_units);
81 QString valueUnitField() const { return vu_field_; }
82 void setValueUnitField(const QString& vu_field);
83 nstime_t startTime() const;
84 unsigned int movingAveragePeriod() const { return moving_avg_period_; }
85 void setInterval(int interval);
86 int packetFromTime(double ts) const;
87 bool hasItemToShow(int idx, double value) const;
88 double getItemValue(int idx, const capture_file* cap_file) const;
89 int maxInterval() const { return cur_idx_; }
90
91 void clearAllData();
92
93 unsigned int moving_avg_period_;
94
95public slots:
96 void recalcGraphData(capture_file* cap_file);
97 void captureEvent(const CaptureEvent& e);
98 void reloadValueUnitField();
99
100signals:
101 void requestReplot();
102 void requestRecalc();
103 void requestRetap();
104
105private:
106 // Callbacks for register_tap_listener
107 static void tapReset(void* iog_ptr);
108 static tap_packet_status tapPacket(void* iog_ptr, packet_info* pinfo, epan_dissect_t* edt, const void* data, tap_flags_t flags);
109 static void tapDraw(void* iog_ptr);
110
111 void removeTapListener();
112
113 bool showsZero() const;
114 double startOffset() const;
115
116 template<class DataMap> double maxValueFromGraphData(const DataMap& map);
117 template<class DataMap> void scaleGraphData(DataMap& map, int scalar);
118
119 QString config_err_;
120 bool tap_registered_;
121 bool need_retap_;
122 QString filter_;
123 QString full_filter_; // Includes vu_field_ if used
124 io_graph_item_unit_t val_units_;
125 QString vu_field_;
126 nstime_t start_time_;
127 int hf_index_;
128 int interval_;
129 bool asAOT_; // Average Over Time interpretation
130
131 // Cached data. We should be able to change the Y axis without retapping as
132 // much as is feasible.
133 std::vector<io_graph_item_t> items_;
134 int cur_idx_;
135};
136
137#endif // IO_GRAPH_H
Definition capture_event.h:21
Definition graph.h:22
Definition io_graph.h:63
format_size_units_e
Definition str_util.h:231
Definition cfile.h:67
Definition packet_info.h:43
Definition value_string.h:26
Definition epan_dissect.h:28
Definition nstime.h:26
tap_packet_status
Definition tap.h:25