To simulate an Exterior Gateway Protocols (EGP), especially BGP (Border Gateway Protocol), using NS3, we must combine an external routing software, like Quagga or FRRouting (FRR), including NS3 via the Direct Code Execution (DCE) module. It permits NS3 to replicate the performance of BGP and the most broadly utilised the EGP for routing among the autonomous systems (ASes) on the Internet. This instruction will teach on how to replicate BGP as an EGP in NS3 by incorporating Quagga or FRRouting with NS3-DCE.
Steps to Simulate EGP (BGP) in NS3
- Install NS3 and NS3-DCE: Make certain we have NS3 installed with the DCE (Direct Code Execution) module. DCE permits to run real-world networking applications (like Quagga or FRRouting) within the NS3 simulation environment.
We can install NS3 and NS3-DCE using the below commands (for Ubuntu):
sudo apt-get install ns3 ns3-dce
- Install Quagga or FRRouting: Quagga and FRRouting are open-source software suites, which support routing protocols like BGP. We can install either of these to mimic BGP.
To install Quagga:
sudo apt-get install quagga
To install FRRouting:
sudo apt-get install frr frr-doc frr-snmp
- Create a Network Topology in NS3: We can utilise the NS3 to make a basic network of routers, that signifying various Autonomous Systems (ASes). Set up Point-to-Point (P2P) links among the routers in distinct ASes.
- Configure BGP Using Quagga or FRR: Quagga or FRRouting will use to set up and handle the BGP on each router. We will be made BGP configuration files for each router to describe its AS number and peering relationships with other routers.
- Use DCE to Run Quagga/FRR in NS3: NS3-DCE permits to run Quagga/FRRouting in the simulation environment. We will run the BGP processes on each router using DCE to mimic the realistic BGP route advertisements and inter-AS communication.
- Set Up Traffic Generating Applications: We can use NS3 applications such as UDP Echo or TCP to generate traffic among the customer devices, which replicating real-world traffic flows among ASes. It will be supported to analyse the routing behaviour of BGP.
Example: Simulating BGP in NS3 using Quagga
Below, we clearly demonstrate a basic instance on how to simulate BGP with two autonomous systems (AS1 and AS2) using Quagga.
Step-by-Step Example:
Step 1: Install NS3 and NS3-DCE
Make certain we have installed both NS3 and the DCE module. We can be verified their installation using:
./waf configure
./waf build
Step 2: Define the Network Topology in NS3
In this instance, we have two ASes (AS1 and AS2) and four routers. For each AS will have a BGP procedure running on its routers, then the two ASes will be connected via a BGP peering relationship.
#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/dce-module.h”
using namespace ns3;
int main (int argc, char *argv[])
{
// Step 1: Create nodes for two ASes
NodeContainer as1Nodes;
as1Nodes.Create (2); // Two routers in AS1
NodeContainer as2Nodes;
as2Nodes.Create (2); // Two routers in AS2
// Step 2: Create point-to-point links between routers
NodeContainer interAsLink = NodeContainer (as1Nodes.Get (1), as2Nodes.Get (0));
// Step 3: Install Internet stack on all nodes
InternetStackHelper internet;
internet.Install (as1Nodes);
internet.Install (as2Nodes);
// Step 4: Set up point-to-point links between routers
PointToPointHelper p2p;
p2p.SetDeviceAttribute (“DataRate”, StringValue (“10Mbps”));
p2p.SetChannelAttribute (“Delay”, StringValue (“2ms”));
NetDeviceContainer devices1 = p2p.Install (as1Nodes);
NetDeviceContainer devices2 = p2p.Install (as2Nodes);
NetDeviceContainer interAsDevices = p2p.Install (interAsLink);
// Step 5: Assign IP addresses
Ipv4AddressHelper ipv4;
ipv4.SetBase (“10.0.1.0”, “255.255.255.0”);
ipv4.Assign (devices1);
ipv4.SetBase (“10.0.2.0”, “255.255.255.0”);
ipv4.Assign (devices2);
ipv4.SetBase (“10.1.1.0”, “255.255.255.0”);
Ipv4InterfaceContainer interAsInterfaces = ipv4.Assign (interAsDevices);
// Step 6: Install Quagga (BGP) on routers using DCE
DceManagerHelper dceManager;
dceManager.Install (as1Nodes);
dceManager.Install (as2Nodes);
QuaggaHelper quagga;
quagga.EnableBgp (as1Nodes.Get (0), “65001”); // Enable BGP on AS1 router 1
quagga.EnableBgp (as1Nodes.Get (1), “65001”);
quagga.EnableBgp (as2Nodes.Get (0), “65002”); // Enable BGP on AS2 router 1
quagga.EnableBgp (as2Nodes.Get (1), “65002”);
// Set up BGP neighbors
quagga.AddBgpNeighbor (as1Nodes.Get (1), “10.1.1.2”, “65002”); // AS1 peer with AS2
quagga.AddBgpNeighbor (as2Nodes.Get (0), “10.1.1.1”, “65001”); // AS2 peer with AS1
// Step 7: Run simulation
Simulator::Stop (Seconds (20.0));
Simulator::Run ();
Simulator::Destroy ();
return 0;
}
Step 3: BGP Configuration Files
We will require to make a BGP configuration files for each router. These configuration files are describe each router’s AS number, router ID, and the BGP neighbours.
Here’s a sample of a bgpd.conf file for routers in AS1:
router bgp 65001
bgp router-id 10.0.1.1
neighbor 10.1.1.2 remote-as 65002
And for routers in AS2:
router bgp 65002
bgp router-id 10.0.2.1
neighbor 10.1.1.1 remote-as 65001
These configuration files will utilise by Quagga to ascertain the BGP peering among two autonomous systems.
Step 4: Set Up Traffic Generation
We can be utilised UDP Echo or TCP applications to replicate traffic among the nodes. This traffic will be routed over the BGP routers from one AS to another.
Example of UDP Echo setup:
UdpEchoServerHelper echoServer (9);
ApplicationContainer serverApps = echoServer.Install (as2Nodes.Get (1)); // Server in AS2
serverApps.Start (Seconds (1.0));
serverApps.Stop (Seconds (10.0));
UdpEchoClientHelper echoClient (interAsInterfaces.GetAddress (1), 9);
echoClient.SetAttribute (“MaxPackets”, UintegerValue (1));
echoClient.SetAttribute (“Interval”, TimeValue (Seconds (1.0)));
echoClient.SetAttribute (“PacketSize”, UintegerValue (1024));
ApplicationContainer clientApps = echoClient.Install (as1Nodes.Get (0)); // Client in AS1
clientApps.Start (Seconds (2.0));
clientApps.Stop (Seconds (10.0));
Performance Metrics to Analyze:
- BGP Convergence Time: Estimate how long it gets for BGP to converge after the peering session begins.
- Route Propagation: Monitor how routes are propagated among various ASes using BGP.
- Packet Delivery Ratio (PDR): Estimate the number of packets are effectively delivered over ASes.
- Latency: Calculate the delay of packets are traveling over the BGP network.
Running the Simulation:
- Build and Run:
./waf configure
./waf build
./waf –run <your-script-name>
- Check Quagga Logs: After running the simulation, then we can observe the Quagga logs in the dce directory to verify the BGP routes, convergence, and neighbour relationships.
Extending the Simulation:
- BGP Route Reflection: Execute more complex BGP topologies by inserting the route reflectors.
- Multiple ASes: Prolong the topology to contain more than two autonomous systems to mimic a real-world BGP network.
- BGP Policy Configurations: Replicate BGP policy configurations such as route filtering or local preference to examine how BGP manages various routing policies.
To conclude, we had illustrated the detailed approach with sample snippets and also we provided above examples process using Quagga are helps you know on how to replicate the BGP as an EGP in NS3 by integrating the Quagga or FRRouting with NS3-DCE. Likewise, we will be shared further advanced informations as per your needs.
phdprime.com are the leading experts who you with tailored research assistance, on simulation of EGP Protocol Projects Using NS3 tool so if you are in need of best research assistance then we stand as the worlds leading research guidance team. We will help in network evaluation for your projects.