Main Content

Get Started with WLAN System-Level Simulation in MATLAB

This example shows how to model a WLAN network consisting of an IEEE® 802.11ax™ (Wi-Fi® 6) [1] access point (AP) and a station (STA).

Using this example, you can:

  1. Simulate a multinode WLAN system by configuring the application layer (APP), medium access control (MAC), and physical layer (PHY) parameters at each node.

  2. Model uplink (UL) and downlink (DL) communication between an AP and a STA.

  3. Switch between the abstracted and full models of MAC and PHY layers.

  4. Visualize the time spent by each node in Idle, Contention, Transmission, and Reception state.

  5. Capture the APP, MAC, and PHY statistics for each node.

The simulation results show performance metrics such as MAC throughput, MAC packet loss, and application latency.

Additionally, you can use this example script to perform these tasks.

WLAN System-Level Simulation

This example shows you how to model a WLAN network with UL and DL communication between an AP and a STA. This figure illustrates the example network.

Get_Started_image.png

This figure shows the example workflow.

To confirm compliance with the IEEE 802.11 standard [2], the features in this example are validated with Box-3 and Box-5 scenarios specified in the TGax evaluation methodology [4]. The network throughputs that are calculated for TGax simulation scenarios [5] are validated against the published calibration results from the TGax Task Group.

Check for Support Package Installation

Check if the Communications Toolbox™ Wireless Network Simulation Library support package is installed. If the support package is not installed, MATLAB® returns an error with a link to download and install the support package.

wirelessnetworkSupportPackageCheck

Configure Simulation Parameters

Set the seed for the random number generator to 1. The seed value controls the pattern of random number generation. The random number generated by the seed value impacts several processes within the simulation, including backoff counter selection at the MAC layer and predicting packet reception success at the physical layer. To improve the accuracy of your simulation results after running the simulation, you can change the seed value, run the simulation again, and average the results over multiple simulations.

rng(1,"combRecursive")

Specify the simulation time in seconds. To visualize a live state transition plot for all of the nodes, set the enablePacketVisualization variable to true. To view the node performance visualization, set the enableNodePerformancePlot variable to true.

simulationTime = 1;
enablePacketVisualization = true;
enableNodePerformancePlot = true;

At the transmitter and receiver, modeling full MAC processing involves complete MAC frame generation at the MAC layer. Similarly, modeling full PHY processing involves complete operations related to waveform transmission and reception through a fading channel. When simulating large networks, full MAC and PHY processing is computationally expensive.

In the abstracted MAC, the node does not generate or decode any frames at the MAC layer. Similarly, in the abstracted PHY, the node does not generate or decode any waveforms at the PHY. MAC and PHY abstraction enable you to minimize the complexity and runtime of system-level simulations. For more information on PHY abstraction, see the Physical Layer Abstraction for System-Level Simulation example.

This table shows you how to switch between the abstracted and full MAC or PHY by configuring the values of the MACFrameAbstraction and PHYAbstractionMethod properties of wlanNode object.

If you set phyabstraction to tgax-evaluation-methodology, the PHY estimates the performance of a link with the TGax channel model by using an effective signal-to-interference-plus-noise ratio (SINR) mapping. Alternatively, if you set phyabstraction to tgax-mac-calibration the PHY assumes a packet failure on interference without actually calculating the link performance. To use the full PHY, set the value of phyabstraction to none.

macabstraction = false;
phyabstraction = "tgax-evaluation-methodology";

The example demonstrates packet capture at both AP and STA nodes. The packet capture (PCAP) or packet capture next generation (PCAPNG) file (.pcap or .pcapng, respectively) is a widely used packet capture file format to perform packet analysis. The packets are captured into a PCAP file in this example. To capture the packets exchanged during the simulation, set the capturePacketsFlag flag to true.

capturePacketsFlag = true;

Configure WLAN Scenario

Initialize the wireless network simulator by using the wirelessNetworkSimulator object.

networkSimulator = wirelessNetworkSimulator.init;

Nodes

