Main Content

wlanMACFrame

Generate WLAN MAC frame (MPDU or A-MPDU)

Description

example

[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 computes frameLength, the total length of the 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, the FrameType property of the cfgMAC input must be set to 'Data' or 'QoS Data'. Otherwise, the function ignores payload.

example

[frame,frameLength] = wlanMACFrame(payload,cfgMAC,cfgPHY) generates a WLAN MAC frame in the physical layer (PHY) format specified by cfgPHY. To generate A-MPDUs, use this syntax.

[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 the FrameType property of the cfgMAC input must be 'Trigger'.

example

[frame,frameLength] = wlanMACFrame(___,'OutputFormat',format) specifies format, the data format in which the function returns frame.

Examples

collapse all

Create a wlanMACFrameConfig object for a request-to-send (RTS) MAC frame. Generate the frame by calling the wlanMACFrame function and display the result.

macConfig = wlanMACFrameConfig('FrameType','RTS');
[frame,frameLength] = wlanMACFrame(macConfig);
disp(frame')
B000FFFFFF013579A952
4000FFFFFF02468B7AB8

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

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

Generate a high-throughput-format (HT-format) A-MPDU frame of length 5000 octets.

Create a MAC frame configuration object.

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

Create an HT-format 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 obtained MSDU length vector.

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

Generate the 5000-octet A-MPDU.

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

Create a wlanMACManagementConfig configuration object, specifying the SSID as 'demo SSID'.

config = 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',config);

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. Generate the RTS MAC frame in bit format.

macConfig = wlanMACFrameConfig('FrameType','RTS');
[frame,frameLength] = wlanMACFrame(macConfig,'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, or wlanHTConfig. 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.

Specify this argument to:

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

  • Add end-of-frame (EOF) padding to frames in very-high-throughput (VHT) or high-efficiency (HE) format.

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

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- and HE-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™-2016 (Revision of IEEE Std 802.11-2012). “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 P802.11ax™/D4.1. “Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications. Amendment 1: Enhancements for High Efficiency WLAN.” Draft 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™.

Introduced in R2018b