From 71a4eb6a101aa1c0cc0e414ea800c72ed7d802a3 Mon Sep 17 00:00:00 2001 From: Kirill Andreev Date: Tue, 9 Jun 2009 21:08:32 +0400 Subject: [PATCH] Restructured mesh - helper --- examples/mesh.cc | 4 +- src/devices/mesh/dot11s/dot11s-helper.cc | 55 +++---------------- src/devices/mesh/dot11s/dot11s-helper.h | 5 +- src/devices/mesh/dot11s/wscript | 11 +--- .../mesh-interface-helper.cc} | 2 +- .../mesh-interface-helper.h} | 0 src/helper/wscript | 2 + 7 files changed, 15 insertions(+), 64 deletions(-) rename src/{devices/mesh/dot11s/dot11s-interface-helper.cc => helper/mesh-interface-helper.cc} (99%) rename src/{devices/mesh/dot11s/dot11s-interface-helper.h => helper/mesh-interface-helper.h} (100%) diff --git a/examples/mesh.cc b/examples/mesh.cc index a71398339..a2212bf31 100644 --- a/examples/mesh.cc +++ b/examples/mesh.cc @@ -124,8 +124,8 @@ MeshTest::CreateNodes () MeshWifiHelper mesh; mesh.SetSpreadInterfaceChannels (chan); std::vector roots; - roots.push_back(xSize-1); - roots.push_back(xSize*ySize-xSize); + //roots.push_back(xSize-1); + //roots.push_back(xSize*ySize-xSize); MeshInterfaceHelper interface = MeshInterfaceHelper::Default (); interface.SetType ("RandomStart", TimeValue (Seconds(randomStart))); diff --git a/src/devices/mesh/dot11s/dot11s-helper.cc b/src/devices/mesh/dot11s/dot11s-helper.cc index ddbed3311..e8dac63c1 100644 --- a/src/devices/mesh/dot11s/dot11s-helper.cc +++ b/src/devices/mesh/dot11s/dot11s-helper.cc @@ -19,6 +19,7 @@ * Pavel Boyko */ #include "dot11s-helper.h" +#include "ns3/dot11s-installator.h" #include "ns3/simulator.h" #include "ns3/mesh-point-device.h" #include "ns3/wifi-net-device.h" @@ -38,7 +39,6 @@ NetDeviceContainer MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, const MeshInterfaceHelper &interfaceHelper, NodeContainer c, std::vector roots, uint32_t nInterfaces) const { NetDeviceContainer devices; - uint32_t node_index = 0; for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i) { Ptr node = *i; @@ -54,25 +54,11 @@ MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, const MeshInterfaceHelp Ptr iface = interfaceHelper.CreateInterface (phyHelper,node, (m_spreadInterfaceChannels ? channel : 0)); mp->AddInterface (iface); } - // Install 802.11s protocols - Ptr pmp = CreateObject (); - pmp->SetMeshId("mesh"); - bool install_ok = pmp->Install (mp); - NS_ASSERT (install_ok); - - Ptr hwmp = CreateObject (); - install_ok = hwmp->Install (mp); - NS_ASSERT (install_ok); - - pmp->SetPeerLinkStatusCallback(MakeCallback(&HwmpProtocol::PeerLinkStatus, hwmp)); - hwmp->SetNeighboursCallback(MakeCallback(&PeerManagementProtocol::GetActiveLinks, pmp)); - // Setting root mesh point - for(std::vector::const_iterator root_iterator = roots.begin (); root_iterator != roots.end (); root_iterator ++) - //if(*root_iterator == i.GetDistanceFrom(c.Begin ())) - if(*root_iterator == node_index) - hwmp->SetRoot (); + if(!Dot11sStackInstallator::InstallDot11sStack (mp, false)) + { + NS_ASSERT(false); + } devices.Add (mp); - node_index ++; } return devices; } @@ -89,40 +75,13 @@ MeshWifiHelper::Report (const ns3::Ptr& device, std::ostream& os NS_ASSERT (mp != 0); std::vector > ifaces = mp->GetInterfaces (); os << "GetAddress () << "\">\n"; - for (std::vector >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i) - { - Ptr device = (*i)->GetObject (); - NS_ASSERT (device != 0); - MeshInterfaceHelper::Report(device, os); - } - Ptr hwmp = mp->GetObject (); - NS_ASSERT(hwmp != 0); - hwmp->Report (os); - - Ptr pmp = mp->GetObject (); - NS_ASSERT(pmp != 0); - pmp->Report (os); + Dot11sStackInstallator::Report (device, os); os << "\n"; } void MeshWifiHelper::ResetStats (const ns3::Ptr& device) { - Ptr mp = device->GetObject (); - NS_ASSERT (mp != 0); - std::vector > ifaces = mp->GetInterfaces (); - for (std::vector >::const_iterator i = ifaces.begin(); i != ifaces.end(); ++i) - { - Ptr device = (*i)->GetObject (); - NS_ASSERT (device != 0); - MeshInterfaceHelper::ResetStats (device); - } - Ptr hwmp = mp->GetObject (); - NS_ASSERT(hwmp != 0); - hwmp->ResetStats (); - - Ptr pmp = mp->GetObject (); - NS_ASSERT(pmp != 0); - pmp->ResetStats (); + Dot11sStackInstallator::ResetStats (device); } } // namespace dot11s } //namespace ns3 diff --git a/src/devices/mesh/dot11s/dot11s-helper.h b/src/devices/mesh/dot11s/dot11s-helper.h index 184128ba2..5c28a9601 100644 --- a/src/devices/mesh/dot11s/dot11s-helper.h +++ b/src/devices/mesh/dot11s/dot11s-helper.h @@ -25,10 +25,7 @@ #include "ns3/wifi-helper.h" #include "ns3/nstime.h" -#include "ns3/peer-management-protocol.h" -#include "ns3/hwmp-protocol.h" -#include "ie-dot11s-id.h" -#include "ns3/dot11s-interface-helper.h" +#include "ns3/mesh-interface-helper.h" namespace ns3 { namespace dot11s { diff --git a/src/devices/mesh/dot11s/wscript b/src/devices/mesh/dot11s/wscript index 74d80ae55..6be48fa71 100644 --- a/src/devices/mesh/dot11s/wscript +++ b/src/devices/mesh/dot11s/wscript @@ -23,19 +23,12 @@ def build(bld): 'hwmp-mac-plugin.cc', 'hwmp-protocol.cc', 'airtime-metric.cc', - 'dot11s-interface-helper.cc', 'dot11s-helper.cc', + 'dot11s-installator.cc', ] headers = bld.new_task_gen('ns3header') headers.module = 'dot11s' headers.source = [ - 'peer-management-protocol.h', - 'ie-dot11s-beacon-timing.h', - 'ie-dot11s-id.h', - 'ie-dot11s-peer-management.h', - 'ie-dot11s-perr.h', - 'hwmp-protocol.h', 'dot11s-helper.h', - 'dot11s-interface-helper.h', - 'dot11s-mac-header.h', + 'dot11s-installator.h', ] diff --git a/src/devices/mesh/dot11s/dot11s-interface-helper.cc b/src/helper/mesh-interface-helper.cc similarity index 99% rename from src/devices/mesh/dot11s/dot11s-interface-helper.cc rename to src/helper/mesh-interface-helper.cc index bcf969dbc..8cc025fb0 100644 --- a/src/devices/mesh/dot11s/dot11s-interface-helper.cc +++ b/src/helper/mesh-interface-helper.cc @@ -19,7 +19,7 @@ */ -#include "dot11s-interface-helper.h" +#include "mesh-interface-helper.h" #include "ns3/wifi-mac.h" #include "ns3/pointer.h" #include "ns3/dca-txop.h" diff --git a/src/devices/mesh/dot11s/dot11s-interface-helper.h b/src/helper/mesh-interface-helper.h similarity index 100% rename from src/devices/mesh/dot11s/dot11s-interface-helper.h rename to src/helper/mesh-interface-helper.h diff --git a/src/helper/wscript b/src/helper/wscript index a9271dfef..6271c709c 100644 --- a/src/helper/wscript +++ b/src/helper/wscript @@ -25,6 +25,7 @@ def build(bld): 'v4ping-helper.cc', 'nqos-wifi-mac-helper.cc', 'qos-wifi-mac-helper.cc', + 'mesh-interface-helper.cc', ] headers = bld.new_task_gen('ns3header') @@ -52,6 +53,7 @@ def build(bld): 'v4ping-helper.h', 'nqos-wifi-mac-helper.h', 'qos-wifi-mac-helper.h', + 'mesh-interface-helper.h', ] env = bld.env_of_name('default')