This example shows how to generate packets containing MAC beacon frames suitable for baseband simulation or over-the-air transmission using an SDR platform.
This example creates an IEEE® 802.11™ beacon frame as described in section 22.214.171.124 of [ 1 ]. A WiFi device can be used to view the beacon packet transmitted using SDR hardware as shown in the figure below.
The beacon frame is a type of management frame, it identifies a basic service set (BSS) formed by a number of 802.11 devices. The access point of a BSS periodically transmits the beacon frame to establish and maintain the network. The beacon frame consists of a MAC header, a beacon frame body and a valid frame check sequence (FCS). The beacon frame body contains the information fields which allows stations to associate with the network. A WLAN beacon frame is created using the
wlanMACFrame function. The beacon frame is encoded and modulated using the
wlanWaveformGenerator function to create a baseband beacon packet. In this example the generated waveform can be:
Stored in a baseband file format. The file format can be used with the example 802.11 OFDM Beacon Receiver with Live Data, which performs beacon packet decoding and describes the receiver processing.
Transmitted over-the-air. The beacon packet is upconverted for RF transmission using Xilinx® Zynq-Based Radio SDR hardware. The radio hardware allows a waveform to be transmitted over-the-air.
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;
The beacon packets are periodically transmitted 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 TBTT, where 1 TU represents 1024 microseconds. A beacon interval of 100 TU results in a 102.4 milliseconds time interval between successive beacons. A beacon frame is generated using the
wlanMACFrame function. This function consumes the MAC frame configuration object
wlanMACFrameConfig. This object accepts
wlanMACManagementConfig as a property to configure the beacon frame-body.
SSID = 'TEST_BEACON'; % Network SSID beaconInterval = 100; % In Time units (TU) band = 5; % Band, 5 or 2.4 GHz chNum = 52; % Channel number, corresponds to 5260MHz bitsPerByte = 8; % Number of bits in 1 byte % Create Beacon frame-body configuration object frameBodyConfig = wlanMACManagementConfig; frameBodyConfig.BeaconInterval = beaconInterval; % Beacon Interval in Time units (TUs) frameBodyConfig.SSID = SSID; % SSID (Name of the network) dsElementID = 3; % DS Parameter IE element ID dsInformation = dec2hex(chNum, 2); % DS Parameter IE information frameBodyConfig = frameBodyConfig.addIE(dsElementID, dsInformation); % Add DS Parameter IE to the configuration % Create Beacon frame configuration object beaconFrameConfig = wlanMACFrameConfig('FrameType', 'Beacon'); beaconFrameConfig.ManagementConfig = frameBodyConfig; % Generate Beacon frame bits [beacon, mpduLength] = wlanMACFrame(beaconFrameConfig, 'OutputFormat', 'bits'); % Calculate center frequency for the given band and channel number fc = helperWLANChannelFrequency(chNum, band);
A beacon packet is synthesized using
wlanWaveformGenerator with a non-HT format configuration object. In this example an object is configured to generate a beacon packet of 20 MHz bandwidth, 1 transmit antenna and BPSK rate 1/2 (MCS 1).
cfgNonHT = wlanNonHTConfig; % Create a wlanNonHTConfig object cfgNonHT.PSDULength = mpduLength; % Set the PSDU length in bytes % The idle time is the length in seconds of an idle period after each % generated packet. The idle time is set to the beacon interval. txWaveform = wlanWaveformGenerator(beacon, cfgNonHT, 'IdleTime', beaconInterval*1024e-6); Rs = wlanSampleRate(cfgNonHT); % Get the input sampling rate
This section saves the waveform in a baseband file using
if saveToFile % The waveform is stored in a baseband file BBW = comm.BasebandFileWriter('nonHTBeaconPacket.bb', Rs, fc); %#ok<UNRCH> BBW(txWaveform); release(BBW); end
For information about automatically detecting and synchronizing the waveform stored in the baseband file format see 802.11 OFDM Beacon Receiver with Live Data.
This section demonstrates the transmission of the beacon packet over-the-air using an SDR device.
if useSDR tx = sdrtx('AD936x'); %#ok<UNRCH> osf = 2; % OverSampling factor tx.BasebandSampleRate = Rs*osf; % The center frequency is set to the corresponding channel number tx.CenterFrequency = fc; end
The transmitter gain
tx.Gain parameter drives the power amplifier in the radio. This parameter is used to impair the quality of the waveform, you can change this parameter to reduce transmission quality, and impair the signal. These are suggested values, depending on your antenna configuration, you may have to tweak these values. The suggested values are:
Set to 0 for increased gain (0dB)
Set to -10 for default gain (-10dB)
Set to -20 for reduced gain (-20dB)
transmitRepeat function transfers the baseband waveform to the SDR platform, and stores 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> % Resample transmit waveform txWaveform = resample(txWaveform, osf, 1); % Transmit over-the-air transmitRepeat(tx, txWaveform); end
This example has demonstrated how to generate a beacon packet for the IEEE 802.11 standard. A Wi-Fi™ device can be used to view the beacon packet transmitted using SDR hardware. Alternatively, the stored baseband beacon packet can be processed to recover the transmitted information using the example 802.11 OFDM Beacon Receiver with Live Data.
This example uses the following helper function:
IEEE Std 802.11™-2016 IEEE Standard for Information technology - Telecommunications and information exchange between systems - Local and metropolitan area networks - Specific requirements - Part 11: Wireless LAN Medium Access Control (MAC) and Physical Layer (PHY) Specifications.