How to Start Dynamic Routing Projects Using NS3

To start a Dynamic Routing project using NS3, we will want to replicate the routing protocols, which adjust to changes within the network topology like link failures, congestion, or node mobility. Dynamic routing protocols are generally utilized within wireless ad hoc networks, mobile networks, and large-scale wired networks.

This guide will instruct how we can start and implement dynamic routing projects in NS3:

Steps to Start Dynamic Routing Project in NS3

  1. Understand Dynamic Routing

Key Features of Dynamic Routing:

  • Adaptability: According to the network changes, we modernize routes automatically.
  • Protocols:
    • Proactive Protocols (Table-Driven): These protocols sustain consistent routing tables such as OLSR, DSDV.
    • Reactive Protocols (On-Demand): It determines the routes only if required like AODV, DSR.
    • Hybrid Protocols: Integrate the proactive and reactive methods. For example ZRP.
  1. Set Up NS3

Install NS3:

  • Go to nsnam.org to download and install NS3.
  • Confirm installation following the installation instructions:

./waf –run scratch/test-example

Required Modules:

  • internet: It supports for IP functionalities.
  • aodv, olsr, dsdv, or other routing protocol modules (allow in the course of build configuration as necessary).
  • point-to-point, wifi, or csma: These are utilized for network topology configuration.
  1. Plan Your Dynamic Routing Simulation

Objectives:

  • To replicate the dynamic routing within a network.
  • Experiment how the routing protocol adjusts to:
    • Link Failures.
    • Mobility.
    • Traffic Fluctuations.

Example Topology:

  • A multi-hop network including traffic sources and sinks:

Node A ↔ Node B ↔ Node C ↔ Node D

↘       ↘       ↘

Node E ↔ Node F

Metrics to Evaluate:

  • Convergence Time: Measure how long time it takes to determine the new routes.
  • Routing Overhead: Estimate the control message traffic created.
  • QoS Metrics: We need to compute the parameters such as throughput, latency, jitter, and packet loss.
  1. Implement Dynamic Routing

Option 1: Use Built-In Dynamic Routing Protocols

NS3 environment offers diverse dynamic routing protocols executions like AODV, OLSR, and DSDV.

Option 2: Create a Custom Dynamic Routing Protocol

We want to execute the own routing protocol by prolonging Ipv4RoutingProtocol class of NS3.

4.1 Using Built-In Protocols

AODV (Ad hoc On-Demand Distance Vector)

AODV is a reactive protocol, which determines the routes on requests and adjusts to topology changes.

Example Code:

#include “ns3/aodv-module.h”

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

NodeContainer nodes;

nodes.Create(6);

PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));

p2p.SetChannelAttribute(“Delay”, StringValue(“5ms”));

NetDeviceContainer devices = p2p.Install(nodes);

InternetStackHelper stack;

AodvHelper aodv;  // Enable AODV routing

stack.SetRoutingHelper(aodv);

stack.Install(nodes);

Ipv4AddressHelper ipv4;

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

ipv4.Assign(devices);

// Create traffic source

OnOffHelper onOffHelper(“ns3::UdpSocketFactory”, Address(InetSocketAddress(ipv4.GetAddress(5), 9)));

onOffHelper.SetAttribute(“DataRate”, StringValue(“1Mbps”));

onOffHelper.SetAttribute(“PacketSize”, UintegerValue(512));

ApplicationContainer app = onOffHelper.Install(nodes.Get(0));

app.Start(Seconds(1.0));

app.Stop(Seconds(10.0));

// Create packet sink

PacketSinkHelper sinkHelper(“ns3::UdpSocketFactory”, Address(InetSocketAddress(Ipv4Address::GetAny(), 9)));

ApplicationContainer sinkApp = sinkHelper.Install(nodes.Get(5));

sinkApp.Start(Seconds(0.0));

sinkApp.Stop(Seconds(10.0));

Simulator::Run();

Simulator::Destroy();

return 0;

}

OLSR (Optimized Link State Routing Protocol)

OLSR is a proactive link-state protocol to sustain the consistent routing tables.

Example Code:

