main content

recover and analyze packets in 802.11 waveform -凯发k8网页登录

this example blindly detects, decodes, and analyzes multiple ieee 802.11a™, ieee 802.11n™, ieee 802.11ac™, and ieee 802.11ax™ 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.

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, and he er su [ 2 ] 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.

  • the spectrum and time domain samples.

  • the signaling field contents.

  • the resource unit and user information for an he waveform.

  • the constellation of the equalized data symbols.

  • the evm of the signaling fields.

  • the evm per data subcarrier averaged over spatial streams and symbols.

  • the evm per data symbol averaged over spatial streams and subcarriers.

  • the spectral flatness for non-ofdma packets.

  • the mac frame contents: a-mpdu deaggregation status, address1, address2, frame check sequence (fcs) and frame type.

setup waveform recovery parameters

this example analyzes i/q data containing non-ht, ht-mf, vht, and he packets. the usesdr variable controls the data source for this example:

  • when you select usesdr, an sdr captures an off-the-air waveform.

  • when you clear usesdr, reads a synthetic waveform stored in a binary file format.

usesdr = false;

reception with an sdr device

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.

  • usrp™ n310/n320/n321/x310/x410 (requires wireless testbench™ and wireless testbnech support package for ni™ usrp radios)

  • adalm-pluto (requires communications toolbox support package for analog devices® adalm-pluto radio)

  • usrp™ e310/e312 (requires communications toolbox support package for usrp™ embedded series radio)

  • ad9361/fmcomms2/3/4/5 (requires communications toolbox support package for xilinx® zynq®-based radio)

  • usrp™ n200/n210/usrp2/b200/b210/x300 (requires communications toolbox support package for usrp™ radio)

see the relevant documentation for the chosen product and sdr on set up and installation.

select sdr device and capture antenna(s)

when you select an sdr as the data source, specify the device name from the dropdown along with the capture antenna configuration.

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.

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.

to determine which channels in the 5 ghz band contain traffic from commercial 802.11 hardware, use the ofdm beacon receiver using software-defined radio example for communication toolbox support package radios or the example for wireless testbench radios.

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 . 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.

% 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 ofdm beacon receiver using software-defined radio example.

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.

analyzer = waveformanalyzer;
process(analyzer,rxwaveform,chanbw,sr);

display a summary of the detected packets.

detectionsummary(analyzer);
                                                                           summary of the detected packets
detsummary=11×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      "he-mu"     "success"        14.98        -39660           5297          "a-mpdu"          -25.353         -12.353   
       5      "non-ht"    "success"        13.04        -39437          18657          "block ack"       -25.564         -17.118   
       6      "non-ht"    "success"        13.07        -29899          20417          "rts"             -25.082         -16.625   
       7      "non-ht"    "success"        13.01         52489          21857          "cts"             -26.118         -18.372   
       8      "vht"       "success"        17.43         62290          23137          "a-mpdu"            -20.9         -10.955   
       9      "non-ht"    "success"        14.99        -38861          28337          "rts"             -27.842         -20.114   
      10      "non-ht"    "success"        14.94         42363          29777          "cts"             -27.409         -19.042   
      11      "ht-mf"     "success"        15.03         22238          31058          "a-mpdu"           -26.55         -17.287   

use the pktnum variable to display the mac and phy analysis for a selected packet.

pktnum = 4;

display the mac information of the selected packet.

macsummary(analyzer,pktnum);
 
                                    recovered mpdu summary of packet 4
    ampdu/mpdu number    staid       address1          address2       ampdu/mpdu decode status    mac frame type
    _________________    _____    ______________    ______________    ________________________    ______________
     "ampdu1_mpdu1"        1      "1342abc2ff1f"    "00123456789b"           "success"              "qos data"  
     "ampdu2_mpdu1"        2      "23ffab1234ac"    "00123456789b"           "success"              "qos data"  
     "ampdu3_mpdu1"        3      "13ef35781356"    "00123456789b"           "success"              "qos data"  
     "ampdu4_mpdu1"        4      "159a123affff"    "00123456789b"           "success"              "qos data"  

display the time samples and spectrum of the detected packet.

plotwaveform(analyzer,pktnum)

figure contains an axes object. the axes object with title power of time-domain samples (packet 4), xlabel samples, ylabel power (dbm) contains 9 objects of type line, area. this object represents he.

figure contains an axes object. the axes object with title power spectrum (packet 4), xlabel frequency (mhz), ylabel power (dbm) contains an object of type line.

display the packet field information of the selected packet.

