To simulate the HWMP (Hybrid Wireless Mesh Protocol) using NS3, which is the default routing protocol for IEEE 802.11s mesh networks. It integrates an elements of proactive and reactive routing to effectively route data in mesh networks. The simulation environment NS3 contains native support for IEEE 802.11s and the HWMP protocol, thus replicating HWMP-based projects in NS3 is straightforward. Here we provide key steps and replication process to simulate a mesh network using HWMP in NS3.
Key Steps for Simulating HWMP Protocol in NS3:
- Set up a mesh network using IEEE 802.11s.
- Utilise HWMP (default) as the routing protocol for the mesh network.
- Make a mobility and traffic applications to generate and replicate traffic within the mesh network.
- Investigate network performance using tools such as PCAP and NetAnim.
Steps to Simulate HWMP Protocol in NS3
- Install NS3
Make sure we have NS3 installed on the computer. Unless, we can download it from the NS3 official website.
- Create a Simulation Using the HWMP Protocol in a Mesh Network
Now, we will make a simulation script, which sets up a mesh network using IEEE 802.11s and the HWMP protocol that is the default routing protocol within mesh networks.
Example Simulation Script for HWMP in NS3
- Include Necessary Headers
These headers are essential for configuring the mesh network, wireless communication, mobility, and traffic applications within NS3.
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/mobility-module.h”
#include “ns3/wifi-module.h”
#include “ns3/mesh-helper.h”
#include “ns3/applications-module.h”
#include “ns3/netanim-module.h”
- Create and Install Nodes
Make a set of nodes, which will signify mesh stations (mesh points) in the IEEE 802.11s mesh network.
NodeContainer meshNodes;
meshNodes.Create(6); // Create 6 mesh nodes (stations)
- Configure IEEE 802.11s Mesh Network (Using HWMP)
Utilise the MeshHelper to set up the IEEE 802.11s mesh network. By default, it will use HWMP as the routing protocol.
MeshHelper meshHelper;
meshHelper.SetStandard(WIFI_PHY_STANDARD_80211s); // Set the standard to 802.11s (Mesh)
meshHelper.SetStackInstaller(“ns3::Dot11sStack”); // Use 802.11s mesh stack
meshHelper.SetNumberOfInterfaces(1); // Set one mesh interface per node
NetDeviceContainer meshDevices = meshHelper.Install(meshPhy, meshNodes);
- Set Up the PHY Layer for Wireless Communication
Set up the physical layer (PHY) using YansWifiPhyHelper and configure the wireless channel using YansWifiChannelHelper.
YansWifiPhyHelper meshPhy = YansWifiPhyHelper::Default();
YansWifiChannelHelper meshChannel = YansWifiChannelHelper::Default();
meshPhy.SetChannel(meshChannel.Create());
- Install Internet Stack on Mesh Nodes
Install the Internet Stack (TCP/IP) on the mesh nodes thus that they can route and forward traffic using the HWMP protocol.
InternetStackHelper internetStack;
internetStack.Install(meshNodes);
- Assign IP Addresses
We can use the Ipv4AddressHelper to allocate an IP addresses to the mesh network interfaces.
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”); // Use the 10.1.1.0/24 address range
Ipv4InterfaceContainer meshInterfaces = address.Assign(meshDevices);
- Set Up Mobility Model for Mesh Nodes
We can use the MobilityHelper to set up the mobility of mesh nodes. This instance uses a random rectangular grid, however we can change it to use other mobility models.
MobilityHelper mobility;
mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,
“MinX”, DoubleValue(0.0),
“MinY”, DoubleValue(0.0),
“DeltaX”, DoubleValue(100.0),
“DeltaY”, DoubleValue(100.0),
“GridWidth”, UintegerValue(3),
“LayoutType”, StringValue(“RowFirst”));
mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”); // Nodes stay fixed
mobility.Install(meshNodes);
- Set Up Traffic Applications
We can be replicated communication among the nodes using TCP or UDP traffic applications. The following is an instance in which one node performs as a UDP Echo Server and another as a UDP Echo Client.
- Server (UDP Echo Server):
uint16_t port = 9;
UdpEchoServerHelper echoServer(port);
ApplicationContainer serverApp = echoServer.Install(meshNodes.Get(0)); // Server on node 0
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(20.0));
- Client (UDP Echo Client):
UdpEchoClientHelper echoClient(meshInterfaces.GetAddress(0), port); // Client sending to node 0
echoClient.SetAttribute(“MaxPackets”, UintegerValue(100));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = echoClient.Install(meshNodes.Get(5)); // Client on node 5
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(20.0));
- Enable Tracing and Animation
Allow PCAP tracing to investigate the packet exchanges among the mesh nodes, and we can use NetAnim to envision the mesh network.
meshPhy.EnablePcapAll(“hwmp_mesh_simulation”); // Enable packet capture for all nodes
AnimationInterface anim(“hwmp_mesh_simulation.xml”); // Enable NetAnim animation
- Run the Simulation
Set the simulation stop time and we run the simulation.
Simulator::Stop(Seconds(20.0)); // Set simulation stop time
Simulator::Run(); // Run the simulation
Simulator::Destroy(); // Clean up after the simulation
- Full Example Script for HWMP in a Mesh Network
Below is the comprehensive simulation script for making an IEEE 802.11s mesh network using HWMP as the routing protocol.
#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/mesh-helper.h”
#include “ns3/applications-module.h”
#include “ns3/netanim-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
// Step 1: Create mesh nodes
NodeContainer meshNodes;
meshNodes.Create(6); // Create 6 mesh nodes
// Step 2: Set up the physical layer and channel
YansWifiPhyHelper meshPhy = YansWifiPhyHelper::Default();
YansWifiChannelHelper meshChannel = YansWifiChannelHelper::Default();
meshPhy.SetChannel(meshChannel.Create());
// Step 3: Set up the mesh network using IEEE 802.11s and HWMP
MeshHelper meshHelper;
meshHelper.SetStandard(WIFI_PHY_STANDARD_80211s); // Set the standard to 802.11s (Mesh)
meshHelper.SetStackInstaller(“ns3::Dot11sStack”); // Use 802.11s stack (HWMP routing)
meshHelper.SetNumberOfInterfaces(1); // Use 1 interface per node
NetDeviceContainer meshDevices = meshHelper.Install(meshPhy, meshNodes);
// Step 4: Install Internet stack on mesh nodes
InternetStackHelper internetStack;
internetStack.Install(meshNodes);
// Step 5: Assign IP addresses to mesh nodes
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer meshInterfaces = address.Assign(meshDevices);
// Step 6: Set up the mobility model for mesh nodes
MobilityHelper mobility;
mobility.SetPositionAllocator(“ns3::GridPositionAllocator”,
“MinX”, DoubleValue(0.0),
“MinY”, DoubleValue(0.0),
“DeltaX”, DoubleValue(100.0),
“DeltaY”, DoubleValue(100.0),
“GridWidth”, UintegerValue(3),
“LayoutType”, StringValue(“RowFirst”));
mobility.SetMobilityModel(“ns3::ConstantPositionMobilityModel”); // Fixed nodes
mobility.Install(meshNodes);
// Step 7: Set up UDP Echo Server on mesh node 0
uint16_t port = 9;
UdpEchoServerHelper echoServer(port);
ApplicationContainer serverApp = echoServer.Install(meshNodes.Get(0)); // Server on node 0
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(20.0));
// Step 8: Set up UDP Echo Client on mesh node 5
UdpEchoClientHelper echoClient(meshInterfaces.GetAddress(0), port);
echoClient.SetAttribute(“MaxPackets”, UintegerValue(100));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = echoClient.Install(meshNodes.Get(5)); // Client on node 5
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(20.0));
// Step 9: Enable tracing and animation
meshPhy.EnablePcapAll(“hwmp_mesh_simulation”);
AnimationInterface anim(“hwmp_mesh_simulation.xml”);
// Step 10: Run the simulation
Simulator::Stop(Seconds(20.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Running the Simulation
- Build and run the script using NS3’s waf build system:
./waf build
./waf –run hwmp_mesh_simulation
- Analyzing Results
- PCAP Traces: The .pcap files are generated in the course of the simulation can be investigated using Wireshark to monitor the packet exchanges.
- NetAnim Visualization: We can be used the NetAnim to envision the mesh network and we view packet transmissions in real time utilising the .xml file generated during the simulation.
- Extending the Simulation
We can expand this simple simulation by:
- Changing node mobility: We can use more furthered mobility models such as RandomWaypointMobilityModel or import real-world movement traces (e.g., from SUMO).
- Using different traffic models: Rather than basic UDP Echo traffic, replicate more realistic applications like TCP, video streaming, or VoIP.
- Adding more mesh nodes: Expand the simulation to larger mesh networks with more nodes and interfaces.
- Performance evaluation: We can use the tools such as FlowMonitor to examine performance parameters such as throughput, delay, and packet loss.
By utilizing the ns3 simulation environment we successfully simulated and extended the HWMP protocol projects with the support of above procedure. Moreover, we will be delivered further informations and sample snippets related to this topic in upcoming manual.
Please send us all the details of your HWMP Protocol Projects at phdprime.com, and we will assist you in achieving the best simulation outcomes. We offer you a variety of research topics and ideas based on your requirements. Let our staff complete an impeccable paper