Merge.
1.1 --- a/bindings/python/callbacks_list.py Thu Apr 30 19:24:40 2009 +0100
1.2 +++ b/bindings/python/callbacks_list.py Thu Apr 30 19:25:52 2009 +0100
1.3 @@ -5,10 +5,10 @@
1.4 ['void', 'ns3::Ptr<ns3::Socket>', 'ns3::Address const&', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'],
1.5 ['bool', 'ns3::Ptr<ns3::Socket>', 'ns3::Address const&', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'],
1.6 ['void', 'ns3::Ptr<ns3::Packet>', 'ns3::Mac48Address', 'ns3::Mac48Address', 'ns3::empty', 'ns3::empty', 'ns3::empty'],
1.7 + ['bool', 'std::string', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'],
1.8 ['bool', 'ns3::Ptr<ns3::NetDevice>', 'ns3::Ptr<ns3::Packet const>', 'unsigned short', 'ns3::Address const&', 'ns3::Address const&', 'ns3::NetDevice::PacketType'],
1.9 ['bool', 'ns3::Ptr<ns3::NetDevice>', 'ns3::Ptr<ns3::Packet const>', 'unsigned short', 'ns3::Address const&', 'ns3::empty', 'ns3::empty'],
1.10 ['void', 'ns3::Ptr<ns3::NetDevice>', 'ns3::Ptr<ns3::Packet const>', 'unsigned short', 'ns3::Address const&', 'ns3::Address const&', 'ns3::NetDevice::PacketType'],
1.11 ['void', 'ns3::Ptr<ns3::Packet>', 'double', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'],
1.12 ['void', 'ns3::Ptr<ns3::Packet>', 'double', 'ns3::WifiMode', 'ns3::WifiPreamble', 'ns3::empty', 'ns3::empty'],
1.13 - ['bool', 'std::string', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty', 'ns3::empty'],
1.14 ]
2.1 --- a/bindings/python/ns3_module_flow_monitor.py Thu Apr 30 19:24:40 2009 +0100
2.2 +++ b/bindings/python/ns3_module_flow_monitor.py Thu Apr 30 19:25:52 2009 +0100
2.3 @@ -174,6 +174,22 @@
2.4 is_const=True, is_virtual=True)
2.5 ## flow-monitor.h: ns3::FlowMonitor::FlowMonitor() [constructor]
2.6 cls.add_constructor([])
2.7 + ## flow-monitor.h: void ns3::FlowMonitor::Start(ns3::Time const & time) [member function]
2.8 + cls.add_method('Start',
2.9 + 'void',
2.10 + [param('ns3::Time const &', 'time')])
2.11 + ## flow-monitor.h: void ns3::FlowMonitor::Stop(ns3::Time const & time) [member function]
2.12 + cls.add_method('Stop',
2.13 + 'void',
2.14 + [param('ns3::Time const &', 'time')])
2.15 + ## flow-monitor.h: void ns3::FlowMonitor::StartRightNow() [member function]
2.16 + cls.add_method('StartRightNow',
2.17 + 'void',
2.18 + [])
2.19 + ## flow-monitor.h: void ns3::FlowMonitor::StopRightNow() [member function]
2.20 + cls.add_method('StopRightNow',
2.21 + 'void',
2.22 + [])
2.23 ## flow-monitor.h: void ns3::FlowMonitor::AddProbe(ns3::Ptr<ns3::FlowProbe> probe) [member function]
2.24 cls.add_method('AddProbe',
2.25 'void',
2.26 @@ -216,6 +232,14 @@
2.27 return
2.28
2.29 def register_Ns3FlowMonitorFlowStats_methods(root_module, cls):
2.30 + ## flow-monitor.h: ns3::FlowMonitor::FlowStats::timeFirstTxPacket [variable]
2.31 + cls.add_instance_attribute('timeFirstTxPacket', 'ns3::Time', is_const=False)
2.32 + ## flow-monitor.h: ns3::FlowMonitor::FlowStats::timeFirstRxPacket [variable]
2.33 + cls.add_instance_attribute('timeFirstRxPacket', 'ns3::Time', is_const=False)
2.34 + ## flow-monitor.h: ns3::FlowMonitor::FlowStats::timeLastTxPacket [variable]
2.35 + cls.add_instance_attribute('timeLastTxPacket', 'ns3::Time', is_const=False)
2.36 + ## flow-monitor.h: ns3::FlowMonitor::FlowStats::timeLastRxPacket [variable]
2.37 + cls.add_instance_attribute('timeLastRxPacket', 'ns3::Time', is_const=False)
2.38 ## flow-monitor.h: ns3::FlowMonitor::FlowStats::delaySum [variable]
2.39 cls.add_instance_attribute('delaySum', 'ns3::Time', is_const=False)
2.40 ## flow-monitor.h: ns3::FlowMonitor::FlowStats::txBytes [variable]
3.1 --- a/examples/flowmon.py Thu Apr 30 19:24:40 2009 +0100
3.2 +++ b/examples/flowmon.py Thu Apr 30 19:25:52 2009 +0100
3.3 @@ -97,6 +97,7 @@
3.4
3.5 #internet.EnablePcapAll("wifi-olsr")
3.6 flowmon_helper = ns3.FlowMonitorHelper()
3.7 + #flowmon_helper.SetMonitorAttribute("StartTime", ns3.TimeValue(ns3.Seconds(31)))
3.8 monitor = flowmon_helper.InstallAll()
3.9
3.10 ns3.Simulator.Stop(ns3.Seconds(44.0))
4.1 --- a/src/contrib/flow-monitor/design.txt Thu Apr 30 19:24:40 2009 +0100
4.2 +++ b/src/contrib/flow-monitor/design.txt Thu Apr 30 19:25:52 2009 +0100
4.3 @@ -34,7 +34,7 @@
4.4
4.5 TODO:
4.6
4.7 - 1. Configurable time when to start/stop monitor.
4.8 + 1. Configurable time when to start/stop monitor. ***DONE***
4.9 2. Possibly, detect packet losses also via "drop" trace sources
4.10 3. FlowMonitor::FlowStats: add time duration metrics: first flow timestamp, last flow timestamp
4.11 > to calculate bitrates...
5.1 --- a/src/contrib/flow-monitor/flow-monitor.cc Thu Apr 30 19:24:40 2009 +0100
5.2 +++ b/src/contrib/flow-monitor/flow-monitor.cc Thu Apr 30 19:25:52 2009 +0100
5.3 @@ -42,6 +42,10 @@
5.4 TimeValue (Seconds (10.0)),
5.5 MakeTimeAccessor (&FlowMonitor::m_maxPerHopDelay),
5.6 MakeTimeChecker ())
5.7 + .AddAttribute ("StartTime", ("The time when the monitoring starts."),
5.8 + TimeValue (Seconds (0.0)),
5.9 + MakeTimeAccessor (&FlowMonitor::Start),
5.10 + MakeTimeChecker ())
5.11 ;
5.12 return tid;
5.13 }
5.14 @@ -53,6 +57,7 @@
5.15 }
5.16
5.17 FlowMonitor::FlowMonitor ()
5.18 + : m_enabled (false)
5.19 {
5.20 }
5.21
5.22 @@ -84,8 +89,13 @@
5.23 void
5.24 FlowMonitor::ReportFirstTx (Ptr<FlowProbe> probe, uint32_t flowId, uint32_t packetId, uint32_t packetSize)
5.25 {
5.26 + if (!m_enabled)
5.27 + {
5.28 + return;
5.29 + }
5.30 + Time now = Simulator::Now ();
5.31 TrackedPacket &tracked = m_trackedPackets[std::make_pair (flowId, packetId)];
5.32 - tracked.firstSeenTime = Simulator::Now ();
5.33 + tracked.firstSeenTime = now;
5.34 tracked.lastSeenTime = tracked.firstSeenTime;
5.35 tracked.timesForwarded = 0;
5.36
5.37 @@ -94,12 +104,21 @@
5.38 FlowStats &stats = GetStatsForFlow (flowId);
5.39 stats.txBytes += packetSize;
5.40 stats.txPackets++;
5.41 + if (stats.txPackets == 1)
5.42 + {
5.43 + stats.timeFirstTxPacket = now;
5.44 + }
5.45 + stats.timeLastTxPacket = now;
5.46 }
5.47
5.48
5.49 void
5.50 FlowMonitor::ReportForwarding (Ptr<FlowProbe> probe, uint32_t flowId, uint32_t packetId, uint32_t packetSize)
5.51 {
5.52 + if (!m_enabled)
5.53 + {
5.54 + return;
5.55 + }
5.56 std::pair<FlowId, FlowPacketId> key (flowId, packetId);
5.57 TrackedPacketMap::iterator tracked = m_trackedPackets.find (key);
5.58 if (tracked == m_trackedPackets.end ())
5.59 @@ -120,6 +139,10 @@
5.60 void
5.61 FlowMonitor::ReportLastRx (Ptr<FlowProbe> probe, uint32_t flowId, uint32_t packetId, uint32_t packetSize)
5.62 {
5.63 + if (!m_enabled)
5.64 + {
5.65 + return;
5.66 + }
5.67 TrackedPacketMap::iterator tracked = m_trackedPackets.find (std::make_pair (flowId, packetId));
5.68 if (tracked == m_trackedPackets.end ())
5.69 {
5.70 @@ -128,13 +151,19 @@
5.71 return;
5.72 }
5.73
5.74 - Time delay = (Simulator::Now () - tracked->second.firstSeenTime);
5.75 + Time now = Simulator::Now ();
5.76 + Time delay = (now - tracked->second.firstSeenTime);
5.77 probe->AddPacketStats (flowId, packetSize, delay);
5.78
5.79 FlowStats &stats = GetStatsForFlow (flowId);
5.80 stats.delaySum += delay;
5.81 stats.rxBytes += packetSize;
5.82 stats.rxPackets++;
5.83 + if (stats.rxPackets == 1)
5.84 + {
5.85 + stats.timeFirstRxPacket = now;
5.86 + }
5.87 + stats.timeLastRxPacket = now;
5.88 stats.timesForwarded += tracked->second.timesForwarded;
5.89
5.90 m_trackedPackets.erase (tracked); // we don't need to track this packet anymore
5.91 @@ -207,5 +236,51 @@
5.92 }
5.93
5.94
5.95 +void
5.96 +FlowMonitor::Start (const Time &time)
5.97 +{
5.98 + if (m_enabled)
5.99 + {
5.100 + return;
5.101 + }
5.102 + Simulator::Cancel (m_startEvent);
5.103 + m_startEvent = Simulator::Schedule (time, &FlowMonitor::StartRightNow, Ptr<FlowMonitor> (this));
5.104 +}
5.105 +
5.106 +void
5.107 +FlowMonitor::Stop (const Time &time)
5.108 +{
5.109 + if (!m_enabled)
5.110 + {
5.111 + return;
5.112 + }
5.113 + Simulator::Cancel (m_stopEvent);
5.114 + m_stopEvent = Simulator::Schedule (time, &FlowMonitor::StopRightNow, Ptr<FlowMonitor> (this));
5.115 +}
5.116 +
5.117 +
5.118 +void
5.119 +FlowMonitor::StartRightNow ()
5.120 +{
5.121 + if (m_enabled)
5.122 + {
5.123 + return;
5.124 + }
5.125 + m_enabled = true;
5.126 +}
5.127 +
5.128 +
5.129 +void
5.130 +FlowMonitor::StopRightNow ()
5.131 +{
5.132 + if (!m_enabled)
5.133 + {
5.134 + return;
5.135 + }
5.136 + m_enabled = false;
5.137 + CheckForLostPackets ();
5.138 +}
5.139 +
5.140 +
5.141 } // namespace ns3
5.142
6.1 --- a/src/contrib/flow-monitor/flow-monitor.h Thu Apr 30 19:24:40 2009 +0100
6.2 +++ b/src/contrib/flow-monitor/flow-monitor.h Thu Apr 30 19:25:52 2009 +0100
6.3 @@ -29,6 +29,7 @@
6.4 #include "ns3/flow-probe.h"
6.5 #include "ns3/flow-classifier.h"
6.6 #include "ns3/nstime.h"
6.7 +#include "ns3/event-id.h"
6.8
6.9 namespace ns3 {
6.10
6.11 @@ -39,6 +40,10 @@
6.12
6.13 struct FlowStats
6.14 {
6.15 + Time timeFirstTxPacket;
6.16 + Time timeFirstRxPacket;
6.17 + Time timeLastTxPacket;
6.18 + Time timeLastRxPacket;
6.19 Time delaySum; // delayCount == rxPackets
6.20 uint64_t txBytes;
6.21 uint64_t rxBytes;
6.22 @@ -53,6 +58,11 @@
6.23 TypeId GetInstanceTypeId () const;
6.24 FlowMonitor ();
6.25
6.26 + void Start (const Time &time);
6.27 + void Stop (const Time &time);
6.28 + void StartRightNow ();
6.29 + void StopRightNow ();
6.30 +
6.31 // --- methods to be used by the FlowMonitorProbe's only ---
6.32 void AddProbe (Ptr<FlowProbe> probe);
6.33 void AddDelayVal (double delay);
6.34 @@ -93,6 +103,10 @@
6.35 Time m_maxPerHopDelay;
6.36 std::vector< Ptr<FlowProbe> > m_flowProbes;
6.37
6.38 + EventId m_startEvent;
6.39 + EventId m_stopEvent;
6.40 + bool m_enabled;
6.41 +
6.42 FlowStats& GetStatsForFlow (FlowId flowId);
6.43 void PeriodicCheckForLostPackets ();
6.44 };