To simulate an AOMDV (Ad hoc On-demand Multipath Distance Vector) using NS3 that is an extension of the AODV (Ad hoc on-demand Distance Vector) routing protocol created for mobile ad-hoc networks (MANETs). AOMDV permits for multipath routing that offers several routes from origin to end which enhancing the load balancing fault tolerance.
In NS3, the AOMDV protocol is not natively comprised, however we can be AOMDV-like behaviour using custom executions or third-party extensions. To explore AOMDV Protocol projects utilizing the NS3 tool, you may consider reaching out to phdprime.com. We invite you to share your research details with us, as we offer tailored solutions and assist you in conducting comparative analyses. There are two choices for mimicking AOMDV in NS3:
- Install a third-party NS3-AOMDV module.
- Execute the AOMDV protocol physically by prolonging the AODV module.
The most general technique contains utilising a third-party NS3-AOMDV module that prolongs NS3 with AOMDV functionalities.
Steps to Simulate AOMDV Protocol in NS3
- Install NS3 and NS3-AOMDV Module
We require to install NS3 and the AOMDV extension module to replicate the AOMDV protocol.
Step-by-step guide for installing NS3-AOMDV:
- Clone the AOMDV Module Repository: We can clone a repository which includes the execution of AOMDV for NS3 from GitHub:
git clone https://github.com/derogab/ns3-AOMDV.git
- Copy AOMDV Module Files into NS3 Source: Copy the AOMDV files into the src directory of NS3:
cp -r ns3-AOMDV/aomdv /path/to/your/ns3/src/
- Rebuild NS3: Set up and build NS3 again to contain the AOMDV module:
cd /path/to/your/ns3/
./waf configure
./waf build
- Create a Simulation Script Using AOMDV Protocol
Now that AOMDV is installed, we can make a replication utilising AOMDV as the routing protocol.
Below is an instance simulation, which configures a wireless ad-hoc network using AOMDV for routing.
Example Simulation Using AOMDV Protocol in NS3
- Include Necessary Headers
These headers are essential to configure wireless communication, mobility, the AOMDV routing protocol, and traffic generation.
#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/aomdv-module.h” // AOMDV routing protocol header
#include “ns3/applications-module.h”
#include “ns3/netanim-module.h”
- Create and Install Nodes
Make a set of nodes are signifying the wireless ad-hoc network. These nodes will be used the AOMDV protocol to communicate.
NodeContainer nodes;
nodes.Create(10); // Create 10 nodes
- Configure Wireless Communication (Wi-Fi)
We can use the WifiHelper and YansWifiChannelHelper to set up wireless communication. This configures how the nodes will be communicated wirelessly in an ad-hoc network.
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
WifiHelper wifi;
wifi.SetStandard(WIFI_PHY_STANDARD_80211g); // Set the Wi-Fi standard to 802.11g
wifi.SetRemoteStationManager(“ns3::AarfWifiManager”);
WifiMacHelper wifiMac;
wifiMac.SetType(“ns3::AdhocWifiMac”); // Ad-hoc MAC layer for nodes
NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, nodes);
- Install Internet Stack and AOMDV Protocol
Now, we install the Internet stack (TCP/IP protocols) and set up AOMDV as the routing protocol.
InternetStackHelper internet;
AomdvHelper aomdv; // Use AOMDV as the routing protocol
internet.SetRoutingHelper(aomdv); // Set AOMDV as the routing protocol
internet.Install(nodes);
- Assign IP Addresses
Allocate an IP addresses to the nodes thus they can communicate across the wireless network.
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”); // Assign IP addresses to the network
Ipv4InterfaceContainer interfaces = address.Assign(devices);
- Set Up Mobility Model for Nodes
We can use the MobilityHelper to allocate the positions and mobility to the nodes. We can be utilised a basic random waypoint mobility model to replicate the node movement.
MobilityHelper mobility;
mobility.SetPositionAllocator(“ns3::RandomRectanglePositionAllocator”,
“X”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”),
“Y”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”));
mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,
“Speed”, StringValue(“ns3::UniformRandomVariable[Min=1.0|Max=10.0]”),
“Pause”, StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”),
“PositionAllocator”, StringValue(“ns3::RandomRectanglePositionAllocator”));
mobility.Install(nodes);
- Set Up Traffic Applications
We can be replicated the communication among nodes using applications like UDP Echo. One node will act as a server, and another as a client.
- Server (UDP Echo Server):
uint16_t port = 9;
UdpEchoServerHelper echoServer(port);
ApplicationContainer serverApp = echoServer.Install(nodes.Get(0)); // Server on node 0
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(20.0));
- Client (UDP Echo Client):
UdpEchoClientHelper echoClient(interfaces.GetAddress(0), port); // Client sends messages to node 0
echoClient.SetAttribute(“MaxPackets”, UintegerValue(50));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = echoClient.Install(nodes.Get(5)); // Client on node 5
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(20.0));
- Enable Tracing and Animation
Allow packet capture (PCAP) to investigate the communication among the nodes and use NetAnim to envision the simulation.
wifiPhy.EnablePcapAll(“aomdv_simulation”); // Enable PCAP tracing for all nodes
AnimationInterface anim(“aomdv_simulation.xml”); // Enable NetAnim animation
- Run the Simulation
Set the simulation stop time and run the simulation.
Simulator::Stop(Seconds(20.0)); // Set the simulation stop time
Simulator::Run(); // Run the simulation
Simulator::Destroy(); // Clean up after the simulation
- Full Example Script for AOMDV Simulation in NS3
At this time, we provide comprehensive example of a simulation script using AOMDV in NS3.
#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/aomdv-module.h”
#include “ns3/applications-module.h”
#include “ns3/netanim-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
// Step 1: Create nodes for the AOMDV network
NodeContainer nodes;
nodes.Create(10); // Create 10 nodes
// Step 2: Configure Wi-Fi communication
YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();
YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();
wifiPhy.SetChannel(wifiChannel.Create());
WifiHelper wifi;
wifi.SetStandard(WIFI_PHY_STANDARD_80211g);
wifi.SetRemoteStationManager(“ns3::AarfWifiManager”);
WifiMacHelper wifiMac;
wifiMac.SetType(“ns3::AdhocWifiMac”); // Ad-hoc MAC for nodes
NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, nodes);
// Step 3: Install AOMDV routing protocol and Internet stack
InternetStackHelper internet;
AomdvHelper aomdv; // AOMDV routing protocol
internet.SetRoutingHelper(aomdv);
internet.Install(nodes);
// Step 4: Assign IP addresses
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = address.Assign(devices);
// Step 5: Set up mobility model for nodes
MobilityHelper mobility;
mobility.SetPositionAllocator(“ns3::RandomRectanglePositionAllocator”,
“X”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”),
“Y”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=500.0]”));
mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,
“Speed”, StringValue(“ns3::UniformRandomVariable[Min=1.0|Max=10.0]”),
“Pause”, StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”),
“PositionAllocator”, StringValue(“ns3::RandomRectanglePositionAllocator”));
mobility.Install(nodes);
// Step 6: Set up UDP Echo Server on node 0
uint16_t port = 9;
UdpEchoServerHelper echoServer(port);
ApplicationContainer serverApp = echoServer.Install(nodes.Get(0)); // Server on node 0
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(20.0));
// Step 7: Set up UDP Echo Client on node 5
UdpEchoClientHelper echoClient(interfaces.GetAddress(0), port); // Client sends messages to node 0
echoClient.SetAttribute(“MaxPackets”, UintegerValue(50));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = echoClient.Install(nodes.Get(5)); // Client on node 5
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(20.0));
// Step 8: Enable tracing and animation
wifiPhy.EnablePcapAll(“aomdv_simulation”);
AnimationInterface anim(“aomdv_simulation.xml”);
// Step 9: Run the simulation
Simulator::Stop(Seconds(20.0));
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Running the Simulation
- Here, we compile and run the script using NS3’s waf build system:
./waf build
./waf –run aomdv_simulation
- Analyzing Results
- PCAP Traces: The pcap files are generated in the course of the simulation can investigate using tools such as Wireshark to monitor packet exchanges and traffic.
- NetAnim: We can envision the network topology and node movements in NetAnim using the .xml file generated during the simulation.
- Extending the Simulation
We can expand this AOMDV simulation by:
- We can use various mobility models (e.g., import SUMO traces for real-world vehicle movement).
- Inserting more nodes to replicate a larger, more complex network.
- Replicating various traffic patterns (e.g., real-time video streaming or sensor data transmission).
These projects will enable you to gain a deeper knowledge regarding simulation process of AOMDV protocol and analyse the outcomes using Wireshark and NetAnim. If you need more information regarding this projects we will offered it.