Main Content

Visualize Node State Transitions in 802.11ax System-Level Simulation

WLAN Toolbox™ features enable you to visualize the time spent by a node in each state in a WLAN system-level simulation. Using this example, you can:

  • Create and configure a four-node 802.11ax™ network consisting of two access points (APs) and two stations (STAs).

  • Simulate the network by configuring uplink and downlink traffic.

  • Visualize the time spent by the nodes in the contention, transmission, reception, and idle time states during the simulation.

For information about the node configuration parameters, see WLAN Node Composition and Configuration.

Configure WLAN Node and Visualize State Transitions in 802.11ax System-Level Simulation

To access the helper files that this example uses, add the mlWLANSystemSimulation folder to the MATLAB path.


Set the simulation time in milliseconds.

simulationTime = 0.02*1e3;

Enable the option to show the live state transition plot for all of the nodes.

showLiveStateTransitionPlot = true;

Specify the total number of nodes (APs and STAs) in the network. This example uses two APs and two STAs.

numNodes = 4;

Specify the x-, y-, and z-coordinates of the WLAN nodes in the Cartesian coordinate system. This example considers the first two nodes as the APs and the next two nodes as the STAs.

nodePositions = [10 0 0; 20 0 0; 15 5 0; 13 8 0];

Load the default configuration for the WLAN nodes.


Set the node configuration parameters.

wlanNodeConfig.TxMCS = 5;                              % Modulation and coding scheme index
wlanNodeConfig.DisableRTS = true;                      % Disable RTS/CTS exchange
wlanNodeConfig.NumTxChains = 3;                        % Number of transmit chains
wlanNodeConfig.MaxSubframes = 64;                      % Maximum number of subframes that can be aggregated in an A-MPDU
wlanNodeConfig.Bandwidth = 80;                         % Channel bandwidth (in MHz)
wlanNodeConfig.TxFormat = 'HE_SU';                     % Frame transmission format

Copy the default configuration for all of the nodes.

nodeConfig = repmat(wlanNodeConfig,1,numNodes);

Initialize the node position of the APs and STAs.

for idx = 1:1:numNodes
    nodeConfig(idx).NodePosition = nodePositions(idx,:);

Load the default application traffic configuration for the WLAN nodes.


Initialize the nodes with uplink and downlink traffic configuration by copying the default configuration for the WLAN nodes.

trafficConfig = repmat(wlanTrafficConfig,1,3);

Configure the AP uplink best effort traffic at the first AP from the first STA. Node IDs 1 and 2 represent the first and second APs, respectively. Node IDs 3 and 4 represent the first and second STAs, respectively.

trafficConfig(1).SourceNode = 3;                       % STA node ID
trafficConfig(1).DestinationNode = 1;                  % AP node ID
trafficConfig(1).AccessCategory = 0;                   % Best Effort (0), Background (1), Video (2), and Voice (3)

Configure the AP downlink video traffic at the second AP to the first STA.

trafficConfig(2).SourceNode = 2;                       % AP node ID
trafficConfig(2).DestinationNode = 3;                  % STA node ID
trafficConfig(2).AccessCategory = 2;

Configure the AP downlink voice traffic at the first AP to the second STA.

trafficConfig(3).SourceNode = 1;                       % AP node ID
trafficConfig(3).DestinationNode = 4;                  % STA node ID
trafficConfig(3).AccessCategory = 3;

Create a WLAN scenario by using the hCreateWLANNodes helper function. The example configures each node with the preceding physical layer (PHY), medium access control (MAC) layer, and application traffic configuration.

wlanNodes = hCreateWLANNodes(nodeConfig,trafficConfig);

Initialize the visualization parameters.

visualizationInfo = struct;
visualizationInfo.Nodes = wlanNodes;
visualizationInfo.NodeNames = ["AP1","AP2","STA1","STA2"];

Configure state transition visualization by using the hPlotStateTransition helper function.

if showLiveStateTransitionPlot

Simulate the network by using the hWirelessNetworkSimulator helper object.

networkSimulator = hWirelessNetworkSimulator(wlanNodes);         % Object that handles network simulation

The network simulator provides flexibility to schedule custom events in the simulation by using the scheduleEvent object function. For example, when you call the simulator, you can schedule an event to refresh the state transition visualization. Specify the function handle, input argument, invocation time, and periodicity of the callback.

scheduleEvent(networkSimulator, @() pause(0.001), [], 0, 5);     % Refresh visualization after every 5 milliseconds

Run all the nodes in the network for the specified simulation time. Visualize the time spent by the nodes in the contention, transmission, reception, and idle time states during the simulation.

title('State Transitions for All Nodes');

Figure MAC State Transitions Over Time contains an axes object and another object of type uicontrol. The axes object with title State Transitions for All Nodes contains 236 objects of type bar, rectangle. These objects represent Contention, Transmission, Reception(destined to others), Idle/EIFS/SIFS, Reception(destined to node).

At the end of the simulation, remove the mlWLANSystemSimulation folder from the path.


Related Topics