WiFi channel without beacon collisions?

160 views
Skip to first unread message

Magí Coscollola Coletes

unread,
Jul 12, 2017, 9:22:37 AM7/12/17
to ns-3-users
Hello,

I am quite new to NS3 and I am trying to see the impact of beacons on the WLAN performance. I started making a scenario with 7 APs working at the same frequency and no stations just to see if the beacons would collide.
When I get the Pcap files I see that all stations are transmitting beacons at the same time and these beacons are not received by anyone else.

How could I make it so I can see how the different APs have to wait for each other to transmit a beacon, and that the STA receives them?

Here you can see my code:

int main (int argc, char *argv[])
{
  uint32_t payloadSize = 1472; //bytes
  uint64_t simulationTime = 10; //seconds
  double distance = 5; //meters
  bool enablePcap = 0;

  CommandLine cmd;
  cmd.AddValue ("payloadSize", "Payload size in bytes", payloadSize);
  cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
  cmd.AddValue ("distance", "Distance in meters between the station and the access point", distance);
  cmd.AddValue ("enablePcap", "Enable/disable pcap file generation", enablePcap);
  cmd.Parse (argc, argv);

  NodeContainer wifiStaNode;
  wifiStaNode.Create (1);
  NodeContainer wifiApNode;
  wifiApNode.Create (7);

  YansWifiChannelHelper channel = YansWifiChannelHelper::Default ();
  YansWifiPhyHelper phy = YansWifiPhyHelper::Default ();
  phy.SetPcapDataLinkType (YansWifiPhyHelper::DLT_IEEE802_11_RADIO);
  phy.SetChannel (channel.Create ());



  WifiHelper wifi;
  wifi.SetStandard (WIFI_PHY_STANDARD_80211n_5GHZ);
  wifi.SetRemoteStationManager ("ns3::ConstantRateWifiManager", "DataMode", StringValue ("HtMcs7"), "ControlMode", StringValue ("HtMcs0"));
  WifiMacHelper mac;
  
  NetDeviceContainer staDeviceA,/* staDeviceB, staDeviceC, staDeviceD,*/ apDeviceA, apDeviceB, apDeviceC, apDeviceD, apDeviceE, apDeviceF, apDeviceG;
  Ssid ssid;

  //Network A
  ssid = Ssid ("network-A");
  phy.Set ("ChannelNumber", UintegerValue(40));
  mac.SetType ("ns3::StaWifiMac",
               "Ssid", SsidValue (ssid));
  staDeviceA = wifi.Install (phy, mac, wifiStaNode.Get(0));

  mac.SetType ("ns3::ApWifiMac",
               "Ssid", SsidValue (ssid),
               "BeaconGeneration", BooleanValue (true));
  apDeviceA = wifi.Install (phy, mac, wifiApNode.Get(0));
  
  //Network B
  ssid = Ssid ("network-B");
  phy.Set ("ChannelNumber", UintegerValue(40));
  mac.SetType ("ns3::StaWifiMac",
               "Ssid", SsidValue (ssid),
               "BE_MaxAmpduSize", UintegerValue (0)); 


  mac.SetType ("ns3::ApWifiMac",
               "Ssid", SsidValue (ssid),
               "BeaconGeneration", BooleanValue (true));
  apDeviceB = wifi.Install (phy, mac, wifiApNode.Get(1));
  
  //Network C
  ssid = Ssid ("network-C");
  phy.Set ("ChannelNumber", UintegerValue(40));
  mac.SetType ("ns3::StaWifiMac",
               "Ssid", SsidValue (ssid));

  mac.SetType ("ns3::ApWifiMac",
               "Ssid", SsidValue (ssid),
               "BeaconGeneration", BooleanValue (true));
  apDeviceC = wifi.Install (phy, mac, wifiApNode.Get(2));
  
  //Network D
  ssid = Ssid ("network-D");
  phy.Set ("ChannelNumber", UintegerValue(40));
  mac.SetType ("ns3::StaWifiMac",
               "Ssid", SsidValue (ssid));

  mac.SetType ("ns3::ApWifiMac",
               "Ssid", SsidValue (ssid),
               "BeaconGeneration", BooleanValue (true));
  apDeviceD = wifi.Install (phy, mac, wifiApNode.Get(3));

  //Network E
  ssid = Ssid ("network-E");
    phy.Set ("ChannelNumber", UintegerValue(40));
    mac.SetType ("ns3::StaWifiMac",
                 "Ssid", SsidValue (ssid));

    mac.SetType ("ns3::ApWifiMac",
                 "Ssid", SsidValue (ssid),
                 "BeaconGeneration", BooleanValue (true));
    apDeviceE = wifi.Install (phy, mac, wifiApNode.Get(4));

  //Network F
  ssid = Ssid ("network-F");
phy.Set ("ChannelNumber", UintegerValue(40));
mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid));

mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true));
apDeviceF = wifi.Install (phy, mac, wifiApNode.Get(5));

  //Network G
  ssid = Ssid ("network-G");
    phy.Set ("ChannelNumber", UintegerValue(40));
    mac.SetType ("ns3::StaWifiMac",
"Ssid", SsidValue (ssid));

    mac.SetType ("ns3::ApWifiMac",
"Ssid", SsidValue (ssid),
"BeaconGeneration", BooleanValue (true));
    apDeviceG = wifi.Install (phy, mac, wifiApNode.Get(6));

  /* Setting mobility model */
  MobilityHelper mobility;
  Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator> ();
  mobility.SetMobilityModel ("ns3::ConstantPositionMobilityModel");

  //Set position for APs
  positionAlloc->Add (Vector (0.0, 0.0, 0.0));
  positionAlloc->Add (Vector (-0.1, 0.0, 0.0));
  positionAlloc->Add (Vector (17.32, 0.0, 0.0));
  positionAlloc->Add (Vector (-8.66, 15.0, 0.0));
  positionAlloc->Add (Vector (8.66, 15.0, 0.0));
  positionAlloc->Add (Vector (-8.66, -15.0, 0.0));
  positionAlloc->Add (Vector (8.66, -15.0, 0.0));
  //Set position for STA
  positionAlloc->Add (Vector (0.0, 0.0, 0.0));

  
  mobility.SetPositionAllocator (positionAlloc);
  mobility.Install (wifiApNode);
  mobility.Install (wifiStaNode);

  /* Internet stack */
  InternetStackHelper stack;
  stack.Install (wifiApNode);
  stack.Install (wifiStaNode);

  Ipv4AddressHelper address;

  address.SetBase ("192.168.1.0", "255.255.255.0");
  Ipv4InterfaceContainer StaInterfaceA;
  StaInterfaceA = address.Assign (staDeviceA);
  Ipv4InterfaceContainer ApInterfaceA;
  ApInterfaceA = address.Assign (apDeviceA);
  
  address.SetBase ("192.168.2.0", "255.255.255.0");
  Ipv4InterfaceContainer ApInterfaceB;
  ApInterfaceB = address.Assign (apDeviceB);
  
  address.SetBase ("192.168.3.0", "255.255.255.0");
  Ipv4InterfaceContainer ApInterfaceC;
  ApInterfaceC = address.Assign (apDeviceC);
  
  address.SetBase ("192.168.4.0", "255.255.255.0");
  Ipv4InterfaceContainer ApInterfaceD;
  ApInterfaceD = address.Assign (apDeviceD);

  address.SetBase ("192.168.5.0", "255.255.255.0");
  Ipv4InterfaceContainer ApInterfaceE;
  ApInterfaceE = address.Assign (apDeviceE);

  address.SetBase ("192.168.6.0", "255.255.255.0");
  Ipv4InterfaceContainer ApInterfaceF;
  ApInterfaceF = address.Assign (apDeviceF);
  
  address.SetBase ("192.168.7.0", "255.255.255.0");
  Ipv4InterfaceContainer ApInterfaceG;
  ApInterfaceG = address.Assign (apDeviceG);


  
  if (enablePcap)
    {
      phy.EnablePcap ("AP_A", apDeviceA.Get (0), true);
      phy.EnablePcap ("AP_B", apDeviceB.Get (0), true);
      phy.EnablePcap ("AP_C", apDeviceC.Get (0), true);
      phy.EnablePcap ("AP_D", apDeviceD.Get (0), true);
      phy.EnablePcap ("STA_A", staDeviceA.Get (0), true);
    }

  Simulator::Stop (Seconds (simulationTime + 1));
  Simulator::Run ();
  Simulator::Destroy ();

  return 0;
}

Thank you very much,

Magí

Rediet

unread,
Jul 13, 2017, 3:00:36 AM7/13/17
to ns-3-users
Hello Magí,

There is already an attribute of ApWifiMac that does precisely that: it's the beacon transmission jitter. It is disabled by default and can be activated using EnableBeaconJitter (see doxygen).

BR,

Rediet

Magí Coscollola Coletes

unread,
Jul 13, 2017, 12:22:35 PM7/13/17
to ns-3-users
That was exactly what I needed.
Thank you very much!

Francisco Eduardo Balart Sanchez

unread,
Aug 31, 2017, 6:02:04 PM8/31/17
to ns-3-users
Is there something for AdhocWifiMac? i searched in the doxygen but didn't found it, having a lot of collisions

Rediet

unread,
Sep 1, 2017, 2:05:10 AM9/1/17
to ns-3-users
I don't think so; AdhocWifiMac doesn't support beacon generation. However you can randomize applications' start time so as to avoid having ARPs sent at the same time (search for Konstantinos' and Tommasso's replies on this particular aspect).

Baraket Ella

unread,
Apr 4, 2018, 6:59:41 AM4/4/18
to ns-3-users
Hi Magi,

I read your  Master’s Thesis  published on the internet, I want to see your presentation in ppt if it is possible.

Br,
Baraket Ella.
Reply all
Reply to author
Forward
0 new messages