Recover and Analyze Packets in 802.11 Waveform
在 802.11 波形中恢复和分析数据包
This example blindly detects, decodes, and analyzes multiple IEEE 802.11a™, IEEE 802.11n™ (Wi-Fi 4), IEEE 802.11ac™ (Wi-Fi 5), IEEE 802.11ax™ (Wi-Fi 6), and IEEE 802.11be™ (Wi-Fi 7) packets in a waveform. The example provides a summary of the detected packets and displays the MAC contents, error vector magnitude (EVM), power, and signaling information for a selected packet.
这个示例在波形中盲目检测、解码和分析多个 IEEE 802.11a™、IEEE 802.11n™(Wi-Fi 4)、IEEE 802.11ac™(Wi-Fi 5)、IEEE 802.11ax™(Wi-Fi 6)和 IEEE 802.11be™(Wi-Fi 7)数据包。该示例提供了检测到的数据包的摘要,并显示所选数据包的 MAC 内容、误差向量幅度(EVM)、功率和信令信息。
Introduction 介绍
In this example, you detect, decode, and analyze multiple packets within a waveform. This example can decode OFDM non-HT, non-HT duplicate, HT, VHT [ 1 ], HE MU, HE SU, HE ER SU [ 2 ], and EHT MU [ 3 ] packet formats. The receiver does not know any transmission parameters, except for the channel bandwidth. It retrieves these parameters by decoding the preamble fields of the packet.
在此示例中,您可以检测、解码和分析波形中的多个数据包。此示例可以解码 OFDM 非 HT、非 HT 副本、HT、VHT[1]、HE MU、HE SU、HE ER SU[2]和 EHT MU[3]数据包格式。接收机除了信道带宽外,不知道任何传输参数。它通过解码数据包的前导字段来检索这些参数。
The spectrum and time domain samples.
频谱和时域样本。The signaling field contents.
信令字段内容。The resource unit and user information for an EHT or HE waveform.
EHT 或 HE 波形的资源单元和用户信息。The constellation of the equalized data symbols.
等量化数据符号的星座。The EVM of the signaling fields.
信令字段的 EVM。The EVM per data subcarrier averaged over spatial streams and symbols.
每个数据子载波上的 EVM 在空间流和符号上平均。The EVM per data symbol averaged over spatial streams and subcarriers.
在空间流和子载波上平均的每个数据符号的 EVM。The spectral flatness for non-OFDMA packets.
非 OFDMA 数据包的频谱平坦度。The MAC frame contents: A-MPDU deaggregation status, Address1, Address2, Frame Check Sequence (FCS) and Frame Type.
MAC 帧内容:A-MPDU 分解状态,地址 1,地址 2,帧校验序列(FCS)和帧类型。
Setup Waveform Recovery Parameters
设置 Waveform 恢复参数
This example analyzes I/Q data containing non-HT, HT-MF, VHT, HE, and EHT packets. The useSDR
variable controls the data source for this example:
该示例分析包含非-HT、HT-MF、VHT、HE 和 EHT 分组的 I/Q 数据。 useSDR
变量控制此示例的数据源:
When you select
useSDR
, an SDR captures an off-the-air waveform.
当您选择useSDR
,SDR 捕获了一个空中波形。When you clear
useSDR
,comm.BasebandFileReader
reads a synthetic waveform stored in a binary file format.
当您清除useSDR
时,comm.BasebandFileReader
读取存储在二进制文件格式中的合成波形。
useSDR = false;
Reception with an SDR Device
使用 SDR 设备接收
This example uses SDRs supported by Wireless Testbench™ and SDRs supported by Communication Toolbox™ support packages. This list provides information on which radios can be used by this example along with the required products.
此示例使用 Wireless Testbench™ 支持的 SDR 和 Communication Toolbox™ 支持包支持的 SDR。此列表提供了有关此示例可以使用哪些无线电以及所需产品的信息。
USRP™ N3xx series or X series (requires Wireless Testbench™ and Wireless Testbench Support Package for NI™ USRP Radios). For more information, see Supported Radio Devices (Wireless Testbench).
USRP™ N3xx 系列或 X 系列(需要 Wireless Testbench™ 和 Wireless Testbench Support Package for NI™ USRP Radios)。有关更多信息,请参见Supported Radio Devices(Wireless Testbench)。ADALM-PLUTO (requires Communications Toolbox Support Package for Analog Devices® ADALM-Pluto Radio). For more information, see ADALM-Pluto Radio.
ADALM-PLUTO(需要 Communications Toolbox Support Package for Analog Devices® ADALM-Pluto Radio)。有关更多信息,请参见 ADALM-Pluto Radio 。USRP™ E310/E312 (requires Communications Toolbox Support Package for USRP™ Embedded Series Radio). For more information, see USRP Embedded Series Radio.
USRP™ E310/E312(需要 USRP™ 嵌入式系列收发器的通信工具箱支持包)。更多信息请参见USRP 嵌入式系列收发器。USRP™ 200 series (requires Communications Toolbox Support Package for USRP™ Radio). For more information, see USRP Radio and Supported Hardware and Required Software.
USRP™ 200 系列(需要 USRP™ 无线电的通信工具包支持包)。有关更多信息,请参阅USRP 无线电 和 支持的硬件和所需软件。
See the relevant documentation for the chosen product and SDR on set up and installation.
查看所选产品和 SDR 的设置和安装相关文档。
Select SDR Device and Capture Antenna(s)
选择 SDR 设备和捕获天线
When you select an SDR as the data source, specify the device name from the dropdown along with the capture antenna configuration.
当您选择 SDR 作为数据源时,请在下拉菜单中指定设备名称,并设置捕获天线配置。
If using an NI USRP hardware with Wireless Testbench, click Update to see your saved radio setup configuration name appear at the top of the dropdown list.
如果使用 NI USRP 硬件与 Wireless Testbench,请单击Update,您会看到您保存的无线电设置配置名称出现在下拉列表的顶部。
if useSDR %#ok<*UNRCH> deviceOptions = getDeviceOptions; deviceName = deviceOptions(1) ; antennaOptions = getAntennaOptions(deviceName); antennaSelection = antennaOptions(1); end
Specify Capture Parameters and Initiate Capture
指定捕获参数并初始化捕获
After configuring deviceName
and antennaSelection
, specify the frequency band, channel number, capture duration, expected channel bandwidth of packets, radio sample rate, and radio gain.
在配置deviceName
和antennaSelection
之后,指定数据包的频段、信道号、捕获持续时间、预期信道带宽、无线采样率和无线增益。
To determine which channels in the 5 GHz band contain traffic from commercial 802.11 hardware, use the WLAN Beacon Receiver Using Software-Defined Radio example for Communication Toolbox Support Package radios or the OFDM Wi-Fi Scanner Using SDR Preamble Detection example for Wireless Testbench radios.
确定 5 GHz 频段中哪些通道包含来自商用 802.11 硬件的流量,请使用 Communication Toolbox 支持包无线电的使用软件定义无线电的 WLAN 信标接收器示例,或者 Wireless Testbench 无线电的使用 SDR 前导检测的 OFDM Wi-Fi 扫描仪示例。
if useSDR frequencyBand = 5; % Frequency band channelNumber = 102; % WLAN channel number captureTime = milliseconds(100); % Signal capture duration, to be specified as a duration type (e.g. seconds(1)) chanBW = 'CBW20'; % Channel bandwidth of all packets within the waveform sr = 20000000; % Radio sample rate gain = 50; % Radio gain % Set the center frequency to the corresponding channel number. The % center frequency should be centered on the channel bandwidth. fc = wlanChannelFrequency(channelNumber,frequencyBand); % Create SDR variable (if one does not exist already) and initiate waveform capture if ~exist('rx','var') rx = []; end rx = getSDRObject(deviceName,antennaSelection,fc,sr,gain,rx); rxWaveform = capture(rx,captureTime); end
Import a Captured Waveform from a File
从文件导入捕获的波形
If using a precaptured waveform as the data source, this section shows how to load I/Q data from an existing binary file using comm.BasebandFileReader
. The baseband file format includes the sample rate and the number of channels in the captured waveform. Alternatively, you can load the waveform from a MAT file.
如果使用预捕获的波形作为数据源,则本节显示如何使用comm.BasebandFileReader
从现有二进制文件加载 I/Q 数据。基带文件格式包括捕获波形的采样率和通道数量。或者,您可以从 MAT 文件加载波形。
% Configure the analysis source if ~useSDR BBR = comm.BasebandFileReader('wlanWaveform.bb'); % Create a baseband file reader object chanBW = 'CBW20'; % Channel bandwidth of all packets within the waveform bbrInfo = info(BBR); BBR.SamplesPerFrame = bbrInfo.NumSamplesInData; % Number of samples in the waveform rxWaveform = BBR(); % Load the I&Q sample from a binary file sr = BBR.SampleRate; % Sampling rate of the input signal release(BBR); end
To recover beacon packets from a MAT-file, see the WLAN Beacon Receiver Using Software-Defined Radio example.
要从 MAT 文件中恢复信标数据包,请参见使用软件定义无线电接收 WLAN 信标示例。
Signal Recovery and Analysis
信号恢复和分析
This section detects, analyzes, and displays a summary of the detected packets. All packets in the waveform must have the specified channel bandwidth. Parse and analyze the packets within a waveform by using the WaveformAnalyzer
object.
这一部分检测、分析并显示检测到的数据包摘要。波形中的所有数据包必须具有指定的信道带宽。通过使用WaveformAnalyzer
对象来解析和分析波形中的数据包。
analyzer = WaveformAnalyzer; process(analyzer,rxWaveform,chanBW,sr);
Display a summary of the detected packets.
显示检测到的数据包的摘要。
detectionSummary(analyzer);
Summary of the Detected Packets
detSummary=14×9 table
Number Format PHY Status Power (dBm) CFO (Hz) Offset (samples) MAC Contents RMS EVM (dB) Max EVM (dB)
______ ________ __________ ___________ ________ ________________ ____________ ____________ ____________
1 "Non-HT" "Success" 12.7 61431 97 "Beacon" -25.824 -17.272
2 "Non-HT" "Success" 13.08 -39757 2577 "RTS" -24.937 -17.737
3 "Non-HT" "Success" 13.01 62250 4017 "CTS" -26.181 -18.982
4 "EHT-MU" "Success" 12.38 61932 5199 "A-MPDU" -28.127 -18.167
5 "Non-HT" "Success" 12.84 62015 14199 "RTS" -29.565 -21.111
6 "Non-HT" "Success" 12.82 61806 15639 "CTS" -29.417 -21.095
7 "HE-MU" "Success" 14.98 -39660 17118 "A-MPDU" -25.353 -12.353
8 "Non-HT" "Success" 13.04 -39437 30478 "Block Ack" -25.564 -17.118
9 "Non-HT" "Success" 13.07 -29899 32238 "RTS" -25.082 -16.625
10 "Non-HT" "Success" 13.01 52489 33678 "CTS" -26.118 -18.372
11 "VHT" "Success" 17.43 62290 34958 "A-MPDU" -20.9 -10.957
12 "Non-HT" "Success" 14.99 -38861 40158 "RTS" -27.842 -20.114
13 "Non-HT" "Success" 14.94 42363 41598 "CTS" -27.409 -19.042
14 "HT-MF" "Success" 15.03 22238 42879 "A-MPDU" -26.55 -17.287
Use the pktNum
variable to display the MAC and PHY analysis for a selected packet.
使用pktNum
变量来展示所选数据包的 MAC 和 PHY 分析。
pktNum = 4 ;
Display the MAC information of the selected packet.
显示所选数据包的 MAC 信息。
macSummary(analyzer,pktNum);
Recovered MPDU Summary of Packet 4 AMPDU/MPDU Number STAID Address1 Address2 AMPDU/MPDU Decode Status MAC Frame Type _________________ _____ ______________ ______________ ________________________ ______________ "AMPDU1_MPDU1" 0 "23AFABC2FA1F" "00123456789B" "Success" "QoS Data" "AMPDU2_MPDU1" 1 "1432ABC2BD1C" "00123456789B" "Success" "QoS Data" "AMPDU3_MPDU1" 2 "3142BAC2AB1F" "00123456789B" "Success" "QoS Data"
Display the time samples and spectrum of the detected packet.
显示检测到的数据包的时间样本和频谱。
plotWaveform(analyzer,pktNum)
Display the packet field information of the selected packet.
显示所选数据包的数据字段信息。
fieldSummary(analyzer,pktNum);
Field Summary of Packet 4 (EHT-MU) Field Name Modulation Num Symbols Parity Check/CRC Power (dBm) RMS EVM (dB) Max EVM (dB) __________ __________ ___________ ________________ ___________ ____________ ____________ L-STF BPSK 2 14.52 L-LTF BPSK 2 14.37 L-SIG BPSK 1 Pass 14.23 -31.43 -25.23 RL-SIG BPSK 1 Pass 14.19 -32.40 -27.57 U-SIG BPSK 2 Pass 14.55 -32.24 -25.35 EHT-SIG BPSK 5 Pass 14.84 -31.78 -20.02 EHT-STF BPSK 1 12.11 EHT-LTF BPSK 1 11.98 Data 23 11.98 -28.13 -18.17
Display the signaling field information of the selected packet.
显示所选数据包的信令字段信息。
signalingSummary(analyzer,pktNum);
Signaling Field Summary of Packet 4 (EHT-MU) Property Value Property Value Property Value ________________ ___________ ______________________ _____ ____________ ________ L-SIG Length 312 Num EHT-SIG Symbols 5 PPDU Type DL OFDMA L-SIG Rate 0xB Spatial Reuse 0 EHT DUP Mode False Bandwidth CBW20 Guard Interval 3.2 UL/DL Indication DL EHT-LTF Type 4 BSS Color 0 Num EHT-LTF Symbols 1 TXOP Unspecified LDPC Extra Symbol True Compression Mode 0 Pre-FEC Padding Factor 4 EHT-SIG MCS 0 PE Disambiguity False
Display the RU information.
显示 RU 信息。
ruSummary(analyzer,pktNum);
Resource Unit (RU) Information of Packet 4 (EHT-MU) RU Number RU/MRU Size Subcarrier Index (Start) Subcarrier Index (End) Num Users Num STS Power (dBm) _________ ___________ ________________________ ______________________ _________ _______ ___________ "RU1" 26 -121 -96 1 1 2.36 "RU2" 52+26 -95 -17 1 1 7.15 "RU3" 106+26 -16 122 1 1 9.41
Display the user information.
显示用户信息。
userSummary(analyzer,pktNum);
User Information of Packet 4 (EHT-MU) STAID RU Number MCS Modulation Code Rate Channel Coding Num STS Transmit Beamforming _____ _________ ___ __________ _________ ______________ _______ ____________________ 0 "RU1" 2 "QPSK" "3/4" "LDPC" 1 0 1 "RU2" 4 "16QAM" "3/4" "LDPC" 1 0 2 "RU3" 6 "64QAM" "3/4" "LDPC" 1 0
Display EVM per spatial streams for all users.
显示所有用户每个空间流的 EVM。
userEVM(analyzer,pktNum);
User EVM per Spatial Stream of Packet 4 (EHT-MU) STAID Spatial Stream Index RMS EVM (dB) Max EVM (dB) _____ ____________________ ____________ ____________ 0 1 -27.928 -19.943 1 1 -28.229 -18.167 2 1 -28.228 -18.687
Plot the constellation for all users.
为所有用户绘制星座图。
plotConstellation(analyzer,pktNum);
Plot the EVM. 绘制 EVM。
plotEVM(analyzer,pktNum);
Plot the spectral flatness of non-punctured, non-OFDMA packets.
绘制非穿孔、非 OFDMA 数据包的频谱平坦度。
plotSpectralFlatness(analyzer,chanBW,pktNum);
Further Exploration 进一步探索
The WaveformAnalyzer
provides properties to control the pilot tracking, equalization, DC blocking, and packet detection algorithms that can be tweaked to improve packet detection and analysis performance.WaveformAnalyzer
提供了控制飞行轨迹跟踪、均衡、DC 阻塞和数据包检测算法的属性,可以对其进行调整以改善数据包检测和分析性能。
False packet detections 虚假数据包检测
False packet detections are detected packets that you do not believe are actual packets. Evaluating the time domain waveform of the packet is one way to determine if the detected packet is legitimate. If there is a significant number of false detections present these techniques may help reduce them:
检测到的错误数据包是您认为不是实际数据包的数据包。评估数据包的时间域波形是确定检测到的数据包是否合法的一种方法。如果存在大量的错误检测,这些技术可能有助于减少它们:
Enable the
EnergyDetection
property and set theEnergyDetectionThreshold
property to a suitable value given the noise floor of the capture device. When enabled,EnergyDetection
only detects packets with a power exceedingEnergyDetectionThreshold
during the preamble.
启用EnergyDetection
属性并将EnergyDetectionThreshold
属性设置为适当的值,考虑到捕获设备的噪声地板。启用EnergyDetection
后仅检测在序言期间功率超过EnergyDetectionThreshold
的数据包。Increase the
LLTFSNRDetectionThreshold
andPacketDetectionThreshold
properties to discard packets with a low measured SNR during detection.
增加LLTFSNRDetectionThreshold
和PacketDetectionThreshold
属性,以在检测期间丢弃信噪比低的数据包。
Missed packet detections 丢包检测
Missed packet detections are packets that you believe are in the waveform but have not been detected.
错过的包检测是您认为存在于波形中但尚未被检测到的包。
One possible reason a packet detection may have been missed is if a false detection occurred earlier in the waveform, but the L-SIG check passed, causing samples to be skipped. To search for possible false detections, enable the
SearchWithinUnsupportedPacket
property.
一个可能导致数据包检测被忽略的原因是在数据波形中早先发生了一次错误检测,但 L-SIG 检查通过,导致样本被跳过。要搜索可能存在的伪检测,启用SearchWithinUnsupportedPacket
属性。Alternatively try decreasing the
PacketDetectionThreshold
property to detect packet with low SNR during detection.
或者尝试减少PacketDetectionThreshold
属性,以便在检测过程中检测低信噪比的分组。
For detail on 802.11be, 802.11ax, 802.11ac signal recovery and processing, see the Recovery Procedure for an 802.11be Packet, Recovery Procedure for an 802.11ax Packet and Recovery Procedure for an 802.11ac Packet examples.
有关 802.11be、802.11ax、802.11ac 信号恢复和处理的详细信息,请参见802.11be 数据包恢复过程、802.11ax 数据包恢复过程和802.11ac 数据包恢复过程示例。
References 参考资料
IEEE Std 802.11™ - 2020 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.
IEEE Std 802.11™ - 2020 IEEE 标准:信息技术 - 系统之间的电信和信息交换 - 局域和城域网 - 特定要求 - 第 11 部分:无线局域网介质访问控制(MAC)和物理层(PHY)规范。IEEE 802.11ax™ - 2021 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 - Amendment 1: Enhancements for High Efficiency WLAN.
IEEE 802.11ax™ - 2021 年 IEEE 标准,涉及信息技术、电信和系统间信息交换的本地和城域网络的特定要求 - 第 11 部分:无线局域网介质访问控制(MAC)和物理层(PHY)规范 - 修正案 1:高效无线局域网增强。IEEE P802.11be™/D4.0 Draft 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 - Amendment 8: Enhancements for extremely high throughput (EHT).
IEEE P802.11be™/D4.0 信息技术标准 - 系统间局域网和城域网之间的电信和信息交换 - 特定要求 - 第 11 部分:无线局域网介质访问控制(MAC)和物理层(PHY)规格 - 修正案 8:极高吞吐量增强。
Local Functions 本地功能
These functions assist in SDR set up.
这些功能有助于 SDR 设置。
function options = getDeviceOptions % GETDEVICEOPTIONS returns a string array with all saved Wireless % Testbench radio configurations and Communication toolbox support package % SDRs spkgSDRs = getSupportPackageSDRs; % Check for WT configurations if user has WT installed and a valid license if ~isempty(ver('wt')) && license('test','Wireless_Testbench') savedRadioConfigurations = radioConfigurations; savedRadioConfigurationNames = [string({savedRadioConfigurations.Name})]; else savedRadioConfigurationNames = []; end options = [savedRadioConfigurationNames spkgSDRs]; end function options = getAntennaOptions(deviceName) %GETANTENNAOPTIONS returns a string array of valid antenna configurations %for a specified DEVICENAME % Acquire valid antenna values based on radio if ~matches(deviceName,getSupportPackageSDRs) antennas = hCaptureAntennas(deviceName); elseif matches(deviceName,["X300","FMCOMMS5"]) antennas = [1 2 3 4]'; elseif matches(deviceName,["Pluto", "B200", "N200/N210/USRP2"]) antennas = 1; else antennas = [1 2]'; end % Generate a string array list of all valid antenna configurations options = strings(0,1); for a = 1:length(antennas) % Generate unique combinations AntennaCombinations = nchoosek(antennas,a); % Generate list of all unique combinations for i = 1:size(AntennaCombinations, 1) options = [options;string(mat2str(AntennaCombinations(i,:)))]; %#ok<AGROW> end end end function spkgSDRs = getSupportPackageSDRs %GETSUPPORTPACKAGESDRs returns a string array of Communication Toolbox %support package SDRs that are supported for this example spkgSDRs = ["Pluto" "E3xx" "B200" "B210" "N200/N210/USRP2" "N300" "X300"]; end function rx = getSDRObject(deviceName,antennas,fc,sr,gain,rx) %GETSDROBJECT returns a Wireless Testbench basebandReceiver object %or an hSDRReceiver object with the properties of the object set according %to the input parameters % Create SDR object for waveform capture and set object's properties if matches(deviceName,getSupportPackageSDRs) rx = hSDRReceiver(deviceName); rx.OutputDataType = 'double'; rx.ChannelMapping = eval(antennas); rx.Gain = gain; else % Wireless Testbench hardware % Keep existing basebandReceiver object for performance purposes if ~isa(rx,'basebandReceiver') rx = basebandReceiver(deviceName); end rx.CaptureDataType = 'double'; rx.Antennas = eval(antennas); rx.RadioGain = gain; end rx.SampleRate = sr; rx.CenterFrequency = fc; end