How to Start AODV Protocol Projects Using NS3

To start Ad hoc On-Demand Distance Vector (AODV) protocol in NS3, for mobile ad hoc networks (MANETs) that is a general reactive routing protocol and NS3 environment inherent support for it. Following is a brief steps on how we can configure an AODV project in NS3.

Steps to Start AODV Protocol Projects in NS3

  1. Install NS3

We can configure it with the below commands (assuming a Linux environment) as NS3 doesn’t install on the system:

# 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

  1. Create a New Script for AODV Simulation
  1. In the NS3’s scratch folder, we need to make a new file named aodv_simulation.cc.
  2. Utilize the below example code outline to configure a simple AODV simulation:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/mobility-module.h”

#include “ns3/aodv-module.h”

#include “ns3/wifi-module.h”

#include “ns3/ipv4-static-routing-helper.h”

using namespace ns3;

int main(int argc, char *argv[]) {

// Enable AODV logging

LogComponentEnable(“AodvRoutingProtocol”, LOG_LEVEL_INFO);

// Create nodes for the MANET

NodeContainer nodes;

nodes.Create(10); // Example with 10 nodes

// Set up mobility model

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 communication

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 with AODV routing

InternetStackHelper internet;

AodvHelper aodv;

internet.SetRoutingHelper(aodv);  // Set AODV as the routing protocol

internet.Install(nodes);

// Assign IP addresses to the devices

Ipv4AddressHelper ipv4;

ipv4.SetBase(“10.1.1.0”, “255.255.255.0”);

Ipv4InterfaceContainer interfaces = ipv4.Assign(devices);

// Set up a UDP echo server and client for testing AODV

UdpEchoServerHelper echoServer(9);

ApplicationContainer serverApps = echoServer.Install(nodes.Get(0));

serverApps.Start(Seconds(1.0));

serverApps.Stop(Seconds(10.0));

UdpEchoClientHelper echoClient(interfaces.GetAddress(0), 9);

echoClient.SetAttribute(“MaxPackets”, UintegerValue(1));

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;

}

In this code:

    • Nodes: We need to make 10 nodes for an ad hoc network.
    • Mobility Model: We utilize RandomWaypointMobilityModel, configuring random movement for nodes that is normal in MANETs.
    • WiFi Configuration: For ad hoc interaction with AdhocWifiMac as the MAC layer, we can use the IEEE 802.11b standard.
    • AODV Routing: We configure AODV like the routing protocol for the network.
    • Application Setup: A UDP echo server and client are set up to experiment connectivity over the AODV network.
  1. Build and Run the Simulation
  1. In the scratch directory, we can store aodv_simulation.cc.
  2. Go to a terminal, pass through to the NS3 directory, and make the script:

./ns3 build

  1. Run the simulation:

./ns3 run scratch/aodv_simulation

  1. Analyze AODV Results

We can be monitored route discovery and maintenance of AODV in the course of the simulation. AODV makes routes only when required thus we will observe route requests and replies since nodes interact. For more in-depth logging, allow additional verbose logging for AodvRoutingProtocol:

LogComponentEnable(“AodvRoutingProtocol”, LOG_LEVEL_ALL);

This logging will be indicated in-depth route discovery, route maintenance, and route error messages.

Experimentation Ideas

To prolong the simulation, we can:

  • Vary Node Count and Density: Maximize the volume of nodes or modify the deployment area, analysing the scalability of AODV.
  • Adjust Mobility Settings: Test with various speeds and stop times, monitoring how mobility affects the performance of AODV.
  • Network Performance Metrics: Monitor performance parameters of network such as packet delivery ratio, latency, and throughput to estimate the performance of AODV in various conditions.

We clearly illustrated the simple method with related coding snippets for AODV Protocol projects that were configured and simulated using NS3 simulation tool. We plan to offer more comprehensive approach and concepts regarding this project.

To attain excellence in your projects, allow our team to take care of your needs. Reach out to us for further guidance. phdprojects.org  specialize in AODV Protocol Projects using the NS3 tool, providing scholars with tailored and impeccable documentation. Our team is well-versed in the Ad hoc On-Demand Distance Vector (AODV) protocol, ensuring you receive top-notch results along with comprehensive explanations. Rest assured, our rates are budget-friendly, and we deliver high-quality work you can trust, completed on time by our experts.