How to Simulate Hot Potato Routing Projects Using NS2

To simulate Hot Potato Routing using NS2, we require setting up a routing protocol, which forwards packets instantaneously to the next hop without waiting for the best path. In Hot Potato Routing is also called as deflection routing, routers transmit packets to adjacent nodes as soon as possible to prevent holding onto them, although it’s not the most finest path. This method is utilized to reduce delays however can outcome in non-optimal routing paths.

Because NS2 doesn’t have a built-in hot potato routing protocol, we can replicate its behaviour by making a network topology and make sure packets are forwarded immediately, which replicating deflection when no direct path is obtainable.

Here’s a step-by-step instruction on how to simulate Hot Potato Routing using NS2.

Steps to Simulate Hot Potato Routing in NS2

  1. Set Up NS2 Environment

Make certain NS2 is installed and running on the system. We can verify this by entering:

ns

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

  1. Understanding Hot Potato Routing

In Hot Potato Routing, routers send packets when they receive them then frequently without holding onto them to wait for the optimal possible path. This routing technique can assist reduce congestion in high-traffic networks, however it lead to longer routes as packets are “deflected” from node to node.

  1. Write a TCL Script for Hot Potato Routing

Following is a TCL script to simulate Hot Potato 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

set n0 [$ns node]

set n1 [$ns node]

set n2 [$ns node]

set n3 [$ns node]

set n4 [$ns node]

# Create duplex links with delays

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

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

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

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

$ns duplex-link $n1 $n3 512Kb 15ms DropTail

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

# Enable static routing to simulate Hot Potato Routing

$ns rtproto Static

# Manually configure deflection routes to simulate hot potato routing

$n0 add-route-to-destination $n4 1   ;# Path through n1 -> n3 -> n4

$n1 add-route-to-destination $n4 1   ;# Path through n1 -> n3 -> n4

$n2 add-route-to-destination $n4 1   ;# Path through n3 -> n4

$n3 add-route-to-destination $n4 1   ;# Direct path from n3 -> n4

# Create a UDP agent and attach it to node n0 (source)

set udp0 [new Agent/UDP]

$ns attach-agent $n0 $udp0

# Create a Null agent and attach it to node n4 (destination)

set null0 [new Agent/Null]

$ns attach-agent $n4 $null0

# Connect the source (n0) to the destination (n4)

$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.005

$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 includes five nodes (n0 to n4), with links having diverse bandwidths and delays. This replicates a network in which few paths are faster however more congested, while others are slower.
  • Static Routing: The script uses $ns rtproto Static to allow static routing that permitting to manually set up routes.
  • Hot Potato Behavior: Routes are manually set to make sure that when a node receives a packet, it sends the packet immediately and following a “deflection” rule if there is congestion.
  • Traffic: A Constant Bit Rate (CBR) traffic generator is made at node n0 and transmits traffic to node n4.
  1. Running the Simulation

We can save the script as hot_potato_routing.tcl and then execute it in the terminal:

ns hot_potato_routing.tcl

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

  1. Visualizing the Simulation

To envision the network and observe the packet flow using NAM, execute:

nam out.nam

In NAM, we will be monitored how packets are deflected from node to node that following hot potato routing behaviour.

  1. Simulating Network Congestion and Deflection

To replicate network congestion and the resulting deflection of packets, we can make several traffic flows and change the routing paths actively. For instance, insert a second traffic flow from n0 to n3:

# Second UDP agent for additional traffic

set udp1 [new Agent/UDP]

$ns attach-agent $n0 $udp1

# Null agent at node n3

set null1 [new Agent/Null]

$ns attach-agent $n3 $null1

# Connect the second traffic flow

$ns connect $udp1 $null1

# Create a second CBR traffic generator

set cbr1 [new Application/Traffic/CBR]

$cbr1 set packetSize_ 512

$cbr1 set interval_ 0.01

$cbr1 attach-agent $udp1

# Schedule the second flow to start later

$ns at 2.0 “$cbr1 start”

$ns at 4.5 “$cbr1 stop”

It will make network congestion, triggering the routing protocol to deflect traffic in accordance with the hot potato routing approach.

  1. Analyzing the Trace File

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

  • Packet Delivery Ratio (PDR): Assess how many packets effectively attain their destination.
  • End-to-End Delay: Compute the delay for each packet from source to destination.
  • Routing Decisions: Examine how packets are deflected by verifying the route taken by each packet.

For instance, to calculate the number of packets received at the destination (n4):

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

  1. Performance Evaluation

We can estimate the performance of hot potato routing by:

  • Increasing the traffic load: Insert more traffic flows to check how successfully the routing deflects packets to prevent congestion.
  • Simulating link failures: Utilize the rtmodel command to replicate link failures and monitor how hot potato routing reacts.
  • Measuring packet delays: Investigate how long it takes for packets to attain their destination under diverse traffic conditions.

In this simulation, we grasped the simulation techniques with sample snippets for Hot Potato routing projects that were simulated and evaluated the performance of these projects using NS2 tool. Additional insights and projects ideas are available for a deeper exploration if required. To facilitate the simulation of Hot Potato Routing Projects utilizing the NS2 tool, phdprime.com offers high-quality services by providing innovative topics and ideas tailored to your interests. For cutting-edge guidance, please connect with phdprime.com.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2