A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
flow-probe.h
Go to the documentation of this file.
1//
2// Copyright (c) 2009 INESC Porto
3//
4// SPDX-License-Identifier: GPL-2.0-only
5//
6// Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> <gjcarneiro@gmail.com>
7//
8
9#ifndef FLOW_PROBE_H
10#define FLOW_PROBE_H
11
12#include "flow-classifier.h"
13
14#include "ns3/nstime.h"
15#include "ns3/object.h"
16
17#include <map>
18#include <vector>
19
20namespace ns3
21{
22
23class FlowMonitor;
24
25/// The FlowProbe class is responsible for listening for packet events
26/// in a specific point of the simulated space, report those events to
27/// the global FlowMonitor, and collect its own flow statistics
28/// regarding only the packets that pass through that probe.
29class FlowProbe : public Object
30{
31 protected:
32 /// Constructor
33 /// \param flowMonitor the FlowMonitor this probe is associated with
34 FlowProbe(Ptr<FlowMonitor> flowMonitor);
35 void DoDispose() override;
36
37 public:
38 ~FlowProbe() override;
39
40 // Delete copy constructor and assignment operator to avoid misuse
41 FlowProbe(const FlowProbe&) = delete;
42 FlowProbe& operator=(const FlowProbe&) = delete;
43
44 /// Register this type.
45 /// \return The TypeId.
46 static TypeId GetTypeId();
47
48 /// Structure to hold the statistics of a flow
49 struct FlowStats
50 {
53 bytes(0),
54 packets(0)
55 {
56 }
57
58 /// packetsDropped[reasonCode] => number of dropped packets
59 std::vector<uint32_t> packetsDropped;
60 /// bytesDropped[reasonCode] => number of dropped bytes
61 std::vector<uint64_t> bytesDropped;
62 /// divide by 'packets' to get the average delay from the
63 /// first (entry) probe up to this one (partial delay)
65 /// Number of bytes seen of this flow
66 uint64_t bytes;
67 /// Number of packets seen of this flow
69 };
70
71 /// Container to map FlowId -> FlowStats
72 typedef std::map<FlowId, FlowStats> Stats;
73
74 /// Add a packet data to the flow stats
75 /// \param flowId the flow Identifier
76 /// \param packetSize the packet size
77 /// \param delayFromFirstProbe packet delay
78 void AddPacketStats(FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe);
79 /// Add a packet drop data to the flow stats
80 /// \param flowId the flow Identifier
81 /// \param packetSize the packet size
82 /// \param reasonCode reason code for the drop
83 void AddPacketDropStats(FlowId flowId, uint32_t packetSize, uint32_t reasonCode);
84
85 /// Get the partial flow statistics stored in this probe. With this
86 /// information you can, for example, find out what is the delay
87 /// from the first probe to this one.
88 /// \returns the partial flow statistics
89 Stats GetStats() const;
90
91 /// Serializes the results to an std::ostream in XML format
92 /// \param os the output stream
93 /// \param indent number of spaces to use as base indentation level
94 /// \param index FlowProbe index
95 void SerializeToXmlStream(std::ostream& os, uint16_t indent, uint32_t index) const;
96
97 protected:
98 Ptr<FlowMonitor> m_flowMonitor; //!< the FlowMonitor instance
99 Stats m_stats; //!< The flow stats
100};
101
102} // namespace ns3
103
104#endif /* FLOW_PROBE_H */
The FlowProbe class is responsible for listening for packet events in a specific point of the simulat...
Definition flow-probe.h:30
FlowProbe & operator=(const FlowProbe &)=delete
Stats m_stats
The flow stats.
Definition flow-probe.h:99
void AddPacketStats(FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe)
Add a packet data to the flow stats.
Definition flow-probe.cc:45
FlowProbe(Ptr< FlowMonitor > flowMonitor)
Constructor.
Definition flow-probe.cc:31
void DoDispose() override
Destructor implementation.
Definition flow-probe.cc:38
void AddPacketDropStats(FlowId flowId, uint32_t packetSize, uint32_t reasonCode)
Add a packet drop data to the flow stats.
Definition flow-probe.cc:54
std::map< FlowId, FlowStats > Stats
Container to map FlowId -> FlowStats.
Definition flow-probe.h:72
Stats GetStats() const
Get the partial flow statistics stored in this probe.
Definition flow-probe.cc:68
FlowProbe(const FlowProbe &)=delete
static TypeId GetTypeId()
Register this type.
Definition flow-probe.cc:18
void SerializeToXmlStream(std::ostream &os, uint16_t indent, uint32_t index) const
Serializes the results to an std::ostream in XML format.
Definition flow-probe.cc:74
Ptr< FlowMonitor > m_flowMonitor
the FlowMonitor instance
Definition flow-probe.h:98
~FlowProbe() override
Definition flow-probe.cc:27
A base class which provides memory management and object aggregation.
Definition object.h:78
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:48
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition nstime.h:1308
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Structure to hold the statistics of a flow.
Definition flow-probe.h:50
uint64_t bytes
Number of bytes seen of this flow.
Definition flow-probe.h:66
uint32_t packets
Number of packets seen of this flow.
Definition flow-probe.h:68
Time delayFromFirstProbeSum
divide by 'packets' to get the average delay from the first (entry) probe up to this one (partial del...
Definition flow-probe.h:64
std::vector< uint32_t > packetsDropped
packetsDropped[reasonCode] => number of dropped packets
Definition flow-probe.h:59
std::vector< uint64_t > bytesDropped
bytesDropped[reasonCode] => number of dropped bytes
Definition flow-probe.h:61
static const uint32_t packetSize
Packet size generated at the AP.