To simulate an Associative-Based Routing (ABR) using NS2 that has stepwise method, which is a protocol created for mobile ad-hoc networks (MANETs) that chooses routes according to the degree of association stability that denotes the long-term availability of links among the mobile nodes. This ABR protocol favours more stable routes to maximize network reliability within highly mobile environments. Because ABR is not obtainable by default in NS2, so we will either require to apply a patch, which encompasses ABR support or replicate ABR’s behaviour manually.
Here’s a step-by-step guide how we can simulate ABR protocol projects in NS2.
Steps to Simulate ABR Protocol Projects in NS2
- Install NS2
Make certain that NS2 is installed on the machine. We can download it from the NS2 official website. If there’s an ABR patch then we apply it as follows:
Applying ABR Patch (If Available)
- Download the ABR patch for NS2.
- Apply the patch:
cd ns-allinone-2.35/ns-2.35/
patch -p1 < abr-patch.diff
- Rebuild NS2:
./configure
make clean
make
- Set Up ABR Network Topology
In ABR, the association stability among adjacent nodes is fundamental. Nodes with stable links are more probable to be utilized in routing decisions. We will be mimicked a mobile ad-hoc network and then assess the stability of associations among the mobile nodes.
Example TCL Script for ABR Topology:
# Create a new simulator instance
set ns [new Simulator]
# Define trace and nam files for logging and visualization
set tracefile [open abr_simulation.tr w]
$ns trace-all $tracefile
set namfile [open abr_simulation.nam w]
$ns namtrace-all $namfile
# Set up network parameters (wireless channel, propagation, MAC, etc.)
set val(chan) Channel/WirelessChannel ;# Channel type
set val(prop) Propagation/TwoRayGround ;# Propagation model
set val(netif) Phy/WirelessPhy ;# Network interface type
set val(mac) Mac/802_11 ;# MAC layer (as ABR operates at network layer)
set val(ifq) Queue/DropTail/PriQueue ;# Interface queue type
set val(ll) LL ;# Link layer type
set val(ant) Antenna/OmniAntenna ;# Antenna type
set val(x) 1000 ;# X-axis dimension (in meters)
set val(y) 1000 ;# Y-axis dimension (in meters)
# Configure nodes to use ABR (you will implement this manually)
$ns node-config -adhocRouting ABR \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan)
# Create nodes for the MANET
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
# Set initial positions for nodes
$n0 set X_ 50; $n0 set Y_ 50; $n0 set Z_ 0.0
$n1 set X_ 200; $n1 set Y_ 100; $n1 set Z_ 0.0
$n2 set X_ 300; $n2 set Y_ 200; $n2 set Z_ 0.0
$n3 set X_ 400; $n3 set Y_ 300; $n3 set Z_ 0.0
$n4 set X_ 500; $n4 set Y_ 400; $n4 set Z_ 0.0
# Enable mobility for the nodes
$ns at 5.0 “$n0 setdest 150 250 10.0” ;# Move node n0 to new location at 10 m/s
$ns at 5.0 “$n1 setdest 250 300 12.0” ;# Move node n1
$ns at 5.0 “$n2 setdest 400 200 8.0” ;# Move node n2
$ns at 5.0 “$n3 setdest 600 350 15.0” ;# Move node n3
$ns at 5.0 “$n4 setdest 800 400 7.0” ;# Move node n4
- Define Traffic for ABR Network
We can replicate TCP or UDP traffic among the nodes in the ad-hoc network to experiment ABR’s ability to route data rely on association stability.
Example for TCP Traffic:
# Set up TCP connection between node 0 and node 4
set tcp0 [new Agent/TCP]
set sink0 [new Agent/TCPSink]
$ns attach-agent $n0 $tcp0
$ns attach-agent $n4 $sink0
$ns connect $tcp0 $sink0
# Create FTP traffic over TCP
set ftp0 [new Application/FTP]
$ftp0 attach-agent $tcp0
$ns at 2.0 “$ftp0 start”
$ns at 10.0 “$ftp0 stop”
Example for UDP Traffic (CBR):
# Set up UDP communication between node 1 and node 3
set udp0 [new Agent/UDP]
set null0 [new Agent/Null]
$ns attach-agent $n1 $udp0
$ns attach-agent $n3 $null0
# Generate CBR traffic over UDP
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 512
$cbr0 set rate_ 100kb
$cbr0 attach-agent $udp0
$ns at 3.0 “$cbr0 start”
$ns at 12.0 “$cbr0 stop”
- Simulate ABR Protocol Behavior
In ABR, routes are selected according to the association stability that is updated periodically. Nodes interchange HELLO packets to calculate their connection stability with neighbours, and this data is utilized to create routing decisions.
We can replicate this by inserting periodic HELLO messages among adjacent nodes and changing the route tables depends on link stability.
- Run the Simulation
We can save the TCL script (e.g., abr_simulation.tcl) and then we run the simulation using NS2:
ns abr_simulation.tcl
It will generate a trace file (.tr) and a NAM file (.nam) for envisioning and examining the simulation outcomes in Network Animator (NAM).
- Analyze the Simulation Results
We can investigate the performance of ABR using the generated trace file. Important parameters to examine contain:
- Packet Delivery Ratio (PDR)
- End-to-End Delay
- Routing Overhead
- Link Stability: The time period over which links remain stable.
Example AWK Script to Calculate Packet Delivery Ratio:
BEGIN { sent = 0; received = 0; }
{
if ($1 == “s” && $4 == “AGT”) { sent++; }
if ($1 == “r” && $4 == “AGT”) { received++; }
}
END { print “Packet Delivery Ratio = “, received/sent*100, “%”; }
- Example Project Ideas for ABR Simulation
- Performance Comparison Between ABR and AODV:
- Replicate both ABR and AODV within the similar mobile network and compare their performance such as packet delivery, delay, and routing overhead.
- Impact of Mobility on ABR:
- Investigate how ABR executes under distinct mobility scenarios. As mobility increases, we can compute the impact on link stability and routing performance.
- Energy-Efficient ABR:
- Execute an energy-efficient version of ABR by deliberating an energy metrics together with association stability, and estimate the impact on network lifetime.
- ABR in Large-Scale Networks:
- Mimic a large-scale MANET utilizing ABR and learn how successfully it scales such as route stability, overhead, and packet delivery ratio.
We efficiently illustrated the methodical approach utilized for ABR protocol projects, which was simulated and analysed its simulation results using NS2 simulator. Further details will be provided regarding this topic depends on your needs.
If you are looking for best simulation assistance, then phdprime.com only can guide you with detailed guidance and project results.