This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

802.11 MAC Frame Decoding

This example shows how to decode IEEE® 802.11™ MAC frames.

Background

The general MAC frame format consists of a header, frame-body, and frame check sequence (FCS). The header holds information about the frame. The frame-body carries data that needs to be transmitted. The transmitter calculates the FCS over the header and frame-body. The receiver uses the FCS to confirm that the header and frame-body are properly received. The following diagram shows the structure of a general MAC frame.

The standard specifies four types of frames: Management, Data, Control, and Extension. There are multiple subtypes of each frame type. These are identified by the Type and Subtype fields of the frame control field in the MAC header.

Management Frames:

  • Frames that are used for connection establishment and maintenance.

  • These frames carry the information fields and elements that indicate the capabilities and configuration of the device operating in the 802.11 network. While establishing the connection, these information fields and elements are communicated between the devices to match capabilities of both devices.

  • The MAC layer adds header and FCS to the frame-body carrying the information to form a MAC protocol data unit (MPDU).

Data Frames:

  • Frames that are used to transmit the higher-layer data.

  • The payload given to the MAC layer is termed MAC service data unit (MSDU). The MAC layer adds header and FCS to the MSDU to form an MPDU.

  • To improve the throughput, WLAN supports aggregated MSDUs (A-MSDUs) and aggregated MPDUs (A-MPDUs) as specified in Sections 9.3.2.2, 9.7 of [ 1 ] and [ 2 ].

  • If MSDU aggregation is enabled, multiple MSDUs are aggregated to form an A-MSDU and then the MAC header and FCS are added to an A-MSDU to form an MPDU.

  • If MPDU aggregation is enabled, multiple MPDUs are aggregated to form an A-MPDU.

Control Frames:

  • Frames that are used to support the delivery of data, management and extension frames.

  • Each control frame has a specific functionality. For instance, control frames like request-to-send (RTS) and clear-to-send (CTS) help in reserving the channel to avoid collisions, while Ack frames help in recognizing successful transmission.

  • The control frames do not contain a frame-body. The MAC layer adds an FCS to the header to form an MPDU.

Extension Frames:

  • This frame type is an extension to the three frame types defined above.

  • DMG Beacon is the only frame currently specified under this frame type in [ 1 ].

Introduction

This example shows how WLAN MAC frames specified in Section 9.3 of [ 1 ] or [ 2 ] can be decoded. It also shows how aggregated MAC frames specified in Section 9.7 of [ 1 ] or [ 2 ] can be deaggregated.

WLAN Toolbox™ supports MPDU decoding for the following MAC frames:

  • Management Frames: Beacon

  • Data Frames: Data, Null, QoS Data, QoS Null

  • Control Frames: RTS, CTS, Ack, Block Ack

In addition to MPDU decoding, WLAN Toolbox also supports deaggregation of an A-MPDU.

MPDU Decoding

An MPDU can be a data, control or management frame type. wlanMPDUDecode can be used to decode an MPDU. This function processes the given MPDU and a physical layer configuration object to output the decoded MAC parameters.

To illustrate MPDU decoding, a valid MPDU is created using wlanMACFrame. The created MPDU is passed to the wlanMPDUDecode function and the outputs are observed.

Create an MPDU

A QoS Data frame is created for this example using wlanMACFrame. The following inputs are required to form a Non-HT format QoS Data frame containing a 40-octet payload:

  1. txFrameCfg : A MAC frame configuration object of type wlanMACFrameConfig.

  2. txMSDU : A 40-octet payload (MSDU) to be included in the QoS Data frame.

% Create a MAC frame configuration object
txFrameCfg = wlanMACFrameConfig('FrameType', 'QoS Data', ...
                            'FrameFormat', 'Non-HT');

% 40-octet payload for each 'QoS Data' frame
txMSDU = randi([0, 255], 40, 1);

% Physical layer configuration
phyCfg = wlanNonHTConfig;

% Create the MPDU
mpdu = wlanMACFrame(txMSDU, txFrameCfg);

Decode the MPDU

wlanMPDUDecode consumes an MPDU, a PHY configuration object of type wlanNonHTConfig, wlanHTConfig, wlanVHTConfig, or wlanHESUConfig and optionally a (Name, Value) pair for DataFormat specifying the input format of the MPDU. Since the MPDU generated using wlanMACFrame is in terms of octets, DataFormat is set to octets. wlanMPDUDecode decodes the MPDU and outputs the following information:

  1. rxFrameCfg : A MAC frame configuration object of type wlanMACFrameConfig, containing the decoded MAC parameters.

  2. rxMSDU : A cell array, where each element is an n-by-2 character array representing the decoded MSDU. Multiple MSDUs are returned when the MPDU contains an aggregated MSDU (A-MSDU) as the payload.

  3. status : An enumeration of type status, which indicates whether the MPDU decoding was successful.

% Decode the MPDU.
[rxFrameCfg, rxMSDU, status] = wlanMPDUDecode(mpdu, phyCfg, ...
                                            'DataFormat', 'octets');

% Check if the MPDU is decoded successfully
disp(['Status of the MPDU decoding: ' char(status)])

% Observe the outputs, if the MPDU is decoded successfully
if strcmp(status, 'Success')
    disp(['Type of the decoded MPDU: ' rxFrameCfg.FrameType])
    disp(['Number of MSDUs in the MPDU: ' num2str(numel(rxMSDU))])
    for i = 1:numel(rxMSDU)
        disp(['Size of MSDU-' num2str(i) ': ' num2str(size(rxMSDU{i}, 1)) ' octets'])
    end
end
Status of the MPDU decoding: Success
Type of the decoded MPDU: QoS Data
Number of MSDUs in the MPDU: 1
Size of MSDU-1: 40 octets

