To simulate an Associative-Based Routing (ABR) in MATLAB, it is a reactive routing protocol modeled for Mobile Ad-hoc Networks (MANETs). The stability of links amongst nodes for finds the optimal routes used by ABR. The stability of a link among two nodes is estimated rely on the time taken, which the link has existed, which stated to as the associativity ticks. The longer a link remains stable, the more probable it is to stay behind the stable in the future that creating it a good applicant for routing.
The main operations of ABR contain:
- Route discovery: Utilizes a broadcast mechanism to find the routes and chooses the most stable paths according to the associativity ticks.
- Route maintenance: Identifies link failures and switches to alternate routes.
- Route erasure: Erases invalid routes once nodes depart of communication range.
Following is an instruction to simulate an ABR protocol project in MATLAB:
Steps to Simulate ABR Protocol in MATLAB
- Define the Network Topology
- Make a network of mobile nodes, describe its locations, and specify their interaction range. The mobility of nodes can be replicated utilizing an arbitrary mobility model such as random waypoint.
Example of defining a mobile ad-hoc network:
numNodes = 10; % Number of mobile nodes
networkArea = 100; % Area size (100×100 meters)
nodePositions = rand(numNodes, 2) * networkArea; % Random positions for nodes
communicationRange = 30; % Communication range (in meters)
% Initialize adjacency matrix to store distances between nodes
adjacencyMatrix = inf(numNodes);
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;
end
end
end
- Initialize Associativity Ticks
- Every single link among the nodes that will have an associated associativity tick value that maximizes with the stability of the link. This tick value shows how long a link has been steady.
Example of initializing associativity ticks:
function assocTicks = initializeAssocTicks(numNodes)
assocTicks = zeros(numNodes); % Associativity ticks matrix
end
assocTicks = initializeAssocTicks(numNodes);
- Update Associativity Ticks
- Associativity ticks maximizes for links, which remain stable (i.e., the nodes stay within communication range) over time. If a link breakdowns due to node mobility then the associativity ticks are reset to zero.
Example of updating associativity ticks:
function assocTicks = updateAssocTicks(adjacencyMatrix, assocTicks)
numNodes = size(adjacencyMatrix, 1);
for i = 1:numNodes
for j = 1:numNodes
if adjacencyMatrix(i,j) < inf
assocTicks(i,j) = assocTicks(i,j) + 1; % Increment associativity tick
else
assocTicks(i,j) = 0; % Reset associativity tick if link breaks
end
end
end
end
% Simulate updating associativity ticks over multiple time steps
numTimeSteps = 20;
for t = 1:numTimeSteps
assocTicks = updateAssocTicks(adjacencyMatrix, assocTicks);
end
- Route Discovery in ABR
- Once a source node requires transmitting data then it introduces route discovery by transmitting a route request (RREQ) to their neighbors. Every single RREQ message encompasses the present associativity ticks, and the destination node chooses the route along with the highest associativity.
Example of route discovery:
function [route, maxAssocTicks] = abrRouteDiscovery(adjacencyMatrix, assocTicks, src, dst)
numNodes = size(adjacencyMatrix, 1);
visited = false(1, numNodes);
queue = src; % Start from the source node
parent = zeros(1, numNodes); % To store the path
assocTickPath = zeros(1, numNodes); % To store associativity ticks along the path
% Breadth-first search (BFS) for route discovery
while ~isempty(queue)
currentNode = queue(1);
queue(1) = []; % Dequeue the current node
visited(currentNode) = true;
if currentNode == dst
% Path found, reconstruct route
route = dst;
maxAssocTicks = assocTickPath(dst);
while parent(currentNode) ~= 0
route = [parent(currentNode), route];
currentNode = parent(currentNode);
maxAssocTicks = max(maxAssocTicks, assocTickPath(currentNode));
end
return;
end
% Explore neighbors
neighbors = find(adjacencyMatrix(currentNode,:) < inf);
for neighbor = neighbors
if ~visited(neighbor)
queue = [queue, neighbor]; % Enqueue the neighbor
parent(neighbor) = currentNode; % Track the path
assocTickPath(neighbor) = max(assocTickPath(currentNode), assocTicks(currentNode, neighbor)); % Track max associativity ticks
end
end
end
route = []; % No route found
maxAssocTicks = 0;
end
- Simulate Route Maintenance
- ABR manages the link failures by executing route maintenance. If a link breakdowns then the protocol attempts to change to an alternative route or causes a new route discovery.
Example of handling route maintenance:
function adjacencyMatrix = simulateLinkFailure(adjacencyMatrix, failedLink)
adjacencyMatrix(failedLink(1), failedLink(2)) = inf;
adjacencyMatrix(failedLink(2), failedLink(1)) = inf;
end
% Example of simulating a link failure between two nodes
failedLink = [2, 3];
adjacencyMatrix = simulateLinkFailure(adjacencyMatrix, failedLink);
- Simulate Data Transmission Using ABR
- When a route is determined then data can be sent along the route. Replicate the process of transmitting information from the origin to the destination utilizing the discovered path.
Example of simulating data transmission:
function transmitData(route)
if isempty(route)
disp(‘No valid route found.’);
else
disp([‘Data transmitted along the route: ‘, num2str(route)]);
end
end
% Example: Simulate data transmission from node 1 to node 7
srcNode = 1;
dstNode = 7;
[route, maxAssocTicks] = abrRouteDiscovery(adjacencyMatrix, assocTicks, srcNode, dstNode);
transmitData(route);
- Evaluate ABR Performance
- We can estimate the protocol’s performance using parameters like average route stability or associativity ticks, number of route discoveries, route length, and packet delivery ratio, after replicating ABR.
Example of calculating the average associativity ticks along the route:
totalAssocTicks = 0;
for i = 1:length(route)-1
totalAssocTicks = totalAssocTicks + assocTicks(route(i), route(i+1));
end
avgAssocTicks = totalAssocTicks / (length(route) – 1);
disp([‘Average associativity ticks along the route: ‘, num2str(avgAssocTicks)]);
- Visualize the Network Topology
- Envision the network topology, nodes, and the discovered routes by using MATLAB’s plotting functions.
Example of visualizing the network and the selected route:
figure;
hold on;
plot(nodePositions(:,1), nodePositions(:,2), ‘bo’); % Plot node positions
% Highlight the selected route
for i = 1:length(route)-1
plot([nodePositions(route(i),1), nodePositions(route(i+1),1)], …
[nodePositions(route(i),2), nodePositions(route(i+1),2)], ‘r-‘, ‘LineWidth’, 2);
end
% Plot communication links
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)], ‘k–‘);
end
end
end
title(‘ABR Protocol: Network Topology and Selected Route’);
hold off;
Conclusion
To replicate the Associative-Based Routing (ABR) Protocol using MATLAB:
- Describe the network topology and make the communication links amongst nodes.
- Introduce associativity ticks that denote the stability of links between nodes.
- Modernize associativity ticks as links among nodes stay behind stable over time.
- Execute the route discovery mechanism in which the source node transmits a route request and chooses the most stable route according to the associativity ticks.
- Manage the route maintenance, identifying and retrieving from link failures.
- Replicate data transmission along the discovered route, and observe its performance.
We had comprehensively explicated the simulation steps along with examples to simulate and visualize the Associative-Based Routing (ABR) protocol projects using MATLAB tool that designed for Mobile Ad-hoc Networks (MANETs). More insights will be inserted in upcoming manual.
Contact us, and we will provide you with the highest quality services. We offer project ideas and conduct performance analyses tailored to your specific areas of interest. Our team at phdprime.com specializes in simulating ABR Protocol projects using MATLAB, focusing on the connection between two nodes and offering expert guidance for your projects.