802.11 OFDM Beacon Frame Generation
802.11 OFDM 信标帧生成
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.
这个示例展示了如何使用软件定义无线电(SDR)平台生成包含介质访问控制(MAC)信标帧的数据包,适用于基带仿真或空中传输。
Introduction 介绍
In this example, you create an IEEE® 802.11™ beacon frame as described in section 9.3.3.3 of [1]. You can view the beacon packet transmitted using SDR by using A Wi-Fi device, as shown in this figure.
在这个例子中,您可以按照[1]中 9.3.3.3 节的描述创建一个 IEEE® 802.11™信标帧。您可以使用 Wi-Fi 设备查看通过 SDR 传输的信标数据包,如图所示。
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.
一个信标帧是一种管理帧,用于识别由一些 802.11 设备组成的基本服务集(BSS)。信标帧由一个 MAC 头部、一个信标帧主体和一个有效的帧校验序列(FCS)组成。信标帧主体包含信息字段,允许站点与网络关联。
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 an Analog Devices® ADALM-Pluto radio. The radio hardware can transmit the waveform over the air.
您还可以通过空中传输生成的波形。使用模拟设备® ADALM-Pluto 无线电将信标数据包上变频,进行射频传输。无线电硬件可以通过空中传输波形。
Transmitting the beacon over the air requires the ADALM-Pluto radio support package, which you can install with the Add-On Explorer. For more information about SDR platforms, see Hardware Support: Communications Toolbox.
通过空中传输信标需要 ADALM-Pluto 无线电支持包,您可以使用附加组件资源管理器进行安装。有关 SDR 平台的更多信息,请参见硬件支持:通信工具箱。
Example Setup 示例设置
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.
将信标数据包写入基带文件,并使用 SDR 平台进行传输。要使用 SDR 平台发送信标,请将useSDR
设置为 true。要写入基带文件,请将saveToFile
设置为 true。
useSDR = false; saveToFile = false;
Create IEEE 802.11 Beacon Frame
创建 IEEE 802.11 信标帧
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 wlanMACManagementConfig
.
一个站点(STA)根据信标间隔字段中的目标信标传输时间(TBTT)定期发送信标数据包。信标间隔表示 TBTT 之间的时间单位(TUs)数量,其中 1 TU 表示 1024 微秒。100 个 TUs 的信标间隔导致连续信标之间的时间间隔为 102.4 毫秒。您可以使用具有介质访问控制(MAC)帧配置对象和 MAC 帧体配置对象的函数生成信标帧。
Specify the network service set identifier (SSID), beacon interval, operating band, and channel number.
指定网络服务集标识符(SSID)、信标间隔、操作频段和信道号。
ssid = "TEST_BEACON";
beaconInterval = 100;
band = 5;
chNum = 52;
Create a MAC frame-body configuration object, setting the SSID and Beacon Interval field value.
创建一个 MAC 帧体配置对象,设置 SSID 和信标间隔字段值。
frameBodyConfig = wlanMACManagementConfig( ... BeaconInterval=beaconInterval, ... SSID=ssid);
Add the DS Parameter information element (IE) to the frame body by using the addIE
object function.
将 DS 参数信息元素(IE)添加到帧体中,使用addIE
对象函数。
dsElementID = 3; dsInformation = dec2hex(chNum,2); frameBodyConfig = frameBodyConfig.addIE(dsElementID,dsInformation);
Create beacon frame configuration object.
创建信标帧配置对象。
beaconFrameConfig = wlanMACFrameConfig(FrameType="Beacon", ... ManagementConfig=frameBodyConfig,FromDS=false);
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
创建 IEEE 802.11 信标数据包
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 wlanNonHTConfig
object.
使用对象配置相关 PSDU 长度的非 HT 信标数据包,指定 20 MHz 的信道带宽,一个发射天线,以及 1/2 的编码率(对应 MCS 指数 0)的 BPSK 调制。
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 comm.BasebandFileWriter
object.
将波形保存在基带文件中,使用 comm.BasebandFileWriter
对象。
if saveToFile bbw = comm.BasebandFileWriter("nonHTBeaconPacket.bb",Rs,fc); %#ok<UNRCH> bbw(txWaveform); release(bbw); end
Transmission with an SDR Device
使用 SDR 设备进行传输
In this section, you transmit the beacon packet over the air using an SDR device.
在这个部分,您使用 SDR 设备通过空中传输信标数据包。
if useSDR % The SDR platform must support transmitRepeat. sdrPlatform = 'Pluto'; %#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.
损害波形信号或降低传输质量,您可以调整发射增益tx.Gain
。这个参数以分贝为单位,驱动无线电中的功率放大器。您可以使用这些建议的值,或选择适合您天线配置的不同值。
For increased gain, set the
tx.Gain
parameter to0
.
为了增加增益,请将tx.Gain
参数设置为0
。For default gain, set the
tx.Gain
parameter to-10
.
将tx.Gain
参数设置为-10
以设置默认增益。For reduced gain, set the
tx.Gain
parameter to-20
.
将tx.Gain
参数设置为-20
以减小增益。
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.
将基带波形通过使用transmitRepeat
函数传输到 SDR 平台,然后将信号样本存储在硬件内存中。然后,该示例将该波形一直重复通过空中传输,直到调用传输对象的释放方法。在命令窗口中显示消息以确认传输已成功启动。
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 WLAN Beacon Receiver Using Software-Defined Radio example.
这个示例展示了如何为 IEEE 802.11 标准生成信标数据包,并使用 Wi-Fi 设备通过 SDR 硬件查看传输的信标数据包。您可以使用存储的基带信标数据包,通过使用软件定义无线电的 WLAN 信标接收器示例来恢复传输的信息。
Related Examples 相关示例
References 参考资料
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.
IEEE 标准 802.11™-2020 IEEE(IEEE 标准 802.11-2016 修订版)。"第 11 部分:无线局域网介质访问控制(MAC)和物理层(PHY)规范。"信息技术 IEEE 标准-系统之间的电信和信息交换。局域网和城域网-特定要求。