diff --git a/examples/mesh.cc b/examples/mesh.cc index 609d1dd85..6fa2ef50d 100644 --- a/examples/mesh.cc +++ b/examples/mesh.cc @@ -44,6 +44,7 @@ main (int argc, char *argv[]) double step = 100.0; // Grid with one-hop edge double randomStart = 0.1; // One beacon interval uint32_t nIfaces = 1; + bool chan = false; bool pcap = false; // Command line arguments @@ -53,6 +54,7 @@ main (int argc, char *argv[]) cmd.AddValue ("step", "Size of edge in our grid, meters. [100 m]", step); cmd.AddValue ("start", "Maximum random start delay, seconds. [0.1 s]", randomStart); cmd.AddValue ("interfaces", "Number of radio interfaces used by each mesh point. [1]", nIfaces); + cmd.AddValue ("channels", "Use different frequency channels for different interfaces. [0]", chan); cmd.AddValue ("pcap", "Enable PCAP traces on interfaces. [0]", pcap); cmd.Parse (argc, argv); @@ -69,6 +71,7 @@ main (int argc, char *argv[]) // Install mesh point devices & protocols MeshWifiHelper mesh; + mesh.SetSpreadInterfaceChannels (chan); NetDeviceContainer meshDevices = mesh.Install (wifiPhy, nodes, nIfaces); // Setup mobility diff --git a/src/devices/mesh/dot11s/dot11s-helper.cc b/src/devices/mesh/dot11s/dot11s-helper.cc index 2761847cf..b5b5d4b4e 100644 --- a/src/devices/mesh/dot11s/dot11s-helper.cc +++ b/src/devices/mesh/dot11s/dot11s-helper.cc @@ -33,7 +33,10 @@ namespace ns3 { namespace dot11s { -MeshWifiHelper::MeshWifiHelper () : m_ssid("mesh"), m_randomStartDelay (Seconds (0)) +MeshWifiHelper::MeshWifiHelper () : + m_ssid("mesh"), + m_randomStartDelay (Seconds (0)), + m_spreadInterfaceChannels (false) { } @@ -54,6 +57,13 @@ MeshWifiHelper::SetRandomStartDelay (Time t) m_randomStartDelay = t; } +void +MeshWifiHelper::SetSpreadInterfaceChannels (bool s) +{ + m_spreadInterfaceChannels = s; +} + + Ptr MeshWifiHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr node) const { @@ -70,7 +80,10 @@ MeshWifiHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr node) device->SetMac (mac); device->SetPhy (phy); device->SetRemoteStationManager (manager); - + /* + if (channel > 0) + mac->SwitchFrequencyChannel (channel); + */ return device; } @@ -96,6 +109,23 @@ MeshWifiHelper::Install (const WifiPhyHelper &phyHelper, NodeContainer c, uint32 mp->AddInterface (iface); } + // Set different channels on different ifaces + if (m_spreadInterfaceChannels) + { + std::vector > ifaces = mp->GetInterfaces (); + for (size_t i = 0; i < ifaces.size(); ++i) + { + uint32_t channel = i * 5; + + Ptr iface = ifaces[i]->GetObject (); + NS_ASSERT (iface); + Ptr mac = iface->GetMac ()->GetObject (); + NS_ASSERT (mac); + + mac->SwitchFrequencyChannel (channel); + } + } + // Install 802.11s protocols Ptr pmp = CreateObject (); bool pmp_ok = pmp->Install (mp); diff --git a/src/devices/mesh/dot11s/dot11s-helper.h b/src/devices/mesh/dot11s/dot11s-helper.h index 0066fe53e..819da8b1a 100644 --- a/src/devices/mesh/dot11s/dot11s-helper.h +++ b/src/devices/mesh/dot11s/dot11s-helper.h @@ -49,6 +49,14 @@ public: Ssid GetSsid () const; /// Set maximum random start delay void SetRandomStartDelay (Time delay); + /** + * \brief Spread/not spread frequency channels of MP interfaces. + * + * If set to true different non-overlaping 20MHz frequency + * channels will be assigned to different mesh point interfaces. + */ + void SetSpreadInterfaceChannels (bool); + /** * \brief Install 802.11s mesh device & protocols on given node * @@ -73,6 +81,7 @@ public: private: Ssid m_ssid; Time m_randomStartDelay; + bool m_spreadInterfaceChannels; /// Create single mesh interface NIC Ptr CreateInterface (const WifiPhyHelper &phyHelper, Ptr node) const;