How to Start Path Vector Routing Projects Using NS3

To start a Path Vector Routing project in NS3, we could be replicate the behaviour of path vector protocol (like BGP) later it is a foundational protocol in this type. Here’s how we can proceed for following steps:

Steps to Start Path Vector Routing Projects Using NS3

  1. Understand Path Vector Routing
  • What is Path Vector Routing?
    • A path vector protocol handles a list of paths such as sequence of nodes or ASes to every destination.
    • Routes are choosing the based-on path attributes such as AS-PATH length, MED (Multi-Exit Discriminator), or custom policies.
  • Examples:
    • Border Gateway Protocol (BGP): The maximum popular path vector routing protocol.
    • Custom path vector methods for inter-domain routing or simulation of large-scale networks.
  1. Set Up NS3
  1. Install NS3:

sudo apt update

sudo apt install g++ python3 git cmake

git clone https://gitlab.com/nsnam/ns-3-dev.git

cd ns-3-dev

./waf configure

./waf build

  1. Verify installation:

./waf –run scratch/my-first

  1. Plan Path Vector Routing Implementation

We could be replicate the path vector routing utilized:

  1. Static Routes: For small-scale simulations.
  2. Dynamic Routing (BGP-like): Utilized the external tools like Quagga.
  3. Custom Path Vector Routing Protocol: Extend the Ipv4RoutingProtocol we estimate the logic.
  1. Option 1: Static Path Vector Routing

This method is suitable for minimum networks in which routes could be predefined.

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/ipv4-static-routing-helper.h”

using namespace ns3;

int main() {

// Create nodes

NodeContainer nodes;

nodes.Create(4); // 4 ASes

// Configure links

PointToPointHelper pointToPoint;

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

pointToPoint.SetChannelAttribute(“Delay”, StringValue(“2ms”));

NetDeviceContainer devices1 = pointToPoint.Install(nodes.Get(0), nodes.Get(1));

NetDeviceContainer devices2 = pointToPoint.Install(nodes.Get(1), nodes.Get(2));

NetDeviceContainer devices3 = pointToPoint.Install(nodes.Get(2), nodes.Get(3));

// Install Internet stack

InternetStackHelper stack;

stack.Install(nodes);

// Assign IP addresses

Ipv4AddressHelper address;

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

address.Assign(devices1);

address.SetBase(“10.1.2.0”, “255.255.255.0”);

address.Assign(devices2);

address.SetBase(“10.1.3.0”, “255.255.255.0”);

address.Assign(devices3);

// Configure static routes (emulating path vector behavior)

Ipv4StaticRoutingHelper staticRoutingHelper;

Ptr<Ipv4StaticRouting> staticRoutingNode0 = staticRoutingHelper.GetStaticRouting(nodes.Get(0)->GetObject<Ipv4>());

staticRoutingNode0->AddHostRouteTo(Ipv4Address(“10.1.3.2”), Ipv4Address(“10.1.1.2”), 1); // Path: Node 0 -> Node 1 -> Node 3

Ptr<Ipv4StaticRouting> staticRoutingNode1 = staticRoutingHelper.GetStaticRouting(nodes.Get(1)->GetObject<Ipv4>());

staticRoutingNode1->AddHostRouteTo(Ipv4Address(“10.1.3.2”), Ipv4Address(“10.1.2.2”), 2); // Path: Node 1 -> Node 3

Simulator::Run();

Simulator::Destroy();

 

return 0;

}

  1. Option 2: Dynamic Path Vector Routing Using Quagga

Integrate the Quagga into NS3 we replicate the BGP as a dynamic path vector protocol.

Steps:

  1. Install Quagga:

sudo apt install quagga

  1. Configure Quagga:
    • We generate the zebra.conf and bgpd.conf files for every node to state the BGP neighbors and policies.
    • Example bgpd.conf:

router bgp 100

neighbor 10.1.1.2 remote-as 200

network 10.1.1.0/24

  1. Use QuaggaHelper in NS3:

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

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

#include “ns3/quagga-helper.h”

using namespace ns3;

int main() {

NodeContainer nodes;

nodes.Create(3); // 3 ASes

 

PointToPointHelper pointToPoint;

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

pointToPoint.SetChannelAttribute(“Delay”, StringValue(“2ms”));

NetDeviceContainer devices1 = pointToPoint.Install(nodes.Get(0), nodes.Get(1));

NetDeviceContainer devices2 = pointToPoint.Install(nodes.Get(1), nodes.Get(2));

InternetStackHelper stack;

stack.Install(nodes);

Ipv4AddressHelper address;

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

address.Assign(devices1);

address.SetBase(“10.1.2.0”, “255.255.255.0”);

address.Assign(devices2);

// Configure Quagga

QuaggaHelper quagga;

quagga.EnableZebraDebug(nodes);

quagga.EnableBgp(nodes);

quagga.EnableBgpConfig(nodes.Get(0), “bgpd.conf.node0”);

quagga.EnableBgpConfig(nodes.Get(1), “bgpd.conf.node1”);

quagga.EnableBgpConfig(nodes.Get(2), “bgpd.conf.node2”);

Simulator::Run();

Simulator::Destroy();

return 0;

}

  1. Option 3: Custom Path Vector Protocol

Estimate the custom protocol which handles the path information and exchanges it dynamically.

Steps:

  1. Extend Ipv4RoutingProtocol:
    • Evaluate the logic we handle the path information for sample AS-PATH.
    • Periodically exchange the routing data with neighbours.
  2. Skeleton Code:

#include “ns3/ipv4-routing-protocol.h”

namespace ns3 {

class PathVectorRouting : public Ipv4RoutingProtocol {

public:

static TypeId GetTypeId();

PathVectorRouting();

virtual ~PathVectorRouting();

Ptr<Ipv4Route> RouteOutput(Ptr<Packet> packet, const Ipv4Header &header,

Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) override;

void ReceiveRoutingUpdate(uint32_t srcAs, std::vector<uint32_t> path);

private:

std::map<uint32_t, std::vector<uint32_t>> pathTable; // Destination -> Path (AS-PATH)

};

} // namespace ns3

  1. Testing and Debugging
  1. Enable logging:

NS_LOG=”PathVectorRouting” ./waf –run your-simulation

  1. Analyse packet traces:
    • Utilized the .pcap files with Wireshark.
    • Checked the exchange of paths and routes.
  1. Performance Evaluation

Estimate the protocol using:

  • Convergence Time: We stabilize their time for routing tables.
  • Control Overhead: Traffic control the amount of routing.
  • Path Optimality: Its effectiveness of the selected routes.

In this report, we had thorough the entire simulation process which understand the concepts and approaches of path vector routing project that were visualized the results and simulated in the NS3 environment. If you need further details regarding this process, we will provide it.

Path vector protocols, such as BGP, are our specialty. You can receive customized project ideas and topics from us. To begin your Path Vector Routing Projects using NS3, please send all your project details to phdprojects.org. We will provide you with excellent results. Share your project information with us, and we will guide you to achieve the best outcomes.