TypeId
Dot11sStack::GetTypeId ()
{
static TypeId tid = TypeId ("ns3::Dot11sStack")
.SetParent<Object> ()
.AddConstructor<Dot11sStack> ()
.AddAttribute ("Root",
"The MAC address of root mesh point.",
Mac48AddressValue (Mac48Address ("ff:ff:ff:ff:ff:ff")),
MakeMac48AddressAccessor (&Dot11sStack::m_root),
MakeMac48AddressChecker ());
return tid;
}
void
HwmpProtocol::DoInitialize ()
{
m_coefficient->SetAttribute ("Max", DoubleValue (m_randomStart.GetSeconds ()));
if (m_isRoot)
{
SetRoot ();
}
}
if (mp->GetAddress () == m_root)
{
hwmp->SetRoot ();
}
MeshPointDevice root_MeshPointDevice;
root_MeshPointDevice.SetNode(nodes.Get(1));
Dot11sStack dot11s;
dot11s.InstallStack(&root_MeshPointDevice);
MeshPointDevice root_MeshPointDevice;
root_MeshPointDevice.SetNode(nodes.Get(1));
Dot11sStack dot11s;
dot11s.InstallStack(&root_MeshPointDevice);
root_MeshPointDevice.SetNode(nodes.Get(1));
we use the function setnode to setup the second nodes as root. for (uint32_t i = 0; i < m_nInterfaces; ++i)
{
uint32_t channel = 0;
if (m_spreadChannelPolicy == ZERO_CHANNEL)
{
channel = 0;
}
if (m_spreadChannelPolicy == SPREAD_CHANNELS)
{
channel = i * 5;
}
Ptr<WifiNetDevice> iface = CreateInterface (phyHelper, node, channel);
mp->AddInterface (iface);
}
/*
create the mesh part
*/
mesh_nodes.Create (6); // Create 6 nodes mesh
// Configure YansWifiChannel
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
/*
* Create mesh helper and set stack installer to it
* Stack installer creates all needed protocols and install them to
* mesh point device
*/
mesh = MeshHelper::Default ();
mesh.SetMacType ("RandomStart", TimeValue (Seconds (m_randomStart)));
// Set number of interfaces for default AP
mesh.SetNumberOfInterfaces (m_nIfaces);
// Install protocols and return container if default MeshPointDevices
mesh_NetDevices = mesh.Install (wifiPhy, mesh_nodes);
// Setup mobility - static topology for default AP
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc =
CreateObject<ListPositionAllocator>();
positionAlloc->Add (Vector (330.0, 380.0, 0.0));// AP in Building 1
positionAlloc->Add (Vector (500.0, 300.0, 0.0));// AP in Building 2
positionAlloc->Add (Vector (740.0, 350.0, 0.0));// AP in Building 3
positionAlloc->Add (Vector (250.0, 800.0, 0.0));// AP in Building 4 : the root node
positionAlloc->Add (Vector (500.0, 740.0, 0.0));// AP in Building 5
positionAlloc->Add (Vector (720.0, 720.0, 0.0));// AP in Building 6
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (mesh_nodes);
MeshPointDevice root_MeshPointDevice;
root_MeshPointDevice.SetNode(mesh_nodes.Get(3));// set the root node
Dot11sStack dot11s;
dot11s.InstallStack(&root_MeshPointDevice);
// Create wifi helper and set the mesh frequence at 5 GHz
wifi = WifiHelper::Default();
wifi.SetStandard(WIFI_PHY_STANDARD_80211n_5GHZ);
/*
create the wifi part
*/
// Create 7 nodes wifi
wifi_AP_nodes.Add(mesh_nodes);// create 6 AP
wifi_AP_nodes.Create (1); // add the second node in building 1
QosWifiMacHelper mac = QosWifiMacHelper::Default();
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("OfdmRate54Mbps"));
wifi_AP_NetDevices = wifi.Install (wifiPhy, mac, wifi_AP_nodes);
// Create wifi helper and set the wifi frequence at 2.4 GHz
wifi.SetStandard(WIFI_PHY_STANDARD_80211n_2_4GHZ);
Ssid ssid = Ssid ("ns-3-ssid");
mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (5)));
InternetStackHelper internetStack;
internetStack.Install (mesh_nodes);
internetStack.Install (wifi_AP_nodes);
Ipv4AddressHelper address;
address.SetBase ("10.1.1.0", "255.255.255.0");
mesh_interfaces = address.Assign (mesh_NetDevices);
wifi_AP_interfaces = address.Assign (wifi_AP_NetDevices);
Hi,
I Have try my best to write a code which create the enclosed topology.
Is this code is correct ?
mesh = MeshHelper::Default ();
if (!Mac48Address (m_root.c_str ()).IsBroadcast ())
{
mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ())));
}
else
{
//If root is not set, we do not use "Root" attribute, because it
//is specified only for 11s
mesh.SetStackInstaller (m_stack);
}
void
MeshHelper::SetStandard (enum WifiPhyStandard standard)
{
m_standard = standard;
}
Ptr<WifiNetDevice>
MeshHelper::CreateInterface (const WifiPhyHelper &phyHelper, Ptr<Node> node, uint16_t channelId) const
mesh.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ())));
Now I'm using the mesh directory provided in the ns3.22 package and it work fine.
so just only set the m_root paramter to the MAC adress of the desired node. In fact, when I check the output file I see that Isroot is set to 1 for this node.
Now as the mesh part is working fine, I will try to setup the AP part.
I will also to see some video related to Design Patterns.
Br.
About setting up the AP in the same node (and the wifi clients) that's done in a totally different way.My suggestion at this point is: try to setup the mesh backbone. Once that's up and running, you'll add the rest. If you do everything at once it won't work (and you'll not know why).
/*
create the mesh part
*/
mesh_nodes.Create (6); // Create 6 nodes mesh
// Configure YansWifiChannel
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
wifiPhy.SetChannel (wifiChannel.Create ());
/*
* Create mesh helper and set stack installer to it
* Stack installer creates all needed protocols and install them to
* mesh point device
*/
mesh = MeshHelper::Default ();
if (!Mac48Address (m_root.c_str ()).IsBroadcast())
{
mesh.SetStackInstaller (m_stack, "Root", Mac48AddressValue (Mac48Address (m_root.c_str ())));
}
else
{
//If root is not set, we do not use "Root" attribute, because it
//is specified only for 11s
mesh.SetStackInstaller (m_stack);
}
if (m_chan)
{
mesh.SetSpreadInterfaceChannels (MeshHelper::SPREAD_CHANNELS);
}
else
{
mesh.SetSpreadInterfaceChannels (MeshHelper::ZERO_CHANNEL);
}
mesh.SetMacType ("RandomStart", TimeValue (Seconds (m_randomStart)));
// Set number of interfaces for mesh node
mesh.SetNumberOfInterfaces (m_nIfaces);
// set mesh standard
mesh.SetStandard(WIFI_PHY_STANDARD_80211n_5GHZ);
// Install protocols and return container if default MeshPointDevices
mesh_NetDevices = mesh.Install (wifiPhy, mesh_nodes);
// Setup mobility - static topology for default AP
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc =
CreateObject<ListPositionAllocator>();
positionAlloc->Add (Vector (330.0, 380.0, 0.0));// AP in Building 1
positionAlloc->Add (Vector (500.0, 300.0, 0.0));// AP in Building 2
positionAlloc->Add (Vector (740.0, 350.0, 0.0));// AP in Building 3
positionAlloc->Add (Vector (250.0, 800.0, 0.0));// AP in Building 4 : the root node
positionAlloc->Add (Vector (500.0, 740.0, 0.0));// AP in Building 5
positionAlloc->Add (Vector (720.0, 720.0, 0.0));// AP in Building 6
mobility.SetPositionAllocator (positionAlloc);
mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");
mobility.Install (mesh_nodes);
// create the wifi part
// Create 7 nodes wifi
wifi_AP_nodes.Add(mesh_nodes);// create 6 AP
wifi_AP_nodes.Create (1); // add the second node in building 1
mobility.Install (wifi_AP_nodes.Get(6));
// Create wifi helper and set the wifi frequence at 2.4 GHz
wifi.SetStandard(WIFI_PHY_STANDARD_80211n_2_4GHZ);
QosWifiMacHelper mac = QosWifiMacHelper::Default();
wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager",
"DataMode", StringValue ("OfdmRate54Mbps"));
Ssid ssid = Ssid ("ns-3-ssid");
mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true),
"BeaconInterval", TimeValue (Seconds (5)));
wifi_AP_NetDevices = wifi.Install (wifiPhy, mac, wifi_AP_nodes);