How to Start MANET Projects Using NS3
To start the Mobile Ad-hoc Network (MANET) projects using NS3 which consists of configuring wireless interaction among the mobile nodes to utilize ad-hoc routing protocols such as AODV, OLSR, and DSDV. MANETs are decentralized networks in which each node can travel independently to need the active routing managing often modifying the network topologies. NS3 is optimal for replicating the MANETs since it contains numerous ad-hoc routing protocols and assist the mobility models that permitting to replicate the real-world conditions.
Following is a stepwise approach to starting a MANET project in NS3.
Steps to Start the MANET Projects in NS3
- Install NS3
- Download and Install NS3 if it is not already installed:
git clone https://gitlab.com/nsnam/ns-3-dev.git ns-3
cd ns-3
./waf configure –enable-examples –enable-tests
./waf build
- Verify Installation: Execute an example, which utilizes a MANET routing protocol like OLSR, making sure that NS3 is correctly functioning.
./waf –run=olsr
- Understand MANET Components in NS3
In a normal MANET project, we will function with:
- Nodes: We denote the mobile devices, which can be travelled independently.
- NetDevices: For wireless interaction, signify the network interfaces, normally within ad-hoc mode.
- Routing Protocols: Ad-hoc protocols such as AODV, DSDV, and OLSR are utilised allowing the active routing among nodes.
- Mobility Models: Describe node movement patterns like Random Waypoint or Constant Velocity, replicating the real-world mobility.
- Applications: For performance analysis, make traffic over the network.
- Create a Basic MANET Topology with Ad-hoc Routing
Initially, we make a basic MANET including a few mobile nodes to utilize an ad-hoc routing protocol like AODV. It will support to know the basics of MANET configuration within NS3.
Example: MANET with AODV Routing and WiFi Communication
This instance configuration a MANET including several nodes to utilize AODV like the routing protocol over WiFi within ad-hoc mode.
#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/aodv-module.h”
#include “ns3/applications-module.h”
using namespace ns3;
int main(int argc, char *argv[]) {
CommandLine cmd;
cmd.Parse(argc, argv);
// Create nodes
NodeContainer nodes;
nodes.Create(5);
// Set up WiFi channel and physical layer
YansWifiChannelHelper channel = YansWifiChannelHelper::Default();
YansWifiPhyHelper phy = YansWifiPhyHelper::Default();
phy.SetChannel(channel.Create());
// Set up WiFi network in ad-hoc mode
WifiHelper wifi;
wifi.SetStandard(WIFI_PHY_STANDARD_80211b);
WifiMacHelper mac;
mac.SetType(“ns3::AdhocWifiMac”);
NetDeviceContainer devices = wifi.Install(phy, mac, 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=5.0|Max=10.0]”),
“Pause”, StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”),
“PositionAllocator”, StringValue(“ns3::RandomRectanglePositionAllocator”));
mobility.Install(nodes);
// Install Internet stack with AODV routing
AodvHelper aodv;
InternetStackHelper stack;
stack.SetRoutingHelper(aodv); // Enable AODV
stack.Install(nodes);
// Assign IP addresses
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interfaces = address.Assign(devices);
// Set up UDP echo server on the first node
UdpEchoServerHelper echoServer(9);
ApplicationContainer serverApp = echoServer.Install(nodes.Get(0));
serverApp.Start(Seconds(1.0));
serverApp.Stop(Seconds(10.0));
// Set up UDP echo clients on other nodes
UdpEchoClientHelper echoClient(interfaces.GetAddress(0), 9);
echoClient.SetAttribute(“MaxPackets”, UintegerValue(10));
echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));
echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));
for (uint32_t i = 1; i < nodes.GetN(); ++i) {
ApplicationContainer clientApp = echoClient.Install(nodes.Get(i));
clientApp.Start(Seconds(2.0 + i));
clientApp.Stop(Seconds(10.0));
}
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Experiment with Different Routing Protocols
Equate the routing protocols, to substitute AodvHelper including other MANET routing protocols like OlsrHelper or DsdvHelper.
Example: Using DSDV rather than AODV
DsdvHelper dsdv;
stack.SetRoutingHelper(dsdv); // Enable DSDV
stack.Install(nodes);
- Configure Mobility Models for Realistic Node Movement
In MANET simulations, mobility is critical. Replicate the movement patterns utilizing mobility models, like:
- RandomWaypointMobilityModel: Nodes arbitrarily travel in a defined area.
- ConstantVelocityMobilityModel: Nodes move on a fixed speed that is helpful for vehicle replictions.
Example:
mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,
“Speed”, StringValue(“ns3::UniformRandomVariable[Min=5.0|Max=20.0]”),
“Pause”, StringValue(“ns3::ConstantRandomVariable[Constant=1.0]”));
- Generate Traffic for Performance Analysis
Make traffic over the network utilizing applications such as OnOffApplication and UdpEchoApplication. It supports to replicate the real-world interaction and examine how routing protocols manage traffic within a mobile environment.
Example: Using OnOffApplication for bursty traffic
OnOffHelper onOff(“ns3::UdpSocketFactory”, InetSocketAddress(interfaces.GetAddress(0), 9));
onOff.SetAttribute(“DataRate”, StringValue(“500Kbps”));
onOff.SetAttribute(“PacketSize”, UintegerValue(1024));
ApplicationContainer clientApp = onOff.Install(nodes.Get(1));
clientApp.Start(Seconds(2.0));
clientApp.Stop(Seconds(10.0));
- Collect and Analyze Performance Metrics
Estimate the MANET performance, to accumulate the parameters like:
- Throughput: Estimate the data rate over the network.
- Latency: Monitor the delay among the packet transmission and reception.
- Packet Delivery Ratio: Compute the percentage of effectively distributed packets to total packets transmitted.
- Routing Overhead: We can observe the control message traffic made by the routing protocol.
Use FlowMonitor accumulating the in-depth performance parameters:
FlowMonitorHelper flowmon;
Ptr<FlowMonitor> monitor = flowmon.InstallAll();
monitor->SerializeToXmlFile(“manet-flowmon.xml”, true, true);
- Visualize Network Simulation
- NetAnim: Examine the node movement, packet transmission, and routing paths utilising NS3’s NetAnim tool.
- Trace Analysis: Analyse the in-depth network events and then examine the performance metrics utilizing NS3 trace files.
- Graphing Tools: Transfer data to plot parameters like throughput, latency, and packet delivery ratio over time.
- Experiment with Network Configurations and Topologies
Test with network sets up to obtain the in-depth insights into MANET behaviour:
- Node Density: Maximize the volume of nodes monitoring the scalability.
- Network Size: In larger MANETs, prolong the area to learn the routing performance.
- Node Speed: We can replicate the high-mobility situation examining routing adaptability.
- Multiple Traffic Flows: Launch diverse traffic patterns and sources to monitor the routing protocol effectiveness.
- Advanced Scenarios
When we know the basics then discover more complex MANET situations:
- Multi-hop Routing: Make sure that nodes can transmit packets to distant nodes via intermediate nodes.
- Protocol Comparison: In the similar network configuration, equate the diverse routing protocols (AODV, OLSR, DSDV) performance in the same network setup.
- Energy Efficiency: Integrate the energy models to learn battery consumption, in MANETs that is a critical factor.
We had offered a structured approach, example coding, and advanced scenarios for the MANET projects, carried out and analysed in the NS3 framework. We will also be shared advanced concept on related aspects.
If you’re looking to kick off your MANET projects with the NS3 tool, our team of experts is here to help! We offer top-notch guidance and can even assist with your project performance presentations. So, don’t hesitate—send us your research details for extra support. We’ve got you covered on ad-hoc routing protocols like AODV, OLSR, and DSDV. Trust phdprojects.org to be your partner in achieving research success!