To simulate Temporally-Ordered Routing Algorithm (TORA) in MATLAB has includes to generating a network design and executing its key operations that are route creation, route maintenance, and route erasure.it is basically a reactive routing protocol modelled for highly dynamic mobile ad hoc networks (MANETs). TORA is concentrated on reducing response to topological variation by sustaining multiple paths to the destination and only responding when all paths are gone astray.
Below is an approach on how to simulate the TORA in MATLAB:
Steps to Simulate TORA Protocol in MATLAB
- Define the Network Topology
- TORA functions on a network of nodes like routers that are connected. The nodes are located arbitrarily in a 2D space, and communication links among them are distinct by a communication range.
Example of defining network nodes and their connections:
numNodes = 10; % Number of nodes
networkArea = 100; % Define network area size (100×100)
nodePositions = rand(numNodes, 2) * networkArea; % Randomly assign node positions
communicationRange = 30; % Define communication range for links
adjacencyMatrix = inf(numNodes); % Initialize adjacency matrix with infinity
% Establish communication links based on distance within the range
for i = 1:numNodes
for j = i+1:numNodes
distance = norm(nodePositions(i,:) – nodePositions(j,:));
if distance <= communicationRange
adjacencyMatrix(i,j) = distance;
adjacencyMatrix(j,i) = distance; % Symmetric links
end
end
end
- Implement Route Creation
- In TORA, the route making process that includes to configure a height parameter for each node. The source node propagates a route creation request, and all nodes update its height according to the height of its neighbours.
- TORA utilizes the height metric to signify the way of flow from higher to lower nodes.
Example of initializing height values:
function heights = initializeHeights(numNodes, destination)
heights = inf(1, numNodes); % Initialize heights with infinity (unknown)
heights(destination) = 0; % Set destination node’s height to 0
end
The route creation process:
function heights = routeCreation(adjacencyMatrix, heights, source, destination)
numNodes = size(adjacencyMatrix, 1);
visited = false(1, numNodes);
queue = [source]; % Start from the source node
while ~isempty(queue)
currentNode = queue(1);
queue(1) = []; % Dequeue the current node
visited(currentNode) = true;
neighbors = find(adjacencyMatrix(currentNode,:) < inf); % Find neighbors
for neighbor = neighbors
if ~visited(neighbor)
queue = [queue, neighbor]; % Enqueue the neighbor
% Update height only if it’s larger than current + link cost
if heights(neighbor) > heights(currentNode) + adjacencyMatrix(currentNode, neighbor)
heights(neighbor) = heights(currentNode) + adjacencyMatrix(currentNode, neighbor);
end
end
end
end
end
- Implement Route Maintenance
- Route maintenance in TORA is act as by modifying the heights of nodes when there is a link failure. This supports to sustain alternative paths or re-establish a route if the previous one fails.
Example of maintaining the route after a link failure:
function heights = routeMaintenance(adjacencyMatrix, heights, failedNode)
% Route maintenance triggered when a link failure is detected
numNodes = size(adjacencyMatrix, 1);
% Set the height of the failed node to infinity (unreachable)
heights(failedNode) = inf;
neighbors = find(adjacencyMatrix(failedNode,:) < inf);
% Recalculate the height for each neighbor
for neighbor = neighbors
% Find the lowest available height among the neighbors
minNeighborHeight = min(heights(neighbors) + adjacencyMatrix(neighbors, neighbor));
if heights(neighbor) > minNeighborHeight
heights(neighbor) = minNeighborHeight;
end
end
end
- Implement Route Erasure
- When a node identifies which each path to the destination is gone astray, it begins a route erasure instruction by broadcasting an erasure message, signify that the route is no longer usable.
Example of route erasure process:
function heights = routeErasure(heights, failedNode)
% Set the height of the failed node to infinity
heights(failedNode) = inf;
% Propagate the erasure to its neighbors
neighbors = find(heights < inf);
for neighbor = neighbors
heights(neighbor) = inf; % Erase routes of all neighbors connected to failed node
end
end
- Simulate Data Transmission
- Data transmission follows the way of decreasing height (from high to low). The packet moves from the origin node to the destination node according to the height values.
Example of simulating data transmission:
function path = dataTransmission(heights, adjacencyMatrix, src, dst)
path = [src];
currentNode = src;
while currentNode ~= dst
neighbors = find(adjacencyMatrix(currentNode,:) < inf);
% Find the neighbor with the lowest height
[~, idx] = min(heights(neighbors));
nextNode = neighbors(idx);
if isempty(nextNode) || isinf(heights(nextNode))
disp(‘No valid path found’);
path = [];
return;
end
path = [path, nextNode]; % Add the next node to the path
currentNode = nextNode; % Move to the next node
end
end
% Example: transmitting data from node 1 to node 10
srcNode = 1;
dstNode = 10;
path = dataTransmission(heights, adjacencyMatrix, srcNode, dstNode);
disp([‘Data transmission path: ‘, num2str(path)]);
- Evaluate Performance Metrics
- After replicating TORA, we can measure numerous key metrics such as route discovery time, average path length, packet delivery ratio, and network throughput.
Example of calculating the average path length:
totalPathLength = 0;
pathCount = 0;
for i = 1:numNodes
for j = i+1:numNodes
if i ~= j
path = dataTransmission(heights, adjacencyMatrix, i, j);
if ~isempty(path)
totalPathLength = totalPathLength + length(path);
pathCount = pathCount + 1;
end
end
end
end
avgPathLength = totalPathLength / pathCount;
disp([‘Average path length: ‘, num2str(avgPathLength)]);
- Visualize the Network Topology
- Envision the network topology and the routing paths using MATLAB’s plotting tools.
Example of visualizing the network:
figure;
plot(nodePositions(:,1), nodePositions(:,2), ‘bo’); % Plot nodes
hold on;
for i = 1:numNodes
for j = i+1:numNodes
if adjacencyMatrix(i,j) < inf
plot([nodePositions(i,1), nodePositions(j,1)], [nodePositions(i,2), nodePositions(j,2)], ‘r-‘);
end
end
end
title(‘TORA Network Topology’);
Conclusion
To replicate the TORA protocol in MATLAB:
- Describe the network topology by insertion nodes and describing communication links.
- Execute route creation by configuring the height values for the nodes.
- Execute route maintenance to manage link failures and modify heights.
- Execute route removal when all paths to a destination are gone astray.
- Replicate data transmission according to the height metric.
- Measure performance with parameters such as average path length and packet delivery ratio.
- Envision the network and the routes taken in the period of data transmission.
Through this demonstration, we have completely delivered the steps which are essential for the implementation of Temporally-Ordered Routing Algorithm within the simulated environment using MATLAB tool. We will offer the additional details regarding this process in the manual.
To initiate the simulation of TORA Protocol Projects in MATLAB, please email us your project details. We will provide you with guidance to ensure successful results. We guarantee you access to the best project ideas and topics.