www.gusucode.com > wlan 源码程序 matlab案例代码 > wlan/RecoverLSIGVHTSIGAVHTSIGBInFadingChannelExample.m
%% Transmit and Recover L-SIG, VHT-SIG-A, VHT-SIG-B in Fading Channel % Transmit a VHT waveform through a noisy MIMO channel. Extract the L-SIG, % VHT-SIG-A, and VHT-SIG-B fields and verify that they were correctly % recovered. %% % Set the parameters used throughout the example. cbw = 'CBW40'; % Channel bandwidth fs = 40e6; % Sample rate (Hz) ntx = 2; % Number of transmit antennas nsts = 2; % Number of space-time streams nrx = 3; % Number of receive antennas %% % Create a VHT configuration object that supports a 2x2 MIMO transmission % and has an APEP length of 2000. vht = wlanVHTConfig('ChannelBandwidth',cbw,'APEPLength',2000, ... 'NumTransmitAntennas',ntx,'NumSpaceTimeStreams',nsts, ... 'SpatialMapping','Direct','STBC',false); %% % Generate a VHT waveform containing a random PSDU. txPSDU = randi([0 1],vht.PSDULength*8,1); txPPDU = wlanWaveformGenerator(txPSDU,vht); %% % Create a 2x2 TGac channel and an AWGN channel with an SNR=10 dB. tgacChan = wlanTGacChannel('SampleRate',fs,'ChannelBandwidth',cbw, ... 'NumTransmitAntennas',ntx,'NumReceiveAntennas',nrx, ... 'LargeScaleFadingEffect','Pathloss and shadowing', ... 'DelayProfile','Model-C'); chNoise = comm.AWGNChannel('NoiseMethod','Signal to noise ratio (SNR)',... 'SNR',10); %% % Pass the VHT waveforms through a 2x2 TGac channel and add the AWGN % channel noise. rxPPDU = chNoise(tgacChan(txPPDU)); %% % Add additional white noise corresponding to a receiver with a 9 dB noise % figure. The noise variance is equal to _k*T*B*F_, where _k_ is % Boltzmann's constant, _T_ is the ambient temperature, _B_ is the channel % bandwidth (sample rate), and _F_ is the receiver noise figure. nVar = 10^((-228.6+10*log10(290) + 10*log10(fs) + 9 )/10); rxNoise = comm.AWGNChannel('NoiseMethod','Variance','Variance',nVar); rxPPDU = rxNoise(rxPPDU); %% % Find the start and stop indices for all component fields of the PPDU. ind = wlanFieldIndices(vht) %% % The preamble is contained in the first 1760 symbols. Plot the preamble. plot(abs(rxPPDU(1:1760))) %% % Extract the L-LTF from the received PPDU using the start and stop indices % determined by the |wlanFieldIndices| function. Demodulate the L-LTF and % estimate the channel coefficients. rxLLTF = rxPPDU(ind.LLTF(1):ind.LLTF(2),:); demodLLTF = wlanLLTFDemodulate(rxLLTF,vht); chEstLLTF = wlanLLTFChannelEstimate(demodLLTF,vht); %% % Extract the L-SIG field from the received PPDU and recover its % information bits. rxLSIG = rxPPDU(ind.LSIG(1):ind.LSIG(2),:); infoLSIG = wlanLSIGRecover(rxLSIG,chEstLLTF,nVar,cbw); %% % Inspect the L-SIG rate information and confirm that the sequence |[1 1 0 % 1]| is received. This sequence corresponds to a 6 MHz data rate, which is % used for all VHT transmissions. rate = infoLSIG(1:4)' %% % Extract the VHT-SIG-A and confirm that the CRC check passed. rxVHTSIGA = rxPPDU(ind.VHTSIGA(1):ind.VHTSIGA(2),:); [infoVHTSIGA,failCRC] = wlanVHTSIGARecover(rxVHTSIGA, ... chEstLLTF,nVar,cbw); failCRC %% % Extract and demodulate the VHT-LTF. Use the demodulated signal to % estimate the channel coefficients needed to recover the VHT-SIG-B field. rxVHTLTF = rxPPDU(ind.VHTLTF(1):ind.VHTLTF(2),:); demodVHTLTF = wlanVHTLTFDemodulate(rxVHTLTF,vht); chEstVHTLTF = wlanVHTLTFChannelEstimate(demodVHTLTF,vht); %% % Extract and recover the VHT-SIG-B. rxVHTSIGB = rxPPDU(ind.VHTSIGB(1):ind.VHTSIGB(2),:); infoVHTSIGB = wlanVHTSIGBRecover(rxVHTSIGB,chEstVHTLTF,nVar,cbw); %% % Verify that the APEP length, contained in the first 19 bits of the % VHT-SIG-B, corresponds to the specified length of 2000 bits. pktLbits = infoVHTSIGB(1:19)'; pktLen = bi2de(double(pktLbits))*4