From 5cde4cf43523bb8f0b26d5e8f0bce8a430363fb3 Mon Sep 17 00:00:00 2001 From: Andreas Boltres Date: Wed, 19 Jun 2024 15:00:08 +0000 Subject: [PATCH] flow-monitor (fixes #1097): add logging of max. and min. packet delay in FlowMonitor --- src/flow-monitor/model/flow-monitor.cc | 18 ++++++++++++++++-- src/flow-monitor/model/flow-monitor.h | 4 ++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/flow-monitor/model/flow-monitor.cc b/src/flow-monitor/model/flow-monitor.cc index 03c03226c..8c7dea5ce 100644 --- a/src/flow-monitor/model/flow-monitor.cc +++ b/src/flow-monitor/model/flow-monitor.cc @@ -24,6 +24,7 @@ #include "ns3/simulator.h" #include +#include #include #define PERIODIC_CHECK_INTERVAL (Seconds(1)) @@ -125,6 +126,8 @@ FlowMonitor::GetStatsForFlow(FlowId flowId) ref.delaySum = Seconds(0); ref.jitterSum = Seconds(0); ref.lastDelay = Seconds(0); + ref.maxDelay = Seconds(0); + ref.minDelay = Seconds(std::numeric_limits::max()); ref.txBytes = 0; ref.rxBytes = 0; ref.txPackets = 0; @@ -245,6 +248,14 @@ FlowMonitor::ReportLastRx(Ptr probe, } } stats.lastDelay = delay; + if (delay > stats.maxDelay) + { + stats.maxDelay = delay; + } + if (delay < stats.minDelay) + { + stats.minDelay = delay; + } stats.rxBytes += packetSize; stats.packetSizeHistogram.AddValue((double)packetSize); @@ -448,8 +459,9 @@ FlowMonitor::SerializeToXmlStream(std::ostream& os, os << "first << "\"" << ATTRIB_TIME(timeFirstTxPacket) << ATTRIB_TIME(timeFirstRxPacket) << ATTRIB_TIME(timeLastTxPacket) << ATTRIB_TIME(timeLastRxPacket) << ATTRIB_TIME(delaySum) << ATTRIB_TIME(jitterSum) - << ATTRIB_TIME(lastDelay) << ATTRIB(txBytes) << ATTRIB(rxBytes) << ATTRIB(txPackets) - << ATTRIB(rxPackets) << ATTRIB(lostPackets) << ATTRIB(timesForwarded) << ">\n"; + << ATTRIB_TIME(lastDelay) << ATTRIB_TIME(maxDelay) << ATTRIB_TIME(minDelay) + << ATTRIB(txBytes) << ATTRIB(rxBytes) << ATTRIB(txPackets) << ATTRIB(rxPackets) + << ATTRIB(lostPackets) << ATTRIB(timesForwarded) << ">\n"; #undef ATTRIB_TIME #undef ATTRIB @@ -537,6 +549,8 @@ FlowMonitor::ResetAllStats() flowStat.delaySum = Seconds(0); flowStat.jitterSum = Seconds(0); flowStat.lastDelay = Seconds(0); + flowStat.maxDelay = Seconds(0); + flowStat.minDelay = Seconds(std::numeric_limits::max()); flowStat.txBytes = 0; flowStat.rxBytes = 0; flowStat.txPackets = 0; diff --git a/src/flow-monitor/model/flow-monitor.h b/src/flow-monitor/model/flow-monitor.h index 37b81b3e5..51f38915f 100644 --- a/src/flow-monitor/model/flow-monitor.h +++ b/src/flow-monitor/model/flow-monitor.h @@ -89,6 +89,10 @@ class FlowMonitor : public Object /// Contains the last measured delay of a packet /// It is stored to measure the packet's Jitter Time lastDelay; + /// Contains the largest measured delay of a received packet + Time maxDelay; + /// Contains the smallest measured delay of a received packet + Time minDelay; /// Total number of transmitted bytes for the flow uint64_t txBytes;