A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
flow-probe.cc
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#include "flow-probe.h"
10
11#include "flow-monitor.h"
12
13namespace ns3
14{
15
16/* static */
17TypeId
19{
20 static TypeId tid = TypeId("ns3::FlowProbe").SetParent<Object>().SetGroupName("FlowMonitor")
21 // No AddConstructor because this class has no default constructor.
22 ;
23
24 return tid;
25}
26
30
32 : m_flowMonitor(flowMonitor)
33{
34 m_flowMonitor->AddProbe(this);
35}
36
37void
43
44void
46{
47 FlowStats& flow = m_stats[flowId];
48 flow.delayFromFirstProbeSum += delayFromFirstProbe;
49 flow.bytes += packetSize;
50 ++flow.packets;
51}
52
53void
55{
56 FlowStats& flow = m_stats[flowId];
57
58 if (flow.packetsDropped.size() < reasonCode + 1)
59 {
60 flow.packetsDropped.resize(reasonCode + 1, 0);
61 flow.bytesDropped.resize(reasonCode + 1, 0);
62 }
63 ++flow.packetsDropped[reasonCode];
64 flow.bytesDropped[reasonCode] += packetSize;
65}
66
69{
70 return m_stats;
71}
72
73void
74FlowProbe::SerializeToXmlStream(std::ostream& os, uint16_t indent, uint32_t index) const
75{
76 os << std::string(indent, ' ') << "<FlowProbe index=\"" << index << "\">\n";
77
78 indent += 2;
79
80 for (auto iter = m_stats.begin(); iter != m_stats.end(); iter++)
81 {
82 os << std::string(indent, ' ');
83 os << "<FlowStats "
84 << " flowId=\"" << iter->first << "\""
85 << " packets=\"" << iter->second.packets << "\""
86 << " bytes=\"" << iter->second.bytes << "\""
87 << " delayFromFirstProbeSum=\"" << iter->second.delayFromFirstProbeSum << "\""
88 << " >\n";
89 indent += 2;
90 for (uint32_t reasonCode = 0; reasonCode < iter->second.packetsDropped.size(); reasonCode++)
91 {
92 os << std::string(indent, ' ');
93 os << "<packetsDropped reasonCode=\"" << reasonCode << "\""
94 << " number=\"" << iter->second.packetsDropped[reasonCode] << "\" />\n";
95 }
96 for (uint32_t reasonCode = 0; reasonCode < iter->second.bytesDropped.size(); reasonCode++)
97 {
98 os << std::string(indent, ' ');
99 os << "<bytesDropped reasonCode=\"" << reasonCode << "\""
100 << " bytes=\"" << iter->second.bytesDropped[reasonCode] << "\" />\n";
101 }
102 indent -= 2;
103 os << std::string(indent, ' ') << "</FlowStats>\n";
104 }
105 indent -= 2;
106 os << std::string(indent, ' ') << "</FlowProbe>\n";
107}
108
109} // namespace ns3
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
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
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
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
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
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.