How to Start Reactive Protocol Projects Using NS2

To start Reactive Protocol projects using NS2 (Network Simulator 2), we can adhere to these comprehensive steps. Reactive protocols such as AODV (Ad-hoc On-Demand Distance Vector), DSR (Dynamic Source Routing), and DYMO are frequently utilized within MANETs (Mobile Ad-hoc Networks) in which routes are made only if required. Here’s a common procedure to get started:

Steps to Start Reactive Protocol Projects in NS2

  1. Set Up NS2 Environment
  • Install NS2: Make sure that NS2 is successfully installed on the system based on the preferred OS like Ubuntu/Linux.
    • We can install NS2 using the below command:

sudo apt-get update

sudo apt-get install ns2

  • Verify Installation:

ns

We should see NS2 interpreter if properly installed NS2.

  1. Understand Reactive Protocols

Reactive protocols function based on the request. They determine the optimal routes as a source node requires for interacting with a destination node.

Common Reactive Protocols:

  • AODV: It is an on-demand route discovery to apply RREQ (Route Request) and RREP (Route Reply) packets.
  • DSR: Route discovery by source routing.
  • DYMO: It is same to AODV protocol however it contains sequence numbers improvement.
  1. Choose a Protocol to Simulate

NS2 environment directly have AODV and DSR routing protocols. We can decide on one of these protocol depends on the project requirements.

  1. Write TCL Script

Make a TCL script for replicating a reactive protocol in NS2. The script describes:

  • Network topology which contains number of nodes and its placement
  • Traffic model (CBR, FTP, or TCP)
  • Routing protocol like AODV or DSR

Example AODV Simulation Script:

# Define Simulator

set ns [new Simulator]

# Trace Files

set nf [open aodv-output.nam w]

$ns namtrace-all $nf

set tr [open aodv-output.tr w]

$ns trace-all $tr

# Define Network Topology

set n 5

for {set i 0} {$i < $n} {incr i} {

set node($i) [$ns node]

}

# Set Node Movement

$ns at 0.0 “$node(0) setdest 50.0 50.0 15.0”

$ns at 0.0 “$node(1) setdest 100.0 50.0 15.0”

# Configure Routing Protocol (AODV)

$ns rtproto AODV

# Traffic Definition (CBR)

set udp [new Agent/UDP]

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

set null [new Agent/Null]

$ns attach-agent $node(4) $null

$ns connect $udp $null

set cbr [new Application/Traffic/CBR]

$cbr attach-agent $udp

$cbr set packetSize_ 512

$cbr set interval_ 0.5

# Simulation Time

$ns at 0.1 “$cbr start”

$ns at 4.5 “$cbr stop”

# Run Simulation

$ns at 5.0 “finish”

proc finish {} {

global ns nf tr

$ns flush-trace

close $nf

close $tr

exec nam aodv-output.nam &

exit 0

}

$ns run

  1. Run the Simulation
  1. We will need to store the above TCL script like aodv_test.tcl.
  2. Then execute the simulation with NS2:

ns aodv_test.tcl

  1. Output:
    • NAM file (aodv-output.nam): Monitor the animation utilizing NAM file.
    • Trace file (aodv-output.tr): It helps to examine the performance of simulation.
  1. Analyze Results
  • Go to NAM file for visual simulation.
  • Make use of trace file to examine the metrics like:
    • Routing Overhead
    • End-to-End Delay
    • Packet Delivery Ratio

Tools:

  • Inscribe AWK or Python scripts to analyze the .tr files for simulation parameters.
  1. Enhance the Project
  • We can integrate the node mobility to apply mobility patterns such as Random Waypoint.
  • Replicate the traffic models such as TCP, FTP, or VoIP.
  • We will need to execute the alterations to the AODV/DSR protocol for energy-aware routing.

By completing these simulation steps, you’ll able to replicate and enhance the Reactive Protocol Projects using NS2 environment. We can ready to expand it further that contains innovative insights and advanced mechanisms regarding this topic.