How to Start XY Routing Projects Using MATLAB

To start XY Routing using MATLAB which is a deterministic routing algorithm that frequently utilised in mesh networks or NoCs (Networks-on-Chip). It transmits packets initially through the X-axis (horizontal) and then sends through Y-axis (vertical). XY routing is simple, deadlock-free, and broadly utilised within grid-based network topologies.

Steps to Start XY Routing Project in MATLAB

  1. Understand XY Routing
  • Routing Rule:
    • Initially, transmit packets horizontally (X-axis) waiting to attain the destination column.
    • Then send vertically (Y-axis) toward the destination row.
  • Topology: Normally it is used in 2D mesh networks.
  • Advantages: Deterministic, deadlock-free and basic execution.
  1. Set Project Objectives
  • Replicate the XY routing within a 2D mesh network for packet delivery.
  • Envision the routing paths.
  • Measure performance parameters such as hop count and routing delay.
  1. Define the Network Topology

We need to denote the network using 2D grid in which every single node contains coordinates (x,y)(x, y)(x,y).

Example: 2D Mesh Topology

% Define network dimensions (e.g., 4×4 mesh)

rows = 4;

cols = 4;

% Create a graph to represent the mesh

G = graph();

% Add nodes

for i = 1:rows

for j = 1:cols

G = addnode(G, sprintf(‘(%d,%d)’, i, j));

end

end

% Add edges for horizontal and vertical connections

for i = 1:rows

for j = 1:cols

if j < cols

G = addedge(G, sprintf(‘(%d,%d)’, i, j), sprintf(‘(%d,%d)’, i, j+1));

end

if i < rows

G = addedge(G, sprintf(‘(%d,%d)’, i, j), sprintf(‘(%d,%d)’, i+1, j));

end

end

end

% Visualize the mesh network

plot(G);

title(‘2D Mesh Network for XY Routing’);

  1. Implement the XY Routing Algorithm

Make a XY routing function for computing the XY route among two nodes according to its coordinates.

MATLAB Implementation:

function path = xyRouting(src, dest)

% Extract coordinates

[srcX, srcY] = deal(src(1), src(2));

[destX, destY] = deal(dest(1), dest(2));

% Initialize the path with the source

path = [src];

% Route along the X-axis

while srcX ~= destX

if srcX < destX

srcX = srcX + 1;

else

srcX = srcX – 1;

end

path = [path; [srcX, srcY]];

end

% Route along the Y-axis

while srcY ~= destY

if srcY < destY

srcY = srcY + 1;

else

srcY = srcY – 1;

end

path = [path; [srcX, srcY]];

end

end

  1. Simulate Routing

Determine the paths among source and a destination nodes to utilise XY routing function.

Example Simulation:

% Define source and destination coordinates

srcNode = [1, 1]; % Top-left corner

destNode = [4, 4]; % Bottom-right corner

% Compute the XY routing path

path = xyRouting(srcNode, destNode);

% Display the routing path

fprintf(‘XY Routing Path from (%d,%d) to (%d,%d):\n’, srcNode, destNode);

disp(path);

  1. Visualize Routing Path

Envision the calculated path on the network graph using MATLAB.

Example:

% Convert path coordinates to node names

pathNodes = arrayfun(@(i) sprintf(‘(%d,%d)’, path(i, 1), path(i, 2)), 1:size(path, 1), ‘UniformOutput’, false);

% Highlight the path

plot(G);

highlight(plot(G), pathNodes, ‘EdgeColor’, ‘r’, ‘LineWidth’, 2);

title(‘XY Routing Path’);

  1. Evaluate Performance

Examine crucial performance parameters such as:

  • Hop Count: Measure the volume of hops within the path that must have length of the path is minus 1.
  • Routing Delay: Evaluate duration according to the fixed delay for each hop.
  • Scalability: Experiment the scale on larger grids.
  1. Extend the Project
  • Dynamic Traffic Simulation: Integrate traffic generation and routing for numerous packets.
  • Fault Tolerance: Change the algorithm for managing node or link failures.
  • Optimization: We need to equate the XY routing including adaptive or load-balanced routing algorithms.

Complete MATLAB Code Example

Below is a comprehensive instance:

% Define network dimensions

rows = 4;

cols = 4;

% Create a graph for the 2D mesh network

G = graph();

% Add nodes

for i = 1:rows

for j = 1:cols

G = addnode(G, sprintf(‘(%d,%d)’, i, j));

end

end

% Add edges

for i = 1:rows

for j = 1:cols

if j < cols

G = addedge(G, sprintf(‘(%d,%d)’, i, j), sprintf(‘(%d,%d)’, i, j+1));

end

if i < rows

G = addedge(G, sprintf(‘(%d,%d)’, i, j), sprintf(‘(%d,%d)’, i+1, j));

end

end

end

% Visualize the mesh network

plot(G);

title(‘2D Mesh Network’);

% XY Routing Function

function path = xyRouting(src, dest)

[srcX, srcY] = deal(src(1), src(2));

[destX, destY] = deal(dest(1), dest(2));

path = [src];

while srcX ~= destX

if srcX < destX

srcX = srcX + 1;

else

srcX = srcX – 1;

end

path = [path; [srcX, srcY]];

end

while srcY ~= destY

if srcY < destY

srcY = srcY + 1;

else

srcY = srcY – 1;

end

path = [path; [srcX, srcY]];

end

end

% Define source and destination

srcNode = [1, 1];

destNode = [4, 4];

% Compute and display the routing path

path = xyRouting(srcNode, destNode);

disp(‘XY Routing Path:’);

disp(path);

% Highlight the routing path on the graph

pathNodes = arrayfun(@(i) sprintf(‘(%d,%d)’, path(i, 1), path(i, 2)), 1:size(path, 1), ‘UniformOutput’, false);

highlight(plot(G), pathNodes, ‘EdgeColor’, ‘r’, ‘LineWidth’, 2);

title(‘XY Routing Path Visualization’);

Conclusion

From this project demonstration, we learnt the simulation process on how to execute and replicate the XY routing for a 2D mesh network using MATLAB. We equipped to extend the fault tolerance or dynamic traffic handling as required.