802.11 OFDM Beacon Frame Generation
This example shows how to generate packets containing medium access control (MAC) beacon frames suitable for baseband simulation or over-the-air transmission using a software-defined radio (SDR) platform.
In this example, you create an IEEE® 802.11™ beacon frame as described in section 18.104.22.168 of [ 1 ]. You can view the beacon packet transmitted using SDR by using A Wi-Fi device, as shown in this figure.
A beacon frame is a type of management frame that identifies a basic service set (BSS) formed by some 802.11 devices. The beacon frame consists of a MAC header, a beacon frame body and a valid frame check sequence (FCS). The beacon frame body contains information fields that allow stations to associate with the network.
You can store the generated waveform in a baseband file format.
You can also transmit the generated waveform over the air. Upconvert the beacon packet for RF transmission using Xilinx® Zynq-Based Radio SDR hardware. The radio hardware can transmit the waveform over the air.
Transmitting the beacon over the air requires the Xilinx Zynq-based radio support package, which you can install with the Add-On Explorer. For more information about SDR platforms, see Hardware Support: Communications Toolbox.
The beacon packet can be written to a baseband file and transmitted using an SDR platform. To transmit the beacon using the SDR platform set
useSDR to true. To write to a baseband file set
saveToFile to true.
useSDR = false; saveToFile = false;
Create IEEE 802.11 Beacon Frame
A station (STA) periodically transmits beacon packets as specified by the target beacon transmission time (TBTT) in the Beacon Interval field. The beacon interval represents the number of time units (TUs) between TBTTs, where 1 TU represents 1024 microseconds. A beacon interval of 100 TUs results in a 102.4 millisecond time interval between successive beacons. You can generate a beacon frame by using the
wlanMACFrame function with medium access control (MAC) frame configuration object
wlanMACFrameConfig and MAC frame-body configuration object
Specify the network service set identifier (SSID), beacon interval, operating band, and channel number.
ssid = "TEST_BEACON"; beaconInterval = 100; band = 5; chNum = 52;
Create a MAC frame-body configuration object, setting the SSID and Beacon Interval field value.
frameBodyConfig = wlanMACManagementConfig( ... BeaconInterval=beaconInterval, ... SSID=ssid);
Add the DS Parameter information element (IE) to the frame body by using the
addIE object function.
dsElementID = 3; dsInformation = dec2hex(chNum,2); frameBodyConfig = frameBodyConfig.addIE(dsElementID,dsInformation);
Create beacon frame configuration object.
beaconFrameConfig = wlanMACFrameConfig(FrameType="Beacon", ... ManagementConfig=frameBodyConfig);
Generate beacon frame bits.
[mpduBits,mpduLength] = wlanMACFrame(beaconFrameConfig,OutputFormat="bits");
Calculate center frequency for the specified operating band and channel number.
fc = wlanChannelFrequency(chNum,band);
Create IEEE 802.11 Beacon Packet
Configure a non-HT beacon packet with the relevant PSDU length, specifying a channel bandwidth of 20 MHz, one transmit antenna, and BPSK modulation with a coding rate of 1/2 (corresponding to MCS index 0) by using the
cfgNonHT = wlanNonHTConfig(PSDULength=mpduLength);
Generate an oversampled beacon packet by using the
wlanWaveformGenerator function, specifying an idle time.
osf = 2; tbtt = beaconInterval*1024e-6; txWaveform = wlanWaveformGenerator(mpduBits,cfgNonHT,... OversamplingFactor=osf,Idletime=tbtt);
Get the waveform sample rate.
Rs = wlanSampleRate(cfgNonHT,OversamplingFactor=osf);
Save Waveform to File
Save the waveform in a baseband file using the
if saveToFile bbw = comm.BasebandFileWriter("nonHTBeaconPacket.bb",Rs,fc); %#ok<UNRCH> bbw(txWaveform); release(bbw); end
Transmission with an SDR Device
In this section, you transmit the beacon packet over the air using an SDR device.
if useSDR % The SDR platform must support transmitRepeat. Valid platforms are % 'AD936x' and 'FMCOMMS5'. sdrPlatform = 'AD936x'; %#ok<UNRCH> tx = sdrtx(sdrPlatform); tx.BasebandSampleRate = Rs; % Set the center frequency to the corresponding channel number tx.CenterFrequency = fc; end
To impair the signal or reduce transmission quality of the waveform, you can adjust the transmitter gain
tx.Gain. This parameter, expressed in dB, drives the power amplifier in the radio. You can use these suggested values, or select different values appropriate for your antenna configuration.
For increased gain, set the
For default gain, set the
For reduced gain, set the
Transfer the baseband waveform to the SDR platform by using the
transmitRepeat function, and then store the signal samples in hardware memory. The example then repeatedly transmits this waveform over-the-air until the release method of the transmit object is called. Messages are displayed in the command window to confirm that transmission has started successfully.
if useSDR % Set transmit gain tx.Gain = 0; %#ok<UNRCH> % Transmit over the air transmitRepeat(tx,txWaveform); end
Conclusion and Further Exploration
This example shows how to generate a beacon packet for the IEEE 802.11 standard and view the beacon packet transmitted using SDR hardware by using a Wi-Fi device. You can use the stored baseband beacon packet to recover the transmitted information using the OFDM Beacon Receiver Using Software-Defined Radio example.
IEEE Std 802.11™-2020 IEEE(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.