Add spread interfaces frequency channels option
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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<WifiNetDevice>
|
||||
MeshWifiHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node) const
|
||||
{
|
||||
@@ -70,7 +80,10 @@ MeshWifiHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> 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<Ptr<NetDevice> > ifaces = mp->GetInterfaces ();
|
||||
for (size_t i = 0; i < ifaces.size(); ++i)
|
||||
{
|
||||
uint32_t channel = i * 5;
|
||||
|
||||
Ptr<WifiNetDevice> iface = ifaces[i]->GetObject<WifiNetDevice> ();
|
||||
NS_ASSERT (iface);
|
||||
Ptr<MeshWifiInterfaceMac> mac = iface->GetMac ()->GetObject<MeshWifiInterfaceMac> ();
|
||||
NS_ASSERT (mac);
|
||||
|
||||
mac->SwitchFrequencyChannel (channel);
|
||||
}
|
||||
}
|
||||
|
||||
// Install 802.11s protocols
|
||||
Ptr<PeerManagementProtocol> pmp = CreateObject<PeerManagementProtocol> ();
|
||||
bool pmp_ok = pmp->Install (mp);
|
||||
|
||||
@@ -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<WifiNetDevice> CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node) const;
|
||||
|
||||
Reference in New Issue
Block a user