To simulate the Mobile Ad-Hoc Networks (MANETs) using MATLAB which has encompasses to design the nodes that are mobile and interact wirelessly without a fixed infrastructure. MANETs are categorized by dynamic topologies in which nodes can connect and exit the network that creating the routing and data transmission challenging. MATLAB tool offers a platform to replicate the node mobility, wireless channels, routing protocols, and network performance parameters. Below is process to simulating MANET projects using MATLAB:
Steps to Simulate MANET Projects in MATLAB
- Define Network Topology
In a MANET, nodes are mobile and can shift arbitrary. We require describing the amount of nodes, its starting positions, and the area where they move.
Example: Describe a MANET with 10 mobile nodes.
% Parameters
numNodes = 10; % Number of nodes
areaSize = 500; % Area size in meters (500m x 500m)
maxSpeed = 10; % Maximum node speed in m/s
simulationTime = 100; % Total simulation time in seconds
% Randomly initialize node positions and velocities
nodePositions = areaSize * rand(numNodes, 2);
nodeVelocities = maxSpeed * (rand(numNodes, 2) – 0.5); % Random velocities for each node
% Plot initial positions of nodes
figure;
scatter(nodePositions(:,1), nodePositions(:,2), ‘bo’, ‘filled’);
title(‘Initial MANET Node Positions’);
xlabel(‘X Position (m)’);
ylabel(‘Y Position (m)’);
axis([0 areaSize 0 areaSize]);
- Simulate Node Mobility
In MANETs, nodes are mobile and their locations are modifying over time. We can mimic arbitrary mobility patterns with the support of models like the Random Waypoint Model.
Example: Replicate random node mobility over time.
% Simulation parameters
timeStep = 1; % Time step in seconds
positionsOverTime = cell(simulationTime, 1); % Store node positions over time
% Simulate node movement over time
for t = 1:simulationTime
nodePositions = nodePositions + nodeVelocities * timeStep; % Update positions
% Ensure nodes stay within the area
nodePositions = mod(nodePositions, areaSize);
% Store positions for plotting
positionsOverTime{t} = nodePositions;
% Plot current positions
scatter(nodePositions(:,1), nodePositions(:,2), ‘bo’, ‘filled’);
title([‘MANET Node Positions at Time ‘, num2str(t), ‘ seconds’]);
xlabel(‘X Position (m)’);
ylabel(‘Y Position (m)’);
axis([0 areaSize 0 areaSize]);
pause(0.1); % Pause to simulate real-time movement
end
- Model Wireless Communication Between Nodes
Nodes within a MANET interact wirelessly, and the signal strength according to the distance amongst them. We can replicate the communication depends on a basic path loss model.
Example: Compute the received power among nodes using path loss.
% Transmit power and carrier frequency parameters
txPower = 10; % Transmit power in dBm
carrierFrequency = 2.4e9; % Carrier frequency in Hz (e.g., 2.4 GHz for Wi-Fi)
c = 3e8; % Speed of light in m/s
% Calculate distance between node pairs
distances = squareform(pdist(nodePositions));
% Free-space path loss model
pathLoss = 20*log10(distances) + 20*log10(carrierFrequency) – 20*log10(c / (4 * pi));
% Calculate received power for each node pair
rxPower = txPower – pathLoss;
disp(‘Received power between nodes (in dBm):’);
disp(rxPower);
- Implement Routing Protocols
MANETs utilize the dynamic routing protocols such as AODV (Ad-Hoc On-Demand Distance Vector), DSDV (Destination-Sequenced Distance-Vector), and DSR (Dynamic Source Routing). We can replicate the routing by describing how packets are sent among the nodes.
Example: Mimic a basic distance-based routing protocol.
% Select a source and destination node
sourceNode = 1;
destinationNode = 5;
% Find the nearest neighbors of the source node
distancesFromSource = distances(sourceNode, :);
[~, nearestNeighbor] = min(distancesFromSource(2:end));
% Display the selected route (source -> nearest neighbor -> destination)
disp([‘Route: Source (Node ‘, num2str(sourceNode), ‘) -> Nearest Neighbor (Node ‘, num2str(nearestNeighbor), ‘) -> Destination (Node ‘, num2str(destinationNode), ‘)’]);
- Simulate Data Transmission
In MANETs, nodes are sending data packets to each other. We can replicate the transmission and reception of data packets among the nodes, which containing delays and potential packet loss.
Example: Replicate the packet transmission among two nodes.
% Define packet size and transmission delay
packetSize = 1024; % Packet size in bytes
transmissionTime = 0.01; % Time to transmit one packet in seconds
% Simulate packet transmission from source to destination via nearest neighbor
disp([‘Node ‘, num2str(sourceNode), ‘ is transmitting data to Node ‘, num2str(nearestNeighbor)]);
pause(transmissionTime); % Simulate transmission time
disp([‘Node ‘, num2str(nearestNeighbor), ‘ is forwarding data to Node ‘, num2str(destinationNode)]);
pause(transmissionTime); % Simulate transmission time
disp(‘Data received by destination node.’);
- Model Energy Consumption
Nodes within a MANET are frequently battery-powered that creating an energy efficiency a crucial concern. We can replicate energy consumption depends on the amount of packets are sent and received.
Example: Replicate energy consumption for the period of data transmission.
% Energy consumption parameters
txPowerWatts = 10^(txPower / 10) / 1000; % Convert dBm to watts
dataRate = 1e6; % Data rate in bits per second (1 Mbps)
% Calculate energy consumption per packet
energyPerPacket = (packetSize * 8) / dataRate * txPowerWatts; % Energy in joules
totalEnergy = energyPerPacket * 2; % For both transmission and forwarding
disp([‘Total energy consumed during transmission: ‘, num2str(totalEnergy), ‘ joules’]);
- Measure Network Performance Metrics
In MANET simulations, the key performance parameters such as throughput, delay, packet delivery ratio (PDR), and energy consumption for estimating network performance.
Example: Evaluate the throughput and packet delivery ratio.
% Parameters for performance metrics
numPackets = 50; % Total number of packets sent
packetsReceived = numPackets – randi([0 10]); % Random packet losses
% Calculate throughput (in bits per second)
throughput = (packetsReceived * packetSize * 8) / (numPackets * transmissionTime);
disp([‘Throughput: ‘, num2str(throughput), ‘ bps’]);
% Calculate packet delivery ratio (PDR)
pdr = packetsReceived / numPackets;
disp([‘Packet Delivery Ratio (PDR): ‘, num2str(pdr * 100), ‘%’]);
- Advanced MANET Simulations
For more difficult MANET projects, we can discover:
- Mobility Models: Utilize the advanced mobility models such as Random Waypoint, Gauss-Markov, or Manhattan Grid to replicate the node movement.
- Routing Protocols: Execute and relate diverse routing protocols like AODV, DSR, and OLSR.
- Security in MANETs: Replicate the security mechanisms for secure information transmission and attack mitigation such as blackhole attacks.
- QoS (Quality of Service): Design MANETs with particular QoS requests for real-time applications.
We have thoroughly offered the entire structured steps on how to simulate and execute the MANET projects and how to measure its performance parameters then we provided their advanced simulations using the MATLAB tool. Additional information will be delivered as per your requirements.