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
66class IOGraph : public Graph {
67 Q_OBJECT
68public:
74 explicit IOGraph(QCustomPlot* parent, const char* type_unit_name);
75
79 ~IOGraph();
80
85 QString configError() const { return config_err_; }
86
91 void setAOT(bool asAOT);
92
97 bool getAOT() const { return asAOT_; }
98
103 QString filter() const { return filter_; }
104
110 bool setFilter(const QString& filter);
111
116 void setVisible(bool visible);
117
122 bool needRetap() const { return need_retap_; }
123
128 void setNeedRetap(bool retap);
129
134 void setPlotStyle(PlotStyles style);
135
140 QString valueUnitLabel() const;
141
147
152 io_graph_item_unit_t valueUnits() const { return val_units_; }
153
158 void setValueUnits(int val_units);
159
164 QString valueUnitField() const { return vu_field_; }
165
170 void setValueUnitField(const QString& vu_field);
171
176 nstime_t startTime() const;
177
182 unsigned int movingAveragePeriod() const { return moving_avg_period_; }
183
188 void setInterval(int interval);
189
195 int packetFromTime(double ts) const;
196
203 bool hasItemToShow(int idx, double value) const;
204
211 double getItemValue(int idx, const capture_file* cap_file) const;
212
217 int maxInterval() const { return cur_idx_; }
218
222 void clearAllData();
223
225 unsigned int moving_avg_period_;
226
227public slots:
232 void recalcGraphData(capture_file* cap_file);
233
238 void captureEvent(const CaptureEvent& e);
239
244
245signals:
250
255
260
261private:
262 // Callbacks for register_tap_listener
267 static void tapReset(void* iog_ptr);
268
278 static tap_packet_status tapPacket(void* iog_ptr, packet_info* pinfo, epan_dissect_t* edt, const void* data, tap_flags_t flags);
279
284 static void tapDraw(void* iog_ptr);
285
289 void removeTapListener();
290
295 bool showsZero() const;
296
301 double startOffset() const;
302
308 template<class DataMap> double maxValueFromGraphData(const DataMap& map);
309
315 template<class DataMap> void scaleGraphData(DataMap& map, int scalar);
316
318 QString config_err_;
319
321 bool tap_registered_;
322
324 bool need_retap_;
325
327 QString filter_;
328
330 QString full_filter_; // Includes vu_field_ if used
331
333 io_graph_item_unit_t val_units_;
334
336 QString vu_field_;
337
339 nstime_t start_time_;
340
342 int hf_index_;
343
345 int interval_;
346
348 bool asAOT_; // Average Over Time interpretation
349
351 const char* type_unit_name_;
352
357 std::vector<io_graph_item_t> items_;
358
360 int cur_idx_;
361};
362
363#endif // IO_GRAPH_H
Represents an event occurring during a capture or file operation.
Definition capture_event.h:24
Represents a single data graph within a QCustomPlot, managing its data, visual style,...
Definition graph.h:25
PlotStyles
Defines the available visual styles for plotting data.
Definition graph.h:37
bool visible() const
Checks if the graph is currently visible.
Definition graph.h:94
Represents an individual input/output graph, handling tapping, packet processing, and data scaling.
Definition io_graph.h:66
bool setFilter(const QString &filter)
Sets the filter string for this graph.
Definition io_graph.cpp:78
void setValueUnits(int val_units)
Sets the core IO graph item unit type.
Definition io_graph.cpp:229
QString filter() const
Retrieves the active filter string for this graph.
Definition io_graph.h:103
void setAOT(bool asAOT)
Sets whether the graph displays values as an Average Over Time (AOT).
Definition io_graph.cpp:153
void clearAllData()
Clears all cached plotting and tap data.
Definition io_graph.cpp:320
void recalcGraphData(capture_file *cap_file)
Recalculates the graph plotting data based on cached tap data.
Definition io_graph.cpp:330
QString valueUnitLabel() const
Generates the label for the value (Y-axis) units.
Definition io_graph.cpp:221
void setInterval(int interval)
Sets the time interval for data bucketing.
Definition io_graph.cpp:557
io_graph_item_unit_t valueUnits() const
Retrieves the core IO graph item unit type.
Definition io_graph.h:152
~IOGraph()
Destroys the IOGraph.
Definition io_graph.cpp:64
void requestRecalc()
Signal emitted to request a recalculation of the graph data.
void requestRetap()
Signal emitted to request a full retap of the packet data.
unsigned int moving_avg_period_
Definition io_graph.h:225
void setVisible(bool visible)
Sets the visibility of the graph.
Definition io_graph.cpp:168
QString valueUnitField() const
Retrieves the field used to calculate the value units (e.g., specific protocol field).
Definition io_graph.h:164
int packetFromTime(double ts) const
Determines the packet number closest to a specific timestamp.
Definition io_graph.cpp:304
void requestReplot()
Signal emitted to request a UI redraw of the parent plot.
void setValueUnitField(const QString &vu_field)
Sets the field used to calculate the value units.
Definition io_graph.cpp:256
nstime_t startTime() const
Retrieves the starting time of the graph data.
Definition io_graph.cpp:293
void reloadValueUnitField()
Reloads and re-evaluates the value unit field setting.
Definition io_graph.cpp:476
void captureEvent(const CaptureEvent &e)
Handles system capture events.
Definition io_graph.cpp:467
bool getAOT() const
Checks if the graph displays values as an Average Over Time (AOT).
Definition io_graph.h:97
void setNeedRetap(bool retap)
Manually flags whether a retap is required.
Definition io_graph.cpp:190
bool needRetap() const
Checks if changing the graph configuration requires a packet retap.
Definition io_graph.h:122
void setPlotStyle(PlotStyles style)
Sets the visual plotting style for this specific IO graph.
Definition io_graph.cpp:200
format_size_units_e formatUnits() const
Retrieves the size formatting enumerator for the Y-axis units.
Definition io_graph.cpp:405
unsigned int movingAveragePeriod() const
Retrieves the period used for moving average calculations.
Definition io_graph.h:182
int maxInterval() const
Retrieves the maximum populated interval index.
Definition io_graph.h:217
bool hasItemToShow(int idx, double value) const
Checks if a specific data item index has a valid value to display.
Definition io_graph.cpp:516
QString configError() const
Retrieves the current configuration error string, if any.
Definition io_graph.h:85
double getItemValue(int idx, const capture_file *cap_file) const
Calculates or retrieves the formatted value for a specific data item index.
Definition io_graph.cpp:566
io_graph_item_unit_t
Selects the Y-axis value unit or aggregate calculation mode for an I/O graph plot.
Definition io_graph_item.h:29
@ IOG_ITEM_UNIT_CALC_FIELDS
Definition io_graph_item.h:36
@ IOG_ITEM_UNIT_BITS
Definition io_graph_item.h:33
@ IOG_ITEM_UNIT_CALC_SUM
Definition io_graph_item.h:34
@ IOG_ITEM_UNIT_CALC_MIN
Definition io_graph_item.h:38
@ IOG_ITEM_UNIT_CALC_THROUGHPUT
Definition io_graph_item.h:40
@ IOG_ITEM_UNIT_BYTES
Definition io_graph_item.h:32
@ IOG_ITEM_UNIT_CALC_FRAMES
Definition io_graph_item.h:35
@ IOG_ITEM_UNIT_PACKETS
Definition io_graph_item.h:31
@ IOG_ITEM_UNIT_CALC_LOAD
Definition io_graph_item.h:41
@ IOG_ITEM_UNIT_CALC_MAX
Definition io_graph_item.h:37
@ IOG_ITEM_UNIT_CALC_AVERAGE
Definition io_graph_item.h:39
format_size_units_e
Unit types used by format_size_wmem() for formatting size values.
Definition str_util.h:327
Represents a capture file and its associated metadata.
Definition cfile.h:84
Represents the metadata and indexing information for a single captured frame.
Definition packet_info.h:43
Mapping between a 32-bit integer value and its string representation.
Definition value_string.h:33
Holds all state for the dissection of a single byte array, including session, buffer,...
Definition epan_dissect.h:28
Definition nstime.h:26
tap_packet_status
Definition tap.h:22