How to Simulate BGP Routing Projects Using NS2

To simulate Border Gateway Protocol (BGP) routing projects utilizing NS2, we will require replicating a situation in which routers are exchange routing data utilizing BGP. Border Gateway Protocol is normally utilized for routing among the autonomous systems (ASes) on the internet that creating it appropriate for large-scale networks in which routers learn routes dynamically across numerous domains.

Because NS2 does not have built-in support for BGP, which replicating BGP routing includes setting up the routing behaviour to simulate BGP’s path-vector behaviour in which routers share their optimal routes with their neighbours. This replication will not fully emulate BGP however will offer a simplified representation of its routing behaviour. For any type of simulation help send us all your project details we will give you best outcomes. To evaluate network analysis stay in touch with us we grant you with  detailed explanation.

Steps to Simulate BGP Routing in NS2

  1. Set Up NS2 Environment

Make sure that NS2 is installed and properly configure on the system. We can verify this by executing:

ns

If NS2 is installed then this command will open the NS2 shell.

  1. Understanding BGP

Border Gateway Protocol is a path-vector protocol utilized to exchange routing data among the autonomous systems (ASes). Routers publicize paths they understand to their neighbours, and each router chooses the finest path rely on multiple attributes (such as path length, policies, etc.).

In a simplified BGP simulation utilizing NS2, we can be replicated routers in diverse ASes exchanging routes, and we can manually set up routes to simulate BGP’s behaviour.

  1. Write a TCL Script to Simulate BGP Routing

Below is an example of how to configure a basic BGP-like scenario with numerous autonomous systems (ASes) using static routes to replicate BGP’s path-vector routing.

# Create a simulator object

set ns [new Simulator]

# Open trace and NAM output files

set tracefile [open out.tr w]

set namfile [open out.nam w]

$ns trace-all $tracefile

$ns namtrace-all $namfile

# Define network topology with multiple ASes (Autonomous Systems)

# Assume AS1 contains n0, n1, AS2 contains n2, n3, and AS3 contains n4, n5

# Create nodes for AS1

set n0 [$ns node]

set n1 [$ns node]

# Create nodes for AS2

set n2 [$ns node]

set n3 [$ns node]

# Create nodes for AS3

set n4 [$ns node]

set n5 [$ns node]

# Create links within each AS

$ns duplex-link $n0 $n1 1Mb 10ms DropTail

$ns duplex-link $n2 $n3 1Mb 10ms DropTail

$ns duplex-link $n4 $n5 1Mb 10ms DropTail

# Create inter-AS links to simulate BGP connections

# Link between AS1 and AS2 (n1 to n2)

$ns duplex-link $n1 $n2 512Kb 20ms DropTail

# Link between AS2 and AS3 (n3 to n4)

$ns duplex-link $n3 $n4 512Kb 25ms DropTail

# Manually configure BGP-like static routes between ASes

# For node n0 in AS1 to reach n5 in AS3, route via n1, n2, n3, n4

$n0 add-route-to-destination $n5 1

$n1 add-route-to-destination $n5 1

$n2 add-route-to-destination $n5 1

$n3 add-route-to-destination $n5 1

$n4 add-route-to-destination $n5 1

# Attach a UDP agent to node n0 (source in AS1)

set udp0 [new Agent/UDP]

$ns attach-agent $n0 $udp0

# Attach a Null agent to node n5 (destination in AS3)

set null0 [new Agent/Null]

$ns attach-agent $n5 $null0

# Connect the source (n0) and destination (n5) agents

$ns connect $udp0 $null0

# Create a CBR traffic generator and attach it to the UDP agent

set cbr0 [new Application/Traffic/CBR]

$cbr0 set packetSize_ 512

$cbr0 set interval_ 0.01

$cbr0 attach-agent $udp0

# Schedule the traffic to start and stop

$ns at 1.0 “$cbr0 start”

$ns at 4.5 “$cbr0 stop”

$ns at 5.0 “finish”

# Define the finish procedure

proc finish {} {

global ns tracefile namfile

$ns flush-trace

close $tracefile

close $namfile

exec nam out.nam &

exit 0

}

# Run the simulation

$ns run

  1. Explanation of the Script
  • Network Topology: The network is split into three autonomous systems (AS1, AS2, and AS3). Each AS has two nodes, and links are configure among ASes to replicate inter-AS routing.
  • Inter-AS Links: Links among n1 (AS1) and n2 (AS2) and between n3 (AS2) and n4 (AS3) signify BGP connections among the ASes.
  • Static Routes: Static routes are manually set up to mimic BGP’s path-vector routing. Each node is manually expressed how to attain the destination n5 in AS3.
  • Traffic: A Constant Bit Rate (CBR) traffic source is made at n0 (in AS1) and transmitted to n5 (in AS3).
  1. Running the Simulation

We can save the TCL script as bgp_simulation.tcl and execute it using the below command:

ns bgp_simulation.tcl

It will make a trace file (out.tr) and a NAM file (out.nam) for network visualization.

  1. Visualizing the Simulation

To visualize the network using NAM, execute:

nam out.nam

The NAM tool will indicate how traffic is routed from n0 (in AS1) to n5 (in AS3) via the intermediate ASes.

  1. Simulating Dynamic Routing with BGP-like Behavior

To replicate more dynamic BGP-like behaviour, we can change the routes for the period of the simulation to signify BGP path modifications. For instance, we can alter the routing paths at runtime:

# Change the route dynamically at 3.0 seconds

$ns at 3.0 “$n1 add-route-to-destination $n5 2”  ;# Change route via another AS

This replicates a BGP-like scenario in which routes change according to the network conditions.

  1. Analysing the Trace File

The trace file (out.tr) includes detailed insights regarding the packet transmissions and routing decisions. We can utilize grep or awk to extract parameters like:

  • Packet Delivery Ratio (PDR): The percentage of packets, which attain the destination.
  • Latency: The time it takes for packets to travel from the origin to the destination.
  • Routing Updates: Replicate BGP routing updates by manually modifying routes for the period of the simulation.

For example, to compute the number of packets received at the destination:

grep “^r” out.tr | wc -l

  1. Performance Evaluation

We can calculate the performance of BGP routing by:

  • Increasing the number of ASes: Insert more autonomous systems to replicate a larger inter-domain network.
  • Simulating link failures: Utilize the rtmodel command to replicate link failures among ASes that forcing BGP-like re-routing.
  • Traffic Load: Change the traffic intensity to monitor how BGP-like routing performs under diverse loads.

At the end, you can know how to execute BGP routing projects, which was simulated and evaluated in the NS2 environment using the given simulation strategy. If needed, we will deliver the entire execution process and more insights in another manual.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2