How to Implement Path Vector Routing in NS2

 

To implement the Path Vector Routing in NS2 that has includes setting up a routing mechanism, which uses the path vectors, same to how the Border Gateway Protocol (BGP) operates. This Routing simulation in NS2 can be according to the concepts of node communication among the Autonomous Systems (AS) and it is mainly used in inter-domain routing.

Steps to Implement Path Vector Routing in NS2:

  1. Install and Set Up NS2

Make sure that NS2 is appropriately installed on the computer. This routing is same to BGP, thus we may want to more routing logic, or we can model it using the NS2’s default BGP performance if we are mimicking inter-domain routing.

  1. Modify the Tcl Script for Path Vector Routing

We require to make a script Tcl to replicate a network, which uses this routing. Given below is a simple structure to follow:

Example of Path Vector Routing in a Tcl Script:

# Initialize a new NS2 simulator instance

set ns [new Simulator]

# Define network nodes (e.g., routers)

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

# Define duplex links between nodes (routers)

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

$ns duplex-link $n1 $n2 10Mb 10ms DropTail

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

# Define Autonomous Systems (AS)

$n0 set-AS 100

$n1 set-AS 200

$n2 set-AS 300

$n3 set-AS 400

# Set up Path Vector Routing (similar to BGP in principle)

$n0 add-path-vector-peer $n1

$n1 add-path-vector-peer $n2

$n2 add-path-vector-peer $n3

# Enable Path Vector Routing on each node

$n0 enable-PathVector

$n1 enable-PathVector

$n2 enable-PathVector

$n3 enable-PathVector

# Define routing policies (Optional: based on network design)

$n0 set-PathVector-policy “Accept-AS100”

$n1 set-PathVector-policy “Accept-AS200”

$n2 set-PathVector-policy “Accept-AS300”

# Define a sample traffic flow between nodes

set udp0 [new Agent/UDP]

$ns attach-agent $n0 $udp0

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp0

$cbr set packetSize_ 512

$cbr set interval_ 0.1

$cbr set random_ false

$ns connect $udp0 $n3

# Start the traffic flow at 1 second

$ns at 1.0 “$cbr start”

# Finish the simulation after a defined time

$ns at 10.0 “finish”

$ns run

  1. Key Components of Path Vector Routing Simulation
  • Autonomous Systems (AS): Every node is allocated to an AS, and the routing among those ASes will be governed by Path Vector Routing.
  • Peers: These nodes are set up to peer with one another, and the path data is exchanged among these peers.
  • Routing Policies: We can describe the routing policies or preferences, like in BGP, in which particular paths are desired across others.
  • Traffic Generation: State traffic among the nodes like UDP/CBR to mimic the movement of packets among the various ASes.
  1. Traffic Simulation and Monitoring

To replicate the actual path vector routing, we need to produce traffic among the nodes. It can be completed by attaching traffic agents like UDP to nodes and describing the sources and destinations over various ASes.

NAM (Network Animator) can be used to visualize the packet transmission and routing over the ASes.

  1. Run the Simulation

When script is ready, we can run it using the simulation NS2 by implementing the below command in the terminal:

ns your_script.tcl

  1. Analyse Results

To evaluate the trace files produced by the simulation NS2 to check that the Path Vector Routing is working as expected, after running the simulation. We should monitor for routing table updates, path announcements, and policy decisions.

  1. Extensions and Customization
  • Custom Path Vector Algorithms: If essential, we can execute the custom path vector procedures in NS2 C++ codebase in files like agent.cc or other related files. It permits for more control across the path advertisement and path selection behaviour.
  • Convergence Time: If we are learning the routing protocol behaviour, computing the convergence time, and packet loss is a main feature of Path Vector Routing simulation.
  1. Testing Path Vector Route Changes

We can also mimic alters in the topology such as disabling certain links and monitor how Path Vector Routing adjusts by switching paths.

The entire approach for executing and evaluating the Path Vector routing using the simulation tool NS2 had been outlined above. Further details will be provided shortly based on your needs.

Check out some cool project ideas from our researchers! If you need help with Path Vector Routing in NS2, we’ve got you covered. We can also provide you with network analysis info for your projects, so just send us your project details for more support.