fieldsummary(analyzer,pktnum);
 
                                           field summary of packet 4 (he-mu)
    field name    modulation    num symbols    parity check/crc    power (dbm)    rms evm (db)    max evm (db)
    __________    __________    ___________    ________________    ___________    ____________    ____________
     l-stf        bpsk               2                                14.59                                   
     l-ltf        bpsk               2                                14.61                                   
     l-sig        bpsk               1               pass             14.96         -27.59          -22.62    
     rl-sig       bpsk               1               pass             14.86         -27.14          -19.87    
     he-sig-a     bpsk               2               pass             15.37         -26.14          -19.54    
     he-sig-b     bpsk               5               pass             14.98         -27.56          -20.08    
     he-stf       bpsk               1                                14.95                                   
     he-ltf       bpsk               2                                15.01                                   
     data                           35                                14.99         -25.35          -12.35    

display the signaling field information of the selected packet.

signalingsummary(analyzer,pktnum);
 
                               signaling field summary of packet 4 (he-mu)
        property        value          property          value          property            value 
    ________________    _____    ____________________    _____    ______________________    _____
    l-sig length        467      bandwidth               cbw20    num he-ltf symbols        2    
    l-sig rate          0xb      num he-sig-b symbols    5        ldpc extra symbol         true 
    ul/dl indication    dl       sigb compression        false    stbc                      false
    sigb mcs            0        guard interval          3.2      pre-fec padding factor    1    
    sigb dcm            false    he-ltf type             4        pe disambiguity           false
    bss color           0        doppler                 false                                   
    spatial reuse       0        txop                    127                                     

display the ru information.

rusummary(analyzer,pktnum);
 
                                    resource unit (ru) information of packet 4 (he-mu)
    ru number    ru size    subcarrier index (start)    subcarrier index (end)    num users    num sts    power (dbm)
    _________    _______    ________________________    ______________________    _________    _______    ___________
      "ru1"        52                 -121                       -70                  1           1          8.98    
      "ru2"        52                  -68                       -17                  1           1          8.96    
      "ru3"        52                   17                        68                  1           2          8.97    
      "ru4"        52                   70                       121                  1           1          8.97    

display the user information.

usersummary(analyzer,pktnum);
 
                                      user information of packet 4 (he-mu)
    staid    ru number    mcs    modulation    code rate    dcm    channel coding    num sts    transmit beamforming
    _____    _________    ___    __________    _________    ___    ______________    _______    ____________________
      1        "ru1"       0      "bpsk"         "1/2"       0         "ldpc"           1                0          
      2        "ru2"       2      "qpsk"         "3/4"       0         "ldpc"           1                0          
      3        "ru3"       4      "16qam"        "3/4"       0         "ldpc"           2                0          
      4        "ru4"       6      "64qam"        "3/4"       0         "ldpc"           1                0          

display evm per spatial streams for all users.

userevm(analyzer,pktnum);
 
          user evm per spatial stream of packet 4 (he-mu)
    staid    spatial stream index    rms evm (db)    max evm (db)
    _____    ____________________    ____________    ____________
      1               1                -26.391         -17.295   
      2               1                -27.401         -19.682   
      3               1                -23.564         -12.353   
      3               2                -23.122         -14.444   
      4               1                -27.278         -17.793   

plot the constellation for all users.

plotconstellation(analyzer,pktnum);
 

figure contains an axes object. the axes object with title equalized data symbols (packet 4), xlabel in-phase amplitude, ylabel quadrature amplitude contains 8 objects of type line. one or more of the lines displays its values using only markers these objects represent staid 1, staid 2, staid 3, staid 4, ref.

plot the evm.

plotevm(analyzer,pktnum);
 

figure contains an axes object. the axes object with title average evm (rms) per data subcarrier (packet 4), xlabel subcarrier number, ylabel evm (db) contains 4 objects of type line. these objects represent staid 1, staid 2, staid 3, staid 4.

 

figure contains an axes object. the axes object with title average evm (rms) per symbol (packet 4), xlabel symbol number, ylabel evm (db) contains 4 objects of type line. these objects represent staid 1, staid 2, staid 3, staid 4.

plot the spectral flatness for non-ofdma packets.

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.

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 the energydetectionthreshold property to a suitable value given the noise floor of the capture device. when enabled, energydetection only detects packets with a power exceeding energydetectionthreshold during the preamble.

  • increase the lltfsnrdetectionthreshold and packetdetectionthreshold properties to discard packets with a low measured snr during detection.

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 within possible false detections, enable the searchwithinunsupportedpacket property.

  • alternatively try decreasing the packetdetectionthreshold property to detect packet with low snr during detection.

for detail on 802.11ax and 802.11ac signal recovery and processing, see the recovery procedure for an 802.11ax packet and examples.

references

  1. 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.

  2. 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 6: enhancements for high efficiency wlan.

local functions

these functions assist in sdr set up.

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
    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" "ad936x" "fmcomms5" "e3xx" "b200" "b210" "n200/n210/usrp2" "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
网站地图