#include “ns3/olsr-module.h”

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

NodeContainer nodes;

nodes.Create(6);

PointToPointHelper p2p;

p2p.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));

p2p.SetChannelAttribute(“Delay”, StringValue(“5ms”));

NetDeviceContainer devices = p2p.Install(nodes);

InternetStackHelper stack;

OlsrHelper olsr;  // Enable OLSR routing

stack.SetRoutingHelper(olsr);

stack.Install(nodes);

Ipv4AddressHelper ipv4;

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

ipv4.Assign(devices);

Simulator::Run();

Simulator::Destroy();

return 0;

}

4.2 Creating a Custom Dynamic Routing Protocol

Step 1: Extend Ipv4RoutingProtocol

We make a new class utilising Ipv4RoutingProtocol, for route discovery, maintenance, and adaptation to execute the custom logic.

Example Code:

#include “ns3/core-module.h”

#include “ns3/internet-module.h”

using namespace ns3;

class DynamicRoutingProtocol : public Ipv4RoutingProtocol {

public:

DynamicRoutingProtocol();

virtual ~DynamicRoutingProtocol();

void DiscoverRoutes();

void HandleLinkFailures();

private:

void MonitorNetworkConditions();

};

DynamicRoutingProtocol::DynamicRoutingProtocol() {}

DynamicRoutingProtocol::~DynamicRoutingProtocol() {}

void DynamicRoutingProtocol::DiscoverRoutes() {

// Implement route discovery logic

}

void DynamicRoutingProtocol::HandleLinkFailures() {

// Handle link failures and update routes

}

void DynamicRoutingProtocol::MonitorNetworkConditions() {

// Periodically monitor network conditions and adapt routes

Simulator::Schedule(Seconds(1.0), &DynamicRoutingProtocol::MonitorNetworkConditions, this);

}

  1. Simulate and Debug

Enable Logging:

Allow NS3 logging to correct and observe the routing behavior.

export NS_LOG=DynamicRoutingProtocol=level_all:AodvRouting=level_all:OlsrRoutingProtocol=level_all

./waf –run scratch/dynamic-routing

Use PCAP for Packet Capture:

To seize network traffic for analysis including tools such as Wireshark.

p2p.EnablePcapAll(“dynamic-routing”);

  1. Evaluate Performance

Metrics to Measure:

  • Convergence Time: How long it takes time to launch the routes after modifications.
  • Routing Overhead: Estimate the volume of control packets created.
  • Throughput and Latency: Asses the application performance parameters such as latency, throughput.

Use FlowMonitor:

We can accumulate information and then estimate the performance parameters using FlowMonitor.

FlowMonitorHelper flowMonitor;

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

monitor->SerializeToXmlFile(“dynamic-routing-performance.xml”, true, true);

  1. Advanced Features
  • Mobility Models: We experiment the dynamic routing including moving nodes.

MobilityHelper mobility;

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

mobility.Install(nodes);

  • Failure Recovery: To replicate the link or node failures analysing recovery mechanisms.

Ptr<NetDevice> device = devices.Get(1);

device->SetReceiveErrorModel(errorModel);

  • QoS-Aware Routing: We can integrate parameters such as bandwidth or latency into route decisions.
  1. Document and Visualize

Document Implementation:

  • It contains project’s goals, procedure, and outcomes.

Visualize Results:

  • Envision the traffic flows to utilize NetAnim.
  • We want to plat the indicators to use tools such as Matplotlib or Gnuplot.

We performed a general approach on how to start and implement the Dynamic Routing Projects and evaluate the performance using NS3. If you required more information on this process, we will deliver in further manual.

Initiating dynamic routing projects utilizing NS3 can be greatly facilitated by phdprojects.org, which offers support in identifying optimal project topics and simulation outcomes. By collaborating with our team, you will be able to observe the results of your project. Please provide us with the specifics of your project, and we will offer prompt guidance. Our team specializes in areas such as space networks, disaster recovery, and vehicular networks, ensuring you receive comprehensive, step-by-step assistance throughout your project. Allow us to manage the performance aspects of your project for you.