How to Start ZRP Protocol Projects Using NS3

To start Zone Routing Protocol (ZRP) in NS3 which is a hybrid routing protocol for mobile ad hoc networks (MANETs) that integrates the proactive and reactive routing approaches. Although NS3 does not directly support a ZRP’s built-in execution then we can be estimated their activities by executing a custom configuration, which incorporates the components of both proactive and reactive routing protocols. This configuration will be included to make zones, configure proactive routing in each zone, and for inter-zone interaction to utilize reactive routing.

This guide provides structured approach to replicate a ZRP Projects in NS3.

Steps to Start Zone Routing Protocol Projects in NS3

  1. Install NS3

If NS3 doesn’t install, we set it up these commands (assuming a Linux environment):

# 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 ZRP Simulation
  1. In the scratch directory of NS3, make a new file then name it like zrp_simulation.cc.
  2. Estimate a ZRP environment to utilise the below example code by making zones including proactive routing within each zone and reactive routing for interaction among the zones.

Basic Structure of zrp_simulation.cc:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/aodv-helper.h”

#include “ns3/olsr-helper.h”

#include “ns3/mobility-module.h”

#include “ns3/wifi-module.h”

#include “ns3/applications-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE(“ZrpSimulation”);

class ZoneRoutingProtocol

{

public:

ZoneRoutingProtocol(NodeContainer nodes, double zoneRadius);

void ConfigureZones();

void IntrazoneRouting();

void InterzoneRouting();

private:

NodeContainer m_nodes;

double m_zoneRadius;

};

ZoneRoutingProtocol::ZoneRoutingProtocol(NodeContainer nodes, double zoneRadius)

: m_nodes(nodes), m_zoneRadius(zoneRadius) {}

void ZoneRoutingProtocol::ConfigureZones() {

// Set up zones based on node positions and zoneRadius

NS_LOG_INFO(“Configuring zones with radius ” << m_zoneRadius << “…”);

// In a full ZRP implementation, you would calculate zones based on node distances.

}

void ZoneRoutingProtocol::IntrazoneRouting() {

// Implement intrazone routing (proactive routing)

NS_LOG_INFO(“Running proactive routing within each zone.”);

// Proactive routing within each zone can be managed by OLSR or DSDV.

}

void ZoneRoutingProtocol::InterzoneRouting() {

// Implement interzone routing (reactive routing)

NS_LOG_INFO(“Running reactive routing between zones.”);

// Reactive routing for interzone communication can be managed by AODV or DSR.

}

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

// Enable logging for debugging

LogComponentEnable(“UdpEchoClientApplication”, LOG_LEVEL_INFO);

LogComponentEnable(“UdpEchoServerApplication”, LOG_LEVEL_INFO);

// Create nodes for the wireless network

NodeContainer nodes;

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

// Set up mobility model for the nodes

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

mobility.Install(nodes);

// Configure WiFi for ad hoc network

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 and set up intrazone and interzone routing protocols

InternetStackHelper internet;

// OLSR for proactive (intrazone) routing

OlsrHelper olsr;

internet.SetRoutingHelper(olsr); // Intrazone proactive routing

// AODV for reactive (interzone) routing

AodvHelper aodv;

internet.SetRoutingHelper(aodv); // Interzone reactive routing

internet.Install(nodes);

// Assign IP addresses to devices

Ipv4AddressHelper ipv4;

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

Ipv4InterfaceContainer interfaces = ipv4.Assign(devices);

// Initialize ZRP

double zoneRadius = 30.0; // Define the radius for each zone

ZoneRoutingProtocol zrp(nodes, zoneRadius);

zrp.ConfigureZones();

// Schedule intrazone and interzone routing

Simulator::Schedule(Seconds(1.0), &ZoneRoutingProtocol::IntrazoneRouting, &zrp);

Simulator::Schedule(Seconds(2.0), &ZoneRoutingProtocol::InterzoneRouting, &zrp);

// Set up a UDP echo server on one node to test connectivity

UdpEchoServerHelper echoServer(9);

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

serverApps.Start(Seconds(1.0));

serverApps.Stop(Seconds(10.0));

// Set up a UDP echo client on another node to communicate with the server

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

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

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;

}

Explanation of the Code

  • Node Creation: We make ten nodes to create a wireless network.
  • Zone Configuration (ConfigureZones): This function can extend according to the distance (radius), splitting the nodes to zones. Zones should compute calculate node distances to make clusters in a full ZRP execution.
  • Intrazone Routing (IntrazoneRouting): Proactive routing in each zone is attained to utilize OLSR or DSDV. For proactive (intrazone) routing, OLSR is utilised.
  • Interzone Routing (InterzoneRouting): To use AODV or DSR, reactive routing among zones is attained. Now, AODV is utilised for reactive (interzone) routing.
  • WiFi Setup: In ad hoc mode, WiFi is set up allowing direct interaction between nodes.
  • UDP Echo Applications:
    • A UDP Echo Server is configured at node 0 to experiment the connectivity.
    • A UDP Echo Client on node 9 transmits packets to the server to illustrate ZRP-like functionality over nodes.
  1. Build and Run the Simulation
  1. In the scratch directory, we want to save zrp_simulation.cc.
  2. Go to terminal then pass through to the NS3 directory, and make the script:

./ns3 build

  1. Run the simulation:

./ns3 run scratch/zrp_simulation

  1. Analyze the Results

This configuration explains the behaviour of ZRP by estimating zone-based routing including both proactive and reactive protocols. We would observe the connectivity among nodes that are handled by proactive routing in zones and reactive routing among the zones.

To allow in-depth logs for each protocol:

  • OLSR (Intrazone):

LogComponentEnable(“OlsrRoutingProtocol”, LOG_LEVEL_ALL);

  • AODV (Interzone):

LogComponentEnable(“AodvRoutingProtocol”, LOG_LEVEL_ALL);

These logs will be offered insight to how routes are sustained in zones and determined among the zones.

Further Experimentation Ideas

To discover more advanced ZRP, we can deliberate the below given experiments:

  • Dynamic Zone Radius: Test with various zone radii, monitoring the influence over the behaviour of routing and protocol overhead.
  • Increase Node Density: Append additional nodes to focus on how the protocol balances with larger networks.
  • Compare with Pure Reactive/Proactive Protocols: We need to replicate the similar network including only proactive or reactive protocols, equating with the ZRP-like configuration.
  • Measure Performance Metrics: Monitor packet delivery ratio, end-to-end delay, and routing overhead to utilize FlowMonitor or another NS3 tool that permitting to examine the effectiveness of ZRP.

This manual illustrates the detailed simulation strategies including examples and further experimentation concepts to replicate the ZRP-like environment projects using NS3 simulation tool. Moreover, we will also be provided further innovative approach on this project using another tool.

Our developers specialize in both proactive and reactive routing protocols, allowing us to exchange innovative project ideas and topics. We encourage you to provide us with your project details, and we will guide you in developing the most effective project strategies. At phdprojects.org, we are dedicated to helping you identify the most suitable project topics and simulation outcomes to initiate your ZRP Protocol Projects utilizing the NS3 tool. Collaborating with us will enable you to achieve your project results efficiently. Allow us to manage the performance of your project on your behalf.