How to Start ABR Protocol Projects Using NS2
To start Associative-Based Routing (ABR) protocol projects in NS2 (Network Simulator 2), which is a type of on-demand routing protocol primarily created for Mobile Ad Hoc Networks (MANETs). It chooses the routes according to the node connections and stability instead of the shortest routes. Here’s a simple guide to get started.
Steps to Start ABR Protocol Projects in NS2
- Set Up NS2 Environment
- Make sure that we have installed NS2 on the system:
- On Linux/Ubuntu:
sudo apt-get update
sudo apt-get install ns2 nam xgraph
- Verify the installation by running:
ns
If % prompt will emerge then installation is effectively completed.
- Understand ABR Protocol
In mobile networks, ABR (Associative-Based Routing) concentrates on route stability:
- Routes are built depends on the node connections.
- Routes are selected including the stability’s highest degree.
- ABR prevents changing routes often within highly mobile networks.
Key Features:
- Stable Routes: According to the association stability, routes are selected.
- Route Repair: When routes interrupt then the local renovates are happen.
- On-Demand: Routes are launched if required.
- Plan the Simulation
- Topology: Create a network topology of mobile nodes including diverse degrees of movement.
- Traffic Model: UDP-based CBR traffic or FTP over TCP.
- Metrics to Measure:
- Routing Overhead
- End-to-End Delay
- Packet Delivery Ratio (PDR)
- Route Stability (path changes)
- Create a TCL Script
Here’s an NS2 TCL script to replicate the ABR-like behavior.
ABR Simulation Script
# Initialize the Simulator
set ns [new Simulator]
set tracefile [open abr_trace.tr w]
$ns trace-all $tracefile
set namfile [open abr_nam.nam w]
$ns namtrace-all $namfile
# Define Colors for Visualization
$ns color 1 Blue
$ns color 2 Red
# Define Parameters
set val(nn) 10 ;# Number of nodes
set val(stop) 10.0 ;# Simulation time
set val(x) 500 ;# X dimension of the area
set val(y) 500 ;# Y dimension of the area
# Create Nodes
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ;# Disable random motion
}
# Define Mobility
$ns at 1.0 “$node_(0) setdest 250 250 5.0”
$ns at 2.0 “$node_(1) setdest 300 300 5.0”
$ns at 3.0 “$node_(2) setdest 100 100 5.0”
# Set Up ABR Routing
$ns rtproto ABR
# Create Links (Optional Static Links to Start)
$ns duplex-link $node_(0) $node_(1) 2Mb 10ms DropTail
$ns duplex-link $node_(1) $node_(2) 2Mb 10ms DropTail
$ns duplex-link $node_(2) $node_(3) 2Mb 10ms DropTail
$ns duplex-link $node_(3) $node_(4) 2Mb 10ms DropTail
# Attach Agents and Applications
set udp [new Agent/UDP]
set null [new Agent/Null]
$ns attach-agent $node_(0) $udp
$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 rate_ 1Mb
# Schedule Traffic
$ns at 1.0 “$cbr start”
$ns at 9.0 “$cbr stop”
# Finish Procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam abr_nam.nam &
exit 0
}
# Run Simulation
$ns at $val(stop) “finish”
$ns run
- Run the Simulation
- We need to store the simulation script like abr_simulation.tcl.
- Then, execute the simulation tcl script using NS2:
ns abr_simulation.tcl
- Outputs:
- Trace file: abr_trace.tr
- NAM file: abr_nam.nam is used for envisioning the packet flow and node movement.
- Analyze Results
Key Metrics:
- Packet Delivery Ratio (PDR): Examine the transmitted and received packets with the support of AWK:
awk ‘BEGIN {sent=0; received=0}
{if ($1==”s”) sent++; if ($1==”r”) received++}
END {print “PDR:”, received/sent*100 “%”}’ abr_trace.tr
- End-to-End Delay: Obtain timestamps to compute the interval for transmitted and received packets.
- Route Stability: Examine the route changes by means of detecting route breaks within trace file.
- Routing Overhead: Measure the volume of control packets that are swapped for routing overhead.
Graph Results:
To envision the performance indicators with xgraph:
xgraph pdr.xg delay.xg overhead.xg
- Extend the Project
- Mobility Models:
- Replicate the realistic mobility node movements to utilise the Random Waypoint.
- Performance Comparison:
- We can equate the performance of ABR with other MANET protocols such as AODV, DSDV, and DSR.
- Energy Efficiency:
- Mimic power utilization and examine the node lifetime.
- Dynamic Route Repair:
- We will need to execute the dynamic local route repair approaches for route failures.
- Document the Results
This project supports to provide more insights like:
- Network Topology: It contains volume of nodes, mobility models.
- Simulation Parameters: We measure the simulation metrics like packet size, traffic rate, bandwidth.
- Performance Metrics: Compute the performance parameters such as PDR, delay, routing overhead.
- Comparative Analysis: Then, compare the performance of ABR vs. other routing protocols for analysis.
From this manual, you may gather more information about ABR Protocol projects that were simulated and analysed using NS2’s simple procedure. We can offer additional information on this subject in upcoming manual.