How to Simulate Border Gateway Protocol Projects Using NS2

To simulate Border Gateway Protocol (BGP) projects within NS2, we will require to make a network with several autonomous systems (AS), which communicate through BGP. BGP is a Layer 3 inter-domain routing protocol utilized to swap routing data among diverse networks or ASes, normally between Internet Service Providers (ISPs).

NS2 does not directly contain BGP, thus we will either want to apply a BGP patch for NS2 or replicate BGP-like behaviour using custom TCL scripts, which execute an inter-domain routing principles.

Here, we provide series of steps to simulate BGP projects using NS2:

Steps to Simulate Border Gateway Protocol Projects in NS2

  1. Install NS2

Make certain that NS2 is installed on the machine. We can download it from the NS2 official website. If there’s a BGP patch obtainable then we implement it as follows:

Applying BGP Patch (If Available)

  1. Download the BGP patch for NS2.
  2. Implement the patch to NS2:

cd ns-allinone-2.35/ns-2.35/

patch -p1 < bgp-patch.diff

  1. Rebuild NS2:

./configure

make clean

make

  1. Create a Basic BGP Network Topology

To replicate BGP, we will require to describe several Autonomous Systems (ASes) and the routers within each AS, which exchange routing data through BGP.

Example TCL Script for BGP Network Topology:

# Create a new simulator instance

set ns [new Simulator]

# Define trace and nam files for logging and visualization

set tracefile [open bgp_simulation.tr w]

$ns trace-all $tracefile

set namfile [open bgp_simulation.nam w]

$ns namtrace-all $namfile

# Create nodes for routers in different ASes

set r1 [$ns node]    ;# Router in AS1

set r2 [$ns node]    ;# Router in AS1

set r3 [$ns node]    ;# Router in AS2

set r4 [$ns node]    ;# Router in AS2

set r5 [$ns node]    ;# Router in AS3

# Create links between routers within and across ASes

$ns duplex-link $r1 $r2 100Mb 10ms DropTail    ;# Internal link within AS1

$ns duplex-link $r1 $r3 10Mb 50ms DropTail     ;# BGP link between AS1 and AS2

$ns duplex-link $r3 $r4 100Mb 10ms DropTail    ;# Internal link within AS2

$ns duplex-link $r4 $r5 10Mb 50ms DropTail     ;# BGP link between AS2 and AS3

# Define BGP routing (custom TCL to simulate BGP behavior or use BGP patch)

In this network:

  • r1 and r2 are routers in AS1.
  • r3 and r4 are routers in AS2.
  • r5 is a router in AS3.
  • Routers r1 and r3, and r4 and r5 communicate through BGP links among ASes.
  1. Implement BGP Protocol Behavior

If a BGP patch has been implemented then we can utilize BGP protocol-specific commands to ascertain BGP peering among the routers. Otherwise, we can manually execute the BGP behaviour using TCL scripts, which replicate route announcements and withdrawals.

Example of Simulating BGP Route Announcement:

# Define route announcements

proc announce_route {from_node to_node destination} {

global ns

$ns at 1.0 “$from_node send-route $to_node $destination”

}

# Announce routes from AS1 to AS2

announce_route $r1 $r3 “10.0.1.0/24”

# Announce routes from AS2 to AS3

announce_route $r4 $r5 “192.168.0.0/16”

  1. Set Up Traffic Between ASes

To examine BGP’s routing capabilities, we need to replicate traffic among the nodes in distinct ASes. It will activate BGP to introduce routes actively among ASes and forward traffic consequently.

Example for TCP Traffic:

# Set up TCP connection between a node in AS1 and a node in AS3

set tcp0 [new Agent/TCP]

set sink0 [new Agent/TCPSink]

$ns attach-agent $r2 $tcp0

$ns attach-agent $r5 $sink0

$ns connect $tcp0 $sink0

# Create FTP traffic over TCP

set ftp0 [new Application/FTP]

$ftp0 attach-agent $tcp0

$ns at 2.0 “$ftp0 start”

$ns at 10.0 “$ftp0 stop”

In this case, BGP must establish the proper routes among AS1 and AS3 to permit traffic to flow between r2 and r5.

  1. Run the Simulation

We can save TCL script (e.g., bgp_simulation.tcl) and run the simulation using NS2:

ns bgp_simulation.tcl

It will make a trace file (.tr) and a NAM file (.nam), which can be examined and envisioned using Network Animator (NAM).

  1. Analyze the Simulation Results

To compute BGP performance, we can assess:

  • Route Convergence Time: How long it takes for BGP routes to stabilize after modifications (e.g., route announcements and withdrawals).
  • Packet Delivery Ratio (PDR): The percentage of effectively delivered packets.
  • BGP Routing Overhead: The amount of control traffic utilized to maintain BGP routes.

Example AWK Script to Analyze Route Convergence:

BEGIN { route_changes = 0; convergence_time = 0; }

{

if ($1 == “r” && $4 == “RTR”) {

route_changes++;

convergence_time += $2;

}

}

END {

avg_convergence_time = convergence_time / route_changes;

print “Average Route Convergence Time = “, avg_convergence_time, “s”;

}

  1. Example Project Ideas for BGP Simulation
  1. BGP Route Convergence Analysis:
    • Replicate a BGP network with numerous ASes and examine how long it takes for routes to converge after a link failure or policy change.
  2. BGP with Policy-Based Routing:
    • Execute policy-based routing within BGP in which diverse ASes prefer particular routes. Investigate how policies effect on route selection and traffic flow.
  3. BGP Route Aggregation:
    • Mimic BGP with route aggregation and assess its effect on routing table size and convergence time.
  4. BGP in Multi-Homed Networks:
    • Replicate a network in which ASes are multi-homed (connected to more than one AS) and examine the impact on route stability and traffic redundancy.

Through NS2 simulations, we carried out a detailed steps to simulate the Border Gateway protocol projects and to analyse its simulation outcomes. We are prepared to expand the findings with more informations if necessary.

phdprime.com is dedicated to providing you with comprehensive guidance and project results. If you are in search of the finest Border Gateway Protocol projects utilizing the NS2 tool, we are here to deliver excellent outcomes.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2