How to Develop TORA Projects Using NS3

To develop the TORA (Temporally Ordered Routing Algorithm) involves the NS3. The Temporally Ordered Routing Algorithm (TORA) is reactive, adaptive, and distributed routing protocol planned for mobile ad-hoc networks (MANETs). It uses a link reversal mechanism to handle network topology changes dynamically.

Steps to Develop TORA Projects Using NS3

  1. Install NS3

We assure the tool like NS3 is installed before proceeding:

sudo apt update

sudo apt install git g++ python3 cmake make

git clone

cd ns-3-dev

./ns3 configure –enable-examples –enable-tests

./ns3 build

  1. Define Network Topology for TORA

We execute the TORA; we build a wireless ad-hoc network (MANET) and ensure for TORA-based routing.

Example: Implementing TORA in NS3

#include “ns3/core-module.h”

#include “ns3/network-module.h”

#include “ns3/internet-module.h”

#include “ns3/mobility-module.h”

#include “ns3/yans-wifi-helper.h”

#include “ns3/tora-helper.h”

#include “ns3/applications-module.h”

using namespace ns3;

NS_LOG_COMPONENT_DEFINE(“TORARoutingExample”);

int main(int argc, char *argv[])

{

uint32_t numNodes = 10;

double simulationTime = 10.0;

CommandLine cmd;

cmd.AddValue(“numNodes”, “Number of nodes in the network”, numNodes);

cmd.Parse(argc, argv);

NodeContainer nodes;

nodes.Create(numNodes);

// Set up mobility model (Random Waypoint)

MobilityHelper mobility;

mobility.SetPositionAllocator(“ns3::RandomRectanglePositionAllocator”,

“X”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=100.0]”),

“Y”, StringValue(“ns3::UniformRandomVariable[Min=0.0|Max=100.0]”));

mobility.SetMobilityModel(“ns3::RandomWaypointMobilityModel”,

“Speed”, StringValue(“ns3::UniformRandomVariable[Min=5.0|Max=10.0]”),

“Pause”, StringValue(“ns3::ConstantRandomVariable[Constant=2.0]”));

mobility.Install(nodes);

// Set up WiFi communication

WifiHelper wifi;

YansWifiPhyHelper wifiPhy = YansWifiPhyHelper::Default();

YansWifiChannelHelper wifiChannel = YansWifiChannelHelper::Default();

wifiPhy.SetChannel(wifiChannel.Create());

WifiMacHelper wifiMac;

wifiMac.SetType(“ns3::AdhocWifiMac”);

NetDeviceContainer devices = wifi.Install(wifiPhy, wifiMac, nodes);

// Install Internet stack and enable TORA routing

InternetStackHelper internet;

ToraHelper tora;

internet.SetRoutingHelper(tora);

internet.Install(nodes);

// Assign IP Addresses

Ipv4AddressHelper address;

address.SetBase(“10.1.1.0”, “255.255.255.0”);

address.Assign(devices);

// Set up UDP traffic

uint16_t port = 8080;

UdpServerHelper server(port);

ApplicationContainer serverApp = server.Install(nodes.Get(numNodes – 1)); // Last node as destination

serverApp.Start(Seconds(1.0));

serverApp.Stop(Seconds(simulationTime));

UdpClientHelper client(Ipv4Address(“10.1.1.10”), port);

client.SetAttribute(“MaxPackets”, UintegerValue(1000));

client.SetAttribute(“Interval”, TimeValue(Seconds(0.1)));

client.SetAttribute(“PacketSize”, UintegerValue(1024));

ApplicationContainer clientApp = client.Install(nodes.Get(0)); // First node as source

clientApp.Start(Seconds(2.0));

clientApp.Stop(Seconds(simulationTime));

Simulator::Stop(Seconds(simulationTime));

Simulator::Run();

Simulator::Destroy();

return 0;

}

  1. Explanation of the Code
  • Configure the Network
    • The 10 mobile nodes are using a Random Waypoint Mobility Model.
    • WiFi Ad-Hoc network for communication.
  • TORA Routing
    • Dynamically updates routes terms on network variations.
    • We utilized the link reversal after a node for identifies the route failures.
  • Traffic Generation
    • The UDP congestion from Node 0 to Node 9.
    • Reactive route discovery terms on network demand.
  1. Run the Simulation

Compile and apply the estimation process in TORA:

./ns3 run tora-routing

  1. Performance Analysis

For examine the outcomes for performance of parameter metrices such as Throughput, Packet Delivery Ratio (PDR), and Delay, use FlowMonitor.

Enable FlowMonitor for TORA Traffic Analysis

#include “ns3/flow-monitor-module.h”

FlowMonitorHelper flowmon;

Ptr<FlowMonitor> monitor = flowmon.InstallAll();

Simulator::Stop(Seconds(10.0));

Simulator::Run();

monitor->SerializeToXmlFile(“tora_results.xml”, true, true);

Simulator::Destroy();

  1. Extend with VANET Simulation

For VANET applications, adjust the mobility model to used SUMO or NS3’s Vehicle Mobility Model.

Example: Implementing TORA in VANET

mobility.SetMobilityModel(“ns3::SteadyStateRandomWaypointMobilityModel”,

“MinSpeed”, DoubleValue(5.0),

“MaxSpeed”, DoubleValue(30.0),

“Bounds”, RectangleValue(Rectangle(-500, 500, -500, 500)));

mobility.Install(nodes);

  1. Advantages of TORA Routing

Highly Adaptive: Appropriate for change the network topologies such as MANETs and VANETs.

Loop-Free Routing: It used a DAG (Directed Acyclic Graph) method.

Multi-Path Routing: We enhance the fault tolerance and load balancing.

In this entire page we had understand the concepts on how the TORA perform in ns3 tool and also we can gain knowledge on how to install ns3 and then how it create the simulation for Wireless ad-hoc network (MANET) subsequently we know how to run the simulation. If you have any doubts regarding this process kindly let me know!