How to Begin Implement IEEE 802.11 WiFi in NS3
To create an Execution of IEEE 802.11 WiFi project using NS-3 has includes the replicate a wireless networks according to the 802.11 standard. The tool NS-3 offers the robust helps for different WiFi standards, has contains the different standards such as 802.11a, 802.11b, 802.11g, 802.11n, and 802.11ac. Here’s a step-by-step guide:
Steps to Begin Implementing a IEEE 802.11 WiFi Projects Using NS3
- Understand IEEE 802.11 WiFi
Key features of IEEE 802.11 WiFi:
- Standards: Changed the standards for sample 802.11a, 802.11b by different data rates, frequencies, and channel widths.
- Modes: The mode are consist the Infrastructure mode like as using access points and Ad-hoc mode such as peer-to-peer communication.
- QoS Features: The QoS characteristics like as EDCA (Enhanced Distributed Channel Access) and aggregation.
- Define Project Objectives
Choose the aim of WiFi project:
- It replicates the simple wireless communication.
- Examine the metrices such as throughput, latency, and packet delivery ratio.
- Examine the performance of below various loads of congestion or mobility designs.
- Research by detailed the IEEE 802.11 standards for instance 802.11n or 802.11ac.
- Install and Set Up NS-3
- Install NS-3: Download the latest version from the NS-3 website.
- Explore WiFi modules:
- YansWifiPhyHelper: Intended for replicate the physical layer.
- WifiMacHelper: Designed for MAC layer settings.
- WifiHelper: Used for set-up the high-level WiFi.
- Design the WiFi Network
Key Components:
- Nodes: Devices in the network (e.g., stations and access points).
- Access Points (AP): The Access points are designed for structure mode.
- Traffic Model: Describe the communication designs for sample uplink, downlink.
- Mobility Model: It replicates the node movement.
- Implement the Simulation
Step A: Create Nodes
It build a nodes for stations (STA) and access points (AP).
NodeContainer wifiStaNodes, wifiApNode;
wifiStaNodes.Create(5); // 5 Stations
wifiApNode.Create(1); // 1 Access Point
Step B: Configure WiFi PHY and MAC
- Physical Layer (PHY):
- Fixed the channel and broadcast for loss the pattern.
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
- MAC Layer:
- Set-up the MAC layer for stations and assign the points.
WifiHelper wifi;
wifi.SetStandard(WIFI_STANDARD_80211ac);
WifiMacHelper wifiMac;
wifiMac.SetType(“ns3::StaWifiMac”,
“Ssid”, SsidValue(Ssid(“ns3-wifi”)),
“ActiveProbing”, BooleanValue(false));
NetDeviceContainer staDevices = wifi.Install(wifiPhy, wifiMac, wifiStaNodes);
wifiMac.SetType(“ns3::ApWifiMac”,
“Ssid”, SsidValue(Ssid(“ns3-wifi”)));
NetDeviceContainer apDevice = wifi.Install(wifiPhy, wifiMac, wifiApNode);
Step C: Install Internet Stack
Download the Internet stack for all nodes.
InternetStackHelper stack;
stack.Install(wifiStaNodes);
stack.Install(wifiApNode);
Allot the IP addresses for internet stack.
Ipv4AddressHelper ipv4;
ipv4.SetBase(“192.168.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer staInterfaces = ipv4.Assign(staDevices);
Ipv4InterfaceContainer apInterface = ipv4.Assign(apDevice);
Step D: Define Mobility
It fixed the mobility for stations and allocate the points.
MobilityHelper mobility;
mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,
“MinX”, DoubleValue(0.0),
“MinY”, DoubleValue(0.0),
“DeltaX”, DoubleValue(5.0),
“DeltaY”, DoubleValue(10.0),
“GridWidth”, UintegerValue(3),
“LayoutType”, StringValue(“RowFirst”));
mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);
mobility.Install(wifiApNode);
mobility.SetMobilityModel(“ns3::RandomWalk2dMobilityModel”,
“Bounds”, RectangleValue(Rectangle(-50, 50, -50, 50)));
mobility.Install(wifiStaNodes);
Step E: Add Traffic Applications
- Install Traffic Source:
- Use the congestion source of replicate the congestion such as OnOffApplication.
OnOffHelper onOff(“ns3::UdpSocketFactory”, InetSocketAddress(apInterface.GetAddress(0), 9));
onOff.SetAttribute(“DataRate”, StringValue(“10Mbps”));
onOff.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer app = onOff.Install(wifiStaNodes.Get(0)); // STA 0 sends traffic
app.Start(Seconds(1.0));
app.Stop(Seconds(10.0));
- Install Traffic Sink:
- Make use the congestion for receive like PacketSink.
PacketSinkHelper packetSink(“ns3::UdpSocketFactory”, InetSocketAddress(Ipv4Address::GetAny(), 9));
ApplicationContainer sinkApp = packetSink.Install(wifiApNode.Get(0));
sinkApp.Start(Seconds(1.0));
sinkApp.Stop(Seconds(10.0));
- Configure Simulation
It configures the replication of duration time for implement the simulation.
Simulator::Stop(Seconds(10.0));
Simulator::Run();
Simulator::Destroy();
- Evaluate Performance
- Metrics:
- The performances are calculating the metrices as throughput, latency, jitter, and packet delivery ratio.
- Visualization:
- It can use envision for graphical tool like NetAnim.
- It transfers the metrices for study the tool MATLAB or Python.
- Advanced Features
- Experiment with Standards:
- The various replication for IEEE 802.11 standards for instance 802.11n, 802.11ac.
- QoS:
- The QoS as assure the EDCA for prioritization of congestion.
- Handover:
- It replicates the mobility for examine the handover among allocate the points.
- Interference:
- It replicates the interference for using the channels for overlapping.
Sample Complete Code Framework
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/wifi-module.h”
#include “ns3/mobility-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main() {
// Create Nodes
NodeContainer wifiStaNodes, wifiApNode;
wifiStaNodes.Create(5); // 5 Stations
wifiApNode.Create(1); // 1 Access Point
// Configure PHY and MAC
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
WifiHelper wifi;
wifi.SetStandard(WIFI_STANDARD_80211ac);
WifiMacHelper wifiMac;
wifiMac.SetType(“ns3::StaWifiMac”,
“Ssid”, SsidValue(Ssid(“ns3-wifi”)),
“ActiveProbing”, BooleanValue(false));
NetDeviceContainer staDevices = wifi.Install(wifiPhy, wifiMac, wifiStaNodes);
wifiMac.SetType(“ns3::ApWifiMac”,
“Ssid”, SsidValue(Ssid(“ns3-wifi”)));
NetDeviceContainer apDevice = wifi.Install(wifiPhy, wifiMac, wifiApNode);
// Install Internet Stack
InternetStackHelper stack;
stack.Install(wifiStaNodes);
stack.Install(wifiApNode);
// Assign IP Addresses
Ipv4AddressHelper ipv4;
ipv4.SetBase(“192.168.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer staInterfaces = ipv4.Assign(staDevices);
Ipv4InterfaceContainer apInterface = ipv4.Assign(apDevice);
// Mobility
MobilityHelper mobility;
mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,
“MinX”, DoubleValue(0.0),
“MinY”, DoubleValue(0.0),
“DeltaX”, DoubleValue(5.0),
“DeltaY”, DoubleValue(10.0),
“GridWidth”, UintegerValue(3),
“LayoutType”, StringValue(“RowFirst”));
mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”);
mobility.Install(wifiApNode);
mobility.SetMobilityModel(“ns3::RandomWalk2dMobilityModel”,
“Bounds”, RectangleValue(Rectangle(-50, 50, -50, 50)));
mobility.Install(wifiStaNodes);
// Applications
OnOffHelper onOff(“ns3::UdpSocketFactory”, InetSocketAddress(apInterface.GetAddress(0), 9));
onOff.SetAttribute(“DataRate”, StringValue(“10Mbps”));
onOff.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer app = onOff.Install(wifiStaNodes.Get(0));
app.Start(Seconds(1.0));
app.Stop(Seconds(10.0));
PacketSinkHelper packetSink(“ns3::UdpSocketFactory”, InetSocketAddress(Ipv4Address::GetAny(), 9));
ApplicationContainer sinkApp = packetSink.Install(wifiApNode.Get(0));
sinkApp.Start(Seconds(1.0));
sinkApp.Stop(Seconds(10.0));
// Run Simulation
Simulator::Stop(Seconds(10.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}
The above project concept explores numerous contexts of IEEE 802.11 Wi-Fi projects performance and the detailed installation procedures to simulate the IEEE 802.11 Wi-Fi projects in ns3 tool. If you’d like more details on any specific project, feel free to ask!
Click Here to watch our latest output video using NS3 simulator
Click Here to watch our latest projects screenshots using NS3 simulator