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// This program is free software; you can redistribute it and/or modify
5// it under the terms of the GNU General Public License version 2 as
6// published by the Free Software Foundation;
7//
8// This program is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11// GNU General Public License for more details.
12//
13// You should have received a copy of the GNU General Public License
14// along with this program; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// Author: Gustavo J. A. M. Carneiro <gjc@inescporto.pt> <gjcarneiro@gmail.com>
18//
19
20#ifndef FLOW_PROBE_H
21#define FLOW_PROBE_H
22
23#include "flow-classifier.h"
24
25#include "ns3/nstime.h"
26#include "ns3/object.h"
27
28#include <map>
29#include <vector>
30
31namespace ns3
32{
33
34class FlowMonitor;
35
36/// The FlowProbe class is responsible for listening for packet events
37/// in a specific point of the simulated space, report those events to
38/// the global FlowMonitor, and collect its own flow statistics
39/// regarding only the packets that pass through that probe.
40class FlowProbe : public Object
41{
42 protected:
43 /// Constructor
44 /// \param flowMonitor the FlowMonitor this probe is associated with
45 FlowProbe(Ptr<FlowMonitor> flowMonitor);
46 void DoDispose() override;
47
48 public:
49 ~FlowProbe() override;
50
51 // Delete copy constructor and assignment operator to avoid misuse
52 FlowProbe(const FlowProbe&) = delete;
53 FlowProbe& operator=(const FlowProbe&) = delete;
54
55 /// Register this type.
56 /// \return The TypeId.
57 static TypeId GetTypeId();
58
59 /// Structure to hold the statistics of a flow
60 struct FlowStats
61 {
64 bytes(0),
65 packets(0)
66 {
67 }
68
69 /// packetsDropped[reasonCode] => number of dropped packets
70 std::vector<uint32_t> packetsDropped;
71 /// bytesDropped[reasonCode] => number of dropped bytes
72 std::vector<uint64_t> bytesDropped;
73 /// divide by 'packets' to get the average delay from the
74 /// first (entry) probe up to this one (partial delay)
76 /// Number of bytes seen of this flow
77 uint64_t bytes;
78 /// Number of packets seen of this flow
80 };
81
82 /// Container to map FlowId -> FlowStats
83 typedef std::map<FlowId, FlowStats> Stats;
84
85 /// Add a packet data to the flow stats
86 /// \param flowId the flow Identifier
87 /// \param packetSize the packet size
88 /// \param delayFromFirstProbe packet delay
89 void AddPacketStats(FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe);
90 /// Add a packet drop data to the flow stats
91 /// \param flowId the flow Identifier
92 /// \param packetSize the packet size
93 /// \param reasonCode reason code for the drop
94 void AddPacketDropStats(FlowId flowId, uint32_t packetSize, uint32_t reasonCode);
95
96 /// Get the partial flow statistics stored in this probe. With this
97 /// information you can, for example, find out what is the delay
98 /// from the first probe to this one.
99 /// \returns the partial flow statistics
100 Stats GetStats() const;
101
102 /// Serializes the results to an std::ostream in XML format
103 /// \param os the output stream
104 /// \param indent number of spaces to use as base indentation level
105 /// \param index FlowProbe index
106 void SerializeToXmlStream(std::ostream& os, uint16_t indent, uint32_t index) const;
107
108 protected:
109 Ptr<FlowMonitor> m_flowMonitor; //!< the FlowMonitor instance
110 Stats m_stats; //!< The flow stats
111};
112
113} // namespace ns3
114
115#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:41
FlowProbe & operator=(const FlowProbe &)=delete
Stats m_stats
The flow stats.
Definition: flow-probe.h:110
void AddPacketStats(FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe)
Add a packet data to the flow stats.
Definition: flow-probe.cc:56
void DoDispose() override
Destructor implementation.
Definition: flow-probe.cc:49
void AddPacketDropStats(FlowId flowId, uint32_t packetSize, uint32_t reasonCode)
Add a packet drop data to the flow stats.
Definition: flow-probe.cc:65
std::map< FlowId, FlowStats > Stats
Container to map FlowId -> FlowStats.
Definition: flow-probe.h:83
Stats GetStats() const
Get the partial flow statistics stored in this probe.
Definition: flow-probe.cc:79
FlowProbe(const FlowProbe &)=delete
static TypeId GetTypeId()
Register this type.
Definition: flow-probe.cc:29
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:85
Ptr< FlowMonitor > m_flowMonitor
the FlowMonitor instance
Definition: flow-probe.h:109
~FlowProbe() override
Definition: flow-probe.cc:38
A base class which provides memory management and object aggregation.
Definition: object.h:89
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1319
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:61
uint64_t bytes
Number of bytes seen of this flow.
Definition: flow-probe.h:77
uint32_t packets
Number of packets seen of this flow.
Definition: flow-probe.h:79
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:75
std::vector< uint32_t > packetsDropped
packetsDropped[reasonCode] => number of dropped packets
Definition: flow-probe.h:70
std::vector< uint64_t > bytesDropped
bytesDropped[reasonCode] => number of dropped bytes
Definition: flow-probe.h:72
static const uint32_t packetSize
Packet size generated at the AP.