A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::FlowMonitor Class Reference

An object that monitors and reports back packet flows observed during a simulation. More...

#include <flow-monitor.h>

+ Inheritance diagram for ns3::FlowMonitor:
+ Collaboration diagram for ns3::FlowMonitor:

Classes

struct  FlowStats
 Structure that represents the measured metrics of an individual packet flow. More...
struct  TrackedPacket

Public Member Functions

 FlowMonitor ()
void AddProbe (Ptr< FlowProbe > probe)
void CheckForLostPackets ()
 Check right now for packets that appear to be lost.
void CheckForLostPackets (Time maxDelay)
std::vector< Ptr< FlowProbe > > GetAllProbes () const
 Get a list of all FlowProbe's associated with this FlowMonitor.
std::map< FlowId, FlowStatsGetFlowStats () const
TypeId GetInstanceTypeId () const
void ReportDrop (Ptr< FlowProbe > probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize, uint32_t reasonCode)
void ReportFirstTx (Ptr< FlowProbe > probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize)
void ReportForwarding (Ptr< FlowProbe > probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize)
void ReportLastRx (Ptr< FlowProbe > probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize)
void SerializeToXmlFile (std::string fileName, bool enableHistograms, bool enableProbes)
void SerializeToXmlStream (std::ostream &os, int indent, bool enableHistograms, bool enableProbes)
std::string SerializeToXmlString (int indent, bool enableHistograms, bool enableProbes)
void SetFlowClassifier (Ptr< FlowClassifier > classifier)
 Set the FlowClassifier to be used by the flow monitor.
void Start (const Time &time)
 Set the time, counting from the current time, from which to start monitoring flows.
void StartRightNow ()
 Begin monitoring flows right now
void Stop (const Time &time)
 Set the time, counting from the current time, from which to stop monitoring flows.
void StopRightNow ()
 End monitoring flows right now
- Public Member Functions inherited from ns3::Object
 Object ()
virtual ~Object ()
void AggregateObject (Ptr< Object > other)
void Dispose (void)
AggregateIterator GetAggregateIterator (void) const
template<typename T >
Ptr< T > GetObject (void) const
template<typename T >
Ptr< T > GetObject (TypeId tid) const
void Start (void)
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 SimpleRefCount (const SimpleRefCount &o)
uint32_t GetReferenceCount (void) const
SimpleRefCountoperator= (const SimpleRefCount &o)
void Ref (void) const
void Unref (void) const
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
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 ()
 This method returns the TypeId associated to ns3::FlowMonitor.

Protected Member Functions

virtual void NotifyConstructionCompleted ()
- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
virtual void DoDispose (void)
virtual void DoStart (void)
virtual void NotifyNewAggregate (void)

Private Types

typedef std::map< std::pair
< FlowId, FlowPacketId >
, TrackedPacket
TrackedPacketMap

Private Member Functions

FlowStatsGetStatsForFlow (FlowId flowId)
void PeriodicCheckForLostPackets ()

Private Attributes

Ptr< FlowClassifierm_classifier
double m_delayBinWidth
bool m_enabled
double m_flowInterruptionsBinWidth
Time m_flowInterruptionsMinTime
std::vector< Ptr< FlowProbe > > m_flowProbes
std::map< FlowId, FlowStatsm_flowStats
double m_jitterBinWidth
Time m_maxPerHopDelay
double m_packetSizeBinWidth
EventId m_startEvent
EventId m_stopEvent
TrackedPacketMap m_trackedPackets

Detailed Description

An object that monitors and reports back packet flows observed during a simulation.

The FlowMonitor class is responsible forcoordinating efforts regarding probes, and collects end-to-end flowstatistics.

Definition at line 41 of file flow-monitor.h.

Member Typedef Documentation

typedef std::map< std::pair<FlowId, FlowPacketId>, TrackedPacket> ns3::FlowMonitor::TrackedPacketMap
private

Definition at line 222 of file flow-monitor.h.

Constructor & Destructor Documentation

ns3::FlowMonitor::FlowMonitor ( )

Definition at line 84 of file flow-monitor.cc.

Member Function Documentation

void ns3::FlowMonitor::AddProbe ( Ptr< FlowProbe probe)

Register a new FlowProbe that will begin monitoring and report events to this monitor. This method is normally only used by FlowProbe implementations.

Definition at line 323 of file flow-monitor.cc.

References m_flowProbes.

Referenced by ns3::FlowProbe::FlowProbe().

+ Here is the caller graph for this function:

void ns3::FlowMonitor::CheckForLostPackets ( )

Check right now for packets that appear to be lost.

Definition at line 303 of file flow-monitor.cc.

References m_maxPerHopDelay.

Referenced by PeriodicCheckForLostPackets(), SerializeToXmlStream(), and StopRightNow().

+ Here is the caller graph for this function:

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

Definition at line 277 of file flow-monitor.cc.

