How to Start Link State Routing Projects Using NS3

To start a Link State Routing project using NS3 has comprise to replicate the protocols, which utilize a map of the network topology calculating the shortest paths among the nodes. General instances contain OSPF (Open Shortest Path First) and IS-IS (Intermediate System to Intermediate System). Although NS3 does not directly support these protocols, we can be replicated the link-state routing to utilize custom applications or existing NS3 functionality.

Let’s we see how to start and simulate the Link State Routing Projects through following procedure using NS3:

Steps to Start Link State Routing Projects in NS3

  1. Understand Link State Routing

How It Works:

  1. Topology Discovery:
    • Every single node collects data regarding their neighbors like link states.
  2. Flooding:
    • Nodes deliver the link state advertisements (LSAs) to every other node within the network.
  3. Shortest Path Calculation:
    • Utilize algorithms such as Dijkstra’s, each node calculates the shortest path to all other nodes.

Key Features:

  • We equate the faster convergence to distance vector routing.
  • Optimize managing of dynamic topologies.
  1. Set Up NS3
  • Install NS3:
    • Go to nsnam.org, we download and install NS3.
    • We adhere to the installation instruction.
  • Verify Installation:

./waf –run scratch/test-example

  • Required Modules:
    • internet: It supports for IP-based interaction.
    • point-to-point, wifi, or csma: For making network topologies.
  1. Plan Your Link State Routing Simulation

Define Objectives:

  • To replicate a custom link-state protocol or simulate OSPF/IS-IS.
  • Experiment behavior of protocol in dynamic topologies, different traffic, or link failures.

Metrics to Evaluate:

  • Convergence Time: Estimate the duration for every node to modernize its routing tables.
  • Routing Overhead: Volume of LSAs swapped.
  • Throughput and Latency: Assess performance parameters such as latency and throughput for data flows.

Example Topology:

  • A basic multi-hop network:

Node A ↔ Node B ↔ Node C ↔ Node D

  1. Implement Link State Routing

Option 1: Create a Custom Link State Protocol

We can prolong the Ipv4RoutingProtocol class executing the custom link-state logic.

Option 2: Use Existing Dynamic Routing

Utilize AODV or DSDV protocols are contained within NS3 to replicate the link-state behavior (simplified for experimentation).

4.1 Implementing a Custom Link State Protocol

Step 1: Define a Link State Routing Protocol Class

Make a class obtaining from Ipv4RoutingProtocol to manage the routing logic.

Example Code:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

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

#include “ns3/applications-module.h”

using namespace ns3;

// Custom Link State Routing Application

class LinkStateRoutingApp : public Application {

public:

LinkStateRoutingApp();

virtual ~LinkStateRoutingApp();

void Setup(Ptr<Node> node);

private:

virtual void StartApplication();

virtual void StopApplication();

void SendLsa();

void ReceiveLsa(Ptr<Socket> socket);

void ComputeShortestPaths(); // Dijkstra’s algorithm

 

Ptr<Node>    m_node;

Ptr<Socket>  m_socket;

Address      m_address;

std::map<uint32_t, uint32_t> m_linkStateDatabase; // Node ID -> Cost

};

LinkStateRoutingApp::LinkStateRoutingApp() : m_socket(0) {}

LinkStateRoutingApp::~LinkStateRoutingApp() {

m_socket = 0;

}

void LinkStateRoutingApp::Setup(Ptr<Node> node) {

m_node = node;

}

void LinkStateRoutingApp::StartApplication() {

m_socket = Socket::CreateSocket(m_node, UdpSocketFactory::GetTypeId());

m_socket->Bind(InetSocketAddress(Ipv4Address::GetAny(), 9999));

m_socket->SetRecvCallback(MakeCallback(&LinkStateRoutingApp::ReceiveLsa, this));

Simulator::Schedule(Seconds(1.0), &LinkStateRoutingApp::SendLsa, this);

}

