flowmonitor: (fixes #901) allow to reset the stats

This commit is contained in:
Tommaso Pecorella
2023-05-18 12:25:04 +02:00
parent ff12f975b2
commit c4e1f0827e
3 changed files with 31 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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;