How to Start Route Source Protocol Projects Using NS2

To start Route Source Protocol projects using NS2, we can function on protocols such as DSR (Dynamic Source Routing) or same protocols, which clearly indicate the complete route in packet headers. Source routing is a basic method in which source node discovers the complete route to the destination node and within the packet header it contains this path.

NS2 supports DSR which is a source routing protocol frequently utilized for MANETs since it is a portion of their default routing protocols. We follow these steps to get started:

Steps to Start Route Source Protocols Projects in NS2

  1. Set Up NS2 Environment

Install NS2

For Ubuntu/Linux:

sudo apt-get update

sudo apt-get install ns2

Verify Installation

We can execute the NS2 interpreter:

ns

If effectively installed NS2 then we can view the NS2 prompt (%).

  1. Understand Source Routing Protocols

Dynamic Source Routing (DSR) is the fundamental protocol, which utilises the source routing in NS2.

Following is crucial aspects of DSR:

  • Route Discovery: To utilize Route Request (RREQ) and Route Reply (RREP) messages, source node determines the routes to the end node.
  • Route Maintenance: It supports to identify the broken connections and renovates the routes.
  • Source Route Header: The packet route header has the entire path from the source to the destination node.
  1. Write a TCL Script for DSR Simulation

Below is an example TCL script for replicating DSR (Route Source Protocol) within a Mobile Ad-Hoc Network (MANET) scenario.

DSR Simulation TCL Script:

# Initialize the Simulator

set ns [new Simulator]

# Define Trace and NAM Files

set tr [open dsr-source-routing.tr w]

$ns trace-all $tr

set nf [open dsr-source-routing.nam w]

$ns namtrace-all-wireless $nf

# Define Topology Dimensions

set val(x) 500           ;# X Dimension

set val(y) 500           ;# Y Dimension

set val(nn) 10           ;# Number of Nodes

set val(stop) 10.0       ;# Simulation Time

# Configure Wireless Channel

set val(chan)  Channel/WirelessChannel

set val(prop)  Propagation/TwoRayGround

set val(netif) Phy/WirelessPhy

set val(mac)   Mac/802_11

set val(ifq)   Queue/DropTail/PriQueue

set val(ll)    LL

set val(ant)   Antenna/OmniAntenna

set val(ifqlen) 50

# Create Topography

set topo [new Topography]

$topo load_flatgrid $val(x) $val(y)

# Define Nodes

for {set i 0} {$i < $val(nn)} {incr i} {

set node_($i) [$ns node]

$node_($i) random-motion 0

}

# Define Node Movement (Mobility)

$ns at 0.0 “$node_(0) setdest 100 200 15.0”

$ns at 1.0 “$node_(1) setdest 200 300 10.0”

$ns at 2.0 “$node_(2) setdest 300 400 20.0”

$ns at 3.0 “$node_(3) setdest 400 200 12.0”

$ns at 4.0 “$node_(4) setdest 150 150 10.0”

# Set Routing Protocol (DSR – Source Routing)

$ns rtproto DSR

# Attach UDP Traffic Sources

set udp [new Agent/UDP]

$ns attach-agent $node_(0) $udp

set null [new Agent/Null]

$ns attach-agent $node_(9) $null

$ns connect $udp $null

# Define CBR Traffic

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$cbr set packetSize_ 512

$cbr set rate_ 1Mbps

# Start and Stop Traffic

$ns at 1.0 “$cbr start”

$ns at 9.0 “$cbr stop”

# Finish Simulation

$ns at $val(stop) “finish”

proc finish {} {

global ns tr nf

$ns flush-trace

close $tr

close $nf

exec nam dsr-source-routing.nam &

exit 0

}

# Run the Simulation

$ns run

  1. Run the Simulation
  1. We will need to store the tcl simulation script like dsr_source_routing.tcl.
  2. Then, execute the simulation:

ns dsr_source_routing.tcl

  1. Outputs:
    • Trace File: dsr-source-routing.tr
    • NAM File: dsr-source-routing.nam which is designed for animation.
  1. Analyze Simulation Results

Key Metrics to Analyze:

  1. Packet Delivery Ratio (PDR): We can estimate the percentage of packets that are effective shared to the total transmitted packets:

awk ‘{if($1==”r” && $4==”cbr”) received++; if($1==”s” && $4==”cbr”) sent++} END {print “PDR: “, received/sent}’ dsr-source-routing.tr

  1. End-to-End Delay: Measure the average time which are undergone by packets:

awk ‘{if($1==”r” && $4==”cbr”) {delay[$6] = $2 – start[$6]}} END {for (i in delay) sum += delay[i]; print “Avg Delay:”, sum/NR}’ dsr-source-routing.tr

  1. Routing Overhead: Compute the volume of DSR control packets such as RREQ, RREP, RERR for routing overhead:

awk ‘{if($1==”s” && $4==”RTR” && $5==”DSR”) overhead++} END {print “Routing Overhead:”, overhead}’ dsr-source-routing.tr

  1. Enhance Your DSR Project
  2. Scalability Analysis:
  • Maximize the volume of nodes that has 50-100 nodes approximately and then monitor the performance protocol.
  1. Traffic Patterns:
  • Launch the TCP traffic models or several CBR flows for examining the behaviour of protocol in high load.
  1. Mobility Models:
  • Replicate the dynamic networks with the support of patterns like Random Waypoint or other mobility models.
  1. Node Failures:
  • We want to replicate the link or node failures to monitor how DSR manages the broken routes:

$ns rtmodel-at 5.0 down $node_(2) $node_(3)

  1. Energy Consumption:
  • Integrate an energy patterns, computing the energy consumption in the course of route discovery and maintenance.
  1. Visualization and Result Plotting
  • NAM: Envision the routing process and packet flow to apply nam file.
  • AWK/Python Scripts: Examine the trace files for performance parameters utilising AWK or Python scripts in NS2.
  • Gnuplot/Matplotlib: We can use these tools to graph the simulation outcomes such as:
    • Packet Delivery Ratio vs Number of Nodes.
    • End-to-End Delay vs Mobility.
    • Routing Overhead vs Simulation Time.
  1. Project Ideas for Source Routing Protocols
  1. Performance Analysis of DSR:
    • We will equate the performance of DSR with AODV in diverse node mobility and traffic scenarios.
  2. Energy-Efficient Source Routing:
    • Execute the energy-aware source routing, prolonging the node lifetime for energy efficiency.
  3. Scalability of DSR:
    • Examine the performance of DSR based on the network size expands.
  4. DSR in VANETs (Vehicular Ad-hoc Networks):
    • Measure DSR under highly dynamic vehicular networks in VANET.
  5. Fault-Tolerant Source Routing:
    • Replicate the node or link failures and then examine the retrieval performance for fault tolerance.

Here, we had demonstrated how the set up the environment, how to simulate and execute the Route Source Protocol Projects through the basic mechanisms by using NS2 simulation tool. We will give elaborate information about how the Route Source Protocol performs in other tool.