Main Content

wlanMACFrame

Generate WLAN MAC frame (MPDU or A-MPDU)

Description

[frame,frameLength] = wlanMACFrame(cfgMAC) generates frame, a WLAN medium access control (MAC) frame for the specified MAC frame configuration object. The function generates a MAC protocol data unit (MPDU) or an aggregate MPDU (A-MPDU), depending on the property values of the cfgMAC input. The function also returns frameLength, the total length of the generated MAC frame.

example

[frame,frameLength] = wlanMACFrame(payload,cfgMAC) generates a WLAN MAC frame containing MAC service data units (MSDUs) payload. For the MAC frame to contain the MSDUs, you must set the FrameType property of the cfgMAC input to 'Data' or 'QoS Data'. Otherwise, the function ignores payload.

example

[frame,frameLength] = wlanMACFrame(payload,cfgMAC,cfgPHY) generates a WLAN MAC frame for the physical layer (PHY) format and transmission parameters specified in cfgPHY. To generate A-MPDUs in high-efficiency (HE), very high throughput (VHT) high-throughput (HT), or extremely high throughput single user (EHT SU) frame formats, use this syntax.

example

[frame,frameLength] = wlanMACFrame(cfgMAC,cfgPHY) generates a WLAN MAC trigger frame for the specified MAC and PHY configurations. To create a MAC trigger frame, the cfgPHY input must be a wlanNonHTConfig object, and you must set the FrameType property of the cfgMAC input to 'Trigger'.

[frame,frameLength] = wlanMACFrame(___,OutputFormat=format) specifies the data format of the generated frame in addition to any input argument combination from previous syntaxes.

example

Examples

collapse all

Create a WLAN MAC frame configuration object, specifying a beacon MAC frame.

cfgMAC = wlanMACFrameConfig(FrameType="Beacon");

Enable the power saving mode and display the result.

cfgMAC.PowerManagement = true;
disp(cfgMAC)
  wlanMACFrameConfig with properties:

           FrameType: 'Beacon'
                ToDS: 0
              FromDS: 1
      Retransmission: 0
     PowerManagement: 1
            MoreData: 0
            Duration: 0
            Address1: 'FFFFFFFFFFFF'
            Address2: '00123456789B'
            Address3: '00123456789B'
      SequenceNumber: 0
    ManagementConfig: [1x1 wlanMACManagementConfig]

   Read-only properties:
             Decoded: 0

Generate the beacon frame.

beaconFrame = wlanMACFrame(cfgMAC);

Generate a quality of service (QoS) Data MAC frame with a specified payload.

