main content

802.11n packet error rate simulation for 2x2 tgn channel -凯发k8网页登录

this example shows how to measure the packet error rate of an ieee® 802.11n™ ht link using an end-to-end simulation with a fading tgn channel model and additive white gaussian noise.

introduction

in this example an end-to-end simulation is used to determine the packet error rate for an 802.11n ht [ 1 ] link with a fading channel at a selection of snr points. at each snr point multiple packets are transmitted through a channel, demodulated and the psdus recovered. the psdus are compared to those transmitted to determine the number of packet errors and hence the packet error rate. packet detection, timing synchronization, carrier frequency offset correction and phase tracking are performed by the receiver. the processing for each packet is summarized in the following diagram.

this example also demonstrates how a loop can be used instead of a loop when simulating each snr point to speed up a simulation. the parfor function, as part of the parallel computing toolbox™, executes processing for each snr in parallel to reduce the total simulation time.

waveform configuration

an 802.11n ht transmission is simulated in this example. the ht format configuration object, , contains the format specific configuration of the transmission. the properties of the object contain the configuration. in this example the object is configured for a 20 mhz channel bandwidth, 2 transmit antennas, 2 space time streams and no space time block coding.

% create a format configuration object for a 2-by-2 ht transmission
cfght = wlanhtconfig;
cfght.channelbandwidth = 'cbw20'; % 20 mhz channel bandwidth
cfght.numtransmitantennas = 2;    % 2 transmit antennas
cfght.numspacetimestreams = 2;    % 2 space-time streams
cfght.psdulength = 1000;          % psdu length in bytes
cfght.mcs = 15;                   % 2 spatial streams, 64-qam rate-5/6
cfght.channelcoding = 'bcc';      % bcc channel coding

channel configuration

in this example a tgn n-los channel model is used with delay profile model-b. for model-b when the distance between transmitter and receiver is greater than or equal to five meters, the model is nlos. this is described further in .

% create and configure the channel
tgnchannel = wlantgnchannel;
tgnchannel.delayprofile = 'model-b';
tgnchannel.numtransmitantennas = cfght.numtransmitantennas;
tgnchannel.numreceiveantennas = 2;
tgnchannel.transmitreceivedistance = 10; % distance in meters for nlos
tgnchannel.largescalefadingeffect = 'none';
tgnchannel.normalizechanneloutputs = false;

simulation parameters

for each snr point in the vector snr a number of packets are generated, passed through a channel and demodulated to determine the packet error rate.

snr = 25:10:45;

the number of packets tested at each snr point is controlled by two parameters:

  1. maxnumpes is the maximum number of packet errors simulated at each snr point. when the number of packet errors reaches this limit, the simulation at this snr point is complete.

  2. maxnumpackets is the maximum number of packets simulated at each snr point and limits the length of the simulation if the packet error limit is not reached.

the numbers chosen in this example will lead to a very short simulation. for meaningful results we recommend increasing the numbers.

maxnumpes = 10; % the maximum number of packet errors at an snr point
maxnumpackets = 100; % the maximum number of packets at an snr point

set the remaining variables for the simulation.

% get the baseband sampling rate
fs = wlansamplerate(cfght);
% get the ofdm info
ofdminfo = wlanhtofdminfo('ht-data',cfght);
% set the sampling rate of the channel
tgnchannel.samplerate = fs;
% indices for accessing each field within the time-domain packet
ind = wlanfieldindices(cfght);

processing snr points

for each snr point a number of packets are tested and the packet error rate calculated.

for each packet the following processing steps occur:

  1. a psdu is created and encoded to create a single packet waveform.

  2. the waveform is passed through a different realization of the tgn channel model.

  3. awgn is added to the received waveform to create the desired average snr per active subcarrier after ofdm demodulation.

  4. the packet is detected.

  5. coarse carrier frequency offset is estimated and corrected.

  6. fine timing synchronization is established. the l-stf, l-ltf and l-sig samples are provided for fine timing to allow for packet detection at the start or end of the l-stf.

  7. fine carrier frequency offset is estimated and corrected.

  8. the ht-ltf is extracted from the synchronized received waveform. the ht-ltf is ofdm demodulated and channel estimation is performed.

  9. the ht data field is extracted from the synchronized received waveform. the psdu is recovered using the extracted field and the channel estimate.

a parfor loop can be used to parallelize processing of the snr points. to enable the use of parallel computing for increased speed comment out the 'for' statement and uncomment the 'parfor' statement below.

