How to Simulate Internal Protocols Projects Using NS2

To simulate an internal routing protocols, like those that function within an Autonomous System (AS) in a network such as RIP, OSPF, EIGRP, in NS2 (Network Simulator 2) follows a systematic approach. These internal protocols are portion of the Interior Gateway Protocol (IGP) family and assist routers in an AS share routing data. Below is a guidelines to replicate an internal protocols in NS2:

Steps to Simulate Internal Routing Protocols in NS2

  1. Ensure NS2 Installation

If NS2 is not installed then we install it on Linux-based systems (e.g., Ubuntu) by running:

sudo apt-get install ns2

Check the installation by entering ns in the terminal, and we should observe the NS2 prompt.

  1. Internal Protocols in NS2

Even though NS2 has built-in support for a few routing protocols (like AODV, DSDV), for internal protocols such as RIP (Routing Information Protocol), OSPF (Open Shortest Path First), or EIGRP (Enhanced Interior Gateway Routing Protocol), we may require to replicate their behaviour using custom Tcl scripts and sets up because NS2 doesn’t natively contain these protocols.

We can replicate the behaviour of these protocols by describing a network topology, establishing routers and routing tables, and examinint data flow.

  1. Create a Tcl Simulation Script

Following is an instance Tcl script, which mimics a basic network with internal routing behaviour, resembling RIP’s distance-vector routing. Even though NS2 doesn’t natively execute RIP then we can replicate the concept of routers exchanging distance-vector information.

# Create a new simulator object

set ns [new Simulator]

# Define the trace file

set tracefile [open out.tr w]

$ns trace-all $tracefile

# Define the network topology

# Create four nodes to represent routers

set n0 [$ns node]  ;# Router 1

set n1 [$ns node]  ;# Router 2

set n2 [$ns node]  ;# Router 3

set n3 [$ns node]  ;# Router 4

# Create duplex links between routers (simulating internal routing)

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

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

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

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

# Create traffic flow from router 1 to router 4 (representing data transfer between two networks)

set tcp [new Agent/TCP]

set sink [new Agent/TCPSink]

$ns attach-agent $n0 $tcp

$ns attach-agent $n3 $sink

$ns connect $tcp $sink

set ftp [new Application/FTP]

$ftp attach-agent $tcp

# Schedule FTP transmission

$ns at 1.0 “$ftp start”

$ns at 9.0 “$ftp stop”

# Schedule end of simulation

$ns at 10.0 “finish”

proc finish {} {

global ns tracefile

$ns flush-trace

close $tracefile

exec nam out.nam &

exit 0

}

# Run the simulation

$ns run

  1. Simulate Routing Behavior (Distance Vector)

In the script above, the routers (nodes) are associated utilising duplex links that replicated an internal routing configuration. To replicate distance-vector routing such as RIP in which routers exchange routing tables, we can modify the behaviour using Tcl scripts to denote routing updates among the routers. For instance, each router could advertise its routing table to its neighbours periodically.

For link-state protocols such as OSPF, we can mimic flooding of link-state advertisements (LSAs) using a custom Tcl script, which replicates the exchange of link-state information among the nodes.

  1. Run the Tcl Script

To run the simulation:

  1. We can save the script as internal_routing.tcl.
  2. Run the script using:

ns internal_routing.tcl

  1. Visualize the Network in NAM

When the simulation runs then we can envision it in NAM (Network Animator):

nam out.nam

NAM offers a graphical interface to monitor the packet flow among the nodes. We can monitor how traffic flows among the routers according to the routing data.

  1. Analyze the Trace File

The out.tr trace file encompasses detailed data regarding the packets sent, received, and dropped. We can parse this file to examine the performance of the network, same to how we could investigate the behaviour of an internal routing protocol such as RIP or OSPF.

For instance, to verify the amount of packets received at the destination, we can utilize AWK:

awk ‘($1 == “r” && $4 == “tcp”) {print “Packet received at time: ” $2}’ out.tr

  1. Simulate OSPF or EIGRP

For protocols such as OSPF (which is link-state) or EIGRP (which is distance-vector with enhancements), we could require to replicate same behaviour by managing how nodes (routers) are share link-state or distance-vector information. While NS2 doesn’t directly support these protocols, we can be mimicked the impacts by changing the Tcl script:

  • For OSPF, replicate link-state advertisements (LSAs) and make sure each node has knowledge of the whole network topology.
  • For EIGRP, mimic a distance-vector routing scheme, however with enhancements like:
    • Diffusing Update Algorithm (DUAL) for route selection.
    • Reliable packet delivery for routing updates.
  1. Enhancing the Simulation

We can improve the internal routing simulation by:

  • Adding more routers: Describe more nodes and establish links among them.
  • Traffic control: Describe traffic patterns using distinct kinds of traffic such as FTP, CBR (Constant Bit Rate), and UDP.
  • Varying bandwidth and delay: Modify the duplex link properties to mimic real-world network conditions.

For example, to replicate OSPF, we can prolong the script to mimic flooding and route computation rely on link-state databases shared between routers.

Example for Simulating Behavior Like OSPF

Here’s an additional snippet, which simulates nodes are exchanging link-state updates periodically:

# Procedure to simulate link-state advertisement (LSA) flooding

proc lsa_flood {sender_node} {

global ns n0 n1 n2 n3

# Broadcast LSA to neighbors

$ns at 2.0 “$sender_node send-lsa”

$ns at 3.0 “$n1 process-lsa”

$ns at 4.0 “$n2 process-lsa”

$ns at 5.0 “$n3 process-lsa”

}

This type of configuration provides a simple way to replicate flooding of link-state updates (which is how OSPF operates).

  1. Performance Evaluation

After running the simulation then we can estimate the performance of the network by investigating parameters like:

  • Throughput: Estimate the total data delivered.
  • Latency/Delay: Assess the end-to-end delay of packet delivery.
  • Packet Delivery Ratio (PDR): Compute the ratio of packets are received at the destination to packets transmitted from the source.

We can utilize trace file analysis tools such as AWK, Python, or MATLAB to extract and visualize these parameters.

We explicated the structured approach for Internal Protocols projects, simulated and evaluated within NS2 simulator. We are prepared to deliver further insights and more sample projects ideas upon your needs.

If you’re finding it challenging to enhance your project performance, our team is here to assist you. We provide comprehensive guidance to help you develop Internal Protocols Projects tailored to your specific requirements. Explore a systematic approach at phdprime.com for RIP, OSPF, and EIGRP in NS2, where we also share top research topics and offer an exceptional writing service.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2