How to Simulate MANET Projects Using NS3

To simulate the Mobile Ad-hoc Networks (MANETs) using NS3, which encompasses configuring mobile nodes, preventing routing protocols that are suited for MANET environments, and replicating their communication over time. Now, we provide simplified step-by-step procedure to simulate MANET projects using NS3:

Steps to Simulate MANET Projects in NS3

  1. Install NS3

Make certain we have NS3 installed. Unless, we can follow the installation steps mentioned earlier or we can use a virtual machine to run NS3.

  1. MANET-Specific Routing Protocols

NS3 supports numerous MANET routing protocols like:

  • AODV (Ad-hoc On-Demand Distance Vector)
  • DSDV (Destination-Sequenced Distance-Vector)
  • OLSR (Optimized Link State Routing)
  • DSR (Dynamic Source Routing)
  1. Basic Setup for MANET Simulation

To replicate a MANET, we require to setup the mobile nodes, wireless communications, and mobility models. Below is a simple instance.

Example Code for MANET Simulation Using AODV:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/mobility-module.h”

#include “ns3/point-to-point-module.h”

#include “ns3/csma-module.h”

#include “ns3/wifi-module.h”

#include “ns3/applications-module.h”

#include “ns3/aodv-module.h”

#include “ns3/olsr-module.h”

#include “ns3/dsdv-module.h”

#include “ns3/dsr-module.h”

#include “ns3/flow-monitor-module.h”

using namespace ns3;

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

{

CommandLine cmd;

cmd.Parse (argc, argv);

// Create nodes for the MANET

NodeContainer nodes;

nodes.Create (10);

// Set up a 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=10.0]”),

“Pause”, StringValue (“ns3::ConstantRandomVariable[Constant=2.0]”),

“PositionAllocator”, StringValue (“ns3::RandomRectanglePositionAllocator”));

mobility.Install (nodes);

// Set up the Wi-Fi network

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

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

NetDeviceContainer devices;

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

// Install Internet stack with AODV routing

AodvHelper aodv;

InternetStackHelper internet;

internet.SetRoutingHelper (aodv);  // 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);

// Create and install UDP traffic applications (optional)

UdpEchoServerHelper echoServer (9);

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

serverApps.Start (Seconds (1.0));

serverApps.Stop (Seconds (10.0));

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

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

echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));

echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));

ApplicationContainer clientApps = echoClient.Install (nodes.Get (0));

clientApps.Start (Seconds (2.0));

clientApps.Stop (Seconds (10.0));

// Set up flow monitoring (optional, for statistics)

FlowMonitorHelper flowmon;

Ptr<FlowMonitor> monitor = flowmon.InstallAll ();

// Run the simulation

Simulator::Stop (Seconds (10.0));

Simulator::Run ();

// Print flow monitor results

monitor->SerializeToXmlFile(“manet-flowmon.xml”, true, true);

Simulator::Destroy ();

return 0;

}

Explanation of Code:

  1. Node Creation: NodeContainer nodes; nodes.Create(10); makes 10 nodes.
  2. Mobility Model: The RandomWaypointMobilityModel is used to replicate the node movement.
  3. Wi-Fi Setup: The simulation uses 802.11b (Wi-Fi) for the ad-hoc communication among the nodes.
  4. Routing Protocol (AODV): AODV routing is allowed using AodvHelper aodv.
  5. Traffic Applications: A UDP echo client-server application is installed to produce traffic.
  6. Flow Monitor: FlowMonitor supports in examining traffic flow, packet delivery ratio, delay, and other performance metrics.
  1. Choosing Other MANET Routing Protocols

To replicate other routing protocols like OLSR, DSR, or DSDV, change the routing protocol helper:

  • OLSR:

OlsrHelper olsr;

internet.SetRoutingHelper (olsr);

  • DSDV:

DsdvHelper dsdv;

internet.SetRoutingHelper (dsdv);

  • DSR: DSR is slightly distinct because it’s a source-routing protocol. We want to set it up using DsraMainHelper:

DsrHelper dsr;

DsrMainHelper dsrMain;

internet.SetRoutingHelper (dsrMain);

dsr.Install (nodes);

  1. Mobility Models

MANETs frequently have mobile nodes, thus we should use proper mobility models such as:

  • ConstantPositionMobilityModel: For static nodes.
  • RandomWaypointMobilityModel: For random movement in a specified area.
  • GaussMarkovMobilityModel: For realistic movement patterns.
  1. Analyzing Results

To capture and investigate the network performance, use:

  • PCAP Tracing:

wifiPhy.EnablePcap (“manet”, devices);

  • FlowMonitor: Captures and shows packet statistics, packet delivery ratio, delays, and so on.
  • NetAnim: A visual tool to animate node movement and packet flow.
  1. Running the Simulation

Here we compile and then run the simulation with:

./waf –run scratch/<your-file>

  1. Visualizing the Simulation

We can be visualized the simulation using NetAnim that can be displayed node movement, packet transmission, and routing behaviour over time. To do this, add:

AnimationInterface anim (“manet-animation.xml”);

Run the simulation and open the manet-animation.xml in NetAnim.

  1. Modifying Parameters

Here, we can be changed various parameters like:

  • Number of nodes.
  • Node mobility speed.
  • Data rates and packet sizes.
  • Simulation time.

It supports to discover various scenarios for MANET performance estimation.

Key Metrics to Evaluate in MANET Simulations:

  • Packet Delivery Ratio (PDR): Percentage of efficiently delivered packets.
  • End-to-End Delay: Average delay from source to destination.
  • Routing Overhead: Extra packets generated by routing protocols.
  • Throughput: The rate of successful data delivery over the network.

By adapting the node mobility, protocol settings, and other parameters, we can be estimated the performance of MANET protocols under several conditions.

We clearly explained the ideas on how the MANET projects will perform and how to simulate it in various scenario using ns3 tool and also we deliver the additional details regarding the MANET.

If you’re looking to simulate MANET projects using NS3, feel free to reach out to phdprime.com. We have a comprehensive range of tools and resources to meet your requirements. Please share the details of your project with us, and we will ensure timely delivery and top-notch support. Our development team specializes in configuring mobile nodes and optimizing routing protocols tailored for MANET environments, ensuring you receive the best possible results.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2