main content

802.11 dynamic rate control simulation -凯发k8网页登录

this example shows dynamic rate control by varying the modulation and coding scheme (mcs) of successive packets transmitted over a frequency selective multipath fading channel.

introduction

the ieee® 802.11™ standard supports dynamic rate control by adjusting the mcs value of each transmitted packet based on the underlying radio propagation channel. maximizing link throughput, in a propagation channel that is time varying due to multipath fading or movement of the surrounding objects, requires dynamic variation of mcs. the ieee 802.11 standard does not define any standardized rate control algorithm (rca) for dynamically varying the modulation rate. the implementation of rca is left open to the wlan device manufacturers. this example uses a closed-loop rate control scheme. a recommended mcs for transmitting a packet is calculated at the receiver and is available at the transmitter without any feedback latency. in a real system this information would be conveyed through a control frame exchange. the mcs is adjusted for each subsequent packet in response to an evolving channel condition with noise power varying over time.

in this example, an ieee 802.11ac™ [ 1 ] waveform consisting of a single vht format packet is generated using the function. the waveform is passed through a tgac channel and noise is added. the packet is synchronized and decoded to recover the psdu. the snr is estimated and compared against thresholds to determine which mcs is suitable for transmission of the next packet. this figure shows the processing for each packet.

waveform configuration

an ieee 802.11ac vht transmission is simulated in this example. the vht waveform properties are specified in a configuration object. in this example the object is initially configured for a 40 mhz channel bandwidth, single transmit antenna and qpsk rate-1/2 (mcs 1). the mcs for the subsequent packets is changed by the algorithm throughout the simulation.

cfgvht = wlanvhtconfig;
cfgvht.channelbandwidth = 'cbw40'; % 40 mhz channel bandwidth
cfgvht.mcs = 1;                    % qpsk rate-1/2
cfgvht.apeplength = 4096;          % apep length in bytes
% set random stream for repeatability of results
s = rng(21);

channel configuration

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

tgacchannel = wlantgacchannel;
tgacchannel.delayprofile = 'model-d';
tgacchannel.channelbandwidth = cfgvht.channelbandwidth;
tgacchannel.numtransmitantennas = 1;
tgacchannel.numreceiveantennas = 1;
tgacchannel.transmitreceivedistance = 20; % distance in meters for nlos
tgacchannel.randomstream = 'mt19937ar with seed';
tgacchannel.seed = 0;
tgacchannel.normalizechanneloutputs = false;
% set the sampling rate for the channel
sr = wlansamplerate(cfgvht);
tgacchannel.samplerate = sr;

rate control algorithm parameters

typically rcas use channel quality or link performance metrics, such as snr or packet error rate, for rate selection. the rca presented in this example estimates the snr of a received packet. on reception, the estimated snr is compared against a predefined threshold. if the snr exceeds the predefined threshold then a new mcs is selected for transmitting the next packet. the rcaattack and rcarelease controls smooth rate changes to avoid changing rates prematurely. the snr must exceed the threshold rcaattack value to increase the mcs and must be under the threshold - rcarelease value to decrease the mcs. in this simulation rcaattack and rcarelease are set to conservatively increase the mcs and aggressively reduce it. for the threshold values selected for the scenario simulated in this example, a small number of packet errors are expected. these settings may not be suitable for other scenarios.

rcaattack = 1;  % control the sensitivity when mcs is increasing
rcarelease = 0; % control the sensitivity when mcs is decreasing
threshold = [11 14 19 20 25 28 30 31 35];
snrup = [threshold inf] rcaattack;
snrdown = [-inf threshold]-rcarelease;
snrind = cfgvht.mcs; % store the start mcs value

simulation parameters

in this simulation numpackets packets are transmitted through a tgac channel, separated by a fixed idle time. the channel state is maintained throughout the simulation, therefore the channel evolves slowly over time. this evolution slowly changes the resulting snr measured at the receiver. since the tgac channel changes very slowly over time, here an snr variation at the receiver visible over a short simulation can be forced using the walksnr parameter to modify the noise power:

  1. setting walksnr to true generates a varying snr by randomly setting the noise power per packet during transmission. the snr walks between 14-33 db (using the amplitude and meansnr variables).

  2. setting walksnr to false fixes the noise power applied to the received waveform, so that channel variations are the main source of snr changes at the receiver.

numpackets = 100; % number of packets transmitted during the simulation
walksnr = true;
% select snr for the simulation
if walksnr
    meansnr = 22;   % mean snr
    amplitude = 14; % variation in snr around the average mean snr value
    % generate varying snr values for each transmitted packet
    basesnr = sin(linspace(1,10,numpackets))*amplitude meansnr;
    snrwalk = basesnr(1); % set the initial snr value
    % the maxjump controls the maximum snr difference between one
    % packet and the next
    maxjump = 0.5;
else
    % fixed mean snr value for each transmitted packet. all the variability
    % in snr comes from a time varying radio channel
    snrwalk = 22; %#ok
