An object that monitors and reports back packet flows observed during a simulation. More...
#include <flow-monitor.h>
Classes | |
struct | FlowStats |
Structure that represents the measured metrics of an individual packet flow. More... | |
struct | TrackedPacket |
Structure to represent a single tracked packet data. More... | |
Public Member Functions | |
FlowMonitor () | |
void | AddProbe (Ptr< FlowProbe > probe) |
Register a new FlowProbe that will begin monitoring and report events to this monitor. More... | |
void | CheckForLostPackets () |
Check right now for packets that appear to be lost. More... | |
void | CheckForLostPackets (Time maxDelay) |
Check right now for packets that appear to be lost, considering packets as lost if not seen in the network for a time larger than maxDelay. More... | |
std::vector< Ptr< FlowProbe > > | GetAllProbes () const |
Get a list of all FlowProbe's associated with this FlowMonitor. More... | |
std::map< FlowId, FlowStats > | GetFlowStats () const |
Retrieve all collected the flow statistics. More... | |
TypeId | GetInstanceTypeId () const |
void | ReportDrop (Ptr< FlowProbe > probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize, uint32_t reasonCode) |
FlowProbe implementations are supposed to call this method to report that a known packet is being dropped due to some reason. More... | |
void | ReportFirstTx (Ptr< FlowProbe > probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize) |
FlowProbe implementations are supposed to call this method to report that a new packet was transmitted (but keep in mind the distinction between a new packet entering the system and a packet that is already known and is only being forwarded). More... | |
void | ReportForwarding (Ptr< FlowProbe > probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize) |
FlowProbe implementations are supposed to call this method to report that a known packet is being forwarded. More... | |
void | ReportLastRx (Ptr< FlowProbe > probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize) |
FlowProbe implementations are supposed to call this method to report that a known packet is being received. More... | |
void | SerializeToXmlFile (std::string fileName, bool enableHistograms, bool enableProbes) |
Same as SerializeToXmlStream, but writes to a file instead. More... | |
void | SerializeToXmlStream (std::ostream &os, int indent, bool enableHistograms, bool enableProbes) |
Serializes the results to an std::ostream in XML format. More... | |
std::string | SerializeToXmlString (int indent, bool enableHistograms, bool enableProbes) |
Same as SerializeToXmlStream, but returns the output as a std::string. More... | |
void | SetFlowClassifier (Ptr< FlowClassifier > classifier) |
Set the FlowClassifier to be used by the flow monitor. More... | |
void | Start (const Time &time) |
Set the time, counting from the current time, from which to start monitoring flows. More... | |
void | StartRightNow () |
Begin monitoring flows right now More... | |
void | Stop (const Time &time) |
Set the time, counting from the current time, from which to stop monitoring flows. More... | |
void | StopRightNow () |
End monitoring flows right now More... | |
Public Member Functions inherited from ns3::Object | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
Run the DoDispose methods of this object and all the objects aggregated to it. More... | |
AggregateIterator | GetAggregateIterator (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
This method calls the virtual DoInitialize method on all the objects aggregated to this object. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
static void | Cleanup (void) |
Noop. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Protected Member Functions | |
virtual void | DoDispose (void) |
This method is called by Object::Dispose or by the object's destructor, whichever comes first. More... | |
virtual void | NotifyConstructionCompleted () |
This method is invoked once all member attributes have been initialized. More... | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
virtual void | DoInitialize (void) |
This method is called only once by Object::Initialize. More... | |
virtual void | NotifyNewAggregate (void) |
This method is invoked whenever two sets of objects are aggregated together. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Private Types | |
typedef std::map< std::pair < FlowId, FlowPacketId > , TrackedPacket > | TrackedPacketMap |
(FlowId,PacketId) –> TrackedPacket More... | |
Private Member Functions | |
FlowStats & | GetStatsForFlow (FlowId flowId) |
Get the stats for a given flow. More... | |
void | PeriodicCheckForLostPackets () |
Periodic function to check for lost packets and prune statistics. More... | |
Private Attributes | |
Ptr< FlowClassifier > | m_classifier |
the FlowClassifier More... | |
double | m_delayBinWidth |
Delay bin width (for histograms) More... | |
bool | m_enabled |
FlowMon is enabled. More... | |
double | m_flowInterruptionsBinWidth |
Flow interruptions bin width (for histograms) More... | |
Time | m_flowInterruptionsMinTime |
Flow interruptions minimum time. More... | |
std::vector< Ptr< FlowProbe > > | m_flowProbes |
all the FlowProbes More... | |
std::map< FlowId, FlowStats > | m_flowStats |
FlowId –> FlowStats. More... | |
double | m_jitterBinWidth |
Jitter bin width (for histograms) More... | |
Time | m_maxPerHopDelay |
Minimum per-hop delay. More... | |
double | m_packetSizeBinWidth |
packet size bin width (for histograms) More... | |
EventId | m_startEvent |
Start event. More... | |
EventId | m_stopEvent |
Stop event. More... | |
TrackedPacketMap | m_trackedPackets |
Tracked packets. More... | |
An object that monitors and reports back packet flows observed during a simulation.
Doxygen introspection did not find any typical Config paths.
The FlowMonitor class is responsible for coordinating efforts regarding probes, and collects end-to-end flow statistics.
No TraceSources are defined for this type.
Definition at line 50 of file flow-monitor.h.
|
private |
(FlowId,PacketId) –> TrackedPacket
Definition at line 263 of file flow-monitor.h.
ns3::FlowMonitor::FlowMonitor | ( | ) |
Definition at line 86 of file flow-monitor.cc.
Register a new FlowProbe that will begin monitoring and report events to this monitor.
This method is normally only used by FlowProbe implementations.
probe | the probe to add |
Definition at line 336 of file flow-monitor.cc.
References m_flowProbes.
void ns3::FlowMonitor::CheckForLostPackets | ( | ) |
Check right now for packets that appear to be lost.
Definition at line 316 of file flow-monitor.cc.
References m_maxPerHopDelay.
Referenced by experiment(), PeriodicCheckForLostPackets(), SerializeToXmlStream(), and StopRightNow().
void ns3::FlowMonitor::CheckForLostPackets | ( | Time | maxDelay | ) |
Check right now for packets that appear to be lost, considering packets as lost if not seen in the network for a time larger than maxDelay.
maxDelay | the max delay for a packet |
Definition at line 290 of file flow-monitor.cc.
References m_flowStats, m_trackedPackets, ns3::Simulator::Now(), and NS_ASSERT.
|
protectedvirtual |
This method is called by Object::Dispose or by the object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.
It is safe to call GetObject from within this method.
Reimplemented from ns3::Object.
Definition at line 93 of file flow-monitor.cc.
References ns3::Object::DoDispose(), m_classifier, and m_flowProbes.
Get a list of all FlowProbe's associated with this FlowMonitor.
Definition at line 342 of file flow-monitor.cc.
References m_flowProbes.
std::map< FlowId, FlowMonitor::FlowStats > ns3::FlowMonitor::GetFlowStats | ( | ) | const |
Retrieve all collected the flow statistics.
Note, if the FlowMonitor has not stopped monitoring yet, you should call CheckForLostPackets() to make sure all possibly lost packets are accounted for.
Definition at line 283 of file flow-monitor.cc.
References m_flowStats.
Referenced by experiment().
|
virtual |
This method is typically implemented by ns3::Object::GetInstanceTypeId but some classes which derive from ns3::ObjectBase directly have to implement it themselves.
Reimplemented from ns3::Object.
Definition at line 81 of file flow-monitor.cc.
References GetTypeId().
|
inlineprivate |
Get the stats for a given flow.
flowId | the Flow identification |
Definition at line 105 of file flow-monitor.cc.
References ns3::FlowMonitor::FlowStats::delayHistogram, ns3::FlowMonitor::FlowStats::delaySum, ns3::FlowMonitor::FlowStats::flowInterruptionsHistogram, ns3::FlowMonitor::FlowStats::jitterHistogram, ns3::FlowMonitor::FlowStats::jitterSum, ns3::FlowMonitor::FlowStats::lastDelay, ns3::FlowMonitor::FlowStats::lostPackets, m_delayBinWidth, m_flowInterruptionsBinWidth, m_flowStats, m_jitterBinWidth, m_packetSizeBinWidth, ns3::FlowMonitor::FlowStats::packetSizeHistogram, ns3::FlowMonitor::FlowStats::rxBytes, ns3::FlowMonitor::FlowStats::rxPackets, ns3::Histogram::SetDefaultBinWidth(), ns3::FlowMonitor::FlowStats::timesForwarded, ns3::FlowMonitor::FlowStats::txBytes, and ns3::FlowMonitor::FlowStats::txPackets.
Referenced by ReportDrop(), ReportFirstTx(), and ReportLastRx().
|
static |
Get the type ID.
Definition at line 42 of file flow-monitor.cc.
References m_delayBinWidth, m_flowInterruptionsBinWidth, m_flowInterruptionsMinTime, m_jitterBinWidth, m_maxPerHopDelay, m_packetSizeBinWidth, ns3::MakeTimeChecker(), ns3::TypeId::SetParent(), and Start().
Referenced by GetInstanceTypeId().
|
protectedvirtual |
This method is invoked once all member attributes have been initialized.
Subclasses can override this method to be notified of this event but if they do this, they must chain up to their parent's NotifyConstructionCompleted method.
Reimplemented from ns3::ObjectBase.
Definition at line 329 of file flow-monitor.cc.
References ns3::ObjectBase::NotifyConstructionCompleted(), PERIODIC_CHECK_INTERVAL, PeriodicCheckForLostPackets(), and ns3::Simulator::Schedule().
|
private |
Periodic function to check for lost packets and prune statistics.
Definition at line 322 of file flow-monitor.cc.
References CheckForLostPackets(), PERIODIC_CHECK_INTERVAL, and ns3::Simulator::Schedule().
Referenced by NotifyConstructionCompleted().
void ns3::FlowMonitor::ReportDrop | ( | Ptr< FlowProbe > | probe, |
FlowId | flowId, | ||
FlowPacketId | packetId, | ||
uint32_t | packetSize, | ||
uint32_t | reasonCode | ||
) |
FlowProbe implementations are supposed to call this method to report that a known packet is being dropped due to some reason.
probe | the reporting probe |
flowId | flow identification |
packetId | Packet ID |
packetSize | packet size |
reasonCode | drop reason code |
Definition at line 250 of file flow-monitor.cc.
References ns3::FlowMonitor::FlowStats::bytesDropped, GetStatsForFlow(), ns3::FlowMonitor::FlowStats::lostPackets, m_enabled, m_trackedPackets, NS_LOG_DEBUG, and ns3::FlowMonitor::FlowStats::packetsDropped.
void ns3::FlowMonitor::ReportFirstTx | ( | Ptr< FlowProbe > | probe, |
FlowId | flowId, | ||
FlowPacketId | packetId, | ||
uint32_t | packetSize | ||
) |
FlowProbe implementations are supposed to call this method to report that a new packet was transmitted (but keep in mind the distinction between a new packet entering the system and a packet that is already known and is only being forwarded).
probe | the reporting probe |
flowId | flow identification |
packetId | Packet ID |
packetSize | packet size |
Definition at line 135 of file flow-monitor.cc.
References ns3::FlowMonitor::TrackedPacket::firstSeenTime, GetStatsForFlow(), ns3::FlowMonitor::TrackedPacket::lastSeenTime, m_enabled, m_trackedPackets, ns3::Simulator::Now(), NS_LOG_DEBUG, ns3::FlowMonitor::FlowStats::timeFirstTxPacket, ns3::FlowMonitor::FlowStats::timeLastTxPacket, ns3::FlowMonitor::TrackedPacket::timesForwarded, ns3::FlowMonitor::FlowStats::txBytes, and ns3::FlowMonitor::FlowStats::txPackets.
void ns3::FlowMonitor::ReportForwarding | ( | Ptr< FlowProbe > | probe, |
FlowId | flowId, | ||
FlowPacketId | packetId, | ||
uint32_t | packetSize | ||
) |
FlowProbe implementations are supposed to call this method to report that a known packet is being forwarded.
probe | the reporting probe |
flowId | flow identification |
packetId | Packet ID |
packetSize | packet size |
Definition at line 163 of file flow-monitor.cc.
References m_enabled, m_trackedPackets, ns3::Simulator::Now(), and NS_LOG_WARN.
void ns3::FlowMonitor::ReportLastRx | ( | Ptr< FlowProbe > | probe, |
FlowId | flowId, | ||
FlowPacketId | packetId, | ||
uint32_t | packetSize | ||
) |
FlowProbe implementations are supposed to call this method to report that a known packet is being received.
probe | the reporting probe |
flowId | flow identification |
packetId | Packet ID |
packetSize | packet size |
Definition at line 187 of file flow-monitor.cc.
References ns3::Histogram::AddValue(), ns3::FlowMonitor::FlowStats::delayHistogram, ns3::FlowMonitor::FlowStats::delaySum, ns3::FlowMonitor::FlowStats::flowInterruptionsHistogram, ns3::Time::GetSeconds(), GetStatsForFlow(), ns3::FlowMonitor::FlowStats::jitterHistogram, ns3::FlowMonitor::FlowStats::jitterSum, ns3::FlowMonitor::FlowStats::lastDelay, m_enabled, m_flowInterruptionsMinTime, m_trackedPackets, ns3::Simulator::Now(), NS_LOG_DEBUG, NS_LOG_WARN, ns3::FlowMonitor::FlowStats::packetSizeHistogram, ns3::FlowMonitor::FlowStats::rxBytes, ns3::FlowMonitor::FlowStats::rxPackets, ns3::FlowMonitor::FlowStats::timeFirstRxPacket, ns3::FlowMonitor::FlowStats::timeLastRxPacket, and ns3::FlowMonitor::FlowStats::timesForwarded.
void ns3::FlowMonitor::SerializeToXmlFile | ( | std::string | fileName, |
bool | enableHistograms, | ||
bool | enableProbes | ||
) |
Same as SerializeToXmlStream, but writes to a file instead.
fileName | name or path of the output file that will be created |
enableHistograms | if true, include also the histograms in the output |
enableProbes | if true, include also the per-probe/flow pair statistics in the output |
Definition at line 490 of file flow-monitor.cc.
References SerializeToXmlStream().
Referenced by main(), and Experiment::Run().
void ns3::FlowMonitor::SerializeToXmlStream | ( | std::ostream & | os, |
int | indent, | ||
bool | enableHistograms, | ||
bool | enableProbes | ||
) |
Serializes the results to an std::ostream in XML format.
os | the output stream |
indent | number of spaces to use as base indentation level |
enableHistograms | if true, include also the histograms in the output |
enableProbes | if true, include also the per-probe/flow pair statistics in the output |
Definition at line 400 of file flow-monitor.cc.
References ATTRIB, CheckForLostPackets(), INDENT, m_classifier, m_flowProbes, and m_flowStats.
Referenced by SerializeToXmlFile(), and SerializeToXmlString().
std::string ns3::FlowMonitor::SerializeToXmlString | ( | int | indent, |
bool | enableHistograms, | ||
bool | enableProbes | ||
) |
Same as SerializeToXmlStream, but returns the output as a std::string.
indent | number of spaces to use as base indentation level |
enableHistograms | if true, include also the histograms in the output |
enableProbes | if true, include also the per-probe/flow pair statistics in the output |
Definition at line 481 of file flow-monitor.cc.
References SerializeToXmlStream().
void ns3::FlowMonitor::SetFlowClassifier | ( | Ptr< FlowClassifier > | classifier | ) |
Set the FlowClassifier to be used by the flow monitor.
classifier | the FlowClassifier |
Definition at line 394 of file flow-monitor.cc.
References m_classifier.
void ns3::FlowMonitor::Start | ( | const Time & | time | ) |
Set the time, counting from the current time, from which to start monitoring flows.
time | delta time to start |
Definition at line 349 of file flow-monitor.cc.
References ns3::Simulator::Cancel(), m_enabled, m_startEvent, ns3::Simulator::Schedule(), and StartRightNow().
Referenced by GetTypeId().
void ns3::FlowMonitor::StartRightNow | ( | ) |
Begin monitoring flows right now
Definition at line 372 of file flow-monitor.cc.
References m_enabled.
Referenced by Start().
void ns3::FlowMonitor::Stop | ( | const Time & | time | ) |
Set the time, counting from the current time, from which to stop monitoring flows.
time | delta time to stop |
Definition at line 360 of file flow-monitor.cc.
References ns3::Simulator::Cancel(), m_enabled, m_stopEvent, ns3::Simulator::Schedule(), and StopRightNow().
void ns3::FlowMonitor::StopRightNow | ( | ) |
End monitoring flows right now
Definition at line 383 of file flow-monitor.cc.
References CheckForLostPackets(), and m_enabled.
Referenced by Stop().
|
private |
the FlowClassifier
Definition at line 269 of file flow-monitor.h.
Referenced by DoDispose(), SerializeToXmlStream(), and SetFlowClassifier().
|
private |
Delay bin width (for histograms)
Definition at line 274 of file flow-monitor.h.
Referenced by GetStatsForFlow(), and GetTypeId().
|
private |
FlowMon is enabled.
Definition at line 273 of file flow-monitor.h.
Referenced by ReportDrop(), ReportFirstTx(), ReportForwarding(), ReportLastRx(), Start(), StartRightNow(), Stop(), and StopRightNow().
|
private |
Flow interruptions bin width (for histograms)
Definition at line 277 of file flow-monitor.h.
Referenced by GetStatsForFlow(), and GetTypeId().
|
private |
Flow interruptions minimum time.
Definition at line 278 of file flow-monitor.h.
Referenced by GetTypeId(), and ReportLastRx().
all the FlowProbes
Definition at line 266 of file flow-monitor.h.
Referenced by AddProbe(), DoDispose(), GetAllProbes(), and SerializeToXmlStream().
FlowId –> FlowStats.
Definition at line 260 of file flow-monitor.h.
Referenced by CheckForLostPackets(), GetFlowStats(), GetStatsForFlow(), and SerializeToXmlStream().
|
private |
Jitter bin width (for histograms)
Definition at line 275 of file flow-monitor.h.
Referenced by GetStatsForFlow(), and GetTypeId().
|
private |
Minimum per-hop delay.
Definition at line 265 of file flow-monitor.h.
Referenced by CheckForLostPackets(), and GetTypeId().
|
private |
packet size bin width (for histograms)
Definition at line 276 of file flow-monitor.h.
Referenced by GetStatsForFlow(), and GetTypeId().
|
private |
|
private |
|
private |
Tracked packets.
Definition at line 264 of file flow-monitor.h.
Referenced by CheckForLostPackets(), ReportDrop(), ReportFirstTx(), ReportForwarding(), and ReportLastRx().