To simulate a Star Topology in MATLAB has includes to generating a network in which a network model where a central hub associates multiple peripheral nodes (clients). In this set up, each peripheral node interacts via the central hub instead of directly with other nodes. Star topologies are usual in wireless and wired networks in which a single access point handles traffic.
Here’s a step-by-step approach to replicate and envision a star topology network in MATLAB:
Steps to Simulate a Star Topology in MATLAB
- Define the Network Topology
- Configure a central node by way of the hub and associate multiple peripheral nodes to it.
- Describe communication paths from each peripheral node to the hub.
- Simulate Data Transmission
- Enable each peripheral node to transmit data to the hub.
- Replicate communication latency and potential data loss to measure the performance.
- Visualize the Topology
- Shows the nodes and their association in a star layout with the hub at the center.
- Evaluate Performance Metrics
- Evaluate the parameters such as throughput, latency, and packet loss for each node-to-hub connection.
Example MATLAB Code for Simulating a Star Topology
The following MATLAB script replicates a star topology with a central hub and multiple nodes that interacts with it.
% Parameters
numNodes = 6; % Number of peripheral nodes
hubNodePosition = [0, 0]; % Position of the central hub at the origin
radius = 10; % Distance of peripheral nodes from the hub
dataPackets = randi([1, 100], numNodes, 1); % Data packets each node wants to send
transmissionDelay = 1; % Fixed delay for each transmission (in seconds)
% Calculate positions of peripheral nodes in a circular layout
theta = linspace(0, 2*pi, numNodes+1); % Equally spaced angles for node placement
theta(end) = []; % Remove duplicate angle at 2*pi
% Calculate (x, y) coordinates for each peripheral node
nodePositions = [radius * cos(theta)’, radius * sin(theta)’];
% Plot the star topology
figure;
hold on;
plot(hubNodePosition(1), hubNodePosition(2), ‘ro’, ‘MarkerSize’, 8, ‘DisplayName’, ‘Hub Node’); % Hub node
for i = 1:numNodes
plot(nodePositions(i,1), nodePositions(i,2), ‘bo’, ‘MarkerSize’, 6, ‘DisplayName’, [‘Node ‘, num2str(i)]);
plot([hubNodePosition(1), nodePositions(i,1)], [hubNodePosition(2), nodePositions(i,2)], ‘k–‘); % Link to hub
end
legend(‘Hub Node’, ‘Peripheral Nodes’);
title(‘Star Topology Network’);
xlabel(‘X Position’);
ylabel(‘Y Position’);
grid on;
axis equal;
hold off;
% Step 1: Simulate Data Transmission
disp(‘Data Transmission Simulation:’);
for i = 1:numNodes
fprintf(‘Node %d sends %d packets to the hub…\n’, i, dataPackets(i));
pause(transmissionDelay); % Simulate delay for each transmission
fprintf(‘Hub received data from Node %d\n’, i);
end
% Step 2: Display Network Metrics (Example: Total Data Received by Hub)
totalData = sum(dataPackets);
disp([‘Total data received by the hub: ‘, num2str(totalData), ‘ packets’]);
Explanation of Code
- Node Setup:
- The central hub node is placed at the origin ([0, 0]).
- The peripheral nodes are organised in a circular layout around the hub with equal spacing, by utilizing polar coordinates for simplicity.
- Topology Visualization:
- Each peripheral node is designed and associated to the hub with dashed lines to illustrate the star topology structure.
- Data Transmission Simulation:
- Each node sends a certain amount of data packets to the hub. The pause function establishes a latency to replicate transmission time.
- After each transmission, a message is shows to signify which the hub has received data from that node.
- Performance Metrics:
- The instance estimates the amount of data received by the hub from all peripheral nodes. We can extend this by incorporating more detailed parameters, such as packet delay and throughput.
Extending the Simulation
- Variable Transmission Delays:
- Allocate random transmission latency to each node to replicate realistic network conditions with wide-ranging delay.
- Packet Loss Simulation:
- Establish a probability of packet loss for each transmission to learn network flexibility in lossy scenarios.
- Bidirectional Communication:
- Enable the hub to transmit responses to peripheral nodes to mimic two-way communication.
- Dynamic Network Changes:
- Incorporate or eliminate nodes in the course of the simulation to learn the impacts of topology variation.
Visualization Enhancements
To improve envision, we can animate the transmission method by focussing the nodes and links which are actively routing data.
% Animate data transmission from each node to the hub
figure;
hold on;
plot(hubNodePosition(1), hubNodePosition(2), ‘ro’, ‘MarkerSize’, 8, ‘DisplayName’, ‘Hub Node’); % Hub node
for i = 1:numNodes
plot(nodePositions(i,1), nodePositions(i,2), ‘bo’, ‘MarkerSize’, 6, ‘DisplayName’, [‘Node ‘, num2str(i)]);
plot([hubNodePosition(1), nodePositions(i,1)], [hubNodePosition(2), nodePositions(i,2)], ‘k–‘); % Link to hub
end
title(‘Star Topology Network’);
xlabel(‘X Position’);
ylabel(‘Y Position’);
grid on;
axis equal;
hold off;
for i = 1:numNodes
line([hubNodePosition(1), nodePositions(i,1)], [hubNodePosition(2), nodePositions(i,2)], ‘Color’, ‘g’, ‘LineWidth’, 2);
pause(transmissionDelay); % Simulate transmission delay
line([hubNodePosition(1), nodePositions(i,1)], [hubNodePosition(2), nodePositions(i,2)], ‘Color’, ‘k’, ‘LineWidth’, 1, ‘LineStyle’, ‘–‘);
end
From the demonstration, we illustrate the complete simulation setup that will help you to execute and simulate the Star Topology projects using MATLAB tool and also we provide the procedures, example snippets and their explanation. If you need to know more details regarding this process we will provide it. We guarantee optimal simulation outcomes and project efficiency. phdprime.com specializes in Star Topology Projects utilizing MATLAB. Should you require tailored simulation concepts, do not hesitate to reach out for valuable