How to Simulate AODV Protocol Projects Using NS3

To simulate the AODV (Ad hoc On-Demand Distance Vector) routing protocol using NS3, which is more straightforward than EIGRP since NS3 encompasses a native execution of AODV. Now we deliver a step-by-step instruction on how to set up and simulate AODV protocol-based projects in NS3.

Steps to Simulate AODV Protocol Using NS3:

  1. Install NS3: Make sure we have NS3 installed. We can download it from the official NS3 website nsnam.org. If we haven’t installed NS3 yet then we follow the installation guide for the operating system.
  2. Create a Basic Network Topology: AODV is mainly used in mobile ad hoc networks (MANETs), thus we will require to make a wireless network of mobile nodes. For simplicity, we begin with a small static network and then move to mobility.
  3. Configure AODV Routing: Simulation tool NS3 comes with a built-in AODV protocol. We can set up the nodes in the network to use AODV by containing the AODV helper class in the simulation script.
  4. Set Up Mobility: Because AODV is frequently utilised in mobile ad hoc networks, inserting mobility to the nodes will be delivered a more realistic scenario. We can be used the MobilityHelper in NS3 to attain this.
  5. Install Applications: When the network is configure, we will want to install some applications, like a client-server setup, to generate network traffic and then we monitor how AODV handles the communication.
  6. Run the Simulation: After setting everything up, run the simulation, gather outcomes, and then investigate the performance of AODV such as parameters like throughput, delay, packet delivery ratio, and so on.

Example Simulation Code for AODV in NS3:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/aodv-helper.h”

#include “ns3/mobility-module.h”

#include “ns3/wifi-module.h”

#include “ns3/applications-module.h”

#include “ns3/netanim-module.h”

using namespace ns3;

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

{

// Step 1: Set up a basic wireless network

NodeContainer nodes;

nodes.Create (10);

WifiHelper wifi;

wifi.SetStandard (WIFI_PHY_STANDARD_80211b);

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default ();

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default ();

wifiPhy.SetChannel (wifiChannel.Create ());

WifiMacHelper wifiMac;

wifi.SetRemoteStationManager (“ns3::AarfWifiManager”);

// Set it to Ad-hoc mode

wifiMac.SetType (“ns3::AdhocWifiMac”);

NetDeviceContainer devices = wifi.Install (wifiPhy, wifiMac, nodes);

// Step 2: Set up mobility model for the nodes

MobilityHelper mobility;

mobility.SetMobilityModel (“ns3::ConstantPositionMobilityModel”);

mobility.Install (nodes);

// Step 3: Install AODV Routing

AodvHelper aodv;

InternetStackHelper internet;

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

internet.Install (nodes);

// Step 4: Assign IP addresses

Ipv4AddressHelper ipv4;

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

Ipv4InterfaceContainer interfaces = ipv4.Assign (devices);

// Step 5: Set up applications (e.g., UDP Echo)

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));

// Step 6: Enable NetAnim for visualization

AnimationInterface anim (“aodv_simulation.xml”);

// Step 7: Run the simulation

Simulator::Run ();

Simulator::Destroy ();

return 0;

}

Explanation of the Code:

  1. Node Creation: We make 10 nodes using NodeContainer.
  2. Wi-Fi Setup: We set up the Wi-Fi settings using WifiHelper to make an ad hoc network among the nodes.
  3. Mobility: We utilise the MobilityHelper to set the mobility model for the nodes. In this case, they are located at constant positions, however we can change it to replicate movement (e.g., RandomWalk2dMobilityModel).
  4. AODV Routing: The AodvHelper is used to set up the AODV protocol for routing.
  5. Applications: We install a simple UDP Echo client-server application. The server is placed on one node (node 0), and the client on another node (node 9). It permits to analyse the communication over the network.
  6. NetAnim: AnimationInterface is used to make an XML file for visualizing the simulation with the help of NetAnim.
  7. Run the Simulation: To end, the simulation is implemented using Simulator::Run(), and after the simulation is finish, Simulator::Destroy() cleans up the resources.

Adding Mobility:

To create the simulation more realistic, we can insert the mobility to the nodes. For instance, we can use the RandomWalk2dMobilityModel to create the nodes move randomly:

mobility.SetMobilityModel (“ns3::RandomWalk2dMobilityModel”,

“Bounds”, RectangleValue (Rectangle (-50, 50, -50, 50)));

Performance Metrics to Evaluate:

To examine the performance of AODV, we can calculate:

  • Throughput: The rate of successful message delivery across the network.
  • Packet Delivery Ratio (PDR): The ratio of packets effectively delivered to the destination against packets sent.
  • End-to-End Delay: The time taken for a packet to travel from the origin to the end.
  • Routing Overhead: The total amount of routing-related control traffic generated by AODV.

Visualization with NetAnim:

We can visualize the movement and communication among the nodes using NetAnim. After the simulation runs, we open the produced aodv_simulation.xml file in NetAnim to observe the network in action.

Running the Simulation:

  1. Create the NS3 code using the below commands:

./waf configure

./waf build

./waf –run <your-script-name>

  1. After the simulation, open the generated NetAnim file:

netanim aodv_simulation.xml

This code configures a simple AODV simulation in NS3, however we can expand it further by inserting more nodes, mobility, varying traffic patterns, and then evaluating various performance metrics to discover the protocol’s behaviour in more complex scenarios.

By using the given stepwise technique with sample snippets and its explanation are supports you on how to simulate and how to set up the AODV protocol projects via NS3 simulator. If you required, we will be offered further insights about this AODV protocol in another script.

We specialize in the native execution of the AODV protocol tailored to your research needs. Share your research details with us, and we will guide you toward the optimal solution. For simulating AODV protocol projects using the NS3 tool, consider reaching out to phdprime.com. By providing us with your research specifics, we can offer you customized solutions and assist you in conducting a comparative analysis.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2