How to Simulate Wireless Routing Protocol Using MATLAB

To simulate wireless routing protocols in MATLAB has includes to configuring a wireless network of nodes, designing their communication over wireless channels, and executing the certain routing protocol like AODV, DSR, OLSR, etc. These protocols support you to regulate the optimal routes for data packets via a dynamic network with nodes which alter their positions over time such as in MANETs or sensor networks.

Here’s a detailed step-by-step guide to simulating wireless routing protocols in MATLAB:

Steps to Simulate Wireless Routing Protocols in MATLAB

  1. Network Initialization:
  • Describe the amount of nodes, the network area, and modify node positions. All nodes should have a communication range such as transmission range, and the network could be a mobile ad hoc network (MANET) or a wireless sensor network (WSN).

Example:

% Number of nodes in the network

num_nodes = 20;

% Size of the simulation area (100×100 units)

area_size = 100;

% Node transmission range (communication range)

comm_range = 30;

% Randomly generate node positions in the area

nodes = area_size * rand(num_nodes, 2); % Random (x, y) coordinates

% Plot the network topology

scatter(nodes(:, 1), nodes(:, 2), ‘filled’);

xlabel(‘X coordinate’);

ylabel(‘Y coordinate’);

title(‘Wireless Network Topology’);

grid on;

  1. Identify Neighboring Nodes:
  • Estimate the distances among nodes and describe neighbours according to the interaction range. If two nodes are inside the communication range, they are deliberated neighbours.

Example:

% Calculate the distances between all nodes

distances = pdist2(nodes, nodes);

% Create adjacency matrix for node connectivity based on the communication range

adjacency_matrix = distances <= comm_range & distances > 0;

% Visualize the connectivity

hold on;

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

  1. Implement the Routing Protocol:
  2. AODV (Ad hoc On-Demand Distance Vector Routing):

AODV is an on-demand routing protocol in which routes are generated only when required by source nodes. It utilizes RREQ (Route Request) and RREP (Route Reply) messages for route discovery.

Example of simplified AODV route discovery process:

% Source and destination nodes

source = 1;

destination = num_nodes;

% Initialize routing table for each node

routing_table = cell(num_nodes, 1);

routing_table{source} = [source]; % Start with source node

% Route discovery using AODV (simplified)

queue = source;  % Start the queue with the source node

found_route = false;

while ~isempty(queue)

current_node = queue(1); % Dequeue the first node

queue(1) = [];           % Remove the first node from the queue

% Broadcast RREQ to neighbors

for i = 1:num_nodes

if adjacency_matrix(current_node, i) && isempty(routing_table{i})

routing_table{i} = [routing_table{current_node}, i]; % Update route

queue = [queue, i];  % Add the neighbor to the queue

% Check if destination is reached

if i == destination

found_route = true;

break;

end

end

end

if found_route

break;

end

end

% Display the route if found

if found_route

disp(‘Route found:’);

disp(routing_table{destination});

else

disp(‘No route found.’);

end

  1. DSR (Dynamic Source Routing):

DSR is a source routing protocol in which the complete route is contained in the packet header. Route discovery and sustain are same as to AODV however with different mechanisms for managing routes.

  1. OLSR (Optimized Link State Routing):

OLSR is a proactive routing protocol which occasionally interchanges link-state information with neighbours. It sustains the routes even when they are not required instantaneously.

  • For OLSR, we execute periodic HELLO messages to identify neighbours and TC (Topology Control) messages to modernize the routing tables.
  1. Packet Forwarding:
  • As soon as the route has been exposed by using AODV or other protocols, we can replicate packet forwarding from the source node to the destination beside the prioritized route.

Example of forwarding a packet after route discovery:

if found_route

route = routing_table{destination};

fprintf(‘Transmitting data from Node %d to Node %d\n’, source, destination);

for i = 1:length(route) – 1

current_node = route(i);

next_node = route(i + 1);

fprintf(‘Data forwarded from Node %d to Node %d\n’, current_node, next_node);

end

else

disp(‘No route available for data transmission.’);

end

  1. Energy Consumption Model (Optional):
  • For wireless networks, energy consumption is usually a vital parameter, specifically for sensor networks. We can design an energy reduction according to transmission and reception of data packets.

Example energy consumption model:

% Energy parameters

E_tx = 50e-9; % Energy to transmit per bit

E_rx = 50e-9; % Energy to receive per bit

packet_size = 4000; % Packet size in bits

% Initialize energy levels for each node

energy = ones(1, num_nodes);  % Starting energy for each node

% Simulate energy consumption during data transmission

if found_route

for i = 1:length(route) – 1

current_node = route(i);

next_node = route(i + 1);

distance = sqrt(sum((nodes(current_node, 🙂 – nodes(next_node, :)).^2));

% Energy consumption

energy(current_node) = energy(current_node) – E_tx * packet_size * distance;

energy(next_node) = energy(next_node) – E_rx * packet_size;

end

end

  1. Mobility Models (Optional):
  • For mobile ad hoc networks (MANETs), nodes can transmit in the course of the simulation. We can replicate node mobility using a model such as the Random Waypoint Mobility Model.

Example of node mobility:

% Random waypoint mobility model

for i = 1:num_nodes

nodes(i, 🙂 = nodes(i, 🙂 + randn(1, 2);  % Update positions randomly

end

% Recalculate distances and update adjacency matrix

distances = pdist2(nodes, nodes);

adjacency_matrix = distances <= comm_range & distances > 0;

  1. Performance Metrics:
  • Measure the protocol’s performance by evaluating the key parameters:
    • Packet Delivery Ratio: Ratio of successfully delivered packets to the total packets transmitted.
    • End-to-End Delay: The average time taken for a packet to transmit from origin to destination.
    • Throughput: Total number of data successfully delivered over the simulation time.
    • Energy Consumption: Total energy consumed by the nodes in the course of the simulation.
    • Routing Overhead: Amount of control packets routed for route discovery.
  1. Simulate Multiple Rounds (Optional):
  • Execute the replication for multiple rounds with diverse source-destination pairs or dynamic node activities.

Example:

rounds = 100;

for round = 1:rounds

source = randi(num_nodes);

destination = randi(num_nodes);

% Perform route discovery and data transmission

% (Repeat the above steps)

end

Simulating Other Wireless Routing Protocols:

  • ZRP (Zone Routing Protocol):
    • ZRP integrates proactive and reactive methods. Nodes sustains proactive routes in a zone, however utilize on-demand routing for nodes outer the zone.
  • TORA (Temporally Ordered Routing Algorithm):
    • TORA constructs and sustains multiple routes to the destination, concentrates on fast route modernization when topology varies.
  • LEACH (Low-Energy Adaptive Clustering Hierarchy) for WSN:
    • LEACH is an ordered routing protocol for wireless sensor networks in which the nodes are grouped into clusters, and a cluster head is accountable for collecting and routing data to the base station.

As shown above, we provided the detailed complete procedures to simulate the wireless routing protocols project which were simulated and analyse the outcomes using the tool of MATLAB. Additional information with certain details on these wireless routing protocols will be provided in upcoming manual.

To simulate the Wireless Routing Protocol in MATLAB, just email us your project details, and we will assist you in achieving successful results. We assure you of the best project ideas and topics. Our team is experienced in working with routing protocols such as AODV, DSR, OLSR, and more.

Opening Time

9:00am

Lunch Time

12:30pm

Break Time

4:00pm

Closing Time

6:30pm

  • award1
  • award2