References m_flowStats, m_trackedPackets, ns3::Now(), and NS_ASSERT.

+ Here is the call graph for this function:

std::vector< Ptr< FlowProbe > > ns3::FlowMonitor::GetAllProbes ( ) const

Get a list of all FlowProbe's associated with this FlowMonitor.

Definition at line 329 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 270 of file flow-monitor.cc.

References m_flowStats.

TypeId ns3::FlowMonitor::GetInstanceTypeId ( ) const
virtual
Returns
the TypeId associated to the most-derived type of this instance.

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 79 of file flow-monitor.cc.

References GetTypeId().

+ Here is the call graph for this function:

TypeId ns3::FlowMonitor::GetTypeId ( void  )
static

This method returns the TypeId associated to ns3::FlowMonitor.

Attributes defined for this type:

  • MaxPerHopDelay: The maximum per-hop delay that should be considered. Packets still not received after this delay are to be considered lost.
    • Set with class: TimeValue
    • Underlying type: Time
    • Initial value: +10000000000.0ns
    • Flags: construct write read
  • StartTime: The time when the monitoring starts.
    • Set with class: TimeValue
    • Underlying type: Time
    • Initial value: +0.0ns
    • Flags: construct write
  • DelayBinWidth: The width used in the delay histogram.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 0.001
    • Flags: construct write read
  • JitterBinWidth: The width used in the jitter histogram.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 0.001
    • Flags: construct write read
  • PacketSizeBinWidth: The width used in the packetSize histogram.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 20
    • Flags: construct write read
  • FlowInterruptionsBinWidth: The width used in the flowInterruptions histogram.
    • Set with class: ns3::DoubleValue
    • Underlying type: double -1.79769e+308:1.79769e+308
    • Initial value: 0.25
    • Flags: construct write read
  • FlowInterruptionsMinTime: The minimum inter-arrival time that is considered a flow interruption.
    • Set with class: TimeValue
    • Underlying type: Time
    • Initial value: +500000000.0ns
    • Flags: construct write read

No TraceSources defined for this type.

Reimplemented from ns3::Object.

Definition at line 40 of file flow-monitor.cc.

References m_delayBinWidth, m_flowInterruptionsBinWidth, m_flowInterruptionsMinTime, m_jitterBinWidth, m_maxPerHopDelay, m_packetSizeBinWidth, ns3::Seconds(), ns3::TypeId::SetParent(), and ns3::Object::Start().

Referenced by GetInstanceTypeId().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::FlowMonitor::NotifyConstructionCompleted ( void  )
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 316 of file flow-monitor.cc.

References PERIODIC_CHECK_INTERVAL, PeriodicCheckForLostPackets(), and ns3::Simulator::Schedule().

+ Here is the call graph for this function:

void ns3::FlowMonitor::PeriodicCheckForLostPackets ( )
private

Definition at line 309 of file flow-monitor.cc.

References CheckForLostPackets(), PERIODIC_CHECK_INTERVAL, and ns3::Simulator::Schedule().

Referenced by NotifyConstructionCompleted().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Definition at line 237 of file flow-monitor.cc.

References ns3::FlowProbe::AddPacketDropStats(), ns3::FlowMonitor::FlowStats::bytesDropped, GetStatsForFlow(), ns3::FlowMonitor::FlowStats::lostPackets, m_enabled, m_trackedPackets, NS_LOG_DEBUG, and ns3::FlowMonitor::FlowStats::packetsDropped.

Referenced by ns3::Ipv4FlowProbe::DropLogger(), and ns3::Ipv4FlowProbe::QueueDropLogger().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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).

Definition at line 122 of file flow-monitor.cc.

References ns3::FlowProbe::AddPacketStats(), ns3::FlowMonitor::TrackedPacket::firstSeenTime, GetStatsForFlow(), ns3::FlowMonitor::TrackedPacket::lastSeenTime, m_enabled, m_trackedPackets, ns3::Now(), NS_LOG_DEBUG, ns3::Seconds(), ns3::FlowMonitor::FlowStats::timeFirstTxPacket, ns3::FlowMonitor::FlowStats::timeLastTxPacket, ns3::FlowMonitor::TrackedPacket::timesForwarded, ns3::FlowMonitor::FlowStats::txBytes, and ns3::FlowMonitor::FlowStats::txPackets.

Referenced by ns3::Ipv4FlowProbe::SendOutgoingLogger().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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.

Definition at line 150 of file flow-monitor.cc.

References ns3::FlowProbe::AddPacketStats(), m_enabled, m_trackedPackets, ns3::Now(), and NS_LOG_WARN.

Referenced by ns3::Ipv4FlowProbe::ForwardLogger().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::FlowMonitor::SerializeToXmlFile ( std::string  fileName,
bool  enableHistograms,
bool  enableProbes 
)

Same as SerializeToXmlStream, but writes to a file instead

Parameters
fileNamename or path of the output file that will be created
enableHistogramsif true, include also the histograms in the output
enableProbesif true, include also the per-probe/flow pair statistics in the output

