How to Start Exterior Gateway Protocol Projects Using NS3

To start Exterior Gateway Protocols (EGPs) like BGP (Border Gateway Protocol) in NS3 that is broadly utilized for routing among the autonomous systems (ASes) on the internet and it is doesn’t native supported. But, we can be estimated an EGP environment by configuring static routing among the networks within diverse ASes and setting up CIDR-based addressing, replicating inter-AS routing.

We need to deliberate external tools such as Quagga or FRRouting (FRR) that can incorporate with NS3 through NS-3-DCE (Direct Code Execution) for more advanced BGP-like replication. Here’s a simple approach to replicate an EGP-like environment including static routing, along with deliberate an advanced option including Quagga if we need to simulate the behaviour of BGP.

Steps to Start Exterior Gateway Protocol Projects in NS3

Option 1: Simulating EGP with Static Routing in NS3

This method contains to configure several ASes and replicating inter-AS routing and a simple EGP estimation to utilize static routes.

Steps

  1. We can install NS3 if doesn’t already install (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. In the scratch directory of NS3, we make a New Simulation Script like egp_static_routing_simulation.cc.
  2. Then, we execute the Simulation Script making several ASes and to set up static routing.

#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”

#include “ns3/ipv4-static-routing-helper.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE(“EgpStaticRoutingSimulation”);

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

// Create nodes for ASes and routers

NodeContainer as1Nodes, as2Nodes, as3Nodes;

NodeContainer routers;

as1Nodes.Create(2); // AS1 nodes

as2Nodes.Create(2); // AS2 nodes

as3Nodes.Create(2); // AS3 nodes

routers.Create(3); // Routers between ASes

// Set up links within ASes and between ASes (via routers)

PointToPointHelper p2p;

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

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

// AS1

NetDeviceContainer as1Devices = p2p.Install(as1Nodes);

NetDeviceContainer as1RouterLink = p2p.Install(as1Nodes.Get(1), routers.Get(0));

// AS2

NetDeviceContainer as2Devices = p2p.Install(as2Nodes);

NetDeviceContainer as2RouterLink = p2p.Install(as2Nodes.Get(1), routers.Get(1));

// AS3

NetDeviceContainer as3Devices = p2p.Install(as3Nodes);

NetDeviceContainer as3RouterLink = p2p.Install(as3Nodes.Get(1), routers.Get(2));

// Inter-AS links between routers

NetDeviceContainer routerLinks;

routerLinks.Add(p2p.Install(routers.Get(0), routers.Get(1)));

routerLinks.Add(p2p.Install(routers.Get(1), routers.Get(2)));

// Install Internet stack

InternetStackHelper internet;

internet.Install(as1Nodes);

internet.Install(as2Nodes);

internet.Install(as3Nodes);

internet.Install(routers);

// Assign IP addresses with CIDR

Ipv4AddressHelper ipv4;

ipv4.SetBase(“10.1.1.0”, “255.255.255.0”);  // AS1 network

ipv4.Assign(as1Devices);

ipv4.SetBase(“10.1.2.0”, “255.255.255.252”);  // AS1 to router link

ipv4.Assign(as1RouterLink);

ipv4.SetBase(“10.2.1.0”, “255.255.255.0”);  // AS2 network

ipv4.Assign(as2Devices);

ipv4.SetBase(“10.2.2.0”, “255.255.255.252”);  // AS2 to router link

ipv4.Assign(as2RouterLink);

ipv4.SetBase(“10.3.1.0”, “255.255.255.0”);  // AS3 network

ipv4.Assign(as3Devices);

ipv4.SetBase(“10.3.2.0”, “255.255.255.252”);  // AS3 to router link

ipv4.Assign(as3RouterLink);

// Inter-AS links (routers)

ipv4.SetBase(“192.168.1.0”, “255.255.255.252”);  // Between AS1 and AS2 routers

ipv4.Assign(routerLinks.Get(0));

ipv4.SetBase(“192.168.2.0”, “255.255.255.252”);  // Between AS2 and AS3 routers

ipv4.Assign(routerLinks.Get(1));

// Static routing setup for inter-AS traffic (simulating EGP behavior)

Ipv4StaticRoutingHelper staticRoutingHelper;

// Router in AS1 to AS2

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

router1StaticRouting->AddNetworkRouteTo(Ipv4Address(“10.2.1.0”), Ipv4Mask(“255.255.255.0”), Ipv4Address(“192.168.1.2”), 1);

// Router in AS2 (to reach AS1 and AS3)

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

router2StaticRouting->AddNetworkRouteTo(Ipv4Address(“10.1.1.0”), Ipv4Mask(“255.255.255.0”), Ipv4Address(“192.168.1.1”), 1);

router2StaticRouting->AddNetworkRouteTo(Ipv4Address(“10.3.1.0”), Ipv4Mask(“255.255.255.0”), Ipv4Address(“192.168.2.2”), 2);

// Router in AS3 to AS2

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

router3StaticRouting->AddNetworkRouteTo(Ipv4Address(“10.2.1.0”), Ipv4Mask(“255.255.255.0”), Ipv4Address(“192.168.2.1”), 1);

// Set up a UDP Echo Server in AS3 Node to test inter-AS connectivity

UdpEchoServerHelper echoServer(9);

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

serverApps.Start(Seconds(1.0));

serverApps.Stop(Seconds(10.0));

// Set up a UDP Echo Client in AS1 Node to communicate with AS3

UdpEchoClientHelper echoClient(Ipv4Address(“10.3.1.1”), 9);

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

echoClient.SetAttribute(“Interval”, TimeValue(Seconds(1.0)));

echoClient.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer clientApps = echoClient.Install(as1Nodes.Get(0));

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 Setup: We configure three ASes such as AS1, AS2, AS3 each contains two nodes and a router.
  • Point-to-Point Links: These links are configured in each AS and among the routers.
  • CIDR Subnets: IP addresses are allocated including /30 and /24 subnets, isolating each AS.
  • Static Routing: Routers utilise static routing, sending packets to certain networks, to mimic simple inter-AS routing.
  • UDP Echo Application: In AS3 we use UDP Echo Server and a UDP Echo Client within AS1 experiment inter-AS connectivity.
  1. Build and Run the Simulation
  1. In the scratch directory, we can save egp_static_routing_simulation.cc.
  2. Go to a terminal, pass through to the NS3 directory, and then make the script:

./ns3 build

  1. Run the simulation:

./ns3 run scratch/egp_static_routing_simulation

Option 2: Advanced BGP Simulation with Quagga and NS-3-DCE

We can combine NS3 including Quagga is an open-source routing suite to utilize NS3 Direct Code Execution (DCE), permitting NS3 to execute the actual BGP routing software for a further BGP simulation. This configuration is more complex and it needs more set up however allows to replicate the real behavior of BGP in NS3.

Steps

  1. Initially, we install NS-3-DCE and Quagga.
  2. Set Quagga configuring BGP routes.
  3. Combine Quagga with NS3 utilising NS-3-DCE.

You can refer to NS3 environment documentation on DCE and Quagga integrations to get in-depth guide.

In this manual, we can get more knowledge on how to configure and simulate the Exterior Gateway Protocol Projects using NS3 simulation tool through above simplified procedure. Likewise, we will also be provided more advanced guide on this topic.

phdprojects.org excels in Exterior Gateway Protocol Projects with the NS3 tool, providing tailored and top-notch simulations for researchers. Our skilled team excels in CIDR-based addressing and can replicate inter-AS routing with thorough explanations. For excellent outcomes in your projects, allow our team to manage your needs. Trust us to enhance your project performance. You can rest assured that our prices are reasonable, and we deliver dependable, high-quality work on time by our experts. Reach out to phdprojects.org for further assistance.