The wlanDeviceConfig object enables you to set the configuration parameters for the AP and STA. Create two WLAN device configuration objects, one for the AP and the other for the STA. Specify the operating mode, modulation and coding scheme, and transmission power (in dBm) for the AP and STA.

accessPointCfg = wlanDeviceConfig(Mode="AP",MCS=2,TransmitPower=15); % AP device configuration
stationCfg = wlanDeviceConfig(Mode="STA",MCS=2,TransmitPower=15);    % STA device configuration

To create an AP node and a STA node from the specified WLAN device configurations, use wlanNode objects. Specify the name and position of the AP and the STA. Specify the PHY abstraction method used for the AP and the STA. Configure the MACFrameAbstraction property of the wlanNode object to indicate if the MAC frames are abstracted by the nodes.

accessPoint = wlanNode(Name="AP", ...
    Position=[10 0 0], ...
    DeviceConfig=accessPointCfg, ...
    PHYAbstractionMethod=phyabstraction, ...
    MACFrameAbstraction=macabstraction);

station = wlanNode(Name="STA", ...
    Position=[20 0 0], ...
    DeviceConfig=stationCfg, ...
    PHYAbstractionMethod=phyabstraction, ...
    MACFrameAbstraction=macabstraction);

Create a WLAN network consisting of the AP and the STA.

nodes = [accessPoint station];

To ensure all the nodes are configured properly, use the hCheckWLANNodesConfiguration helper function.

hCheckWLANNodesConfiguration(nodes)

Association and Application Traffic

Associate the STA to the AP by using the associateStations object function of the wlanNode object. To configure UL and DL application traffic between the AP and STA, use the FullBufferTraffic argument of the associateStations object function.

associateStations(accessPoint,station,FullBufferTraffic="on");

Wireless Channel

To model a random TGax fading channel between each node, this example uses the hSLSTGaxMultiFrequencySystemChannel helper object. Add the channel model to the wireless network simulator by using the addChannelModel object function of the wirelessNetworkSimulator object.

channel = hSLSTGaxMultiFrequencySystemChannel(nodes);
addChannelModel(networkSimulator,channel.ChannelFcn)

Export WLAN MAC Frames to PCAP or PCAPNG File

Create a hExportWLANPackets helper object to generate PCAP files. Specify the node objects at which you want to capture the packets. The helper object captures transmitted and received packets at each of these nodes and generates a PCAP file for each node. If you want to capture the packets in a PCAPNG file, specify the string "pcapng" as the second argument to the object function call. Note that capturing packets is possible only when macabstraction flag is set to false.

if capturePacketsFlag
    clear capturePacketsObj;                       % Clear existing helper object
    capturePacketsObj = hExportWLANPackets(nodes);
end

You can visualize and analyze the PCAP or PCAPNG file by using a third-party packet analyzer tool such as Wireshark.

Simulation and Results

Add the nodes to the wireless network simulator.

addNodes(networkSimulator,nodes)

To view the state transition plot, use the hPlotPacketTransitions helper object. To disable the packet communication over frequency subplot, set the FrequencyPlotFlag property of hPlotPacketTransitions helper object to false.

if enablePacketVisualization
    packetVisObj = hPlotPacketTransitions(nodes,simulationTime,FrequencyPlotFlag=false);
end

To view the node performance, use the hPerformanceViewer helper object.

perfViewerObj = hPerformanceViewer(nodes,simulationTime);

Run the network simulation for the specified simulation time. The runtime visualization shows the time spent by the AP and the STA in Idle, Contention, Transmission, and Reception state.

run(networkSimulator,simulationTime);

Figure Packet Communication Over Time contains an axes object and another object of type uigridlayout. The axes object with title State Transitions of Nodes, xlabel Time (seconds), ylabel Node Names contains 4 objects of type patch, constantline.

The plotNetworkStats object function displays these simulation plots.

  • MAC throughput (in Mbps) at each transmitter (AP and STA).

  • MAC packet loss ratio (ratio of unsuccessful data transmissions to the total data transmissions) at each transmitter (AP and STA).

  • Average application packet latency incurred at each receiver (AP and STA). The average application packet latency shows the average latency that the STA incurs to receive the DL traffic from the AP and the average latency that the AP incurs to receive UL traffic from the STA.

