To simulate the Dynamic MANET On-demand (DYMO) that is a reactive routing protocol modeled for mobile ad hoc networks (MANETs). It founds routes on-demand once a source node requires transmitting data to a destination. The DYMO protocol operates by transmitting Route Requests (RREQ) and Route Replies (RREP) to find out routes, and Route Error (RERR) messages when a link failure happens. It distributes the likenesses with AODV however with enhanced route discovery and maintenance mechanisms.
Following is a comprehensive step-by-step instruction to simulate the DYMO protocol in MATLAB:
Steps to Simulate DYMO Protocol in MATLAB
- Define the Network Topology:
- Make a wireless network in which nodes are shared within a provided area. The distances amongst nodes to find whether they can interact directly with each other.
Example:
% Number of nodes in the network
num_nodes = 15;
% Define the size of the simulation area (e.g., 100×100 units)
area_size = 100;
% Randomly generate node positions
nodes = area_size * rand(num_nodes, 2); % Random (x, y) coordinates for nodes
% Define the communication range (e.g., 30 units)
comm_range = 30;
% Plot the network topology
figure;
scatter(nodes(:, 1), nodes(:, 2), ‘filled’);
xlabel(‘X coordinate’);
ylabel(‘Y coordinate’);
title(‘Network Topology for DYMO Simulation’);
grid on;
hold on;
- Create the Adjacency Matrix:
- Find the neighbors for each node according to its distances. If the distance amongst two nodes is not more than the communication range then there is a link between them.
Example:
% Calculate pairwise distances between nodes
distances = pdist2(nodes, nodes);
% Create adjacency matrix based on communication range
adjacency_matrix = distances <= comm_range & distances > 0;
% Plot the links between neighboring nodes
for i = 1:num_nodes
for j = i+1:num_nodes
if adjacency_matrix(i, j)
plot([nodes(i, 1), nodes(j, 1)], [nodes(i, 2), nodes(j, 2)], ‘k–‘);
end
end
end
- Initialize Routing Tables:
- For each node, make a routing table which will store data regarding discovered routes that containing the next hop, destination, and hop count.
Example:
% Initialize the routing table for each node
routing_table = cell(num_nodes, 1);
% Each node’s routing table will store {Destination, Next Hop, Hop Count}
for i = 1:num_nodes
routing_table{i} = {};
end
- Route Discovery Process (RREQ and RREP):
- DYMO sets up routes utilizing Route Request (RREQ) and Route Reply (RREP) messages. Once a source node requires transmitting a packet to a destination however it has no route, it transmits an RREQ. Nodes which receive the RREQ broadcast it until it attains the destination that reacts with an RREP.
Example of Route Discovery:
% Function to handle Route Request (RREQ) and propagate it through the network
function dymo_route_request(source, destination, adjacency_matrix, nodes)
% Queue to store nodes for breadth-first search (BFS)
queue = [source];
visited = zeros(1, num_nodes); % Mark visited nodes
visited(source) = 1;
% Parent structure to reconstruct the path
parent = cell(num_nodes, 1);
while ~isempty(queue)
current_node = queue(1); % Dequeue the first node
queue(1) = [];
% Get neighbors of the current node
neighbors = find(adjacency_matrix(current_node, :));
for i = 1:length(neighbors)
next_node = neighbors(i);
if ~visited(next_node)
visited(next_node) = 1;
queue = [queue, next_node]; % Enqueue the neighbor
% Record the parent node for path reconstruction
parent{next_node} = current_node;
% If destination is reached, send Route Reply (RREP)
if next_node == destination
fprintf(‘Route Reply (RREP): Path found from %d to %d\n’, source, destination);
% Reconstruct the path
path = [];
current = destination;
hop_count = 0;
while current ~= source
hop_count = hop_count + 1;
path = [current, path]; % Add current node to the path
prev_node = parent{current};
update_routing_table(prev_node, destination, current, hop_count);
current = prev_node;
end
path = [source, path]; % Add source to the path
disp([‘Path: ‘, num2str(path)]);
return;
end
end
end
end
end
% Function to update the routing table of a node
function update_routing_table(node, destination, next_hop, hop_count)
if isempty(routing_table{node})
routing_table{node} = {destination, next_hop, hop_count};
else
% Check if destination already exists, and update if the new path is shorter
for j = 1:size(routing_table{node}, 1)
if routing_table{node}{j, 1} == destination
if routing_table{node}{j, 3} > hop_count
routing_table{node}{j, 2} = next_hop;
routing_table{node}{j, 3} = hop_count;
end
return;
end
end
% Add new entry if destination does not exist in the table
routing_table{node} = [routing_table{node}; {destination, next_hop, hop_count}];
end
end
% Example: Perform route discovery from Node 1 to Node 10
dymo_route_request(1, 10, adjacency_matrix, nodes);
- Route Maintenance (Handling Link Breaks):
- If a link breaks even though packets are being sent then the node identifying the break transmits a Route Error (RERR) message again to the origin to inform it of the route failure. The source node can then try to discover a new route.
Example of Handling Link Breaks:
% Function to handle route error (RERR)
function handle_route_error(node, destination)
% Remove the broken route from the routing table
for i = 1:size(routing_table{node}, 1)
if routing_table{node}{i, 1} == destination
routing_table{node}(i, 🙂 = [];
fprintf(‘Route Error (RERR): Broken route from Node %d to Node %d\n’, node, destination);
break;
end
end
end
% Simulate a link break between Node 2 and Node 3
adjacency_matrix(2, 3) = 0;
adjacency_matrix(3, 2) = 0;
handle_route_error(2, 3);
- Packet Forwarding:
- When the routes are founded then packets can be sent from the source to the destination utilising the data within the routing tables.
Example of Packet Forwarding:
% Function to forward a packet from source to destination using routing table
function forward_packet(source, destination)
current_node = source;
% Continue forwarding until the destination is reached
while current_node ~= destination
% Check the routing table for the next hop
next_hop_entry = routing_table{current_node};
if isempty(next_hop_entry)
fprintf(‘No route found from Node %d to Node %d\n’, current_node, destination);
return;
end
% Select the next hop (simplified to choose the first entry)
next_hop = next_hop_entry{1, 2};
fprintf(‘Packet forwarded from Node %d to Node %d\n’, current_node, next_hop);
% Move to the next node
current_node = next_hop;
end
fprintf(‘Packet successfully delivered from Node %d to Node %d\n’, source, destination);
end
% Example of forwarding a packet from Node 1 to Node 10
forward_packet(1, 10);
- Simulate Multiple Packet Flows:
- We can replicate numerous packet flows among diverse source-destination pairs to monitor the DYMO protocol’s behaviour under several conditions.
Example:
% Simulate multiple flows
num_flows = 5;
for flow = 1:num_flows
% Randomly select source and destination nodes
source_node = randi(num_nodes);
destination_node = randi(num_nodes);
fprintf(‘Flow %d: Forwarding packet from Node %d to Node %d\n’, flow, source_node, destination_node);
% Perform route discovery
dymo_route_request(source_node, destination_node, adjacency_matrix, nodes);
% Forward the packet after route discovery
forward_packet(source_node, destination_node);
end
- Performance Metrics:
- We can estimate numerous performance parameters, like:
- Packet Delivery Ratio (PDR): Ratio of effectively delivered packets to total packets transmitted.
- End-to-End Delay: Duration for a packet to attain the destination.
- Routing Overhead: Amount of control messages such as RREQ, RREP, and RERR swapped.
Example of calculating end-to-end delay:
% Define hop delay (e.g., 2 ms per hop)
hop_delay = 0.002; % Example value in seconds
% Example hop count for a route
hop_count = 4; % Number of hops
% Calculate the total end-to-end delay
total_delay = hop_count * hop_delay;
fprintf(‘End-to-End Delay: %.4f seconds\n’, total_delay);
Conclusion:
This procedure delivers a framework for replicating DYMO (Dynamic MANET On-demand) protocol using MATLAB. The DYMO protocol is a reactive routing protocol, which finds routes on-demand with the help of RREQ and RREP messages, sustains routes utilizing routing tables, and manages the route errors via RERR messages.
Crucial steps contain:
- Describing the network topology and adjacency matrix.
- Executing route discovery using RREQ and RREP.
- Managing link failures with RERR.
- Replicating the packet sending among source and destination.
This project walks you through the simulations of DYMO protocol projects using MATLAB helping you explore numerous contexts of this protocol. We plan to deliver the detailed guidelines on this topic in further manual.
It will be quite hard to Simulate DYMO Protocol Projects Using MATLAB tool stay in touch with phdprime.com, all you have to do is send us all your research details by mail we will give you best guidance.