end
% to plot the equalized constellation for each spatial stream set
% displayconstellation to true
displayconstellation = false;
if displayconstellation
    constellationdiagram = comm.constellationdiagram; %#ok
    constellationdiagram.showgrid = true;
    constellationdiagram.name = 'equalized data symbols';
end
% define simulation variables
snrmeasured = zeros(1,numpackets);
mcs = zeros(1,numpackets);
ber = zeros(1,numpackets);
packetlength = zeros(1,numpackets);

processing chain

the following processing steps occur for each packet:

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

  2. a fixed idle time is added between successive packets.

  3. the waveform is passed through an evolving tgac channel.

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

  5. this local function processpacket passes the transmitted waveform through the tgac channel, performs receiver processing, and snr estimation.

  6. the vht-ltf is extracted from the received waveform. the vht-ltf is ofdm demodulated and channel estimation is performed.

  7. the vht data field is extracted from the synchronized received waveform.

  8. noise estimation is performed using the demodulated data field pilots and single-stream channel estimate at pilot subcarriers.

  9. the estimated snr for each packet is compared against the threshold, the comparison is used to adjust the mcs for the next packet.

  10. the psdu is recovered using the extracted vht-data field.

for simplicity, this example assumes:

  1. fixed bandwidth and antenna configuration for each transmitted packet.

  2. there is no explicit feedback packet to inform the transmitter about the suggested mcs setting for the next packet. the example assumes that this information is known to the transmitter before transmitting the subsequent packet.

  3. fixed idle time of 0.5 milliseconds between packets.

for numpkt = 1:numpackets
    if walksnr
        % generate snr value per packet using random walk algorithm biased
        % towards the mean snr
        snrwalk = 0.9*snrwalk 0.1*basesnr(numpkt) rand(1)*maxjump*2-maxjump;
    end
    % generate a single packet waveform
    txpsdu = randi([0,1],8*cfgvht.psdulength,1,'int8');
    txwave = wlanwaveformgenerator(txpsdu,cfgvht,'idletime',5e-4);
    % receive processing, including snr estimation
    y = processpacket(txwave,snrwalk,tgacchannel,cfgvht);
    % plot equalized symbols of data carrying subcarriers
    if displayconstellation && ~isempty(y.estimatedsnr)
        release(constellationdiagram);
        constellationdiagram.referenceconstellation = wlanreferencesymbols(cfgvht);
        constellationdiagram.title = ['packet ' int2str(numpkt)];
        constellationdiagram(y.eqdatasym(:));
        drawnow
    end
    % store estimated snr value for each packet
    if isempty(y.estimatedsnr)
        snrmeasured(1,numpkt) = nan;
    else
        snrmeasured(1,numpkt) = y.estimatedsnr;
    end
    % determine the length of the packet in seconds including idle time
    packetlength(numpkt) = y.rxwaveformlength/sr;
    % calculate packet error rate (per)
    if isempty(y.rxpsdu)
        % set the per of an undetected packet to nan
        ber(numpkt) = nan;
    else
        [~,ber(numpkt)] = biterr(y.rxpsdu,txpsdu);
    end
    % compare the estimated snr to the threshold, and adjust the mcs value
    % used for the next packet
    mcs(numpkt) = cfgvht.mcs; % store current mcs value
    increasemcs = (mean(y.estimatedsnr) > snrup((snrind==0) snrind));
    decreasemcs = (mean(y.estimatedsnr) <= snrdown((snrind==0) snrind));
    snrind = snrind increasemcs-decreasemcs;
    cfgvht.mcs = snrind-1;
end

display and plot simulation results

this example plots the variation of mcs, snr, ber, and data throughput over the duration of the simulation.

  1. the mcs used to transmit each packet is plotted. when compared to the estimated snr, you can see the mcs selection is dependent on the estimated snr.

  2. the bit error rate per packet depends on the channel conditions, snr, and mcs used for transmission.

  3. the throughput is maximized by varying the mcs according to the channel conditions. the throughput is calculated using a sliding window of three packets. for each point plotted, the throughput is the number of data bits, successfully recovered over the duration of three packets. the length of the sliding window can be increased to further smooth the throughput. you can see drops in the throughput either when the mcs decreases or when a packet error occurs.

% display and plot simulation results
disp(['overall data rate: ' num2str(8*cfgvht.apeplength*(numpackets-numel(find(ber)))/sum(packetlength)/1e6) ' mbps']);
disp(['overall packet error rate: ' num2str(numel(find(ber))/numpackets)]);
plotresults(ber,packetlength,snrmeasured,mcs,cfgvht);
% restore default stream
rng(s);
overall data rate: 20.631 mbps
overall packet error rate: 0.03

conclusion and further exploration

this example uses a closed-loop rate control scheme where knowledge of the mcs used for subsequent packet transmission is assumed to be available to the transmitter.

