A Discrete-Event Network Simulator
API
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 
31 namespace ns3
32 {
33 
34 class FlowMonitor;
35 
40 class FlowProbe : public Object
41 {
42  protected:
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 
57  static TypeId GetTypeId();
58 
60  struct FlowStats
61  {
64  bytes(0),
65  packets(0)
66  {
67  }
68 
70  std::vector<uint32_t> packetsDropped;
72  std::vector<uint64_t> bytesDropped;
77  uint64_t bytes;
79  uint32_t packets;
80  };
81 
83  typedef std::map<FlowId, FlowStats> Stats;
84 
89  void AddPacketStats(FlowId flowId, uint32_t packetSize, Time delayFromFirstProbe);
94  void AddPacketDropStats(FlowId flowId, uint32_t packetSize, uint32_t reasonCode);
95 
100  Stats GetStats() const;
101 
106  void SerializeToXmlStream(std::ostream& os, uint16_t indent, uint32_t index) const;
107 
108  protected:
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
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
FlowProbe(Ptr< FlowMonitor > flowMonitor)
Constructor.
Definition: flow-probe.cc:42
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
FlowProbe & operator=(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
uint32_t FlowId
Abstract identifier of a packet flow.
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1326
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.