To simulate Route Source Protocols in NS2, we need to include setting up the features of the network routing by defining how routes are sourced and handled within the network. A Route Source Protocol can be any routing protocol in which the path selection, source routing, or packet-forwarding decisions relay on the source node or a certain source-routing mechanism such as Dynamic Source Routing, DSR.phdprime.com will provide you with utmost simulation guidance on your projects send us a mail by sharing all your research needs we guarantee novel results.
Here is a guide on how to simulate the route source protocol using ns2.
Steps to Simulate Route Source Protocol Projects in NS2
- Install NS2
Make sure that NS2 is installed on the system.
- Set up the Network Topology for Source Routing
In a source routing protocol such as DSR, the entire route from source to destination is encompassed in the packet headers. Nodes along the path forward the packet according to this source route.
Example TCL Script for Route Source Network Topology Using DSR:
# Create a new simulator instance
set ns [new Simulator]
# Define trace and nam files for logging and visualization
set tracefile [open route_source_simulation.tr w]
$ns trace-all $tracefile
set namfile [open route_source_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 type
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) 500 ;# X dimension (network size)
set val(y) 500 ;# Y dimension
# Configure nodes to use DSR (Dynamic Source Routing)
$ns node-config -adhocRouting DSR \
-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 network
set n0 [$ns node] ;# Node 0 (Source)
set n1 [$ns node] ;# Node 1
set n2 [$ns node] ;# Node 2
set n3 [$ns node] ;# Node 3 (Destination)
# Set node positions
$n0 set X_ 100; $n0 set Y_ 100
$n1 set X_ 200; $n1 set Y_ 150
$n2 set X_ 300; $n2 set Y_ 200
$n3 set X_ 400; $n3 set Y_ 250
# Create wireless links between nodes
$ns duplex-link $n0 $n1 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 2Mb 10ms DropTail
This configures a simple network in which the DSR will be utilized for source routing. In DSR, the source node (n0) specifies the entire route to the destination (n3) in the packet header.
- Implement Traffic in the Network
To validate source routing, we can replicate traffic among the source and destination nodes using TCP or UDP.
Example for TCP Traffic:
# Set up TCP connection between node 0 (source) and node 3 (destination)
set tcp0 [new Agent/TCP]
set sink0 [new Agent/TCPSink]
$ns attach-agent $n0 $tcp0
$ns attach-agent $n3 $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”
In this configuration, node 0 performs as the source, and node 3 is the destination. The DSR protocol will identify the route and source the packets consequently.
- Run the Simulation
Save the TCL script (e.g., route_source_simulation.tcl) and execute it using NS2:
ns route_source_simulation.tcl
This will create trace files (.tr) and NAM files (.nam) that can be measured and envisioned by using Network Animator (NAM).
- Analyse the Simulation Results
In source routing protocols such as DSR, we need to measure:
- Route Discovery Time: The time it takes for the source node to identify a route to the destination.
- Packet Delivery Ratio (PDR): The percentage of packets successfully delivered to the destination.
- Route Maintenance Overhead: The number of route maintenance packets transmit during the simulation.
Example AWK Script for 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, “%”; }
These script estimates the Packet Delivery Ratio according to the number of packets transmit and received for the period of the simulation.
- Example Project Ideas for Route Source Protocol Simulation
- Performance Analysis of DSR in Mobile Ad-Hoc Networks (MANETs):
- Replicate node mobility and evaluate on how DSR manage route discovery and maintenance in highly dynamic scenarios.
- Energy-Efficient Route Source Protocols:
- Execute energy-aware routing parameters in DSR and measure their effect on network lifetime and packet delivery.
- Comparison Between DSR and AODV:
- Replicate both DSR and AODV in the same network and relate their performance based on route discovery time, packet delivery ratio, and overhead.
- Impact of Traffic Load on Source Routing:
- Replicate different traffic loads and measure on how increased traffic impacts the performance of source routing protocols based on latency and routing overhead.
We had explicit the information about the simulation process with examples regarding the Route Source Protocols that was executed using the tool of ns2 and also we provide the additional example ideas for this process. We plan to elaborate on the Route Source Protocols procedure in other simulation scenarios.