How to Start BGP Routing Projects Using NS3

To start a Border Gateway Protocol (BGP) routing project in NS3, we follow the detailed guide:

Steps to Start BGP Routing Projects in NS3

  1. Understand BGP in Routing
  • What is BGP?
    • BGP is a path-vector protocol utilised for routing among the autonomous systems (ASes) on the internet.
    • It permits routers under various ASes to swap the routing and reachability data.
  • Applications:
    • To replicate an internet-scale networks.
    • We can learn routing policies and inter-AS interaction.
  1. Install and 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. BGP in NS3

BGP doesn’t include in NS3 however we can:

  1. Use a BGP module such as Quagga or ExaBGP:
    • Incorporate these BGP executions in NS3 to utilize socket interaction.
  2. Simulate BGP-like behavior to utilize Static Routing:
    • For small-scale replication.
  3. Implement Custom BGP Logic:
    • Execute a custom protocol to prolong routing interface of NS3.
  1. Option 1: Using Quagga with NS3

Quagga is an open-source routing suite, which contains BGP. We can be executed the Quagga routers within NS3.

Steps:

  1. Install Quagga:

sudo apt install quagga

  1. Set Up NS3 to Use Quagga:
    • In NS3, configure nodes like Quagga routers to utilise the QuaggaHelper class.
    • Example Quagga configuration files (BGP configuration):
      • zebra.conf (IP interface setup)
      • bgpd.conf (BGP setup for neighbor relations and policies)
  2. Sample Quagga-NS3 Integration Code:

#include “ns3/core-module.h”

#include “ns3/internet-module.h”

#include “ns3/quagga-helper.h”

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

using namespace ns3;

int main() {

NodeContainer nodes;

nodes.Create(3); // Create 3 nodes (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 BGP

QuaggaHelper quagga;

quagga.EnableZebraDebug(nodes);

quagga.EnableBgp(nodes);

// Create configurations for each node

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 2: Simulating BGP Using Static Routing

If we want to replicate the BGP’s behavior then static routes can be simulated inter-AS interaction.

Example: Static Routing Simulation

#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() {

NodeContainer nodes;

nodes.Create(3); // Create 3 AS nodes

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

Ipv4InterfaceContainer interfaces1 = address.Assign(devices1);

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

Ipv4InterfaceContainer interfaces2 = address.Assign(devices2);

// Static routing (emulating BGP behavior)

Ipv4StaticRoutingHelper staticRoutingHelper;

// Node 0 static route to Node 2 via Node 1

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

staticRoutingNode0->AddHostRouteTo(Ipv4Address(“10.1.2.2”), Ipv4Address(“10.1.1.2”), 1);

// Node 2 static route to Node 0 via Node 1

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

staticRoutingNode2->AddHostRouteTo(Ipv4Address(“10.1.1.1”), Ipv4Address(“10.1.2.1”), 1);

Simulator::Run();

Simulator::Destroy();

return 0;

}

In this setup, we had seen how to initiate and simulate the BGP (Border Gateway Protocol) Routing Projects through the above steps in NS3 simulation environment. Additional specifics will be provided on the methodology of the BGP Routing in other simulations tool.

One must require skills to perform the BGP (Border Gateway Protocol) Routing Projects experts at phdprojects.org will share with you all the needed ideas and perfect aligned topic that attract the readers. Drop us  message to guide you more.