To simulate Temporally Ordered Routing Algorithm (TORA) projects using NS2, we need to set up the TORA routing protocol, that is a highly adaptive, distributed routing protocol modelled for mobile ad-hoc networks (MANETs). TORA is intended to deliver the loop-free, multi-path, and distributed routing in scenarios with frequent network topology changes.
Below is a step-by-step guide to simulate TORA routing using NS2.
Steps to Simulate TORA Routing in NS2
- Set up NS2 Environment
Make sure that NS2 is installed and executing on the system. To validate, open the terminal and run:
ns
If NS2 is correctly installed, this command will open the NS2 shell.
- Understanding TORA
TORA is an on-demand routing protocol which responds to network topology changes quickly and effectively. It introduces multiple routes for each destination, and routes are only sustained among nodes that need a communication.
- Write a TCL Script for TORA Routing
Here is an instance TCL script to replicate TORA routing:
# Create a simulator object
set ns [new Simulator]
# Open trace and NAM output files
set tracefile [open out.tr w]
set namfile [open out.nam w]
$ns trace-all $tracefile
$ns namtrace-all $namfile
# Define network topology
set topo [new Topography]
$topo load_flatgrid 500 500
# Create nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
# Create links between nodes
$ns duplex-link $n0 $n1 2Mb 10ms DropTail
$ns duplex-link $n1 $n2 2Mb 10ms DropTail
$ns duplex-link $n2 $n3 1Mb 20ms DropTail
$ns duplex-link $n3 $n4 1Mb 20ms DropTail
# Set up the routing protocol as TORA
$ns rtproto TORA
# Create a UDP agent and attach it to node n0
set udp0 [new Agent/UDP]
$ns attach-agent $n0 $udp0
# Create a Null agent and attach it to node n4
set null4 [new Agent/Null]
$ns attach-agent $n4 $null4
# Connect the UDP agent to the Null agent (n0 -> n4)
$ns connect $udp0 $null4
# Create a CBR traffic generator and attach it to the UDP agent
set cbr0 [new Application/Traffic/CBR]
$cbr0 set packetSize_ 512
$cbr0 set interval_ 0.005
$cbr0 attach-agent $udp0
# Schedule the traffic to start and stop
$ns at 1.0 “$cbr0 start”
$ns at 4.5 “$cbr0 stop”
$ns at 5.0 “finish”
# Define the finish procedure
proc finish {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
exec nam out.nam &
exit 0
}
# Run the simulation
$ns run
- Explanation of the Script
- Routing Protocol: The $ns rtproto TORA command sets TORA by way of the routing protocol.
- Network Topology: This sample consists of five nodes associated in a chain topology, with links having diverse bandwidth and delay characteristics.
- Traffic: A UDP agent is attached to n0 and traffic is sent to n4. A Constant Bit Rate (CBR) application creates the traffic.
- TORA Features: TORA sustains multiple routes for each destination and adjust rapidly to changes in the network topology.
- Simulate Link Failures and Mobility
To demonstrate TORA’s adaptability to network changes, we need to replicate link failures or mobility. Incorporate the following lines to emulate a link failure:
# Simulate link failure between n2 and n3 at 2.5 seconds
$ns rtmodel-at 2.5 down $n2 $n3
# Restore the link at 4.0 seconds
$ns rtmodel-at 4.0 up $n2 $n3
This will concentrate TORA to react and recomputed the routes according to the link failure and restoration.
- Running the Simulation
To execute the TORA routing simulation, save the script as tora_simulation.tcl and run it in the terminal:
ns tora_simulation.tcl
This will create two output files:
- Trace File (out.tr): This file logs packet transmissions, routing updates, and link failures.
- NAM File (out.nam): This file can be utilized to envision the network and routing behaviour.
- Visualize the Simulation
We can envision the network and monitor the TORA routing behaviour using NAM:
nam out.nam
In the NAM tool, we can see how TORA dynamically adapt routes as the network changes (such as during link failures).
- Modify the Simulation for Advanced Scenarios
We need to extend this simple simulation to discover more complex scenarios:
- Node Mobility: Establish node mobility to monitor how TORA adapts to rapidly changing network topologies.
- Increase the Network Size: incorporate more nodes and links to replicate a larger mobile ad-hoc network (MANET).
- Different Traffic Types: Utilize TCP rather than UDP or alter the traffic load with numerous CBR rates.
- Analyse the Trace File
The trace file (out.tr) encompasses detailed information about packet transmissions, routing decisions, and network changes. We need to utilize tools such as awk or grep to extract parameters like:
- Packet Delivery Ratio (PDR): evaluate on how efficiently TORA delivers packets in dynamic scenarios.
- End-to-End Delay: Estimate the time it takes for packets to travel from the source to the destination.
- Routing Overhead: Total the amount of control packets created by TORA to sustain routes.
Example to count received packets:
grep “^r” out.tr | wc -l
- Performance Evaluation
Measure TORA’s performance in different conditions:
- Mobility: Validate on how well TORA manage mobile nodes and frequent topology changes.
- Scalability: Add the number of nodes to measure on how TORA act as in larger networks.
- Traffic Load: change the traffic load to evaluate TORA’s efficiency in different network loads.
Conclusion
To replicate the Temporally Ordered Routing Algorithm (TORA) in NS2 permits you to learn on how this adaptive, multi-path routing protocol acts as in dynamic network settings. TORA is specifically helpful for mobile ad-hoc networks (MANETs) in which the topology changes frequently. By using this script, we need to monitor how TORA adapts to link failures and network changes.
We had successfully executed the Temporally Ordered Routing Algorithm in ns2 environment and it is useful to select the routes in the dynamic environment. Feel free to ask if you want more help with advanced TORA simulations or additional configurations!
At phdprime.com, we have assembled a team of specialists dedicated to simulating Temporally Ordered Routing Projects using the NS2 tool. We invite you to share your project details with us, and we will provide guidance throughout the entire process. Additionally, we offer innovative project ideas and have expertise in distributed routing protocols designed for mobile ad-hoc networks (MANETs).