A-MPDU Deaggregation

An A-MPDU is an aggregation of multiple MPDUs. The type of MPDUs in an A-MPDU are restricted as specified in Section 9.7.3 of [ 1 ].

wlanAMPDUDeaggregate can be used to deaggregate an A-MPDU. This function processes the given A-MPDU and the corresponding physical layer configuration object to output the deaggregated list of MPDUs. wlanAMPDUDeaggregate is capable of decoding HT (High Throughput), VHT (Very High Throughput), HE-SU (High Efficiency Single User) and HE-EXT-SU (High Efficiency Extended Range Single User) format A-MPDUs as specified in [ 1 ] and [ 2 ].

To illustrate the A-MPDU deaggregation, a valid A-MPDU containing five MPDUs is created using wlanMACFrame. The created A-MPDU is passed to the wlanAMPDUDeaggregate function and the outputs are observed.

Create an A-MPDU

The following inputs are required to form an HE-SU format A-MPDU containing five MPDUs (QoS Data frames), each MPDU containing a 40-octet payload:

  1. txFrameCfg : A MAC frame configuration object of type wlanMACFrameConfig.

  2. txMSDUList : A five element cell array containing payload (MSDU) for five MPDUs. Since MSDUAggregation is set to false in the txFrameCfg, a separate MPDU is created for each MSDU.

  3. phyCfg : A physical layer configuration object of type wlanHESUConfig.

% Create a MAC frame configuration object
txFrameCfg = wlanMACFrameConfig('FrameType', 'QoS Data', ...
                            'FrameFormat', 'HE-SU', ...
                            'MPDUAggregation', true, ...
                            'MSDUAggregation', false);

% 40-octet payload for each 'QoS Data' frame
txMSDUList = repmat({randi([0, 255], 40, 1)}, 1, 5);

% Physical layer configuration
phyCfg = wlanHESUConfig('MCS', 3);

% Create the A-MPDU containing 5 MPDUs
ampdu = wlanMACFrame(txMSDUList, txFrameCfg, phyCfg);

Deaggregate the A-MPDU

wlanAMPDUDeaggregate consumes an A-MPDU, a PHY configuration object of type wlanHTConfig, wlanVHTConfig, or wlanHESUConfig and optionally a (Name, Value) pair for DataFormat specifying the input format of the A-MPDU. It finds and validates the MPDU delimiters, extracts the MPDUs and outputs the following information that can be used for further processing the MPDUs:

  1. mpduList : A cell array containing the list of MPDUs extracted from the A-MPDU.

  2. delimCRCFails : A logical row vector representing delimiter CRC validity for the corresponding index in mpduList. A value of true represents that the MPDU present in mpduList at the corresponding index may not be properly extracted.

  3. ampduStatus : An enumeration of type status, which indicates whether the A-MPDU deaggregation was successful.

% Deaggregate the A-MPDU
[mpduList, delimCRCFails, ampduStatus] = wlanAMPDUDeaggregate(ampdu, phyCfg, ...
                                                    'DataFormat', 'octets');

% Observe the outputs
disp(['Status of A-MPDU deaggregation: ' char(ampduStatus)])
disp(['Number of MPDUs extracted from the A-MPDU: ' num2str(numel(mpduList))])
disp(['Number of MPDUs with delimiter CRC fails: ' num2str(nnz(delimCRCFails))])
Status of A-MPDU deaggregation: Success
Number of MPDUs extracted from the A-MPDU: 5
Number of MPDUs with delimiter CRC fails: 0

Decode the list of MPDUs

The mpduList contains the list of MPDUs extracted from the A-MPDU. Each of the MPDUs present in the list can be decoded separately. However, if the delimCRCFails contains any true values, the MPDU present in mpduList at the corresponding index can be considered invalid as it may not be properly extracted because of the delimiter CRC failure.

% Decode the list of MPDUs
if strcmp(ampduStatus, 'Success')
    % Number of MPDUs in the list
    numMPDUs = numel(mpduList);

    for i = 1:numMPDUs
        % Decode the MPDU only if the corresponding delimiter CRC is valid
        if ~delimCRCFails(i)
            [rxFrameCfg, rxMSDU, mpduStatus] = wlanMPDUDecode(mpduList{i}, phyCfg, ...
                                                        'DataFormat', 'octets');
            disp(['MPDU-' num2str(i) ' decoding status: ' char(mpduStatus)])
            disp(['MPDU-' num2str(i) ' type: ' rxFrameCfg.FrameType])
            disp(['MPDU-' num2str(i) ' payload size: ' num2str(size(rxMSDU{1}, 1)) ' octets'])
            disp(' ')
        end
    end
end
MPDU-1 decoding status: Success
MPDU-1 type: QoS Data
MPDU-1 payload size: 40 octets
 
MPDU-2 decoding status: Success
MPDU-2 type: QoS Data
MPDU-2 payload size: 40 octets
 
MPDU-3 decoding status: Success
MPDU-3 type: QoS Data
MPDU-3 payload size: 40 octets
 
MPDU-4 decoding status: Success
MPDU-4 type: QoS Data
MPDU-4 payload size: 40 octets
 
MPDU-5 decoding status: Success
MPDU-5 type: QoS Data
MPDU-5 payload size: 40 octets
 

Conclusion and Further Exploration

This example demonstrated how to deaggregate and decode IEEE 802.11 MAC frames. You can also explore 802.11 OFDM Beacon Receiver with Live Data and 802.11ac Signal Recovery with Preamble Decoding examples for decoding the MAC frames retrieved from the captured waveforms.

Selected Bibliography

  1. IEEE Std 802.11™-2016 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

  2. IEEE P802.11ax™/D3.1 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 6: Enhancements for High Efficiency WLAN