macConfig = wlanMACFrameConfig(FrameType="QoS Data");
payload = "00576000103afffe80";
[frame,frameLength] = wlanMACFrame(payload,macConfig);
disp(frame')
8000FFFFFF0135790135790020056013FF88241
8200FFFFFF02468B02468B000007000AFE0EA33

Create a MAC frame configuration object.

 cfgMAC = wlanMACFrameConfig(FrameType="QoS Data", ...
     FrameFormat="HT-Mixed", ...
     MPDUAggregation=true);

Create an HT PHY configuration object.

cfgPHY = wlanHTConfig(MCS=4);  

Calculate the MSDU lengths required to generate a 5000-octet A-MPDU frame, displaying the result.

msduLengths = wlanMSDULengths(5000,cfgMAC,cfgPHY);
disp(msduLengths)
        2302        2302         294

Create MSDUs with random data using the MSDU length vector.

 numMSDUs = numel(msduLengths);
 payload = cell(1,numMSDUs);
  for i = 1:numMSDUs
      payload{i} = randi([0 255],1,msduLengths(i));
  end

Generate the 5000-octet A-MPDU.

[frame,frameLength] = wlanMACFrame(payload,cfgMAC,cfgPHY);
disp(frameLength)
        5000

Create a wlanMACManagementConfig configuration object, specifying the service set identifier (SSID).

cfgMgmt = wlanMACManagementConfig(SSID="demo SSID");

Create a wlanMACFrameConfig configuration object, specifying the management frame-body configuration object as mgmtConfig and a beacon MAC frame.

cfgMAC = wlanMACFrameConfig(FrameType="Beacon", ...
    ManagementConfig=cfgMgmt);

Generate the beacon MAC frame with the specified SSID.

[macFrame,frameLength] = wlanMACFrame(cfgMAC);

Display the frame length.

frameLength
frameLength = 
56

Create a basic MAC trigger frame to carry information for two users.

Create a MAC trigger frame-body configuration object, specifying a channel bandwidth of 40 MHz.

cfgTrigger = wlanMACTriggerConfig(ChannelBandwidth="CBW40");

Create configuration objects for the User Info fields of the trigger frame.

cfgUser1 = wlanMACTriggerUserConfig(AID12=1, ...
    RUSize=242,RUIndex=1);
cfgUser2 = wlanMACTriggerUserConfig(AID12=2, ...
    RUSize=242,RUIndex=2);

Add the User Info fields to the trigger frame.

cfgTrigger = addUserInfo(cfgTrigger,cfgUser1);
cfgTrigger = addUserInfo(cfgTrigger,cfgUser2);

Configure the trigger frame by creating a MAC frame-body configuration object, specifying the frame type and the trigger frame-body configuration.

cfgMAC = wlanMACFrameConfig(FrameType="Trigger", ...
    TriggerConfig=cfgTrigger);

Specify a non-HT PHY configuration by creating a default non-HT configuration object.

cfgPHY = wlanNonHTConfig;

Create the MAC trigger frame and display its length.

[frame,frameLength] = wlanMACFrame(cfgMAC,cfgPHY);
disp(frameLength)
    40

Create a wlanMACFrameConfig object for an RTS MAC frame.

cfgMAC = wlanMACFrameConfig(FrameType="RTS");

Generate the RTS MAC frame in bit format.

[frame,frameLength] = wlanMACFrame(cfgMAC,OutputFormat="bits");

Input Arguments

collapse all

MAC frame configuration, specified as a wlanMACFrameConfig object. This object defines the type of MAC frame and its applicable properties.

One or more MSDUs, specified as a numeric vector, character vector, string, or cell array. The value you specify depends on whether the frame is aggregated.

  • To generate an MPDU, specify this argument as one of these values:

    • A numeric vector of octets in decimal format, where each element is an integer in the interval [0, 255]

    • A character vector of octets in hexadecimal format

    • A string scalar of octets in hexadecimal format

    The value you specify represents one MSDU.

  • To generate an A-MPDU, specify this argument as one of these values:

    • A cell array of numeric vectors

    • A cell array of character vectors

    • A string array

    Each element of the specified array represents one MSDU.

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

PHY format configuration, specified as a configuration object of type wlanHESUConfig, wlanVHTConfig, wlanHTConfig, or wlanEHTMUConfig. The value you specify must be compatible with the frame format specified in the cfgMAC input.

  • If the FrameFormat property of cfgMAC is "HE-SU" or "HE-EXT-SU", specify this argument as a wlanHESUConfig object.

  • If the FrameFormat property of cfgMAC is "VHT", specify this argument as a wlanVHTConfig object.

  • If the FrameFormat property of cfgMAC is "HT-Mixed", specify this argument as a wlanHTConfig object.

  • If the FrameFormat property of cfgMAC is "EHT-SU", specify this argument as a wlanEHTMUConfig object with SU transmission.

Specify this argument to:

  • Ensure that the frame does not exceed the transmission time limit.

  • Add end-of-frame (EOF) padding to frames in VHT, HE, or EHT format.

  • Maintain minimum start spacing between MPDUs in an A-MPDU.

The function uses this input only when generating the VHT, HE, or EHT format frames and HT format aggregated frames.

MAC frame format, specified as "octets" or "bits".

Data Types: char | string

Output Arguments

collapse all

MAC frame (MPDU or A-MPDU), returned as one of these values.

  • A character array, where each row is an octet in hexadecimal format, when you specify the format input as "octets"

  • A binary-valued column vector when you specify the format input as "bits"

Data Types: int8 | char

Length of generated MAC frame, in octets, returned as a nonnegative integer. For VHT, HE, and EHT format A-MPDUs, this output is the A-MPDU pre-EOF padding (APEP) length, which is less than or equal to the length of the frame output. For all other formats, this output is the physical layer convergence procedure (PLCP) service data unit (PSDU) length.

Data Types: double

References

[1] IEEE Std 802.11™-2020 (Revision of IEEE Std 802.11-2016). “Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications.” IEEE Standard for Information Technology — Telecommunications and Information Exchange between Systems — Local and Metropolitan Area Networks — Specific Requirements.

[2] IEEE® Std 802.11ax™-2021 (Amendment to IEEE Std 802.11-2020). “Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications. Amendment 1: Enhancements for High Efficiency WLAN.” IEEE Standard for Information Technology — Telecommunications and Information Exchange between Systems. Local and Metropolitan Area Networks — Specific Requirements.

Extended Capabilities

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

Version History

Introduced in R2018b