if enableNodePerformancePlot
    plotNetworkStats(perfViewerObj);
end

Figure contains 3 axes objects and another object of type subplottext. Axes object 1 with title Throughput at Each Node, xlabel Node Name, ylabel Throughput (Mbps) contains an object of type bar. Axes object 2 with title Packet Loss at Each Node, xlabel Node Name, ylabel Packet Loss Ratio contains an object of type bar. Axes object 3 with title Average Packet Latency at Each Node, xlabel Node Name, ylabel Latency (s) contains an object of type bar.

Calculate the MAC throughput and MAC packet loss ratio at the AP.

apThroughput = throughput(perfViewerObj,accessPoint.ID)
apThroughput = 
9.3960
apPacketLossRatio = packetLossRatio(perfViewerObj,accessPoint.ID)
apPacketLossRatio = 
0

Calculate the average application receive latency at the STA.

staAverageReceiveLatency = averageReceiveLatency(perfViewerObj,station.ID)
staAverageReceiveLatency = 
0.2777

Retrieve the APP, MAC, and PHY statistics at each node by using the statistics object function of the wlanNode object. For more information about the statistics, see WLAN System-Level Simulation Statistics.

stats = statistics(nodes);

Because the hExportWLANPackets helper object does not overwrite the existing PCAP or PCAPNG file, deleting the PCAP objects used in this simulation.

if capturePacketsFlag
    delete(capturePacketsObj.PCAPObjList);
end

Further Exploration

You can use this example to further explore these functionalities.

Configure IEEE 802.11be Compliant Frame Transmissions

To configure IEEE 802.11be [3] compliant frame transmissions, you can:

  1. Specify the PHY transmission format of the WLAN device as "EHT-SU".

  2. Specify the modulation and coding scheme (MCS) of the WLAN device as an integer in the range [0,13].

For more information on TransmissionFormat and MCS properties, see the wlanDeviceConfig object.

Add Mobility To Nodes

You can add mobility to any node by using the addMobility object function. For more information on how to simulate a network by adding a mobility model to the node, see the Create, Configure, and Simulate Wireless Local Area Network example.

Configure External Application Traffic

You can generate and add external application traffic such as On-Off, Video, Voice, and FTP by using the networkTrafficOnOff, networkTrafficVideoConference, networkTrafficVoIP, and networkTrafficFTP objects, respectively. For more information on how to configure, generate, and attach On-Off application traffic to the nodes, see the Simulate an 802.11ax Network with Quality of Service Parameters example.

Capture IQ Samples

Capture the IQ samples of the nodes by using the hCaptureIQSamples helper object. For more information on how to capture IQ samples for all nodes in the simulation, see Simulate Noncollaborative Coexistence of Bluetooth LE, Bluetooth BR/EDR, and WLAN Networks example.

Appendix

This example uses these helpers:

References

  1. "IEEE Standard for Information Technology--Telecommunications and Information Exchange between Systems Local and Metropolitan Area Networks--Specific Requirements Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications Amendment 1: Enhancements for High-Efficiency WLAN." IEEE. https://doi.org/10.1109/IEEESTD.2021.9442429.

  2. "IEEE Standard for Information Technology--Telecommunications and Information Exchange between Systems - Local and Metropolitan Area Networks--Specific Requirements Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications." IEEE. https://doi.org/10.1109/IEEESTD.2021.9363693.

  3. “IEEE Draft Standard for Information Technology–Telecommunications and Information Exchange between Systems Local and Metropolitan Area Networks–Specific Requirements - Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications Amendment: Enhancements for Extremely High Throughput (EHT).” IEEE P802.11be/D5.0, November 2023, January 2024, 1–1045. https://ieeexplore.ieee.org/document/10381585.

  4. IEEE P802.11 Wireless LANs - 11ax Evaluation Methodology. IEEE 802.11-14/0571r12. IEEE, January 2016.

  5. IEEE P802.11 Wireless LANs - TGax Simulation Scenarios. IEEE 802.11-14/0980r16. IEEE, July 2015.

See Also

Functions

Objects

Related Topics