Main Content

nrMACPDUDecode

Decode MAC PDU

Since R2022b

    Description

    [msgIndexList,payloadList] = nrMACPDUDecode(macPDU,linkDir) decodes the medium access control (MAC) protocol data unit (PDU) macPDU as defined in 3GPP TS 38.321 section 6.1.2 release 16 [1]. linkDir specifies the transmission direction of the MAC PDU. The function returns the message indices msgIndexList, where each message index represents either the logical channel ID (LCID) or extended logical channel ID (eLCID) field of a MAC subPDU. The function also returns the payloads of the corresponding MAC subPDUs payloadList.

    example

    [msgIndexList,payloadList,headerLengthList] = nrMACPDUDecode(macPDU,linkDir) also returns the header lengths of the MAC subPDUs.

    [msgIndexList,payloadList] = nrMACPDUDecode(msgIndexList,payloadList,softErrorFlag) additionally specifies how to handle errors in decoding.

    [msgIndexList,payloadList,headerLengthList] = nrMACPDUDecode(msgIndexList,payloadList,softErrorFlag) also returns the header lengths of the MAC subPDUs and specifies how to handle errors in decoding.

    Examples

    collapse all

    Decode an uplink MAC PDU that contains five MAC subPDUs in the uplink direction with LCID and eLCID values 20, 2487, 55, 54, and 63 (2487 represents an eLCID and the rest are LCIDs).

    The five subPDUs carry these payloads, in order:

    • Two service data units (SDUs), one of 344 bytes and the other of 166 bytes

    • Fixed-size control element (CE) of 0 bytes

    • Variable-size CE of 4 bytes

    • Padding of 0 bytes

    Generate the MAC PDU that contains the five MAC subPDUs.

    macPDU = [84; 1; 88; ones(344,1); ...
              33; 8; 119; 166; ones(166,1); ...
              55; ...
              54; 4; ones(4,1); ...
              63];

    Set the transmission direction of the link.

    linkDir = 1; % Uplink

    Decode the MAC PDU.

    [msgIndexList,payloadList] = nrMACPDUDecode(macPDU,linkDir)
    msgIndexList = 5×1
    
              20
            2487
              55
              54
              63
    
    
    payloadList=5×1 cell array
        {344x1 double}
        {166x1 double}
        {  0x0 double}
        {  4x1 double}
        {  0x0 double}
    
    

    Decode a downlink MAC PDU that contains a padding MAC subPDU in the downlink direction (with an LCID value of 63). The MAC subPDU carries a padding payload of 7 bytes.

    macPDU = [63; 0; 0; 0; 0; 0; 0; 0];
    linkDir = 0;                  % Downlink direction

    Decode the MAC PDU.

    [msgIndexList,payloadList] = nrMACPDUDecode(macPDU,linkDir)
    msgIndexList = 
    63
    
    payloadList = 1x1 cell array
        {7x1 double}
    
    

    Input Arguments

    collapse all

    MAC PDU, specified as a vector of octets in decimal format.

    Data Types: double

    Transmission direction of the MAC PDU, specified as one of these values.

    • 0 — Use this value to set the transmission direction to downlink.

    • 1 — Use this value to set the transmission direction to uplink.

    Data Types: double

    Soft error flag, specified as one of these numeric or logical values. This value determines the error handling in decoding.

    • 0 (false) — When the function encounters a corrupted MAC PDU, the execution stops with a corresponding error message.

    • 1 (true) — When the function encounters a corrupted MAC PDU, the execution does not stop, and the function returns empty values.

    Data Types: logical

    Output Arguments

    collapse all

    Message indices, returned as a vector of integers. Each message index represents the LCID or eLCID field of a MAC subPDU.

    The index values returned in msgIndexList correspond to these tables specified in 3GPP TS 38.321.

    • For a downlink shared channel (DL-SCH) subPDU, the msgIndex corresponds to the index value specified in 3GPP TS 38.321 table 6.2.1-1, 6.2.1-1a, or 6.2.1-1b [1].

    • For an uplink shared channel (UL-SCH) subPDU, the msgIndex corresponds to the index value specified in 3GPP TS 38.321 table 6.2.1-2, 6.2.1-2a, or 6.2.1-2b [1].

    Data Types: double

    Payload of subPDUs, returned as a cell array. Each payload in the payload list is either MAC SDU, MAC CE, or padding payload.

    Data Types: cell

    Header lengths of MAC subPDUs, returned as an array containing the header lengths of MAC subPDUs.

    Data Types: cell

    References

    [1] 3GPP TS 38.321. “NR; Medium Access Control (MAC) protocol specification.” 3rd Generation Partnership Project; Technical Specification Group Radio Access Network.

    Extended Capabilities

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

    Version History

    Introduced in R2022b

    expand all

    See Also