How to Implement Temporary Ordered Routing in NS2
To implement the Temporally Ordered Routing Algorithm (TORA) in NS2, we can influence the existing support delivered by the NS2 for TORA routing. TORA is an adaptive, distributed routing protocol mainly utilized in mobile ad-hoc networks (MANETs). It is considered to reduce the reaction to topological changes that creates it appropriate for dynamic environments. For more guidance feel free to approach us we are ready to guide you with best results.
The below is the procedure to implement the TORA in NS2:
Steps to Implement Temporally Ordered Routing Algorithm (TORA) in NS2:
- Install and Set Up NS2
Make sure NS2 is installed and working properly on system.
- Understanding TORA in NS2
NS2 comes with built-in support for TORA, particularly in mobile ad-hoc network (MANET) simulations. TORA uses a directed acyclic graph (DAG) to make sure loop-free multipath routing.
- Modify Tcl Script to Use TORA Routing
To mimic a TORA routing, we need to configure a mobile ad-hoc network in NS2 and specify TORA as the routing protocol. The given Below is an sample of Tcl script to mimic a simple mobile network using TORA.
Example of a Tcl Script for TORA Routing:
# Create a new NS2 simulator instance
set ns [new Simulator]
# Define simulation parameters
set val(chan) Channel/WirelessChannel ;# Channel type
set val(prop) Propagation/TwoRayGround ;# Radio-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 model
set val(x) 500 ;# X dimension of the topography
set val(y) 500 ;# Y dimension of the topography
set val(ifqlen) 50 ;# Max packet in ifq
set val(adhocRouting) TORA ;# Ad-hoc routing protocol (TORA)
set val(nn) 5 ;# Number of mobile nodes
set val(stop) 10.0 ;# Simulation time
# Create the topography object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
# Create a God object (Global node tracking object)
create-god $val(nn)
# Define the nodes
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0 ;# Disable random motion (you can enable mobility)
}
# Define the wireless channel and configure the nodes with wireless settings
$ns node-config -adhocRouting $val(adhocRouting) \
-llType $val(ll) \
-macType $val(mac) \
-ifqType $val(ifq) \
-ifqLen $val(ifqlen) \
-antType $val(ant) \
-propType $val(prop) \
-phyType $val(netif) \
-channelType $val(chan) \
-topoInstance $topo \
-agentTrace ON \
-routerTrace ON \
-macTrace OFF
# Create wireless nodes (Mobile nodes)
for {set i 0} {$i < $val(nn)} {incr i} {
$node_($i) set X_ [expr {int(rand()*$val(x))}]
$node_($i) set Y_ [expr {int(rand()*$val(y))}]
$node_($i) set Z_ 0.0
}
# Create traffic sources (CBR over UDP)
set udp [new Agent/UDP]
set null [new Agent/Null]
set cbr [new Application/Traffic/CBR]
# Attach UDP agents to source and destination
$ns attach-agent $node_(0) $udp
$ns attach-agent $node_(4) $null
$ns connect $udp $null
# Configure CBR traffic
$cbr attach-agent $udp
$cbr set packetSize_ 512
$cbr set interval_ 0.05
# Start the CBR traffic at time 1.0
$ns at 1.0 “$cbr start”
# Define when to stop the simulation
$ns at $val(stop) “finish”
# Procedure to finish the simulation
proc finish {} {
global ns
$ns flush-trace
exec nam out.nam &
exit 0
}
# Execute the simulation
$ns run
- Key Components of the Tcl Script for TORA:
- Simulator Object: The Simulator instance (set ns [new Simulator]) is the core of the simulation environment.
- Channel, Propagation, Network Interface Configurations: The wireless simulation needs to configure the communication channel, propagation model, network interface type, MAC layer type, and so on.
- Nodes: Mobile nodes (n0, n1, n2 …) are generated and placed within the simulation environment. Each node is organized to use the TORA protocol (-adhocRouting TORA).
- Traffic Source: A CBR (Constant Bit Rate) application over UDP creates traffic among the nodes n0 and n4.
- Mobility: In this instance, node positions are static, nevertheless we can add mobility patterns by permitting the random-motion or using mobility models such as the Random Waypoint Mobility Model.
- Run the Simulation
Save the Tcl script and execute it using NS2:
ns tora_simulation.tcl
This will make an output trace file and a NAM file (out.nam) that can be used for analysis.
- Analyse Results
After the simulation executes, we can evaluate the trace file for routing details and visualize the network topology using NAM:
nam out.nam
In NAM, We can track the behaviour of the TORA protocol that has includes on how it reacts to topology changes and how traffic flows via the network.
- Testing TORA’s Adaptive Routing
We can validate TORA’s reaction to network changes like link failures or mobility by describing mobility models or mimicking the network failures. For instance, we need to mimic a link failure among the nodes after some time to monitor on how TORA adapts:
# Simulate a link failure between node 0 and node 1 at time 3.0
$ns at 3.0 “$ns detach-agent $node_(0) $node_(1)”
This will might TORA to adjust and identify an alternate route (if possible) after the link failure.
- TORA’s Features in NS2:
- Multipath routing: TORA handles multiple routes to make sure fault tolerance.
- Adaptively: TORA is intended to manage network changes effectively by adapting the directed acyclic graph (DAG) dynamically.
- Localized updates: TORA tries to localize routing updates, minimizing the overhead of global route recomputation.
Conclusion:
- TORA is already executed in NS2, so we can utilize it by specifying TORA as the routing protocol in Tcl script.
- The routing behaviour can be monitored by executing the simulation and using NAM for visualization or inspecting the trace files for routing decisions.
- We need to mimic numerous network conditions, like node mobility and link failures, to validate the adaptability of TORA.
In the end, we had explored the basic implementation process on how to execute the Temporally-Ordered Routing Algorithm that was mostly used in MANET environment. If you need additional information regarding the TORA we will provide it too.
ns2project.com team presents a variety of project ideas, providing you with unique topics to investigate. We offer tailored assistance for implementing Temporary Ordered Routing in NS2. Don’t hesitate to reach out for further guidance; we are here to help you achieve the best outcomes.