Wi-Fi (IEEE 802.11)

If you want to know 802.11 thoroghly, here is a article for you.

How 802.11 Wireless Works

Term you need to know

  1. BSS ( Basic Service Set ) : A block of 802.11 wireless LAN
  2. STA ( Station ) : End nodes in wireless LAN
  3. AP ( Access Point ) : The nodes in charge of forwarding packet
  4. IBSS ( independent BSS ) : Ad hoc mode BSS
  5. infrastructure BSS : BSS which needs AP
  6. SSID ( Service Set Identifier ) : human readable identifier of the network
  7. BSSID (Basic Service Set Identifier ) : The MAC address of the access point in infrastructure BSS

There are two modes in Wi-Fi communication.

  1. IBSS (Independent BSS): You don't need an AP.
  2. infrastructure BSS : You need an AP

The following demo both of two.

Simulation Parameter

This is not so important. You can see this from the code.

You can control the Wi-Fi setting through the following object.

  1. WifiHelper
  2. WifiMacHelper
  3. YansWifiPhyHelper : Yans means Yet Another,
  4. YansWifiChannelHelper

Their relationship

WifiHelper

    WifiMacHelper        
    YansWifiPhyHelper
            YansWifiChannelHelper

1. Independent BSS (Adhoc mode)

adhoc source code

It's for adhoc communication. You can see that the logic of NS-3 is adding some property to the nodes, then you can make the nodes with specific protocol or hardware.

So for this part, we only need to install the node with Wi-Fi netdevice. We only talk about the part of Wi-Fi setting here.

  1. Initialize the WifiHelper

    WifiHelper wifi;
    Wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
    
  2. Initialize the MacHelper, AdhocWifiMac means the device mode is Adhoc now.

    WifiMacHelper mac;
    mac.SetType ("ns3::AdhocWifiMac");
    
  3. Initialize the Channel, and TXPower is the parameter about power of radio.

    YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();
    
    Ptr<YansWifiChannel> channel = wifiChannel.Create ();
    YansWifiPhyHelper phy =  YansWifiPhyHelper::Default ();
    phy.SetChannel (channel);
    
    double m_txp = 20;    
    phy.Set ("TxPowerStart",DoubleValue (m_txp));
    phy.Set ("TxPowerEnd", DoubleValue (m_txp));
    

2. infrastructure BSS (AP mode)

ap-sta source code

It's make almost no different from the Wi-Fi adhoc setting. The only difference is adhoc communication works well with two node and ap-mode needs three nodes.

For this part we set up 3 nodes. 2 for Stationary Node and 1 for Ap Node.

  1. Initialize Wi-Fi helper. But here I add another setting. It is not necessary. You can also set up in the adhoc mode. ArfWifiManager is auto rate fallback. It means send packet depends on the network condition.
    WifiHelper wifi;
    wifi.SetStandard (WIFI_PHY_STANDARD_80211a);
    wifi.SetRemoteStationManager ("ns3::ArfWifiManager");
    
  2. Initialize the channel.

    YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();    
    Ptr<YansWifiChannel> channel = wifiChannel.Create ();
    YansWifiPhyHelper phy =  YansWifiPhyHelper::Default ();
    phy.SetChannel (channel);
    
    double m_txp = 20;    
    phy.Set ("TxPowerStart",DoubleValue (m_txp));
    phy.Set ("TxPowerEnd", DoubleValue (m_txp));
    
  3. For here, we have to set up two kinds of node, one is Stationary node, and the other is Ap node. The key different is in the MAC helper. What they do is setup the SSID to the AP and tell the stationary node to find the specific SSID. That'a all. There are some trick for node manipulation between NodeContainer. You can think NodeContainer is just an array of Node. Take it easy.

    WifiMacHelper mac;
    mac.SetType ("ns3::StaWifiMac",
          "Ssid", SsidValue (Ssid ("wifi0")),
               "ActiveProbing", BooleanValue (true));
    
    NodeContainer sta_nodes;
    uint32_t last_node_index = wifi_nodes.GetN ()-1;
    for (uint32_t i = 0; i < last_node_index; ++i)
    {
      sta_nodes.Add (wifi_nodes.Get (i));
    }
    NetDeviceContainer nic_container = wifi.Install (phy, mac, sta_nodes);
    
    NodeContainer ap_nodes;    
    ap_nodes.Add (wifi_nodes.Get (last_node_index));
    mac.SetType ("ns3::ApWifiMac",
          "Ssid", SsidValue (Ssid ("wifi0")));
    
    nic_container.Add (wifi.Install (phy, mac, ap_nodes));
    
    return nic_container;
    

results matching ""

    No results matching ""