Definition at line 477 of file flow-monitor.cc.

References SerializeToXmlStream().

Referenced by main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::FlowMonitor::SerializeToXmlStream ( std::ostream &  os,
int  indent,
bool  enableHistograms,
bool  enableProbes 
)

Serializes the results to an std::ostream in XML format

Parameters
osthe output stream
indentnumber of spaces to use as base indentation level
enableHistogramsif true, include also the histograms in the output
enableProbesif true, include also the per-probe/flow pair statistics in the output

Definition at line 387 of file flow-monitor.cc.

References ATTRIB, CheckForLostPackets(), INDENT, m_classifier, m_flowProbes, m_flowStats, and ns3::FlowClassifier::SerializeToXmlStream().

Referenced by SerializeToXmlFile(), and SerializeToXmlString().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

std::string ns3::FlowMonitor::SerializeToXmlString ( int  indent,
bool  enableHistograms,
bool  enableProbes 
)

Same as SerializeToXmlStream, but returns the output as a std::string

Parameters
indentnumber of spaces to use as base indentation level
enableHistogramsif true, include also the histograms in the output
enableProbesif true, include also the per-probe/flow pair statistics in the output
Returns
the XML output as string

Definition at line 468 of file flow-monitor.cc.

References SerializeToXmlStream().

+ Here is the call graph for this function:

void ns3::FlowMonitor::SetFlowClassifier ( Ptr< FlowClassifier classifier)

Set the FlowClassifier to be used by the flow monitor.

Definition at line 381 of file flow-monitor.cc.

References m_classifier.

Referenced by ns3::FlowMonitorHelper::GetMonitor().

+ Here is the caller graph for this function:

void ns3::FlowMonitor::Start ( const Time time)

Set the time, counting from the current time, from which to start monitoring flows.

Definition at line 336 of file flow-monitor.cc.

References ns3::Simulator::Cancel(), m_enabled, m_startEvent, ns3::Simulator::Schedule(), and StartRightNow().

+ Here is the call graph for this function:

void ns3::FlowMonitor::StartRightNow ( )

Begin monitoring flows right now

Definition at line 359 of file flow-monitor.cc.

References m_enabled.

Referenced by Start().

+ Here is the caller graph for this function:

void ns3::FlowMonitor::Stop ( const Time time)

Set the time, counting from the current time, from which to stop monitoring flows.

Definition at line 347 of file flow-monitor.cc.

References ns3::Simulator::Cancel(), m_enabled, m_stopEvent, ns3::Simulator::Schedule(), and StopRightNow().

+ Here is the call graph for this function:

void ns3::FlowMonitor::StopRightNow ( )

End monitoring flows right now

Definition at line 370 of file flow-monitor.cc.

References CheckForLostPackets(), and m_enabled.

Referenced by Stop().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

Ptr<FlowClassifier> ns3::FlowMonitor::m_classifier
private

Definition at line 228 of file flow-monitor.h.

Referenced by SerializeToXmlStream(), and SetFlowClassifier().

double ns3::FlowMonitor::m_delayBinWidth
private

Definition at line 233 of file flow-monitor.h.

Referenced by GetStatsForFlow(), and GetTypeId().

bool ns3::FlowMonitor::m_enabled
private
double ns3::FlowMonitor::m_flowInterruptionsBinWidth
private

Definition at line 236 of file flow-monitor.h.

Referenced by GetStatsForFlow(), and GetTypeId().

Time ns3::FlowMonitor::m_flowInterruptionsMinTime
private

Definition at line 237 of file flow-monitor.h.

Referenced by GetTypeId(), and ReportLastRx().

std::vector< Ptr<FlowProbe> > ns3::FlowMonitor::m_flowProbes
private

Definition at line 225 of file flow-monitor.h.

Referenced by AddProbe(), GetAllProbes(), and SerializeToXmlStream().

std::map<FlowId, FlowStats> ns3::FlowMonitor::m_flowStats
private
double ns3::FlowMonitor::m_jitterBinWidth
private

Definition at line 234 of file flow-monitor.h.

Referenced by GetStatsForFlow(), and GetTypeId().

Time ns3::FlowMonitor::m_maxPerHopDelay
private

Definition at line 224 of file flow-monitor.h.

Referenced by CheckForLostPackets(), and GetTypeId().

double ns3::FlowMonitor::m_packetSizeBinWidth
private

Definition at line 235 of file flow-monitor.h.

Referenced by GetStatsForFlow(), and GetTypeId().

EventId ns3::FlowMonitor::m_startEvent
private

Definition at line 230 of file flow-monitor.h.

Referenced by Start().

EventId ns3::FlowMonitor::m_stopEvent
private

Definition at line 231 of file flow-monitor.h.

Referenced by Stop().

TrackedPacketMap ns3::FlowMonitor::m_trackedPackets
private

The documentation for this class was generated from the following files: