diff --git a/CHANGES.md b/CHANGES.md index 0e40e76c3..689d72a8e 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -25,6 +25,7 @@ Changes from ns-3.38 to ns-3-dev * (lr-wpan) Added `LrwpanMac::MlmeGetRequest` function and the corresponding confirm callbacks as well as `LrwpanMac::SetMlmeGetConfirm` function. * (applications) Added `Tx` and `TxWithAddresses` trace sources in `UdpClient`. * (stats) Added `Histogram::Clear` function to clear the histogram contents. +* (flow-monitor) Added `FlowMonitor::ResetAllStats` function to reset the FlowMonitor statistics. ### Changes to existing API diff --git a/src/flow-monitor/model/flow-monitor.cc b/src/flow-monitor/model/flow-monitor.cc index fd6b3a693..9369004dc 100644 --- a/src/flow-monitor/model/flow-monitor.cc +++ b/src/flow-monitor/model/flow-monitor.cc @@ -534,4 +534,31 @@ FlowMonitor::SerializeToXmlFile(std::string fileName, bool enableHistograms, boo os.close(); } +void +FlowMonitor::ResetAllStats() +{ + NS_LOG_FUNCTION(this); + + for (auto& iter : m_flowStats) + { + auto& flowStat = iter.second; + flowStat.delaySum = Seconds(0); + flowStat.jitterSum = Seconds(0); + flowStat.lastDelay = Seconds(0); + flowStat.txBytes = 0; + flowStat.rxBytes = 0; + flowStat.txPackets = 0; + flowStat.rxPackets = 0; + flowStat.lostPackets = 0; + flowStat.timesForwarded = 0; + flowStat.bytesDropped.clear(); + flowStat.packetsDropped.clear(); + + flowStat.delayHistogram.Clear(); + flowStat.jitterHistogram.Clear(); + flowStat.packetSizeHistogram.Clear(); + flowStat.flowInterruptionsHistogram.Clear(); + } +} + } // namespace ns3 diff --git a/src/flow-monitor/model/flow-monitor.h b/src/flow-monitor/model/flow-monitor.h index 767719dd3..a0be703e9 100644 --- a/src/flow-monitor/model/flow-monitor.h +++ b/src/flow-monitor/model/flow-monitor.h @@ -273,6 +273,9 @@ class FlowMonitor : public Object /// \param enableProbes if true, include also the per-probe/flow pair statistics in the output void SerializeToXmlFile(std::string fileName, bool enableHistograms, bool enableProbes); + /// Reset all the statistics + void ResetAllStats(); + protected: void NotifyConstructionCompleted() override; void DoDispose() override;