s = numel(snr);
packeterrorrate = zeros(s,1);
%parfor i = 1:s % use 'parfor' to speed up the simulation
for i = 1:s % use 'for' to debug the simulation
    % set random substream index per iteration to ensure that each
    % iteration uses a repeatable set of random numbers
    stream = randstream('combrecursive','seed',0);
    stream.substream = i;
    randstream.setglobalstream(stream);
    % account for noise energy in nulls so the snr is defined per
    % active subcarrier
    packetsnr = snr(i)-10*log10(ofdminfo.fftlength/ofdminfo.numtones);
    % loop to simulate multiple packets
    numpacketerrors = 0;
    n = 1; % index of packet transmitted
    while numpacketerrors<=maxnumpes && n<=maxnumpackets
        % generate a packet waveform
        txpsdu = randi([0 1],cfght.psdulength*8,1); % psdulength in bytes
        tx = wlanwaveformgenerator(txpsdu,cfght);
        % add trailing zeros to allow for channel filter delay
        tx = [tx; zeros(15,cfght.numtransmitantennas)]; %#ok
        % pass the waveform through the tgn channel model
        reset(tgnchannel); % reset channel for different realization
        rx = tgnchannel(tx);
        % add noise
        rx = awgn(rx,packetsnr);
        % packet detect and determine coarse packet offset
        coarsepktoffset = wlanpacketdetect(rx,cfght.channelbandwidth);
        if isempty(coarsepktoffset) % if empty no l-stf detected; packet error
            numpacketerrors = numpacketerrors 1;
            n = n 1;
            continue; % go to next loop iteration
        end
        % extract l-stf and perform coarse frequency offset correction
        lstf = rx(coarsepktoffset (ind.lstf(1):ind.lstf(2)),:);
        coarsefreqoff = wlancoarsecfoestimate(lstf,cfght.channelbandwidth);
        rx = frequencyoffset(rx,fs,-coarsefreqoff);
        % extract the non-ht fields and determine fine packet offset
        nonhtfields = rx(coarsepktoffset (ind.lstf(1):ind.lsig(2)),:);
        finepktoffset = wlansymboltimingestimate(nonhtfields,...
            cfght.channelbandwidth);
        % determine final packet offset
        pktoffset = coarsepktoffset finepktoffset;
        % if packet detected outwith the range of expected delays from the
        % channel modeling; packet error
        if pktoffset>15
            numpacketerrors = numpacketerrors 1;
            n = n 1;
            continue; % go to next loop iteration
        end
        % extract l-ltf and perform fine frequency offset correction
        lltf = rx(pktoffset (ind.lltf(1):ind.lltf(2)),:);
        finefreqoff = wlanfinecfoestimate(lltf,cfght.channelbandwidth);
        rx = frequencyoffset(rx,fs,-finefreqoff);
        % extract ht-ltf samples from the waveform, demodulate and perform
        % channel estimation
        htltf = rx(pktoffset (ind.htltf(1):ind.htltf(2)),:);
        htltfdemod = wlanhtltfdemodulate(htltf,cfght);
        chanest = wlanhtltfchannelestimate(htltfdemod,cfght);
        % extract ht data samples from the waveform
        htdata = rx(pktoffset (ind.htdata(1):ind.htdata(2)),:);
        % estimate the noise power in ht data field
        nvarht = htnoiseestimate(htdata,chanest,cfght);
        % recover the transmitted psdu in ht data
        rxpsdu = wlanhtdatarecover(htdata,chanest,nvarht,cfght,...
            "ldpcdecodingmethod","norm-min-sum");
        % determine if any bits are in error, i.e. a packet error
        packeterror = any(biterr(txpsdu,rxpsdu));
        numpacketerrors = numpacketerrors packeterror;
        n = n 1;
    end
    % calculate packet error rate (per) at snr point
    packeterrorrate(i) = numpacketerrors/(n-1);
    disp(['snr ' num2str(snr(i))...
          ' completed after '  num2str(n-1) ' packets,'...
          ' per: ' num2str(packeterrorrate(i))]);
end
snr 25 completed after 11 packets, per: 1
snr 35 completed after 45 packets, per: 0.24444
snr 45 completed after 100 packets, per: 0.01

plot packet error rate vs snr results

figure;
semilogy(snr,packeterrorrate,'-ob');
grid on;
xlabel('snr [db]');
ylabel('per');
title('802.11n 20mhz, mcs15, direct mapping, 2x2 channel model b-nlos');

further exploration

the number of packets tested at each snr point is controlled by two parameters; maxnumpes and maxnumpackets. for meaningful results it is recommended that these values should be larger than those presented in this example. increasing the number of packets simulated allows the per under different scenarios to be compared. try changing the transmit encoding scheme to ldpc and compare the packet error rate. as an example, the figure below was created by running the example for maxnumpes: 200 and maxnumpackets: 10000, with four different configurations; 1x1 and 2x2 with bcc and ldpc encoding.

appendix

this example uses the following helper functions:

selected bibliography

  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.

网站地图