How to Implement on TORA Protocol in NS2
To implement the Temporally-Ordered Routing Algorithm (TORA) in Network Simulator 2 (NS2) has needs to simulate the network to utilize the TORA that is reactive routing protocol intended for mobile ad hoc networks (MANETs). The TORA concentrates on delivering the loop-free, multi-path routes to destinations and is highly adaptive to network topology changes. The given below are the procedures to execute the TORA protocol in ns2:
Step-by-Step Guide to Implement TORA in NS2
Step 1: Install NS2
Make sure NS2 is installed on system.
Step 2: Create a Simulation Script
Generate a Tcl script to setup the network and mimic the routing using the TORA protocol.
- Create a New Tcl Script: Open a text editor and generate a new file, for instance, tora_example.tcl.
- Set Up the Simulation Environment: Describe the simulator, configure the network topology, and setup the metrics specific to the simulation.
# Create a simulator object
set ns [new Simulator]
# Define options for the simulation
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(ifqlen) 50 ;# Max packet in ifq
set val(nn) 10 ;# Number of mobile nodes
set val(rp) TORA ;# Routing Protocol (TORA)
set val(x) 500 ;# X dimension of topography
set val(y) 500 ;# Y dimension of topography
set val(stop) 10.0 ;# Simulation time
# Initialize the topology object
set topo [new Topography]
$topo load_flatgrid $val(x) $val(y)
# Create the God object
create-god $val(nn)
# Configure the nodes
$ns node-config -adhocRouting $val(rp) \
-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 ON \
-movementTrace ON
# Create nodes
for {set i 0} {$i < $val(nn)} {incr i} {
set node_($i) [$ns node]
$node_($i) random-motion 0
}
# Define node movement (Optional for mobile nodes)
$node_(0) set X_ 50.0
$node_(0) set Y_ 50.0
$node_(0) set Z_ 0.0
$node_(1) set X_ 150.0
$node_(1) set Y_ 100.0
$node_(1) set Z_ 0.0
# (Add more nodes and positions as needed)
- Setup traffic sources:
# Setup a UDP agent and attach it to node 0
set udp [new Agent/UDP]
$ns attach-agent $node_(0) $udp
# Setup CBR (Constant Bit Rate) application to generate traffic
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_ 512
$cbr set interval_ 0.1
$cbr start
# Setup a Null agent (sink) on node 1
set null [new Agent/Null]
$ns attach-agent $node_(1) $null
# Connect the agents
$ns connect $udp $null
- Setup simulation end:
# Define simulation end time
$ns at $val(stop) “stop”
$ns at $val(stop) “$ns nam-end-wireless $val(stop)”
$ns at $val(stop) “exit 0”
proc stop {} {
global ns tracefile namfile
$ns flush-trace
close $tracefile
close $namfile
}
# Run the simulation
$ns run
Step 3: Run the Simulation
- Save the Tcl script (tora_example.tcl).
- Open a terminal and navigate to the directory in which we saved the Tcl script.
- Execute the simulation using the following command:
ns tora_example.tcl
This command will produce the trace files and optionally a network animation file (if enabled in script).
Step 4: Analyse the Results
Use trace files and the network animator (NAM) to evaluate the performance of the TORA protocol concentrates on parameters like route discovery time, packet delivery ratio, and network overhead.
Step 5: Visualize the Results (Optional)
If we have permitted the network animator (NAM) in the script, we can visualize the simulation:
nam tora_example.nam
This will open the NAM window, in which we can see the network topology and the characteristics of the TORA protocol during the simulation.
Additional Considerations
- Mobility: Validate TORA in numerous mobility scenarios to see how it manages the dynamic topologies.
- Network Size: changing the number of nodes to monitor on how TORA scales.
- Traffic Patterns: Test with diverse traffic patterns like CBR, FTP, and TCP to see how TORA performs in diverse conditions.
- Performance Metrics: Evaluate and relate the performance of TORA in terms of delay, packet delivery ratio, routing overhead, and energy consumption.
In the end, we had explored the basic implementation process on how to execute the Temporally-Ordered Routing Algorithm that handles to estimate the multi-path routes in the network. If you need additional information regarding the TORA we will provide it too.
For the finest TORA Protocol implementation in NS2, we offer you expert guidance and exemplary results. Reach out to us for bespoke services tailored to your needs. Discover exceptional research ideas on TORA in NS2 at ns2project.com.