GUI-thread facade that owns the interface-statistics sampler and is the single source of truth for per-interface history.
More...
#include <interface_statistics.h>
|
| void | start () |
| | Begins sampling: opens the dumpcap statistics stream via the worker.
|
|
void | stop () |
| | Stops sampling and tears down the dumpcap stream.
|
| void | pauseSampling () |
| | Temporarily suspends sampling (e.g. while a capture is active).
|
|
void | resumeSampling () |
| | Resumes sampling previously suspended with pauseSampling().
|
| void | setUpdateInterval (int intervalMsec) |
| | Sets the sampling interval and forwards it to the worker.
|
| void | setInterfaceFilter (const QStringList &interfaceNames) |
| | Restricts which interfaces are sampled/emitted (empty = all).
|
| void | removeInterfaces (const QStringList &removedInterfaceNames) |
| | Drops all retained state for the given (vanished) interfaces.
|
| void | resetActivity () |
| | Re-evaluates interface activity, e.g. on a manual interface refresh.
|
| void | setHistoryCapacity (int maxEntries) |
| | Sets the per-interface history capacity in entries.
|
|
|
void | statisticsUpdated () |
| | Emitted after a worker snapshot has been folded into the history.
|
| void | activityChanged () |
| | Emitted when the set of active interfaces changes.
|
|
| | InterfaceStatistics (QObject *parent=nullptr) |
| | Constructs the facade and starts the worker thread (idle).
|
|
| ~InterfaceStatistics () override |
| | Tears down the worker and its thread safely, then destroys.
|
| QList< int > | pointsFor (const QString &interfaceName) const |
| | Received-packet deltas for an interface, oldest to newest.
|
| QList< int > | droppedPointsFor (const QString &interfaceName) const |
| | Dropped-packet deltas for an interface, oldest to newest.
|
| bool | isActive (const QString &interfaceName) const |
| | Whether an interface is currently considered active for sorting.
|
| unsigned | rate (const QString &interfaceName) const |
| | Most recent received-packet delta for an interface.
|
|
int | updateInterval () const |
| | Returns the current sampling interval, in milliseconds.
|
|
int | historyCapacity () const |
| | Returns the per-interface history capacity, in entries.
|
|
bool | isRunning () const |
| | Returns true between start() and stop() (sampling requested).
|
GUI-thread facade that owns the interface-statistics sampler and is the single source of truth for per-interface history.
Responsibilities:
- Owns one InterfaceStatsWorker living on a dedicated QThread, with the standard finished -> deleteLater teardown.
- Receives cumulative counter snapshots from the worker (queued, cross-thread) and converts them to per-interval deltas, tolerating counter resets (e.g. after a pause/resume cycle spawns a fresh dumpcap).
- Keeps each interface's delta history in a fixed-capacity FIFO buffer so a long-running session stays bounded; history and the "active" flag survive interface-list rescans and are pruned only for interfaces that disappear.
- Latches an interface "active" once it has shown any traffic, giving a stable activity-first sort order.
All accessors and accumulated state are confined to the GUI thread; the only cross-thread interaction is the signal/slot bridge to the worker. The facade is expected to be owned by the MainWindow base class (shared by both flavors), not by MainApplication.
◆ InterfaceStatistics()
| InterfaceStatistics::InterfaceStatistics |
( |
QObject * | parent = nullptr | ) |
|
|
explicit |
Constructs the facade and starts the worker thread (idle).
Sampling does not begin until start() is called.
- Parameters
-
| parent | Optional parent QObject. |
◆ activityChanged
| void InterfaceStatistics::activityChanged |
( |
| ) |
|
|
signal |
Emitted when the set of active interfaces changes.
Distinct from statisticsUpdated() (which fires every sampling cycle): this fires only when activity actually changes, so consumers can re-sort by activity without churning on every tick.
◆ droppedPointsFor()
| QList< int > InterfaceStatistics::droppedPointsFor |
( |
const QString & | interfaceName | ) |
const |
Dropped-packet deltas for an interface, oldest to newest.
Parallel to pointsFor(); intended for future sparkline drop annotation.
- Parameters
-
| interfaceName | The interface name. |
- Returns
- The bounded drop-delta history, or an empty list if unknown.
◆ isActive()
| bool InterfaceStatistics::isActive |
( |
const QString & | interfaceName | ) |
const |
Whether an interface is currently considered active for sorting.
Set when a positive received-packet delta is observed, and held across implicit interface-list rescans and capture pause/resume so the activity-first sort order stays stable. It is re-evaluated only by resetActivity() (the hook a manual interface refresh calls), at which point an interface that has gone quiet correctly drops to inactive.
- Parameters
-
| interfaceName | The interface name. |
- Returns
- true if the interface is currently considered active.
◆ pauseSampling
| void InterfaceStatistics::pauseSampling |
( |
| ) |
|
|
slot |
Temporarily suspends sampling (e.g. while a capture is active).
Frees the dumpcap process but retains accumulated history and active flags; the diff baseline is reset so resume() does not produce a spike.
◆ pointsFor()
| QList< int > InterfaceStatistics::pointsFor |
( |
const QString & | interfaceName | ) |
const |
Received-packet deltas for an interface, oldest to newest.
This is the series drawn by the interface sparkline.
- Parameters
-
| interfaceName | The interface name. |
- Returns
- The bounded delta history, or an empty list if unknown.
◆ rate()
| unsigned InterfaceStatistics::rate |
( |
const QString & | interfaceName | ) |
const |
Most recent received-packet delta for an interface.
- Parameters
-
| interfaceName | The interface name. |
- Returns
- The latest delta, or 0 if unknown.
◆ removeInterfaces
| void InterfaceStatistics::removeInterfaces |
( |
const QStringList & | removedInterfaceNames | ) |
|
|
slot |
Drops all retained state for the given (vanished) interfaces.
Called when the interface list changes; surviving interfaces keep their history and active flag. Implicit/automatic rescans should call only this; a manual refresh additionally calls resetActivity().
- Parameters
-
| removedInterfaceNames | Interface names that no longer exist. |
◆ resetActivity
| void InterfaceStatistics::resetActivity |
( |
| ) |
|
|
slot |
Re-evaluates interface activity, e.g. on a manual interface refresh.
Clears the latched active set so that, on subsequent samples, only interfaces still showing traffic are re-marked active; interfaces that have gone quiet drop to inactive. History and diff baselines are kept. Implicit/automatic rescans should NOT call this (to avoid a spurious sort reshuffle); only a user-initiated refresh should.
◆ setHistoryCapacity
| void InterfaceStatistics::setHistoryCapacity |
( |
int | maxEntries | ) |
|
|
slot |
Sets the per-interface history capacity in entries.
- Parameters
-
| maxEntries | Maximum retained samples per interface; values < 1 are ignored. Existing buffers are trimmed to the new cap. |
◆ setInterfaceFilter
| void InterfaceStatistics::setInterfaceFilter |
( |
const QStringList & | interfaceNames | ) |
|
|
slot |
Restricts which interfaces are sampled/emitted (empty = all).
- Parameters
-
| interfaceNames | Interface names to keep. |
◆ setUpdateInterval
| void InterfaceStatistics::setUpdateInterval |
( |
int | intervalMsec | ) |
|
|
slot |
Sets the sampling interval and forwards it to the worker.
- Parameters
-
| intervalMsec | Interval in milliseconds; values < 1 are ignored. |
◆ start
| void InterfaceStatistics::start |
( |
| ) |
|
|
slot |
Begins sampling: opens the dumpcap statistics stream via the worker.
A no-op if already running.
The documentation for this class was generated from the following files:
- /builds/wireshark/wireshark/ui/qt/manager/interface_statistics.h
- /builds/wireshark/wireshark/ui/qt/manager/interface_statistics.cpp