How to Start DSR Protocol Projects Using NS2
To start a Dynamic Source Routing (DSR) protocol project in NS2 (Network Simulator 2) which encompasses to replicate a mobile ad hoc network (MANET) in which nodes are determine and sustain the routes based on the request. NS2 supports for DSR, to create it for setting up and experiment the diverse conditions. Below is a structured method to get started:
Steps to Start DSR Protocol Projects in NS2
- Understand DSR Protocol and NS2 Capabilities
- DSR Protocol Overview:
- DSR is an on-demand routing protocol, which consumes the source routing.
- Nodes sustain a route cache and determine the routes only as needed.
- NS2 Support:
- NS2 environment has a DSR’s basic execution in their wireless networking module, which permit for replicating DSR devoid of more extensions.
- Set Up NS2 Environment
- We can set up NS2 on the Linux system:
sudo apt-get install ns2
- Confirm the installation including an example script:
ns example.tcl
- Define the Project Scope
- Choose Objectives:
- Replicate the DSR protocol under diverse network topologies.
- Measure the performance of DSR in various scenarios like node mobility, traffic load.
- Improve DSR including more aspects such as security, QoS metics.
- Example Scenarios:
- Experiment the route discovery and maintenance of DSR within a dynamic network.
- Estimate the metrics like packet delivery ratio, latency, and routing overhead.
- Design the Network Topology
- Plan the Topology:
- Make mobile nodes including wireless links.
- Set the mobility models like Random Waypoint, Gauss-Markov.
- Make use of UDP or TCP agents for traffic generation.
- Example:
- A network contains 10 nodes that support to arbitrarily transmit in a 1000m x 1000m area.
- Write the TCL Script
- Set the simulation in tcl script to leverage the NS2’s wireless and DSR compnents.
Example TCL Script for DSR Simulation:
# Initialize the simulator
set ns [new Simulator]
# Define trace file and NAM file
set tracefile [open dsr_trace.tr w]
$ns trace-all $tracefile
set namfile [open dsr_simulation.nam w]
$ns namtrace-all-wireless $namfile 1000 1000
# Configure wireless topology
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(x) 1000
set val(y) 1000
set val(ifqlen) 50
set val(seed) 1.0
set val(energy) 100.0
# Create nodes
set num_nodes 10
set nodes {}
for {set i 0} {$i < $num_nodes} {incr i} {
set node($i) [$ns node]
$node($i) random-motion 1
$nodes($i) $node($i)
}
# Define mobility model
$ns at 1.0 “$node(0) setdest 500.0 500.0 10.0”
$ns at 2.0 “$node(1) setdest 800.0 200.0 10.0”
$ns at 3.0 “$node(2) setdest 100.0 300.0 10.0”
# Enable DSR routing
for {set i 0} {$i < $num_nodes} {incr i} {
$node($i) set ragent_ [new Agent/DSR]
}
# Attach traffic agents
set udp [new Agent/UDP]
set null [new Agent/Null]
$ns attach-agent $node(0) $udp
$ns attach-agent $node(9) $null
$ns connect $udp $null
set cbr [new Application/Traffic/CBR]
$cbr set packetSize_ 512
$cbr set interval_ 0.1
$cbr attach-agent $udp
# Start traffic
$ns at 5.0 “$cbr start”
$ns at 25.0 “$cbr stop”
# End simulation
$ns at 30.0 “finish”
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam dsr_simulation.nam &
exit 0
}
$ns run
- Simulate Network Dynamics
- Experiment the behaviour of DSR in modifying the dynamic network scenarios:
- Node Mobility: Actively nodes are transferred by leveraging the $node setdest commands.
- Link Failures: Replicate the link failures for monitoring DSR’s route maintenance.
- Run the Simulation
- Run the TCL script simulation to use following command line:
ns dsr_simulation.tcl
- Utilise NAM to envision the simulation:
nam dsr_simulation.nam
- Analyze Performance
- Examine the performance parameters from the trace file as dsr_trace.tr:
- Packet Delivery Ratio (PDR): Compute the rate of packets that are effectively distributed.
- Routing Overhead: Count the volume of routing packets which are made for routing overhead.
- End-to-End Delay: Measure the duration, attaining its destination node for packets.
Example AWK Script for PDR:
BEGIN {sent=0; received=0;}
{
if ($1 == “s” && $4 == “UDP”) {
sent++;
} else if ($1 == “r” && $4 == “UDP”) {
received++;
}
}
END {
print “Packet Delivery Ratio:”, received/sent;
}
- Enhance DSR Functionality
- Add Security: Execute the encryption or authentication and integrate security for route discovery.
- Optimize Route Caching: Enhance the route caching mechanisms for improving the performance.
- Simulate Attacks: Experiment the behavior of DSR in attacks such as blackhole or wormhole attacks for simulation.
- Document the Project
- This projects contains more insights like:
- Clear project goals and problem statement.
- Description of the network topology.
- Simulation outcomes using graphs and tables.
- Performance observations and references for future work.
We provided more details for DSR Protocol projects that were executed and analysed using given basic procedure in NS2 environment, can be accessed. We can equip to offer more specifies on this topic through upcoming guide.