Decode MPDU
[
recovers cfgMAC
,payload
,status
] = wlanMPDUDecode(mpdu
,cfgPHY
)payload
, one or more MAC service data units (MSDUs), by
decoding MAC protocol data unit (MPDU) mpdu
for physical layer (PHY)
format configuration object cfgPHY
. The function also returns
status
, which indicates the result of MPDU decoding, and
cfgMAC
, a wlanMACFrameConfig
configuration
object.
Create a WLAN MAC frame configuration object for a QoS data frame, and then generate the QoS data MPDU in octet form.
txCfgMAC = wlanMACFrameConfig('FrameType','QoS Data'); mpduOctets = wlanMACFrame(randi([0 255],1,40),txCfgMAC);
Convert the MPDU to bit form.
mpdu = reshape(de2bi(hex2dec(mpduOctets), 8)',[],1);
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.
[rxCfgMAC,payload,status] = wlanMPDUDecode(mpdu,cfgPHY);
Create a WLAN MAC frame configuration object for a QoS data frame, then generate the QoS data MPDU in octet form.
txCfgMAC = wlanMACFrameConfig('FrameType','QoS Data'); mpdu = wlanMACFrame(randi([0 255],1,40),txCfgMAC);
Create a non-HT-format configuration object with default settings.
cfgPHY = wlanNonHTConfig;
Return the MSDUs by decoding the MPDU for the specified PHY format configuration.
[rxCfgMAC,payload,status] = wlanMPDUDecode(mpdu,cfgPHY,'DataFormat','octets');
Deaggregate a VHT-format A-MPDU and decode the extracted MPDUs.
Create a WLAN MAC frame configuration object for a VHT-format 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);
Return the list of MPDUs by deaggregating the A-MPDU. Display the status of the deaggregation and the delimiter CRC.
[mpduList, delimiterCRCFail, status] = ... wlanAMPDUDeaggregate(ampdu,cfgPHY,'DataFormat','octets'); disp(status)
Success
disp(delimiterCRCFail)
0 0 0 0 0 0 0 0
Decode all the MPDUs in the extracted list.
if strcmp(status,'Success') for i = 1:numel(mpduList) if ~delimiterCRCFail(i) [cfgMAC, payload, decodeStatus] = ... wlanMPDUDecode(mpduList{i},cfgPHY,'DataFormat','octets'); end end end
mpdu
— MPDU to be decodedMPDU to be decoded, specified as one of these values:
a binary vector representing the MPDU in bit form;
a numeric vector representing octets in decimal format, where each element is an integer in the interval [0, 255];
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: double
| char
| string
cfgPHY
— PHY format configurationwlanHESUConfig
object | wlanVHTConfig
object | wlanHTConfig
object | wlanNonHTConfig
objectPHY format configuration, specified as an object of type wlanHESUConfig
,
wlanVHTConfig
, wlanHTConfig
, wlanNonHTConfig
. This object defines the PHY format configuration and its
applicable properties.
format
— Format of the input MPDU'bits'
(default) | 'octets'
Format of the input MPDU, specified as 'bits'
or
'octets'
.
Data Types: string
cfgMAC
— MAC frame configurationwlanMACFrameConfig
objectMAC frame configuration, returned as a wlanMACFrameConfig
object.
payload
— One or more MSDUsOne 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
— Status of MPDU decodingStatus 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 value | Member of enumeration class | Decoding Status |
0 | Success | MAC frame successfully decoded |
–1 | FCSFailed | Frame check sequence (FCS) failed |
–2 | InvalidProtocolVersion | Invalid protocol version |
–3 | UnsupportedFrameType | Unsupported frame type |
–4 | UnsupportedFrameSubtype | Unsupported frame subtype |
–5 | NotEnoughData | Insufficient data to decode the frame |
–6 | UnsupportedBAVariant | Unsupported variant of Block Ack frame |
–7 | UnknownBitmapSize | Unknown bitmap size |
–8 | UnknownAddressExtMode | Unknown address extension mode |
–9 | MalformedAMSDULength | Malformed aggregated MAC service data unit (A-MSDU) with invalid length |
–10 | MalformedSSID | Malformed service set identifier (SSID) information element (IE) |
–11 | MalformedSupportedRatesIE | Malformed supported rates IE |
–12 | MalformedIELength | Malformed IE length field |
–13 | MissingMandatoryIEs | Mandatory IEs missing |
–14 | NoMPDUFound | No MPDU found in the A-MPDU |
–15 | CorruptedAMPDU | All the delimiters in the given A-MPDU failed the cyclic redundancy check (CRC) |
–16 | InvalidDelimiterLength | Invalid length field in MPDU delimiter |
–17 | MaxAMSDULenthExceeded | A-MSDU exceeded the maximum length limit |
–18 | MaxMPDULengthExceeded | MPDU exceeded the maximum length limit |
–19 | MaxMMPDULengthExceeded | MAC management frame exceeded the maximum length limit |
–20 | MaxMSDULengthExceeded | MSDU exceeded the maximum length limit |
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
You have a modified version of this example. Do you want to open this example with your edits?