How to Start TORA Projects Using NS3
To start TORA (Temporally Ordered Routing Algorithm) projects using NS3, we follow this structured method:
Steps to Start TORA Projects in NS3
- Understand TORA
- TORA Overview:
- TORA is created for Mobile Ad Hoc Networks (MANETs), which is a reactive routing protocol.
- It is distributed and highly adaptive and it concentrates on sustaining the loop-free and several paths to destinations.
- It utilizes directed acyclic graphs (DAGs) for routing.
- Applications:
- It supports for dynamic mobile networks.
- Highly scalable networks including often topology changes.
- Set Up NS3
- Install NS3:
sudo apt update
sudo apt install g++ python3 git cmake
git clone https://gitlab.com/nsnam/ns-3-dev.git
cd ns-3-dev
./waf configure
./waf build
- Verify Installation:
./waf –run scratch/my-first
- TORA in NS3
NS3 environment lacks built-in TORA protocol thus we execute the TORA:
- We can utilise an external TORA module (if available).
- Execute TORA manually by prolonging the NS3’s Ipv4RoutingProtocol.
- Option 1: Use an External TORA Module
- Find a TORA Implementation:
- Look for GitHub or NS3 repositories for TORA modules like NS3-TORA.
- Integrate the Module:
- In the src/ directory, locate the module.
- Modernize the wscript file containing the module:
obj = bld.create_ns3_module(‘tora’, [‘core’, ‘network’, ‘internet’])
-
- Reconstruct NS3:
./waf configure
./waf build
- Use the TORA Protocol in Simulations:
- Set up and install TORA on nodes to utilize the ToraHelper.
Example Code:
#include “ns3/core-module.h”
#include “ns3/network-module.h”
#include “ns3/internet-module.h”
#include “ns3/tora-helper.h”
#include “ns3/point-to-point-module.h”
using namespace ns3;
int main() {
NodeContainer nodes;
nodes.Create(5); // Create 5 nodes
PointToPointHelper pointToPoint;
pointToPoint.SetDeviceAttribute(“DataRate”, StringValue(“10Mbps”));
pointToPoint.SetChannelAttribute(“Delay”, StringValue(“2ms”));
NetDeviceContainer devices1 = pointToPoint.Install(nodes.Get(0), nodes.Get(1));
NetDeviceContainer devices2 = pointToPoint.Install(nodes.Get(1), nodes.Get(2));
NetDeviceContainer devices3 = pointToPoint.Install(nodes.Get(2), nodes.Get(3));
NetDeviceContainer devices4 = pointToPoint.Install(nodes.Get(3), nodes.Get(4));
InternetStackHelper stack;
ToraHelper tora;
stack.SetRoutingHelper(tora); // Use TORA
stack.Install(nodes);
Ipv4AddressHelper address;
address.SetBase(“10.1.1.0”, “255.255.255.0”);
address.Assign(devices1);
address.SetBase(“10.1.2.0”, “255.255.255.0”);
address.Assign(devices2);
address.SetBase(“10.1.3.0”, “255.255.255.0”);
address.Assign(devices3);
address.SetBase(“10.1.4.0”, “255.255.255.0”);
address.Assign(devices4);
Simulator::Run();
Simulator::Destroy();
return 0;
}
- Option 2: Implement TORA from Scratch
Steps:
- Extend Ipv4RoutingProtocol:
- We can execute core TORA functionalities:
- Route creation.
- Route maintenance.
- Route erasure.
- We can execute core TORA functionalities:
- Key Components:
- Directed Acyclic Graphs (DAGs):
- Sustain several loop-free routes using DAGs.
- Route Maintenance:
- Respond to topology modifications by modernizing the DAGs.
- Directed Acyclic Graphs (DAGs):
Skeleton Code:
#include “ns3/ipv4-routing-protocol.h”
namespace ns3 {
class ToraRoutingProtocol : public Ipv4RoutingProtocol {
public:
static TypeId GetTypeId();
ToraRoutingProtocol();
virtual ~ToraRoutingProtocol();
Ptr<Ipv4Route> RouteOutput(Ptr<Packet> packet, const Ipv4Header &header,
Ptr<NetDevice> oif, Socket::SocketErrno &sockerr) override;
bool RouteInput(Ptr<const Packet> packet, const Ipv4Header &header,
Ptr<const NetDevice> idev, UnicastForwardCallback ucb,
MulticastForwardCallback mcb, LocalDeliverCallback lcb,
ErrorCallback ecb) override;
private:
void CreateRoute(uint32_t destination);
void MaintainRoute(uint32_t destination);
void EraseRoute(uint32_t destination);
std::map<uint32_t, uint32_t> routingTable; // Destination -> Next Hop
};
} // namespace ns3
Implement Core Logic:
- Route Creation:
- Make use of query and response messages constructing the DAG.
- According to the DAG, we can set the nodes altitudes.
- Route Maintenance:
- We need to modernize routes depends on the detecting link failures.
- Route Erasure:
- Eliminate invalid routes and then inform neighbors.
- Testing and Debugging
- Enable Logging:
NS_LOG=”ToraRoutingProtocol” ./waf –run tora-simulation
- Verify Routing Behavior:
- Examine the packet flow to utilize .pcap files:
pointToPoint.EnablePcapAll(“tora-simulation”);
- Check Routing Tables: We can print the nodes’ routing tables confirming the structures of DAG.
Throughout the setup, we delivered the step by step procedures with sample coding to simulate and examine the TORA Projects using the NS3 simulation tool. We plan to offer more details in forthcoming manual regarding the TORA projects.
Send us an email to receive the latest project topics in this field. Let us handle your project performance. To initiate TORA (Temporally Ordered Routing Algorithm) projects using NS3, our team will provide you with a comprehensive step-by-step guide to ensure your work is started and simulated on schedule.