1.1 --- a/bindings/python/ns3_module_bridge.py Wed Apr 29 15:39:19 2009 +0100
1.2 +++ b/bindings/python/ns3_module_bridge.py Wed Apr 29 19:08:39 2009 +0100
1.3 @@ -1,4 +1,4 @@
1.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
1.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
1.6
1.7 def register_types(module):
1.8 root_module = module.get_root()
2.1 --- a/bindings/python/ns3_module_common.py Wed Apr 29 15:39:19 2009 +0100
2.2 +++ b/bindings/python/ns3_module_common.py Wed Apr 29 19:08:39 2009 +0100
2.3 @@ -1,4 +1,4 @@
2.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
2.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
2.6
2.7 def register_types(module):
2.8 root_module = module.get_root()
3.1 --- a/bindings/python/ns3_module_contrib.py Wed Apr 29 15:39:19 2009 +0100
3.2 +++ b/bindings/python/ns3_module_contrib.py Wed Apr 29 19:08:39 2009 +0100
3.3 @@ -1,4 +1,4 @@
3.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
3.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
3.6
3.7 def register_types(module):
3.8 root_module = module.get_root()
4.1 --- a/bindings/python/ns3_module_core.py Wed Apr 29 15:39:19 2009 +0100
4.2 +++ b/bindings/python/ns3_module_core.py Wed Apr 29 19:08:39 2009 +0100
4.3 @@ -1,4 +1,4 @@
4.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
4.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
4.6
4.7 def register_types(module):
4.8 root_module = module.get_root()
5.1 --- a/bindings/python/ns3_module_csma.py Wed Apr 29 15:39:19 2009 +0100
5.2 +++ b/bindings/python/ns3_module_csma.py Wed Apr 29 19:08:39 2009 +0100
5.3 @@ -1,4 +1,4 @@
5.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
5.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
5.6
5.7 def register_types(module):
5.8 root_module = module.get_root()
6.1 --- a/bindings/python/ns3_module_flow_monitor.py Wed Apr 29 15:39:19 2009 +0100
6.2 +++ b/bindings/python/ns3_module_flow_monitor.py Wed Apr 29 19:08:39 2009 +0100
6.3 @@ -1,4 +1,4 @@
6.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
6.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
6.6
6.7 def register_types(module):
6.8 root_module = module.get_root()
6.9 @@ -21,6 +21,8 @@
6.10 module.add_class('FlowStats', outer_class=root_module['ns3::FlowMonitor'])
6.11 module.add_container('std::map< unsigned int, ns3::FlowProbe::FlowStats >', ('unsigned int', 'ns3::FlowProbe::FlowStats'), container_type='map')
6.12 module.add_container('std::map< unsigned int, ns3::FlowMonitor::FlowStats >', ('unsigned int', 'ns3::FlowMonitor::FlowStats'), container_type='map')
6.13 + typehandlers.add_type_alias('uint32_t', 'ns3::FlowPacketId')
6.14 + typehandlers.add_type_alias('uint32_t', 'ns3::FlowId')
6.15
6.16 ## Register a nested module for the namespace Config
6.17
6.18 @@ -124,6 +126,11 @@
6.19 cls.add_method('Classify',
6.20 'bool',
6.21 [param('ns3::Ipv4Header const &', 'ipHeader'), param('ns3::Ptr< ns3::Packet const >', 'ipPayload'), param('uint32_t *', 'out_flowId'), param('uint32_t *', 'out_packetId')])
6.22 + ## ipv4-flow-classifier.h: ns3::Ipv4FlowClassifier::FiveTuple ns3::Ipv4FlowClassifier::FindFlow(ns3::FlowId flowId) const [member function]
6.23 + cls.add_method('FindFlow',
6.24 + 'ns3::Ipv4FlowClassifier::FiveTuple',
6.25 + [param('ns3::FlowId', 'flowId')],
6.26 + is_const=True)
6.27 return
6.28
6.29 def register_Ns3Ipv4FlowClassifierFiveTuple_methods(root_module, cls):
7.1 --- a/bindings/python/ns3_module_global_routing.py Wed Apr 29 15:39:19 2009 +0100
7.2 +++ b/bindings/python/ns3_module_global_routing.py Wed Apr 29 19:08:39 2009 +0100
7.3 @@ -1,4 +1,4 @@
7.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
7.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
7.6
7.7 def register_types(module):
7.8 root_module = module.get_root()
8.1 --- a/bindings/python/ns3_module_helper.py Wed Apr 29 15:39:19 2009 +0100
8.2 +++ b/bindings/python/ns3_module_helper.py Wed Apr 29 19:08:39 2009 +0100
8.3 @@ -1,4 +1,4 @@
8.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
8.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
8.6
8.7 def register_types(module):
8.8 root_module = module.get_root()
8.9 @@ -267,6 +267,10 @@
8.10 cls.add_method('GetMonitor',
8.11 'ns3::Ptr< ns3::FlowMonitor >',
8.12 [])
8.13 + ## flow-monitor-helper.h: ns3::Ptr<ns3::FlowClassifier> ns3::FlowMonitorHelper::GetClassifier() [member function]
8.14 + cls.add_method('GetClassifier',
8.15 + 'ns3::Ptr< ns3::FlowClassifier >',
8.16 + [])
8.17 return
8.18
8.19 def register_Ns3InternetStackHelper_methods(root_module, cls):
9.1 --- a/bindings/python/ns3_module_internet_stack.py Wed Apr 29 15:39:19 2009 +0100
9.2 +++ b/bindings/python/ns3_module_internet_stack.py Wed Apr 29 19:08:39 2009 +0100
9.3 @@ -1,4 +1,4 @@
9.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
9.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
9.6
9.7 def register_types(module):
9.8 root_module = module.get_root()
10.1 --- a/bindings/python/ns3_module_mobility.py Wed Apr 29 15:39:19 2009 +0100
10.2 +++ b/bindings/python/ns3_module_mobility.py Wed Apr 29 19:08:39 2009 +0100
10.3 @@ -1,4 +1,4 @@
10.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
10.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
10.6
10.7 def register_types(module):
10.8 root_module = module.get_root()
11.1 --- a/bindings/python/ns3_module_node.py Wed Apr 29 15:39:19 2009 +0100
11.2 +++ b/bindings/python/ns3_module_node.py Wed Apr 29 19:08:39 2009 +0100
11.3 @@ -1,4 +1,4 @@
11.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
11.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
11.6
11.7 def register_types(module):
11.8 root_module = module.get_root()
12.1 --- a/bindings/python/ns3_module_olsr.py Wed Apr 29 15:39:19 2009 +0100
12.2 +++ b/bindings/python/ns3_module_olsr.py Wed Apr 29 19:08:39 2009 +0100
12.3 @@ -1,4 +1,4 @@
12.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
12.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
12.6
12.7 def register_types(module):
12.8 root_module = module.get_root()
12.9 @@ -70,6 +70,7 @@
12.10 module.add_container('std::vector< ns3::olsr::MessageHeader::Hello::LinkMessage >', 'ns3::olsr::MessageHeader::Hello::LinkMessage', container_type='vector')
12.11 module.add_container('std::vector< ns3::olsr::MessageHeader::Hna::Association >', 'ns3::olsr::MessageHeader::Hna::Association', container_type='vector')
12.12 module.add_container('std::vector< ns3::olsr::RoutingTableEntry >', 'ns3::olsr::RoutingTableEntry', container_type='vector')
12.13 + typehandlers.add_type_alias('std::vector< ns3::olsr::MessageHeader, std::allocator< ns3::olsr::MessageHeader > >', 'ns3::olsr::MessageList')
12.14
12.15 def register_methods(root_module):
12.16 register_Ns3OlsrAgent_methods(root_module, root_module['ns3::olsr::Agent'])
13.1 --- a/bindings/python/ns3_module_onoff.py Wed Apr 29 15:39:19 2009 +0100
13.2 +++ b/bindings/python/ns3_module_onoff.py Wed Apr 29 19:08:39 2009 +0100
13.3 @@ -1,4 +1,4 @@
13.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
13.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
13.6
13.7 def register_types(module):
13.8 root_module = module.get_root()
14.1 --- a/bindings/python/ns3_module_packet_sink.py Wed Apr 29 15:39:19 2009 +0100
14.2 +++ b/bindings/python/ns3_module_packet_sink.py Wed Apr 29 19:08:39 2009 +0100
14.3 @@ -1,4 +1,4 @@
14.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
14.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
14.6
14.7 def register_types(module):
14.8 root_module = module.get_root()
15.1 --- a/bindings/python/ns3_module_point_to_point.py Wed Apr 29 15:39:19 2009 +0100
15.2 +++ b/bindings/python/ns3_module_point_to_point.py Wed Apr 29 19:08:39 2009 +0100
15.3 @@ -1,4 +1,4 @@
15.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
15.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
15.6
15.7 def register_types(module):
15.8 root_module = module.get_root()
16.1 --- a/bindings/python/ns3_module_simulator.py Wed Apr 29 15:39:19 2009 +0100
16.2 +++ b/bindings/python/ns3_module_simulator.py Wed Apr 29 19:08:39 2009 +0100
16.3 @@ -1,4 +1,4 @@
16.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
16.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
16.6
16.7 def register_types(module):
16.8 root_module = module.get_root()
16.9 @@ -59,6 +59,10 @@
16.10 module.add_class('RealtimeSimulatorImpl', parent=root_module['ns3::SimulatorImpl'])
16.11 ## realtime-simulator-impl.h: ns3::RealtimeSimulatorImpl::SynchronizationMode [enumeration]
16.12 module.add_enum('SynchronizationMode', ['SYNC_BEST_EFFORT', 'SYNC_HARD_LIMIT'], outer_class=root_module['ns3::RealtimeSimulatorImpl'])
16.13 + typehandlers.add_type_alias('ns3::TimeUnit< 2 >', 'ns3::TimeSquare')
16.14 + typehandlers.add_type_alias('ns3::TimeUnit< - 1 >', 'ns3::TimeInvert')
16.15 + typehandlers.add_type_alias('ns3::TimeUnit< 0 >', 'ns3::Scalar')
16.16 + typehandlers.add_type_alias('ns3::TimeUnit< 1 >', 'ns3::Time')
16.17
16.18 ## Register a nested module for the namespace Config
16.19
17.1 --- a/bindings/python/ns3_module_stats.py Wed Apr 29 15:39:19 2009 +0100
17.2 +++ b/bindings/python/ns3_module_stats.py Wed Apr 29 19:08:39 2009 +0100
17.3 @@ -1,4 +1,4 @@
17.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
17.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
17.6
17.7 def register_types(module):
17.8 root_module = module.get_root()
17.9 @@ -25,6 +25,8 @@
17.10 module.add_class('CounterCalculator', template_parameters=['unsigned int'], parent=root_module['ns3::DataCalculator'])
17.11 ## packet-data-calculators.h: ns3::PacketCounterCalculator [class]
17.12 module.add_class('PacketCounterCalculator', parent=root_module['ns3::CounterCalculator< unsigned int >'])
17.13 + typehandlers.add_type_alias('std::list< ns3::Ptr< ns3::DataCalculator >, std::allocator< ns3::Ptr< ns3::DataCalculator > > >', 'ns3::DataCalculatorList')
17.14 + typehandlers.add_type_alias('std::list< std::pair< std::string, std::string >, std::allocator< std::pair< std::string, std::string > > >', 'ns3::MetadataList')
17.15
17.16 ## Register a nested module for the namespace Config
17.17
18.1 --- a/bindings/python/ns3_module_udp_echo.py Wed Apr 29 15:39:19 2009 +0100
18.2 +++ b/bindings/python/ns3_module_udp_echo.py Wed Apr 29 19:08:39 2009 +0100
18.3 @@ -1,4 +1,4 @@
18.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
18.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
18.6
18.7 def register_types(module):
18.8 root_module = module.get_root()
19.1 --- a/bindings/python/ns3_module_wifi.py Wed Apr 29 15:39:19 2009 +0100
19.2 +++ b/bindings/python/ns3_module_wifi.py Wed Apr 29 19:08:39 2009 +0100
19.3 @@ -1,4 +1,4 @@
19.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
19.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
19.6
19.7 def register_types(module):
19.8 root_module = module.get_root()
19.9 @@ -95,6 +95,7 @@
19.10 module.add_class('WifiNetDevice', parent=root_module['ns3::NetDevice'])
19.11 ## aarf-wifi-manager.h: ns3::AarfWifiManager [class]
19.12 module.add_class('AarfWifiManager', parent=root_module['ns3::ArfWifiManager'])
19.13 + typehandlers.add_type_alias('std::vector< ns3::ThresholdsItem, std::allocator< ns3::ThresholdsItem > >', 'ns3::Thresholds')
19.14
19.15 ## Register a nested module for the namespace Config
19.16
20.1 --- a/bindings/python/ns3modulegen_generated.py Wed Apr 29 15:39:19 2009 +0100
20.2 +++ b/bindings/python/ns3modulegen_generated.py Wed Apr 29 19:08:39 2009 +0100
20.3 @@ -1,4 +1,4 @@
20.4 -from pybindgen import Module, FileCodeSink, param, retval, cppclass
20.5 +from pybindgen import Module, FileCodeSink, param, retval, cppclass, typehandlers
20.6
20.7
20.8 import pybindgen.settings
21.1 --- a/bindings/python/wscript Wed Apr 29 15:39:19 2009 +0100
21.2 +++ b/bindings/python/wscript Wed Apr 29 19:08:39 2009 +0100
21.3 @@ -22,7 +22,7 @@
21.4 os.environ['PYTHONPATH'] = LOCAL_PYBINDGEN_PATH
21.5
21.6 ## https://launchpad.net/pybindgen/
21.7 -REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 601)
21.8 +REQUIRED_PYBINDGEN_VERSION = (0, 10, 0, 636)
21.9 REQUIRED_PYGCCXML_VERSION = (0, 9, 5)
21.10
21.11
22.1 --- a/examples/flowmon.py Wed Apr 29 15:39:19 2009 +0100
22.2 +++ b/examples/flowmon.py Wed Apr 29 19:08:39 2009 +0100
22.3 @@ -83,6 +83,7 @@
22.4 #internet.EnablePcapAll("wifi-olsr")
22.5 flowmon_helper = ns3.FlowMonitorHelper()
22.6 monitor = flowmon_helper.InstallAll()
22.7 + classifier = flowmon_helper.GetClassifier()
22.8
22.9 ns3.Simulator.Stop(ns3.Seconds(44.0))
22.10 if 0:
22.11 @@ -102,7 +103,10 @@
22.12
22.13 monitor.CheckForLostPackets()
22.14 for flow_id, flow_stats in monitor.GetFlowStats():
22.15 - print "FlowID: ", flow_id
22.16 + t = classifier.FindFlow(flow_id)
22.17 + proto = {6: 'TCP', 17: 'UDP'} [t.protocol]
22.18 + print "FlowID: %i (%s %s/%s --> %s/%i)" % \
22.19 + (flow_id, proto, t.sourceAddress, t.sourcePort, t.destinationAddress, t.destinationPort)
22.20 print_stats(sys.stdout, flow_stats)
22.21
22.22 return 0
23.1 --- a/src/contrib/flow-monitor/ipv4-flow-classifier.cc Wed Apr 29 15:39:19 2009 +0100
23.2 +++ b/src/contrib/flow-monitor/ipv4-flow-classifier.cc Wed Apr 29 19:08:39 2009 +0100
23.3 @@ -149,5 +149,22 @@
23.4 }
23.5
23.6
23.7 +Ipv4FlowClassifier::FiveTuple
23.8 +Ipv4FlowClassifier::FindFlow (FlowId flowId) const
23.9 +{
23.10 + for (std::map<FiveTuple, FlowId>::const_iterator
23.11 + iter = m_flowMap.begin (); iter != m_flowMap.end (); iter++)
23.12 + {
23.13 + if (iter->second == flowId)
23.14 + {
23.15 + return iter->first;
23.16 + }
23.17 + }
23.18 + NS_FATAL_ERROR ("Could not find the flow with ID " << flowId);
23.19 + FiveTuple retval = { Ipv4Address::GetZero (), Ipv4Address::GetZero (), 0, 0, 0 };
23.20 + return retval;
23.21 +}
23.22 +
23.23 +
23.24 } // namespace ns3
23.25
24.1 --- a/src/contrib/flow-monitor/ipv4-flow-classifier.h Wed Apr 29 15:39:19 2009 +0100
24.2 +++ b/src/contrib/flow-monitor/ipv4-flow-classifier.h Wed Apr 29 19:08:39 2009 +0100
24.3 @@ -52,6 +52,8 @@
24.4 bool Classify (const Ipv4Header &ipHeader, Ptr<const Packet> ipPayload,
24.5 uint32_t *out_flowId, uint32_t *out_packetId);
24.6
24.7 + /// Searches for the FiveTuple corresponding to the given flowId
24.8 + FiveTuple FindFlow (FlowId flowId) const;
24.9
24.10 private:
24.11
25.1 --- a/src/helper/flow-monitor-helper.cc Wed Apr 29 15:39:19 2009 +0100
25.2 +++ b/src/helper/flow-monitor-helper.cc Wed Apr 29 19:08:39 2009 +0100
25.3 @@ -27,6 +27,17 @@
25.4
25.5 namespace ns3 {
25.6
25.7 +namespace {
25.8 + template <typename T1, typename T2>
25.9 + Ptr<T1>
25.10 + DynamicCast (Ptr<T2> const&p)
25.11 + {
25.12 + return Ptr<T1> (dynamic_cast<T1 *> (PeekPointer (p)));
25.13 + }
25.14 +}
25.15 +
25.16 +
25.17 +
25.18 FlowMonitorHelper::FlowMonitorHelper ()
25.19 {
25.20 m_monitorFactory.SetTypeId ("ns3::FlowMonitor");
25.21 @@ -51,11 +62,25 @@
25.22 }
25.23
25.24
25.25 +Ptr<FlowClassifier>
25.26 +FlowMonitorHelper::GetClassifier ()
25.27 +{
25.28 + if (!m_flowClassifier)
25.29 + {
25.30 + m_flowClassifier = Create<Ipv4FlowClassifier> ();
25.31 + }
25.32 + return m_flowClassifier;
25.33 +}
25.34 +
25.35 +
25.36 Ptr<FlowMonitor>
25.37 FlowMonitorHelper::Install (Ptr<Node> node)
25.38 {
25.39 - GetMonitor ();
25.40 - Ptr<Ipv4FlowProbe> probe = Create<Ipv4FlowProbe> (m_flowMonitor, m_flowClassifier, node);
25.41 + Ptr<FlowMonitor> monitor = GetMonitor ();
25.42 + Ptr<FlowClassifier> classifier = GetClassifier ();
25.43 + Ptr<Ipv4FlowProbe> probe = Create<Ipv4FlowProbe> (monitor,
25.44 + DynamicCast<Ipv4FlowClassifier> (classifier),
25.45 + node);
25.46 return m_flowMonitor;
25.47 }
25.48
26.1 --- a/src/helper/flow-monitor-helper.h Wed Apr 29 15:39:19 2009 +0100
26.2 +++ b/src/helper/flow-monitor-helper.h Wed Apr 29 19:08:39 2009 +0100
26.3 @@ -23,6 +23,7 @@
26.4 #include "node-container.h"
26.5 #include "ns3/object-factory.h"
26.6 #include "ns3/flow-monitor.h"
26.7 +#include "ns3/flow-classifier.h"
26.8 #include <string>
26.9
26.10 namespace ns3 {
26.11 @@ -41,11 +42,12 @@
26.12 Ptr<FlowMonitor> InstallAll ();
26.13
26.14 Ptr<FlowMonitor> GetMonitor ();
26.15 + Ptr<FlowClassifier> GetClassifier ();
26.16
26.17 private:
26.18 ObjectFactory m_monitorFactory;
26.19 Ptr<FlowMonitor> m_flowMonitor;
26.20 - Ptr<Ipv4FlowClassifier> m_flowClassifier;
26.21 + Ptr<FlowClassifier> m_flowClassifier;
26.22 };
26.23
26.24 } // namespace ns3