From: Richard Whitehouse Date: Sun, 20 Feb 2011 02:08:08 +0000 (+0000) Subject: Add ability to pass statically determined routing information. Also allow bridge... X-Git-Url: https://git.richardwhiuk.com/?a=commitdiff_plain;h=ba19c054c7e43c3a56d5efbd779687bbcd6526a2;p=ns-moose.git Add ability to pass statically determined routing information. Also allow bridge address to be specified. --- diff --git a/code/src/devices/bridge/helper/moose-bridge-helper.cc b/code/src/devices/bridge/helper/moose-bridge-helper.cc index ee3b838..7d4b727 100644 --- a/code/src/devices/bridge/helper/moose-bridge-helper.cc +++ b/code/src/devices/bridge/helper/moose-bridge-helper.cc @@ -23,6 +23,7 @@ #include "ns3/moose-bridge-net-device.h" #include "ns3/node.h" #include "ns3/names.h" +#include "ns3/moose-address.h" NS_LOG_COMPONENT_DEFINE ("MooseBridgeHelper"); @@ -41,14 +42,47 @@ MooseBridgeHelper::SetDeviceAttribute (std::string n1, const AttributeValue &v1) m_deviceFactory.Set (n1, v1); } +NetDeviceContainer +MooseBridgeHelper::Install (Ptr node, NetDeviceContainer c, MoosePrefixAddress addr, std::map, MoosePrefixAddress> routes) +{ + NS_LOG_FUNCTION_NOARGS (); + NS_LOG_LOGIC ("**** Install MOOSE bridge device on node " << node->GetId ()); + + SetDeviceAttribute("MooseAddress", MooseAddressValue(MooseAddress::Allocate(addr))); + + NetDeviceContainer devs; + Ptr dev = m_deviceFactory.Create (); + devs.Add (dev); + node->AddDevice (dev); + + std::map > portMap; + + for (NetDeviceContainer::Iterator i = c.Begin (); i != c.End (); ++i) + { + NS_LOG_LOGIC ("**** Add MooseBridgePort "<< *i); + Ptr port = dev->AddBridgePort (*i); + std::map, MoosePrefixAddress>::iterator it = routes.find(*i); + if(it != routes.end()){ + portMap[routes[*i]] = port; + } + } + + dev->AddRoutes(portMap); + + return devs; +} + + NetDeviceContainer MooseBridgeHelper::Install (Ptr node, NetDeviceContainer c) { NS_LOG_FUNCTION_NOARGS (); NS_LOG_LOGIC ("**** Install MOOSE bridge device on node " << node->GetId ()); + SetDeviceAttribute("MooseAddress", MooseAddressValue(MooseAddress::Allocate())); + NetDeviceContainer devs; - Ptr dev = m_deviceFactory.Create (); + Ptr dev = m_deviceFactory.Create (); devs.Add (dev); node->AddDevice (dev); diff --git a/code/src/devices/bridge/helper/moose-bridge-helper.h b/code/src/devices/bridge/helper/moose-bridge-helper.h index fa2e1e1..c6fa8d9 100644 --- a/code/src/devices/bridge/helper/moose-bridge-helper.h +++ b/code/src/devices/bridge/helper/moose-bridge-helper.h @@ -28,6 +28,8 @@ #include "ns3/net-device-container.h" #include "ns3/object-factory.h" #include +#include +#include "ns3/moose-prefix-address.h" namespace ns3 { @@ -63,6 +65,12 @@ public: * \returns A container holding the added net device. */ NetDeviceContainer Install (Ptr node, NetDeviceContainer c); + /** + * This method creates an ns3::MooseBridgeNetDevice with static routing. + */ + + NetDeviceContainer Install (Ptr node, NetDeviceContainer c, MoosePrefixAddress addr, std::map, MoosePrefixAddress> routes); + /** * This method creates an ns3::MooseBridgeNetDevice with the attributes * configured by MooseBridgeHelper::SetDeviceAttribute, adds the device @@ -82,3 +90,4 @@ private: #endif /* MOOSE_BRIDGE_HELPER_H */ +