in this example the variation in mcs over time due to the received snr is controlled by the threshold, rcaattack and rcarelease parameters. the rcaattack and rcarelease are used as controls to smooth the rate changes, this is to avoid changing rates prematurely. try changing the rcarelease control to two. in this case, the decrease in mcs is slower to react when channel conditions are not good, resulting in higher ber.

try setting the displayconstellation to true in order to plot the equalized symbols per received packet, you can see the modulation scheme changing over time. also try setting walksnr to false in order to visualize the mcs change per packet. here the variability in snr is only caused by the radio channel, rather than the combination of channel and random walk.

further exploration includes using an alternate rca scheme, more realistic mcs variation including changing number of space time streams, packet size and enabling stbc for subsequent transmitted packets.

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.

local functions

the following local functions are used in this example:

  • processpacket: add channel impairments and decode receive packet

  • plotresults: plot the simulation results

function y = processpacket(txwave,snrwalk,tgacchannel,cfgvht)
    % pass the transmitted waveform through the channel, perform
    % receiver processing, and snr estimation.
    chanbw = cfgvht.channelbandwidth; % channel bandwidth
    % set the following parameters to empty for an undetected packet
    estimatedsnr = [];
    eqdatasym = [];
    noisevarvht = [];
    rxpsdu = [];
    % get the ofdm info
    ofdminfo = wlanvhtofdminfo('vht-data',cfgvht);
    % pass the waveform through the fading channel model
    rxwave = tgacchannel(txwave);
    % account for noise energy in nulls so the snr is defined per
    % active subcarrier
    packetsnr = snrwalk-10*log10(ofdminfo.fftlength/ofdminfo.numtones);
    % add noise
    rxwave = awgn(rxwave,packetsnr);
    rxwaveformlength = size(rxwave,1); % length of the received waveform
    % recover packet
    ind = wlanfieldindices(cfgvht); % get field indices
    pktoffset = wlanpacketdetect(rxwave,chanbw); % detect packet
    if ~isempty(pktoffset) % if packet detected
        % extract the l-ltf field for fine timing synchronization
        lltfsearchbuffer = rxwave(pktoffset (ind.lstf(1):ind.lsig(2)),:);
        % start index of l-ltf field
        finepktoffset = wlansymboltimingestimate(lltfsearchbuffer,chanbw);
        % determine final packet offset
        pktoffset = pktoffset finepktoffset;
        if pktoffset<15 % if synchronization successful
            % extract vht-ltf samples from the waveform, demodulate and
            % perform channel estimation
            vhtltf = rxwave(pktoffset (ind.vhtltf(1):ind.vhtltf(2)),:);
            demodvhtltf = wlanvhtltfdemodulate(vhtltf,cfgvht);
            [chanestvhtltf,chanestsspilots] = wlanvhtltfchannelestimate(demodvhtltf,cfgvht);
            % extract vht data field
            vhtdata = rxwave(pktoffset (ind.vhtdata(1):ind.vhtdata(2)),:);
            % estimate the noise power in vht data field
            noisevarvht = vhtnoiseestimate(vhtdata,chanestsspilots,cfgvht);
            % recover equalized symbols at data carrying subcarriers using
            % channel estimates from vht-ltf
            [rxpsdu,~,eqdatasym] = wlanvhtdatarecover(vhtdata,chanestvhtltf,noisevarvht,cfgvht);
            % snr estimation per receive antenna
            powvhtltf = mean(vhtltf.*conj(vhtltf));
            estsigpower = powvhtltf-noisevarvht;
            estimatedsnr = 10*log10(mean(estsigpower./noisevarvht));
        end
    end
    % set output
    y = struct( ...
        'rxpsdu',           rxpsdu, ...
        'eqdatasym',        eqdatasym, ...
        'rxwaveformlength', rxwaveformlength, ...
        'noisevar',         noisevarvht, ...
        'estimatedsnr',     estimatedsnr);
end
function plotresults(ber,packetlength,snrmeasured,mcs,cfgvht)
    % visualize simulation results
    figure('outerposition',[50 50 900 700])
    subplot(4,1,1);
    plot(mcs);
    xlabel('packet number')
    ylabel('mcs')
    title('mcs selected for transmission')
    subplot(4,1,2);
    plot(snrmeasured);
    xlabel('packet number')
    ylabel('snr')
    title('estimated snr')
    subplot(4,1,3);
    plot(find(ber==0),ber(ber==0),'x')
    hold on; stem(find(ber>0),ber(ber>0),'or')
    if any(ber)
        legend('successful decode','unsuccessful decode')
    else
        legend('successful decode')
    end
    xlabel('packet number')
    ylabel('ber')
    title('instantaneous bit error rate per packet')
    subplot(4,1,4);
    windowlength = 3; % length of the averaging window
    movdatarate = movsum(8*cfgvht.apeplength.*(ber==0),windowlength)./movsum(packetlength,windowlength)/1e6;
    plot(movdatarate)
    xlabel('packet number')
    ylabel('mbps')
    title(sprintf('throughput over last %d packets',windowlength))
end
网站地图