--- a/bindings/python/ns3_module_flow_monitor.py Thu Apr 30 18:43:24 2009 +0100
+++ b/bindings/python/ns3_module_flow_monitor.py Thu Apr 30 19:02:46 2009 +0100
@@ -232,6 +232,14 @@
return
def register_Ns3FlowMonitorFlowStats_methods(root_module, cls):
+ ## flow-monitor.h: ns3::FlowMonitor::FlowStats::timeFirstTxPacket [variable]
+ cls.add_instance_attribute('timeFirstTxPacket', 'ns3::Time', is_const=False)
+ ## flow-monitor.h: ns3::FlowMonitor::FlowStats::timeFirstRxPacket [variable]
+ cls.add_instance_attribute('timeFirstRxPacket', 'ns3::Time', is_const=False)
+ ## flow-monitor.h: ns3::FlowMonitor::FlowStats::timeLastTxPacket [variable]
+ cls.add_instance_attribute('timeLastTxPacket', 'ns3::Time', is_const=False)
+ ## flow-monitor.h: ns3::FlowMonitor::FlowStats::timeLastRxPacket [variable]
+ cls.add_instance_attribute('timeLastRxPacket', 'ns3::Time', is_const=False)
## flow-monitor.h: ns3::FlowMonitor::FlowStats::delaySum [variable]
cls.add_instance_attribute('delaySum', 'ns3::Time', is_const=False)
## flow-monitor.h: ns3::FlowMonitor::FlowStats::txBytes [variable]
--- a/src/contrib/flow-monitor/flow-monitor.cc Thu Apr 30 18:43:24 2009 +0100
+++ b/src/contrib/flow-monitor/flow-monitor.cc Thu Apr 30 19:02:46 2009 +0100
@@ -93,8 +93,9 @@
{
return;
}
+ Time now = Simulator::Now ();
TrackedPacket &tracked = m_trackedPackets[std::make_pair (flowId, packetId)];
- tracked.firstSeenTime = Simulator::Now ();
+ tracked.firstSeenTime = now;
tracked.lastSeenTime = tracked.firstSeenTime;
tracked.timesForwarded = 0;
@@ -103,6 +104,11 @@
FlowStats &stats = GetStatsForFlow (flowId);
stats.txBytes += packetSize;
stats.txPackets++;
+ if (stats.txPackets == 1)
+ {
+ stats.timeFirstTxPacket = now;
+ }
+ stats.timeLastTxPacket = now;
}
@@ -145,13 +151,19 @@
return;
}
- Time delay = (Simulator::Now () - tracked->second.firstSeenTime);
+ Time now = Simulator::Now ();
+ Time delay = (now - tracked->second.firstSeenTime);
probe->AddPacketStats (flowId, packetSize, delay);
FlowStats &stats = GetStatsForFlow (flowId);
stats.delaySum += delay;
stats.rxBytes += packetSize;
stats.rxPackets++;
+ if (stats.rxPackets == 1)
+ {
+ stats.timeFirstRxPacket = now;
+ }
+ stats.timeLastRxPacket = now;
stats.timesForwarded += tracked->second.timesForwarded;
m_trackedPackets.erase (tracked); // we don't need to track this packet anymore
--- a/src/contrib/flow-monitor/flow-monitor.h Thu Apr 30 18:43:24 2009 +0100
+++ b/src/contrib/flow-monitor/flow-monitor.h Thu Apr 30 19:02:46 2009 +0100
@@ -40,6 +40,10 @@
struct FlowStats
{
+ Time timeFirstTxPacket;
+ Time timeFirstRxPacket;
+ Time timeLastTxPacket;
+ Time timeLastRxPacket;
Time delaySum; // delayCount == rxPackets
uint64_t txBytes;
uint64_t rxBytes;