How to Start Wireless Routing Protocol Projects Using NS3
To start wireless routing protocols in NS3 that can be generally accomplished for Mobile Ad Hoc Networks (MANETs), Wireless Mesh Networks, and Wireless Sensor Networks (WSNs). NS3 environments have diverse wireless routing protocols like AODV (Ad hoc On-Demand Distance Vector), DSDV (Destination-Sequenced Distance Vector), OLSR (Optimized Link State Routing), and DSR (Dynamic Source Routing). These protocols are created for various wireless network situations and it can utilise to replicate the dynamic, mobile, or sensor-based wireless networks.
Following is a stepwise method to making and simulating a wireless routing protocol project in NS3.
Steps to Start Wireless Routing Protocol Projects in NS3
- Install NS3
We can follow these commands (assuming a Linux environment) as NS3 doesn’t install:
# Update system and install dependencies
sudo apt update
sudo apt install -y gcc g++ python3 python3-dev cmake libgsl-dev libsqlite3-dev
# Clone the NS-3 repository
git clone https://gitlab.com/nsnam/ns-3-dev.git ns-3
cd ns-3
# Configure and build NS-3
./ns3 configure –enable-examples –enable-tests
./ns3 build
- Create a New Script for Wireless Routing Protocol Simulation
- In the NS3’s scratch directory, we want to make a new file like wireless_routing_protocol_simulation.cc.
- We can adhere to below structure that illustrates how to configure a wireless ad hoc network with selectable routing protocols.
Basic Structure of wireless_routing_protocol_simulation.cc:
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/aodv-helper.h”
#include “ns3/dsdv-helper.h”
#include “ns3/olsr-helper.h”
#include “ns3/dsr-helper.h”
#include “ns3/mobility-module.h”
#include “ns3/wifi-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
NS_LOG_COMPONENT_DEFINE(“WirelessRoutingProtocolSimulation”);
int main(int argc, char *argv[]) {
// Enable logging
LogComponentEnable(“UdpEchoClientApplication”, LOG_LEVEL_INFO);
LogComponentEnable(“UdpEchoServerApplication”, LOG_LEVEL_INFO);
// Create nodes for the wireless network
NodeContainer nodes;
nodes.Create(10); // Example with 10 nodes
// Set up mobility model for the nodes
MobilityHelper mobility;
mobility.SetPositionAllocator(“ns3::RandomRectanglePositionAllocator”,
“X”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=100.0]”),
“Y”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=100.0]”));
mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,
“Speed”, StringValue(“ns3::UniformRandomVariable[Min=1.0|Max=5.0]”),
“Pause”, StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”));
mobility.Install(nodes);
// Configure WiFi for ad hoc network
WifiHelper wifi;
wifi.SetStandard(WIFI_STANDARD_80211b);
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
WifiMacHelper wifiMac;
wifiMac.SetType(“ns3::AdhocWifiMac”);
NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, nodes);
// Install Internet stack and set up routing protocols
InternetStackHelper internet;
// Uncomment one of the following lines to select a routing protocol
AodvHelper aodv;
internet.SetRoutingHelper(aodv); // Use AODV as the routing protocol
// OlsrHelper olsr;
// internet.SetRoutingHelper(olsr); // Use OLSR as the routing protocol
// DsdvHelper dsdv;
// internet.SetRoutingHelper(dsdv); // Use DSDV as the routing protocol
// DsrMainHelper dsrMain;
// DsrHelper dsr;
// internet.Install(nodes);
// dsrMain.Install(dsr, nodes);
internet.Install(nodes);
// Assign IP addresses
Ipv4AddressHelper ipv4;
ipv4.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = ipv4.Assign(devices);
// Set up a UDP echo server on one node to test connectivity
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApps = echoServer.Install(nodes.Get(0));
serverApps.Start(Seconds(1.0));
serverApps.Stop(Seconds(10.0));
// Set up a UDP echo client on another node to communicate with the server
UdpEchoClientHelper echoClient(interfaces.GetAddress(0), 9);
echoClient.SetAttribute(“MaxPackets”, UintegerValue(3));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApps = echoClient.Install(nodes.Get(9));
clientApps.Start(Seconds(2.0));
clientApps.Stop(Seconds(10.0));
// Run the simulation
Simulator::Stop(Seconds(10.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}
Explanation of the Code
- Node Creation: Ten nodes are created to form the wireless network.
- Mobility Model: Utilise RandomWaypointMobilityModel to replicate the node movement that is helpful for MANETs or any dynamic wireless network.
- WiFi Setup: In ad hoc mode, WiFi is set up those permitting nodes to directly interact with each other deprived of a central access point.
- Routing Protocols:
- AODV (Ad hoc On-Demand Distance Vector): A reactive protocol, which launches the routes only if required.
- OLSR (Optimized Link State Routing): It is a proactive link-state routing protocol.
- DSDV (Destination-Sequenced Distance Vector): A proactive distance-vector protocol including sequence numbers, preventing loops.
- DSR (Dynamic Source Routing): A reactive protocol which utilizes route discovery and maintenance.
- UDP Echo Applications:
- A UDP Echo Server is configured at node 0.
- A UDP Echo Client on node 9 transmits packets to the server, with the help of chosen routing protocol analysing end-to-end connectivity.
- Build and Run the Simulation
- In the scratch directory, we can save wireless_routing_protocol_simulation.cc.
- Go to terminal then pass through to NS3 directory, and make the script:
./ns3 build
- Now, we need to execute the simulation including chosen routing protocol by uncommenting the corresponding line in the code:
./ns3 run scratch/wireless_routing_protocol_simulation
- Analyze the Results
This simulation will be illustrated the connectivity among nodes to utilise the chosen wireless routing protocol. The protocol will be managed route discovery, route maintenance, and packet forwarding as per their certain characteristics.
To allow comprehensive logs for each protocol:
- AODV:
LogComponentEnable(“AodvRoutingProtocol”, LOG_LEVEL_ALL);
- OLSR:
LogComponentEnable(“OlsrRoutingProtocol”, LOG_LEVEL_ALL);
- DSDV:
LogComponentEnable(“DsdvRoutingProtocol”, LOG_LEVEL_ALL);
- DSR:
LogComponentEnable(“DsrRoutingProtocol”, LOG_LEVEL_ALL);
These logs will show data regarding route discovery, route maintenance, and packet forwarding activities.
Experimentation Ideas
To discover further wireless routing protocols, we can consider following experiment:
- Change Node Density: We maximize or minimise the volume of nodes to monitor the scalability of protocol.
- Adjust Mobility Parameters: Test with diverse speeds and pause times to focus on how mobility impacts the performance of protocol.
- Compare Protocol Performance: We execute several simulations along with each protocol and then estimate the performance indicators like packet delivery ratio, end-to-end delay, and routing overhead.
- Add More Traffic Sources: Configure numerous clients and servers, calculating the performance of protocol in higher traffic loads.
- Use FlowMonitor for Performance Metrics: NS3’s FlowMonitor module can be monitored the performance parameters such as packet delivery ratio, throughput, delay, and packet loss that permitting to observe and also equate the performance.
As illustrated above, we had efficiently created and simulated the Wireless Routing Protocol Projects through given simulation procedure with example coding and further project’s ideas in NS3 tool. If you have any query on this process, we will clarify it also.
At phdprojects.org, we’re here to help you discover the perfect project topics and simulation outcomes to get your Wireless Routing Protocol Projects with NS3tool. Partner with us, and you’ll see the results of your project come to life. We’ll take care of the project performance for you. We cover AODV (Ad hoc On-Demand Distance Vector), DSDV (Destination-Sequenced Distance Vector), OLSR (Optimized Link State Routing), and DSR (Dynamic Source Routing). Share your project details with us, and we’ll provide you with the best ideas and topics to work with.