diff -r 96811f76c3e2 bindings/python/ns3_module_core.py --- a/bindings/python/ns3_module_core.py Mon Jun 22 18:29:43 2009 -0700 +++ b/bindings/python/ns3_module_core.py Tue Jun 23 11:05:56 2009 +0200 @@ -2043,7 +2043,7 @@ cls.add_method('ConnectWithoutContext', 'void', [param('ns3::CallbackBase const &', 'cb')]) - ## traced-value.h: void ns3::TracedValue::Connect(ns3::CallbackBase const & cb, std::basic_string,std::allocator > path) [member function] + ## traced-value.h: void ns3::TracedValue::Connect(ns3::CallbackBase const & cb, std::string path) [member function] cls.add_method('Connect', 'void', [param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')]) @@ -2051,7 +2051,7 @@ cls.add_method('DisconnectWithoutContext', 'void', [param('ns3::CallbackBase const &', 'cb')]) - ## traced-value.h: void ns3::TracedValue::Disconnect(ns3::CallbackBase const & cb, std::basic_string,std::allocator > path) [member function] + ## traced-value.h: void ns3::TracedValue::Disconnect(ns3::CallbackBase const & cb, std::string path) [member function] cls.add_method('Disconnect', 'void', [param('ns3::CallbackBase const &', 'cb'), param('std::string', 'path')]) @@ -2199,7 +2199,7 @@ module.add_function('TypeNameGet', 'std::string', [], - template_parameters=['long']) + template_parameters=['long long']) ## type-name.h: extern std::string ns3::TypeNameGet() [free function] module.add_function('TypeNameGet', 'std::string', @@ -2219,7 +2219,7 @@ module.add_function('TypeNameGet', 'std::string', [], - template_parameters=['unsigned long']) + template_parameters=['unsigned long long']) ## type-name.h: extern std::string ns3::TypeNameGet() [free function] module.add_function('TypeNameGet', 'std::string', diff -r 96811f76c3e2 bindings/python/ns3_module_helper.py --- a/bindings/python/ns3_module_helper.py Mon Jun 22 18:29:43 2009 -0700 +++ b/bindings/python/ns3_module_helper.py Tue Jun 23 11:05:56 2009 +0200 @@ -17,8 +17,10 @@ module.add_class('Ipv4AddressHelper', allow_subclassing=False) ## ipv4-interface-container.h: ns3::Ipv4InterfaceContainer [class] module.add_class('Ipv4InterfaceContainer') + ## internet-stack-helper.h: ns3::Ipv4RoutingHelper [class] + module.add_class('Ipv4RoutingHelper', allow_subclassing=False) ## ipv4-static-routing-helper.h: ns3::Ipv4StaticRoutingHelper [class] - module.add_class('Ipv4StaticRoutingHelper', allow_subclassing=False) + module.add_class('Ipv4StaticRoutingHelper', allow_subclassing=False, parent=root_module['ns3::Ipv4RoutingHelper']) ## mobility-helper.h: ns3::MobilityHelper [class] module.add_class('MobilityHelper', allow_subclassing=False) ## net-device-container.h: ns3::NetDeviceContainer [class] @@ -28,7 +30,7 @@ ## ns2-mobility-helper.h: ns3::Ns2MobilityHelper [class] module.add_class('Ns2MobilityHelper', allow_subclassing=False) ## olsr-helper.h: ns3::OlsrHelper [class] - module.add_class('OlsrHelper', allow_subclassing=False) + module.add_class('OlsrHelper', allow_subclassing=False, parent=root_module['ns3::Ipv4RoutingHelper']) ## on-off-helper.h: ns3::OnOffHelper [class] module.add_class('OnOffHelper', allow_subclassing=False) ## packet-sink-helper.h: ns3::PacketSinkHelper [class] @@ -57,6 +59,8 @@ module.add_class('YansWifiPhyHelper', allow_subclassing=False, parent=root_module['ns3::WifiPhyHelper']) ## yans-wifi-helper.h: ns3::YansWifiPhyHelper::PcapFormat [enumeration] module.add_enum('PcapFormat', ['PCAP_FORMAT_80211', 'PCAP_FORMAT_80211_PRISM', 'PCAP_FORMAT_80211_RADIOTAP'], outer_class=root_module['ns3::YansWifiPhyHelper']) + ## internet-stack-helper.h: ns3::Ipv4ListRoutingHelper [class] + module.add_class('Ipv4ListRoutingHelper', allow_subclassing=False, parent=root_module['ns3::Ipv4RoutingHelper']) ## nqos-wifi-mac-helper.h: ns3::NqosWifiMacHelper [class] module.add_class('NqosWifiMacHelper', allow_subclassing=False, parent=root_module['ns3::WifiMacHelper']) ## qos-wifi-mac-helper.h: ns3::QosWifiMacHelper [class] @@ -120,6 +124,7 @@ register_Ns3InternetStackHelper_methods(root_module, root_module['ns3::InternetStackHelper']) register_Ns3Ipv4AddressHelper_methods(root_module, root_module['ns3::Ipv4AddressHelper']) register_Ns3Ipv4InterfaceContainer_methods(root_module, root_module['ns3::Ipv4InterfaceContainer']) + register_Ns3Ipv4RoutingHelper_methods(root_module, root_module['ns3::Ipv4RoutingHelper']) register_Ns3Ipv4StaticRoutingHelper_methods(root_module, root_module['ns3::Ipv4StaticRoutingHelper']) register_Ns3MobilityHelper_methods(root_module, root_module['ns3::MobilityHelper']) register_Ns3NetDeviceContainer_methods(root_module, root_module['ns3::NetDeviceContainer']) @@ -139,6 +144,7 @@ register_Ns3WifiPhyHelper_methods(root_module, root_module['ns3::WifiPhyHelper']) register_Ns3YansWifiChannelHelper_methods(root_module, root_module['ns3::YansWifiChannelHelper']) register_Ns3YansWifiPhyHelper_methods(root_module, root_module['ns3::YansWifiPhyHelper']) + register_Ns3Ipv4ListRoutingHelper_methods(root_module, root_module['ns3::Ipv4ListRoutingHelper']) register_Ns3NqosWifiMacHelper_methods(root_module, root_module['ns3::NqosWifiMacHelper']) register_Ns3QosWifiMacHelper_methods(root_module, root_module['ns3::QosWifiMacHelper']) return @@ -420,6 +426,10 @@ cls.add_constructor([param('ns3::InternetStackHelper const &', 'arg0')]) ## internet-stack-helper.h: ns3::InternetStackHelper::InternetStackHelper() [constructor] cls.add_constructor([]) + ## internet-stack-helper.h: void ns3::InternetStackHelper::SetRoutingHelper(ns3::Ipv4RoutingHelper const & routing) [member function] + cls.add_method('SetRoutingHelper', + 'void', + [param('ns3::Ipv4RoutingHelper const &', 'routing')]) ## internet-stack-helper.h: void ns3::InternetStackHelper::Install(std::string nodeName) const [member function] cls.add_method('Install', 'void', @@ -516,11 +526,28 @@ [param('std::string', 'ipv4Name'), param('uint32_t', 'interface')]) return +def register_Ns3Ipv4RoutingHelper_methods(root_module, cls): + ## internet-stack-helper.h: ns3::Ipv4RoutingHelper::Ipv4RoutingHelper(ns3::Ipv4RoutingHelper const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Ipv4RoutingHelper const &', 'arg0')]) + ## internet-stack-helper.h: ns3::Ipv4RoutingHelper::Ipv4RoutingHelper() [constructor] + cls.add_constructor([]) + ## internet-stack-helper.h: ns3::Ptr ns3::Ipv4RoutingHelper::Create(ns3::Ptr node) const [member function] + cls.add_method('Create', + 'ns3::Ptr< ns3::Ipv4RoutingProtocol >', + [param('ns3::Ptr< ns3::Node >', 'node')], + is_pure_virtual=True, is_const=True, is_virtual=True) + return + def register_Ns3Ipv4StaticRoutingHelper_methods(root_module, cls): ## ipv4-static-routing-helper.h: ns3::Ipv4StaticRoutingHelper::Ipv4StaticRoutingHelper(ns3::Ipv4StaticRoutingHelper const & arg0) [copy constructor] cls.add_constructor([param('ns3::Ipv4StaticRoutingHelper const &', 'arg0')]) ## ipv4-static-routing-helper.h: ns3::Ipv4StaticRoutingHelper::Ipv4StaticRoutingHelper() [constructor] cls.add_constructor([]) + ## ipv4-static-routing-helper.h: ns3::Ptr ns3::Ipv4StaticRoutingHelper::Create(ns3::Ptr node) const [member function] + cls.add_method('Create', + 'ns3::Ptr< ns3::Ipv4RoutingProtocol >', + [param('ns3::Ptr< ns3::Node >', 'node')], + is_const=True, is_virtual=True) ## ipv4-static-routing-helper.h: ns3::Ptr ns3::Ipv4StaticRoutingHelper::GetStaticRouting(ns3::Ptr ipv4) const [member function] cls.add_method('GetStaticRouting', 'ns3::Ptr< ns3::Ipv4StaticRouting >', @@ -752,26 +779,15 @@ cls.add_constructor([param('ns3::OlsrHelper const &', 'arg0')]) ## olsr-helper.h: ns3::OlsrHelper::OlsrHelper() [constructor] cls.add_constructor([]) - ## olsr-helper.h: void ns3::OlsrHelper::SetAgent(std::string tid, std::string n0="", ns3::AttributeValue const & v0=ns3::EmptyAttributeValue(), std::string n1="", ns3::AttributeValue const & v1=ns3::EmptyAttributeValue(), std::string n2="", ns3::AttributeValue const & v2=ns3::EmptyAttributeValue(), std::string n3="", ns3::AttributeValue const & v3=ns3::EmptyAttributeValue(), std::string n4="", ns3::AttributeValue const & v4=ns3::EmptyAttributeValue(), std::string n5="", ns3::AttributeValue const & v5=ns3::EmptyAttributeValue(), std::string n6="", ns3::AttributeValue const & v6=ns3::EmptyAttributeValue(), std::string n7="", ns3::AttributeValue const & v7=ns3::EmptyAttributeValue()) [member function] - cls.add_method('SetAgent', + ## olsr-helper.h: ns3::Ptr ns3::OlsrHelper::Create(ns3::Ptr node) const [member function] + cls.add_method('Create', + 'ns3::Ptr< ns3::Ipv4RoutingProtocol >', + [param('ns3::Ptr< ns3::Node >', 'node')], + is_const=True, is_virtual=True) + ## olsr-helper.h: void ns3::OlsrHelper::Set(std::string name, ns3::AttributeValue const & value) [member function] + cls.add_method('Set', 'void', - [param('std::string', 'tid'), param('std::string', 'n0', default_value='""'), param('ns3::AttributeValue const &', 'v0', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n1', default_value='""'), param('ns3::AttributeValue const &', 'v1', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n2', default_value='""'), param('ns3::AttributeValue const &', 'v2', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n3', default_value='""'), param('ns3::AttributeValue const &', 'v3', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n4', default_value='""'), param('ns3::AttributeValue const &', 'v4', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n5', default_value='""'), param('ns3::AttributeValue const &', 'v5', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n6', default_value='""'), param('ns3::AttributeValue const &', 'v6', default_value='ns3::EmptyAttributeValue()'), param('std::string', 'n7', default_value='""'), param('ns3::AttributeValue const &', 'v7', default_value='ns3::EmptyAttributeValue()')]) - ## olsr-helper.h: void ns3::OlsrHelper::Install(ns3::NodeContainer container) [member function] - cls.add_method('Install', - 'void', - [param('ns3::NodeContainer', 'container')]) - ## olsr-helper.h: void ns3::OlsrHelper::Install(ns3::Ptr node) [member function] - cls.add_method('Install', - 'void', - [param('ns3::Ptr< ns3::Node >', 'node')]) - ## olsr-helper.h: void ns3::OlsrHelper::Install(std::string nodeName) [member function] - cls.add_method('Install', - 'void', - [param('std::string', 'nodeName')]) - ## olsr-helper.h: void ns3::OlsrHelper::InstallAll() [member function] - cls.add_method('InstallAll', - 'void', - []) + [param('std::string', 'name'), param('ns3::AttributeValue const &', 'value')]) return def register_Ns3OnOffHelper_methods(root_module, cls): @@ -1217,6 +1233,22 @@ is_const=True, visibility='private', is_virtual=True) return +def register_Ns3Ipv4ListRoutingHelper_methods(root_module, cls): + ## internet-stack-helper.h: ns3::Ipv4ListRoutingHelper::Ipv4ListRoutingHelper(ns3::Ipv4ListRoutingHelper const & arg0) [copy constructor] + cls.add_constructor([param('ns3::Ipv4ListRoutingHelper const &', 'arg0')]) + ## internet-stack-helper.h: ns3::Ipv4ListRoutingHelper::Ipv4ListRoutingHelper() [constructor] + cls.add_constructor([]) + ## internet-stack-helper.h: void ns3::Ipv4ListRoutingHelper::Add(ns3::Ipv4RoutingHelper const & routing, int16_t priority) [member function] + cls.add_method('Add', + 'void', + [param('ns3::Ipv4RoutingHelper const &', 'routing'), param('int16_t', 'priority')]) + ## internet-stack-helper.h: ns3::Ptr ns3::Ipv4ListRoutingHelper::Create(ns3::Ptr node) const [member function] + cls.add_method('Create', + 'ns3::Ptr< ns3::Ipv4RoutingProtocol >', + [param('ns3::Ptr< ns3::Node >', 'node')], + is_const=True, is_virtual=True) + return + def register_Ns3NqosWifiMacHelper_methods(root_module, cls): ## nqos-wifi-mac-helper.h: ns3::NqosWifiMacHelper::NqosWifiMacHelper(ns3::NqosWifiMacHelper const & arg0) [copy constructor] cls.add_constructor([param('ns3::NqosWifiMacHelper const &', 'arg0')]) diff -r 96811f76c3e2 bindings/python/ns3_module_internet_stack.py --- a/bindings/python/ns3_module_internet_stack.py Mon Jun 22 18:29:43 2009 -0700 +++ b/bindings/python/ns3_module_internet_stack.py Tue Jun 23 11:05:56 2009 +0200 @@ -172,6 +172,11 @@ 'uint16_t', [], is_const=True) + ## icmpv4.h: uint32_t ns3::Icmpv4Echo::GetDataSize() const [member function] + cls.add_method('GetDataSize', + 'uint32_t', + [], + is_const=True) ## icmpv4.h: uint32_t ns3::Icmpv4Echo::GetData(uint8_t * payload) const [member function] cls.add_method('GetData', 'uint32_t', diff -r 96811f76c3e2 bindings/python/ns3_module_olsr.py --- a/bindings/python/ns3_module_olsr.py Mon Jun 22 18:29:43 2009 -0700 +++ b/bindings/python/ns3_module_olsr.py Tue Jun 23 11:05:56 2009 +0200 @@ -102,13 +102,13 @@ module.add_container('std::vector< ns3::olsr::MessageHeader::Hello::LinkMessage >', 'ns3::olsr::MessageHeader::Hello::LinkMessage', container_type='vector') module.add_container('std::vector< ns3::olsr::MessageHeader::Hna::Association >', 'ns3::olsr::MessageHeader::Hna::Association', container_type='vector') typehandlers.add_type_alias('std::vector< ns3::olsr::DuplicateTuple, std::allocator< ns3::olsr::DuplicateTuple > >', 'ns3::olsr::DuplicateSet') - typehandlers.add_type_alias('std::vector< ns3::olsr::TopologyTuple, std::allocator< ns3::olsr::TopologyTuple > >', 'ns3::olsr::TopologySet') typehandlers.add_type_alias('std::set< ns3::Ipv4Address, std::less< ns3::Ipv4Address >, std::allocator< ns3::Ipv4Address > >', 'ns3::olsr::MprSet') typehandlers.add_type_alias('std::vector< ns3::olsr::MprSelectorTuple, std::allocator< ns3::olsr::MprSelectorTuple > >', 'ns3::olsr::MprSelectorSet') typehandlers.add_type_alias('std::vector< ns3::olsr::MessageHeader, std::allocator< ns3::olsr::MessageHeader > >', 'ns3::olsr::MessageList') typehandlers.add_type_alias('std::vector< ns3::olsr::IfaceAssocTuple, std::allocator< ns3::olsr::IfaceAssocTuple > >', 'ns3::olsr::IfaceAssocSet') typehandlers.add_type_alias('std::vector< ns3::olsr::NeighborTuple, std::allocator< ns3::olsr::NeighborTuple > >', 'ns3::olsr::NeighborSet') typehandlers.add_type_alias('std::vector< ns3::olsr::TwoHopNeighborTuple, std::allocator< ns3::olsr::TwoHopNeighborTuple > >', 'ns3::olsr::TwoHopNeighborSet') + typehandlers.add_type_alias('std::vector< ns3::olsr::TopologyTuple, std::allocator< ns3::olsr::TopologyTuple > >', 'ns3::olsr::TopologySet') typehandlers.add_type_alias('std::vector< ns3::olsr::LinkTuple, std::allocator< ns3::olsr::LinkTuple > >', 'ns3::olsr::LinkSet') def register_methods(root_module): @@ -747,10 +747,6 @@ is_static=True) ## olsr-routing-protocol.h: ns3::olsr::RoutingProtocol::RoutingProtocol() [constructor] cls.add_constructor([]) - ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::Start() [member function] - cls.add_method('Start', - 'void', - []) ## olsr-routing-protocol.h: void ns3::olsr::RoutingProtocol::SetMainInterface(uint32_t interface) [member function] cls.add_method('SetMainInterface', 'void', diff -r 96811f76c3e2 examples/mixed-wireless.cc --- a/examples/mixed-wireless.cc Mon Jun 22 18:29:43 2009 -0700 +++ b/examples/mixed-wireless.cc Tue Jun 23 11:05:56 2009 +0200 @@ -152,11 +152,23 @@ YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default (); wifiPhy.SetChannel (wifiChannel.Create ()); NetDeviceContainer backboneDevices = wifi.Install (wifiPhy, mac, backbone); + + // We enable OLSR (which will be consulted at a higher priority than + // the global routing above) on the backbone ad hoc nodes + NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes"); + OlsrHelper olsr; + + Ipv4ListRoutingHelper list; + list.Add (olsr, 10); + // // Add the IPv4 protocol stack to the nodes in our container // InternetStackHelper internet; + internet.SetRoutingHelper (list); internet.Install (backbone); + + // // Assign IPv4 addresses to the device drivers (actually to the associated // IPv4 interfaces) we just created. @@ -324,12 +336,6 @@ NS_LOG_INFO ("Enabling global routing on all nodes"); GlobalRouteManager::PopulateRoutingTables (); - // We enable OLSR (which will be consulted at a higher priority than - // the global routing above) on the backbone ad hoc nodes - NS_LOG_INFO ("Enabling OLSR routing on all backbone nodes"); - OlsrHelper olsr; - olsr.Install (backbone); - /////////////////////////////////////////////////////////////////////////// // // // Application configuration // diff -r 96811f76c3e2 examples/simple-point-to-point-olsr.cc --- a/examples/simple-point-to-point-olsr.cc Mon Jun 22 18:29:43 2009 -0700 +++ b/examples/simple-point-to-point-olsr.cc Tue Jun 23 11:05:56 2009 +0200 @@ -82,7 +82,18 @@ NodeContainer n32 = NodeContainer (c.Get(3), c.Get (2)); NodeContainer n34 = NodeContainer (c.Get (3), c.Get (4)); + // Enable OLSR + NS_LOG_INFO ("Enabling OLSR Routing."); + OlsrHelper olsr; + + Ipv4StaticRoutingHelper staticRouting; + + Ipv4ListRoutingHelper list; + list.Add (staticRouting, 0); + list.Add (olsr, 10); + InternetStackHelper internet; + internet.SetRoutingHelper (list); internet.Install (c); // We create the channels first without any IP addressing information @@ -112,11 +123,6 @@ ipv4.SetBase ("10.1.4.0", "255.255.255.0"); Ipv4InterfaceContainer i34 = ipv4.Assign (nd34); - // Enable OLSR - NS_LOG_INFO ("Enabling OLSR Routing."); - OlsrHelper olsr; - olsr.InstallAll (); - // Create the OnOff application to send UDP datagrams of size // 210 bytes at a rate of 448 Kb/s NS_LOG_INFO ("Create Applications."); diff -r 96811f76c3e2 src/helper/internet-stack-helper.cc --- a/src/helper/internet-stack-helper.cc Mon Jun 22 18:29:43 2009 -0700 +++ b/src/helper/internet-stack-helper.cc Tue Jun 23 11:05:56 2009 +0200 @@ -153,7 +153,6 @@ #include "ns3/object.h" #include "ns3/names.h" #include "ns3/ipv4.h" -#include "internet-stack-helper.h" #include "ns3/packet-socket-factory.h" #include "ns3/config.h" #include "ns3/simulator.h" @@ -164,6 +163,8 @@ #include "ns3/core-config.h" #include "ns3/ipv4-list-routing.h" #include "ns3/ipv4-static-routing.h" +#include "internet-stack-helper.h" +#include "ipv4-static-routing-helper.h" #include namespace ns3 { @@ -171,9 +172,42 @@ std::vector InternetStackHelper::m_traces; std::string InternetStackHelper::m_pcapBaseFilename; +Ipv4RoutingHelper::~Ipv4RoutingHelper () +{} + +Ipv4ListRoutingHelper::Ipv4ListRoutingHelper() +{} +void +Ipv4ListRoutingHelper::Add (const Ipv4RoutingHelper &routing, int16_t priority) +{ + m_list.push_back (std::make_pair(&routing,priority)); +} +Ptr +Ipv4ListRoutingHelper::Create (Ptr node) const +{ + Ptr list = CreateObject (); + for (std::list >::const_iterator i = m_list.begin (); + i != m_list.end (); ++i) + { + Ptr prot = i->first->Create (node); + list->AddRoutingProtocol (prot,i->second); + } + return list; +} + InternetStackHelper::InternetStackHelper () { SetTcp ("ns3::TcpL4Protocol"); + static Ipv4StaticRoutingHelper staticRouting; + static Ipv4ListRoutingHelper listRouting; + listRouting.Add (staticRouting,0); + SetRoutingHelper (listRouting); +} + +void +InternetStackHelper::SetRoutingHelper (const Ipv4RoutingHelper &routing) +{ + m_routing = &routing; } void @@ -213,8 +247,8 @@ } } -static void -CreateAndAggregateObjectFromTypeId (Ptr node, const std::string typeId) +void +InternetStackHelper::CreateAndAggregateObjectFromTypeId (Ptr node, const std::string typeId) { ObjectFactory factory; factory.SetTypeId(typeId); @@ -241,10 +275,7 @@ node->AggregateObject (factory); // Set routing Ptr ipv4 = node->GetObject (); - // XXX cut this over to use of TypeIds and factories - Ptr ipv4Routing = CreateObject (); - Ptr ipv4staticRouting = CreateObject (); - ipv4Routing->AddRoutingProtocol (ipv4staticRouting, 0); + Ptr ipv4Routing = m_routing->Create (node); ipv4->SetRoutingProtocol (ipv4Routing); } diff -r 96811f76c3e2 src/helper/internet-stack-helper.h --- a/src/helper/internet-stack-helper.h Mon Jun 22 18:29:43 2009 -0700 +++ b/src/helper/internet-stack-helper.h Tue Jun 23 11:05:56 2009 +0200 @@ -27,10 +27,29 @@ #include "ns3/packet.h" #include "ns3/ptr.h" #include "ns3/object-factory.h" +#include namespace ns3 { class Node; +class Ipv4RoutingProtocol; + +class Ipv4RoutingHelper +{ +public: + virtual ~Ipv4RoutingHelper (); + virtual Ptr Create (Ptr node) const = 0; +}; + +class Ipv4ListRoutingHelper : public Ipv4RoutingHelper +{ +public: + Ipv4ListRoutingHelper(); + void Add (const Ipv4RoutingHelper &routing, int16_t priority); + virtual Ptr Create (Ptr node) const; +private: + std::list > m_list; +}; /** * \brief aggregate IP/TCP/UDP functionality to existing Nodes. @@ -40,6 +59,8 @@ public: InternetStackHelper(void); + void SetRoutingHelper (const Ipv4RoutingHelper &routing); + /** * Aggregate implementations of the ns3::Ipv4, ns3::Udp, and ns3::Tcp classes * onto the provided node. This method will assert if called on a node that @@ -132,6 +153,8 @@ private: ObjectFactory m_tcpFactory; + const Ipv4RoutingHelper *m_routing; + static void CreateAndAggregateObjectFromTypeId (Ptr node, const std::string typeId); static void Cleanup (void); static void LogRxIp (std::string context, Ptr packet, uint32_t deviceId); static void LogTxIp (std::string context, Ptr packet, uint32_t deviceId); diff -r 96811f76c3e2 src/helper/ipv4-static-routing-helper.cc --- a/src/helper/ipv4-static-routing-helper.cc Mon Jun 22 18:29:43 2009 -0700 +++ b/src/helper/ipv4-static-routing-helper.cc Tue Jun 23 11:05:56 2009 +0200 @@ -33,6 +33,15 @@ namespace ns3 { +Ipv4StaticRoutingHelper::Ipv4StaticRoutingHelper() +{} +Ptr +Ipv4StaticRoutingHelper::Create (Ptr node) const +{ + return CreateObject (); +} + + Ptr Ipv4StaticRoutingHelper::GetStaticRouting (Ptr ipv4) const { diff -r 96811f76c3e2 src/helper/ipv4-static-routing-helper.h --- a/src/helper/ipv4-static-routing-helper.h Mon Jun 22 18:29:43 2009 -0700 +++ b/src/helper/ipv4-static-routing-helper.h Tue Jun 23 11:05:56 2009 +0200 @@ -25,14 +25,18 @@ #include "ns3/ipv4-address.h" #include "ns3/node.h" #include "ns3/net-device.h" +#include "internet-stack-helper.h" #include "node-container.h" #include "net-device-container.h" namespace ns3 { -class Ipv4StaticRoutingHelper +class Ipv4StaticRoutingHelper : public Ipv4RoutingHelper { public: + Ipv4StaticRoutingHelper(); + virtual Ptr Create (Ptr node) const; + Ptr GetStaticRouting (Ptr ipv4) const; void AddMulticastRoute (Ptr n, Ipv4Address source, Ipv4Address group, diff -r 96811f76c3e2 src/helper/olsr-helper.cc --- a/src/helper/olsr-helper.cc Mon Jun 22 18:29:43 2009 -0700 +++ b/src/helper/olsr-helper.cc Tue Jun 23 11:05:56 2009 +0200 @@ -30,64 +30,18 @@ m_agentFactory.SetTypeId ("ns3::olsr::RoutingProtocol"); } -void -OlsrHelper::SetAgent (std::string tid, - std::string n0, const AttributeValue &v0, - std::string n1, const AttributeValue &v1, - std::string n2, const AttributeValue &v2, - std::string n3, const AttributeValue &v3, - std::string n4, const AttributeValue &v4, - std::string n5, const AttributeValue &v5, - std::string n6, const AttributeValue &v6, - std::string n7, const AttributeValue &v7) +Ptr +OlsrHelper::Create (Ptr node) const { - m_agentFactory.SetTypeId (tid); - m_agentFactory.Set (n0, v0); - m_agentFactory.Set (n1, v1); - m_agentFactory.Set (n2, v2); - m_agentFactory.Set (n3, v3); - m_agentFactory.Set (n4, v4); - m_agentFactory.Set (n5, v5); - m_agentFactory.Set (n6, v6); - m_agentFactory.Set (n7, v7); + Ptr agent = m_agentFactory.Create (); + node->AggregateObject (agent); + return agent; } void -OlsrHelper::Install (NodeContainer container) +OlsrHelper::Set (std::string name, const AttributeValue &value) { - for (NodeContainer::Iterator i = container.Begin (); i != container.End (); ++i) - { - Ptr node = *i; - Install (node); - } -} -void -OlsrHelper::Install (Ptr node) -{ - if (node->GetObject () != 0) - { - NS_FATAL_ERROR ("OlsrHelper::Install(): Aggregating " - "an Olsr Agent to a node with an existing Olsr RoutingProtocol"); - return; - } - Ptr agent = m_agentFactory.Create (); - node->AggregateObject (agent); - Ptr ipv4 = node->GetObject (); - Ptr ipv4Routing = DynamicCast (ipv4->GetRoutingProtocol ()); - NS_ASSERT (ipv4Routing); - ipv4Routing->AddRoutingProtocol (agent, 10); - agent->Start (); -} -void -OlsrHelper::Install (std::string nodeName) -{ - Ptr node = Names::Find (nodeName); - Install (node); -} -void -OlsrHelper::InstallAll (void) -{ - Install (NodeContainer::GetGlobal ()); + m_agentFactory.Set (name, value); } } // namespace ns3 diff -r 96811f76c3e2 src/helper/olsr-helper.h --- a/src/helper/olsr-helper.h Mon Jun 22 18:29:43 2009 -0700 +++ b/src/helper/olsr-helper.h Tue Jun 23 11:05:56 2009 +0200 @@ -21,48 +21,25 @@ #define OLSR_HELPER_H #include "ns3/object-factory.h" -#include "ns3/node-container.h" #include "ns3/node.h" +#include "node-container.h" +#include "internet-stack-helper.h" namespace ns3 { /** * \brief Helper class that adds OLSR routing to nodes. */ -class OlsrHelper +class OlsrHelper : public Ipv4RoutingHelper { public: OlsrHelper (); + virtual Ptr Create (Ptr node) const; /** * \brief Set default OLSR routing agent attributes */ - void SetAgent (std::string tid, - std::string n0 = "", const AttributeValue &v0 = EmptyAttributeValue (), - std::string n1 = "", const AttributeValue &v1 = EmptyAttributeValue (), - std::string n2 = "", const AttributeValue &v2 = EmptyAttributeValue (), - std::string n3 = "", const AttributeValue &v3 = EmptyAttributeValue (), - std::string n4 = "", const AttributeValue &v4 = EmptyAttributeValue (), - std::string n5 = "", const AttributeValue &v5 = EmptyAttributeValue (), - std::string n6 = "", const AttributeValue &v6 = EmptyAttributeValue (), - std::string n7 = "", const AttributeValue &v7 = EmptyAttributeValue ()); - - /** - * \brief Enable OLSR routing for a set of nodes - */ - void Install (NodeContainer container); - /** - * \brief Enable OLSR routing for a single node - */ - void Install (Ptr node); - /** - * \brief Enable OLSR routing for a single node - */ - void Install (std::string nodeName); - /** - * \brief Enable OLSR routing for all nodes - */ - void InstallAll (void); + void Set (std::string name, const AttributeValue &value); private: ObjectFactory m_agentFactory; }; diff -r 96811f76c3e2 src/internet-stack/ipv4-l3-protocol.cc --- a/src/internet-stack/ipv4-l3-protocol.cc Mon Jun 22 18:29:43 2009 -0700 +++ b/src/internet-stack/ipv4-l3-protocol.cc Tue Jun 23 11:05:56 2009 +0200 @@ -187,11 +187,7 @@ } m_interfaces.clear (); m_node = 0; - if (m_routingProtocol) - { - m_routingProtocol->Dispose (); - m_routingProtocol = 0; - } + m_routingProtocol = 0; Object::DoDispose (); } diff -r 96811f76c3e2 src/routing/olsr/olsr-routing-protocol.cc --- a/src/routing/olsr/olsr-routing-protocol.cc Mon Jun 22 18:29:43 2009 -0700 +++ b/src/routing/olsr/olsr-routing-protocol.cc Tue Jun 23 11:05:56 2009 +0200 @@ -213,6 +213,8 @@ m_linkTupleTimerFirstTime = true; m_ipv4 = ipv4; + + Simulator::ScheduleNow (&RoutingProtocol::Start, this); } void RoutingProtocol::DoDispose () diff -r 96811f76c3e2 src/routing/olsr/olsr-routing-protocol.h --- a/src/routing/olsr/olsr-routing-protocol.h Mon Jun 22 18:29:43 2009 -0700 +++ b/src/routing/olsr/olsr-routing-protocol.h Tue Jun 23 11:05:56 2009 +0200 @@ -68,7 +68,6 @@ RoutingProtocol (); virtual ~RoutingProtocol (); - void Start (); void SetMainInterface (uint32_t interface); private: @@ -101,7 +100,7 @@ Ptr m_ipv4; private: - + void Start (); void Clear (); uint32_t GetSize () const { return m_table.size (); } std::vector GetEntries () const;