void LinkStateRoutingApp::StopApplication() {

if (m_socket) {

m_socket->Close();

m_socket = 0;

}

}

void LinkStateRoutingApp::SendLsa() {

Ptr<Packet> packet = Create<Packet>();

// Serialize the link state database (LSDB) into the packet

for (auto &entry : m_linkStateDatabase) {

// Add entries to the packet

}

m_socket->SendTo(packet, 0, InetSocketAddress(Ipv4Address(“255.255.255.255”), 9999));

Simulator::Schedule(Seconds(10.0), &LinkStateRoutingApp::SendLsa, this);

}

void LinkStateRoutingApp::ReceiveLsa(Ptr<Socket> socket) {

Ptr<Packet> packet;

Address from;

while ((packet = socket->RecvFrom(from))) {

// Deserialize LSDB from the packet

// Update local LSDB and trigger Dijkstra’s algorithm

ComputeShortestPaths();

}

}

void LinkStateRoutingApp::ComputeShortestPaths() {

// Implement Dijkstra’s algorithm to compute shortest paths

// Update the routing table accordingly

}

4.2 Using AODV for Dynamic Routing

AODV (Ad hoc On-Demand Distance Vector Routing) distributes some characteristics including link-state protocols, and then we can be utilised it to replicate the dynamic routing.

Step 1: Enable AODV

#include “ns3/aodv-module.h”

AodvHelper aodv;

InternetStackHelper stack;

stack.SetRoutingHelper(aodv);

stack.Install(nodes);

Step 2: Add Traffic

Make traffic to utilize OnOffHelper and PacketSinkHelper for experimentation.

  1. Simulate and Debug
  • Enable Logging:

export NS_LOG=LinkStateRoutingApp=level_all:AodvRouting=level_all

./waf –run scratch/link-state-routing

  • Inspect Routing Tables: Confirm accuracy to analyse the routing tables at each node:

Ptr<Ipv4> ipv4 = nodes.Get(0)->GetObject<Ipv4>();

ipv4->GetRoutingProtocol()->Print(std::cout);

  • Capture Packets with PCAP: Examine packet flows to utilize PCAP tracing:

pointToPoint.EnablePcapAll(“link-state”);

  1. Evaluate Performance

Metrics to Measure:

  • Convergence Time: We estimate the duration for every node modernizing its routing tables.
  • Routing Overhead: Compute volume of control traffic (LSAs) that are made.
  • Throughput and Latency: For application traffic, we need to measure the performance indicators such as latency and throughput.

Use FlowMonitor:

FlowMonitorHelper flowMonitor;

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

monitor->SerializeToXmlFile(“link-state-performance.xml”, true, true);

  1. Advanced Features
  • Dynamic Topologies:
    • Replicate a dynamic network to utilize mobility models.

MobilityHelper mobility;

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

mobility.Install(nodes);

  • Fault Injection:
    • We mimic link failures to experiment the recovery mechanisms.
  • Scalability:
    • Maximize the volume of nodes estimating the scalability of protocol.
  1. Document and Visualize
  • Document Implementation:
    • It contains protocol design, goals, and outcomes.
  • Visualize Results:
    • Visualize the simulation to utilize NetAnim tool.
    • We need to plot the parameters such as delay and overhead to utilize Matplotlib or Gnuplot tools.

In this project, we had delivered the comprehensive methodology along with sample coding to start and simulate the Link State Routing Projects and to analyse the performance using NS3 simulation environment. We are equipped to offer additional guidelines to this project in upcoming manual.

To get on with your  Link State Routing Projects utilizing the NS3 tool, rely on the expertise of the team at phdprojects.org to assist you at every phase. Benefit from our customized support, ensuring optimal project outcomes and timely completion. Our specialization in OSPF (Open Shortest Path First) and IS-IS (Intermediate System to Intermediate System) allows us to provide you with the most relevant ideas tailored to your research requirements.