1.1 --- a/bindings/python/callbacks_list.py Thu Apr 30 16:17:06 2009 +0100
1.2 +++ b/bindings/python/callbacks_list.py Thu Apr 30 18:43:24 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 16:17:06 2009 +0100
2.2 +++ b/bindings/python/ns3_module_flow_monitor.py Thu Apr 30 18:43:24 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',
3.1 --- a/examples/flowmon.py Thu Apr 30 16:17:06 2009 +0100
3.2 +++ b/examples/flowmon.py Thu Apr 30 18:43:24 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 16:17:06 2009 +0100
4.2 +++ b/src/contrib/flow-monitor/design.txt Thu Apr 30 18:43:24 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 16:17:06 2009 +0100
5.2 +++ b/src/contrib/flow-monitor/flow-monitor.cc Thu Apr 30 18:43:24 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,6 +89,10 @@
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 TrackedPacket &tracked = m_trackedPackets[std::make_pair (flowId, packetId)];
5.31 tracked.firstSeenTime = Simulator::Now ();
5.32 tracked.lastSeenTime = tracked.firstSeenTime;
5.33 @@ -100,6 +109,10 @@
5.34 void
5.35 FlowMonitor::ReportForwarding (Ptr<FlowProbe> probe, uint32_t flowId, uint32_t packetId, uint32_t packetSize)
5.36 {
5.37 + if (!m_enabled)
5.38 + {
5.39 + return;
5.40 + }
5.41 std::pair<FlowId, FlowPacketId> key (flowId, packetId);
5.42 TrackedPacketMap::iterator tracked = m_trackedPackets.find (key);
5.43 if (tracked == m_trackedPackets.end ())
5.44 @@ -120,6 +133,10 @@
5.45 void
5.46 FlowMonitor::ReportLastRx (Ptr<FlowProbe> probe, uint32_t flowId, uint32_t packetId, uint32_t packetSize)
5.47 {
5.48 + if (!m_enabled)
5.49 + {
5.50 + return;
5.51 + }
5.52 TrackedPacketMap::iterator tracked = m_trackedPackets.find (std::make_pair (flowId, packetId));
5.53 if (tracked == m_trackedPackets.end ())
5.54 {
5.55 @@ -207,5 +224,51 @@
5.56 }
5.57
5.58
5.59 +void
5.60 +FlowMonitor::Start (const Time &time)
5.61 +{
5.62 + if (m_enabled)
5.63 + {
5.64 + return;
5.65 + }
5.66 + Simulator::Cancel (m_startEvent);
5.67 + m_startEvent = Simulator::Schedule (time, &FlowMonitor::StartRightNow, Ptr<FlowMonitor> (this));
5.68 +}
5.69 +
5.70 +void
5.71 +FlowMonitor::Stop (const Time &time)
5.72 +{
5.73 + if (!m_enabled)
5.74 + {
5.75 + return;
5.76 + }
5.77 + Simulator::Cancel (m_stopEvent);
5.78 + m_stopEvent = Simulator::Schedule (time, &FlowMonitor::StopRightNow, Ptr<FlowMonitor> (this));
5.79 +}
5.80 +
5.81 +
5.82 +void
5.83 +FlowMonitor::StartRightNow ()
5.84 +{
5.85 + if (m_enabled)
5.86 + {
5.87 + return;
5.88 + }
5.89 + m_enabled = true;
5.90 +}
5.91 +
5.92 +
5.93 +void
5.94 +FlowMonitor::StopRightNow ()
5.95 +{
5.96 + if (!m_enabled)
5.97 + {
5.98 + return;
5.99 + }
5.100 + m_enabled = false;
5.101 + CheckForLostPackets ();
5.102 +}
5.103 +
5.104 +
5.105 } // namespace ns3
5.106
6.1 --- a/src/contrib/flow-monitor/flow-monitor.h Thu Apr 30 16:17:06 2009 +0100
6.2 +++ b/src/contrib/flow-monitor/flow-monitor.h Thu Apr 30 18:43:24 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 @@ -53,6 +54,11 @@
6.12 TypeId GetInstanceTypeId () const;
6.13 FlowMonitor ();
6.14
6.15 + void Start (const Time &time);
6.16 + void Stop (const Time &time);
6.17 + void StartRightNow ();
6.18 + void StopRightNow ();
6.19 +
6.20 // --- methods to be used by the FlowMonitorProbe's only ---
6.21 void AddProbe (Ptr<FlowProbe> probe);
6.22 void ReportFirstTx (Ptr<FlowProbe> probe, FlowId flowId, FlowPacketId packetId, uint32_t packetSize);
6.23 @@ -91,6 +97,10 @@
6.24 Time m_maxPerHopDelay;
6.25 std::vector< Ptr<FlowProbe> > m_flowProbes;
6.26
6.27 + EventId m_startEvent;
6.28 + EventId m_stopEvent;
6.29 + bool m_enabled;
6.30 +
6.31 FlowStats& GetStatsForFlow (FlowId flowId);
6.32 void PeriodicCheckForLostPackets ();
6.33 };