Main Content

wlanMPDUDecode

Description

example

[cfgMAC,payload,status] = wlanMPDUDecode(mpdu,phyFormat) recovers payload, one or more MAC service data units (MSDUs), by decoding MAC protocol data unit (MPDU) mpdu. The function decodes the MPDU by using parameters appropriate for the specified PHY format.

The function also returns status, the result of the MPDU decoding, and cfgMAC, a wlanMACFrameConfig configuration object.

example

[cfgMAC,payload,status] = wlanMPDUDecode(mpdu,cfgPHY) decodes the MPDU by using PHY transmission parameters cfgPHY.

example

[cfgMAC,payload,status] = wlanMPDUDecode(___,Name,Value) specifies options using one or more name-value pair arguments in addition any input argument combination from previous syntaxes.

Examples

collapse all

Create a WLAN MAC frame configuration object for an MPDU in high-efficiency single-user (HE SU) format, and then generate the MPDU.

phyFormat = 'HE-SU';
cfgMAC =  wlanMACFrameConfig('FrameFormat',phyFormat);
payload = randi([0 255],1,40);
mpdu = wlanMACFrame(payload,cfgMAC,'OutputFormat','bits');

Return the MSDUs by decoding the MPDU for the specified PHY format configuration.

[rxCfgMAC,payload,status] = wlanMPDUDecode(mpdu,phyFormat);

Confirm successful decoding by displaying the status.

disp(status)
    Success

Create a WLAN MAC frame configuration object for a QoS Data frame, and then generate the MPDU.

cfgMAC = wlanMACFrameConfig('FrameType','QoS Data');
payload = randi([0 255],1,40);
mpdu = wlanMACFrame(payload,cfgMAC,'OutputFormat','bits');

Create a non-high-throughput-format (non-HT-format) configuration object with default settings.

cfgPHY = wlanNonHTConfig;

Return the MSDUs by decoding the MPDU for the specified PHY format configuration.

[cfgMAC,payload,status] = wlanMPDUDecode(mpdu,cfgPHY);

Confirm successful decoding by displaying the status.

disp(status)
    Success

Deaggregate a VHT A-MPDU and decode the extracted MPDUs.

Create a WLAN MAC frame configuration object for a VHT A-MPDU.

txCfgMAC = wlanMACFrameConfig('FrameType','QoS Data','FrameFormat','VHT');

Create a VHT-format configuration object with default settings.

cfgPHY = wlanVHTConfig;

Generate a random payload of eight MSDUs.

txPayload =  repmat({randi([0 255],1,40)},1,8);

Generate the A-MPDU containing eight MPDUs for the specified MAC and PHY configurations.

ampdu = wlanMACFrame(txPayload,txCfgMAC,cfgPHY);

Extract the list of MPDUs by deaggregating the A-MPDU. Display the status of the deaggregation and the delimiter CRC.

[mpduList,failCRC,status] = wlanAMPDUDeaggregate(ampdu,cfgPHY,'DataFormat','octets');
disp(status)
    Success
disp(failCRC)
   0   0   0   0   0   0   0   0

Decode all of the MPDUs in the extracted. Confirm successful decoding by displaying the status.

if strcmp(status,'Success')
    for i = 1:numel(mpduList)
        if ~failCRC(i)
            [cfgMAC,payload,status(i)] = ...
                wlanMPDUDecode(mpduList{i},cfgPHY,'DataFormat','octets');
        end
    end
end
disp(status)
  Columns 1 through 7

    Success    Success    Success    Success    Success    Success    Success

  Column 8

    Success

Input Arguments

collapse all

MPDU to be decoded, specified as one of these values.

  • A binary-valued vector representing the MPDU in bit form

  • A vector of integers in the interval [0, 255] representing octets in decimal format

  • A string scalar representing the MPDU as octets in hexadecimal format

  • A character vector representing the MPDU as octets in hexadecimal format

  • A character array, where each row represents an octet in hexadecimal format

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | char | string

PHY format, specified as one of these values.

  • 'HE-SU' — High-efficiency single-user (HE SU) format

  • 'HE-EXT-SU' — HE extended-range SU (HE ER SU) format

  • 'HE-MU' — HE multi-user (HE MU) format

  • 'HE-TB' — HE trigger-based (HE TB) format

  • 'VHT' — Very-high-throughput (VHT) format

  • 'HT' — High-throughput (HT) format

Data Types: char | string

PHY format and transmission parameters, specified as one of these objects.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside quotes. You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

Example: 'DataFormat','octets'

Format of input MPDU, specified as the comma-separated pair consisting of 'DataFormat' and one of these values.

  • 'bits' — Specify the mpdu input in bit format

  • 'octets' — Specify the mpdu input in octet format

Data Types: char | string

Suppress warning messages, specified as the comma-separated pair consisting of 'SuppressWarnings' and one of these values.

  • false or 0 — Allow warning messages.

  • true or 1 — Suppress warning messages.

Data Types: logical

Output Arguments

collapse all

MAC frame configuration, returned as a wlanMACFrameConfig object.

One or more MSDUs, returned as a cell array of character arrays. The function returns a character array for each MSDU. In these character arrays, each row is the hexadecimal representation of an octet. For each MAC frame that contains no data, the function returns payload as an empty cell array.

Data Types: cell

Status of MPDU decoding, returned as a nonpositive integer in the interval [–20, 0]. Each value of status corresponds to a member of the wlanMACDecodeStatus enumeration class, which indicates the status of MAC frame decoding according to this table.

Enumeration valueMember of enumeration classDecoding Status
0SuccessMAC frame successfully decoded
–1FCSFailedFrame check sequence (FCS) failed
–2InvalidProtocolVersionInvalid protocol version
–3UnsupportedFrameTypeUnsupported frame type
–4UnsupportedFrameSubtypeUnsupported frame subtype
–5NotEnoughDataInsufficient data to decode the frame
–6UnsupportedBAVariantUnsupported variant of Block Ack frame
–7UnknownBitmapSizeUnknown bitmap size
–8UnknownAddressExtModeUnknown address extension mode
–9MalformedAMSDULengthMalformed aggregated MAC service data unit (A-MSDU) with invalid length
–10MalformedSSIDMalformed service set identifier (SSID) information element (IE)
–11MalformedSupportedRatesIEMalformed supported rates IE
–12MalformedIELengthMalformed IE length field
–13MissingMandatoryIEsMandatory IEs missing
–14NoMPDUFoundNo MPDU found in the A-MPDU
–15CorruptedAMPDUAll the delimiters in the given A-MPDU failed the cyclic redundancy check (CRC)
–16InvalidDelimiterLengthInvalid length field in MPDU delimiter
–17MaxAMSDULenthExceededA-MSDU exceeds the maximum length limit
–18MaxMPDULengthExceededMPDU exceeds the maximum length limit
–19MaxMMPDULengthExceededMAC management frame exceeds the maximum length limit
–20MaxMSDULengthExceededMSDU exceeds the maximum length limit
–21UnexpectedProtectedFrameInvalid value of protected bit for this frame type

An enumeration value other than 0 means that MPDU decoding failed. If the decoding fails, the output cfgMAC displays no properties and the output payload is returned as an empty cell array.

Data Types: int16

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced in R2019a