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.
addpath(genpath(fullfile(pwd,'mlWLANSystemSimulation')));
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 names for the WLAN nodes in the network.
nodeNames = ["AP1", "AP2", "STA1", "STA2"];
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.
load('wlanNodeConfig.mat');
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).NodeName = nodeNames(idx); nodeConfig(idx).NodePosition = nodePositions(idx,:); end
Load the default application traffic configuration for the WLAN nodes.
load('wlanTrafficConfig.mat');
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. The first and second structures in the nodeConfig
array represent the first and second APs, respectively. The third and fourth structures in the nodeConfig
array represent the first and second STAs, respectively.
trafficConfig(1).SourceNode = nodeConfig(3).NodeName; % STA1 node name trafficConfig(1).DestinationNode = nodeConfig(1).NodeName; % AP1 node name 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 = nodeConfig(2).NodeName; % AP2 node name trafficConfig(2).DestinationNode = nodeConfig(3).NodeName; % STA1 node name trafficConfig(2).AccessCategory = 2;
Configure the AP downlink voice traffic at the first AP to the second STA.
trafficConfig(3).SourceNode = nodeConfig(1).NodeName; % AP1 node ID trafficConfig(3).DestinationNode = nodeConfig(4).NodeName; % STA2 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;
Configure state transition visualization by using the hPlotStateTransition
helper function.
if showLiveStateTransitionPlot hPlotStateTransition(visualizationInfo); end
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.
run(networkSimulator,simulationTime);
title('State Transitions for All Nodes');
At the end of the simulation, remove the mlWLANSystemSimulation
folder from the path.
rmpath(genpath(fullfile(pwd,'mlWLANSystemSimulation')));
Related Topics
- WLAN Node Composition and Configuration
- Statistics Captured in WLAN System-Level Simulation
- Create and Visualize 802.11ax Multinode Residential Scenario
- Configure Uplink and Downlink Traffic at 802.11ax Access Point
- MAC and PHY Layer Abstraction in System-Level Simulation
- 802.11ax Multinode System-Level Simulation of Residential Scenario Using MATLAB
- Get Started with WLAN System-Level Simulation in MATLAB