MATLAB Examples

HT Packet Recovery

This example shows how to recover content from a HT format waveform.

Contents

Generate 20 MHz HT Waveform

Create an HT configuration object and transmission PSDU. Set MCS to 2. Later these settings are compared to recovered signal information. For an HT waveform, the data field is PSDULength*8 bits.

ht = wlanHTConfig('MCS',2);
txPSDU = randi([0 1],ht.PSDULength*8,1);

Create the PPDU fields individually. Create L-STF, L-LTF, L-SIG, HT-SIG, HT-STF, and HT-LTF preamble fields and the HT-Data field.

lstf = wlanLSTF(ht);
lltf = wlanLLTF(ht);
lsig = wlanLSIG(ht);
htsig = wlanHTSIG(ht);
htstf = wlanHTSTF(ht);
htltf = wlanHTLTF(ht);
htData = wlanHTData(txPSDU,ht);

Concatenate the individual fields to create a single PPDU waveform.

txPPDU = [lstf; lltf; lsig; htsig; htstf; htltf; htData];

Pass HT Waveform Through TGn SISO Channel

Create TGn SISO channel and AWGN channel objects.

fs = 20e6;
tgnChan = wlanTGnChannel('SampleRate',fs,'LargeScaleFadingEffect','Pathloss and shadowing');
awgnChan = comm.AWGNChannel('NoiseMethod','Variance','VarianceSource','Input port');

Calculate the noise variance for a receiver with a 9 dB noise figure. The noise variance, noiseVar, is equal to kTBF, where k is Boltzmann's constant, T is the ambient temperature of 290 K, B is the bandwidth (sample rate), and F is the receiver noise figure. Pass the transmitted waveform through the noisy TGn channel.

noiseVar = 10^((-228.6 + 10*log10(290) + 10*log10(fs) + 9)/10);
rxPPDU = awgnChan(tgnChan(txPPDU),noiseVar);

Recover HT Preamble Contents from PPDU

In general, the L-STF and L-LTF are processed to perform frequency offset estimation and correction, and symbol timing. For this example, the carrier frequency is not offset and the packet timing is 'on-time'. Therefore, for accurate demodulation, determination of carrier frequency offset and symbol timing is not required.

Find the start and stop indices for the PPDU fields.

fieldInd = wlanFieldIndices(ht)
fieldInd = 

  struct with fields:

      LSTF: [1 160]
      LLTF: [161 320]
      LSIG: [321 400]
     HTSIG: [401 560]
     HTSTF: [561 640]
     HTLTF: [641 720]
    HTData: [721 9200]

The stop index of HT-LTF indicates the preamble length in samples.

numSamples = fieldInd.HTLTF(2);

Plot the preamble and the beginning of the packet data. Add markers to and plot to delineate the packet field boundaries.

time = ([0:double(numSamples)-1]/fs)*1e6;
peak = 1.2*max(abs(rxPPDU(1:numSamples)));
fieldMarkers = zeros(numSamples,1);
fieldMarkers(fieldInd.LSTF(2)-1,1) = peak;
fieldMarkers(fieldInd.LLTF(2)-1,1) = peak;
fieldMarkers(fieldInd.LSIG(2)-1,1) = peak;
fieldMarkers(fieldInd.HTSIG(2)-1,1) = peak;
fieldMarkers(fieldInd.HTSTF(2)-1,1) = peak;
fieldMarkers(fieldInd.HTLTF(2)-1,1) = peak;
plot(time,abs(rxPPDU(1:numSamples)),time,fieldMarkers)
xlabel ('Time (microseconds)')
ylabel('Magnitude')
title('HT Format Preamble')

Demodulate the L-LTF and estimate the channel.

rxLLTF = rxPPDU(fieldInd.LLTF(1):fieldInd.LLTF(2),:);
demodLLTF = wlanLLTFDemodulate(rxLLTF,ht);
chEstLLTF = wlanLLTFChannelEstimate(demodLLTF,ht);

Extract the L-SIG field from the received PPDU and recover its information bits.

rxLSIG = rxPPDU(fieldInd.LSIG(1):fieldInd.LSIG(2),:);
[recLSIG,failCRC] = wlanLSIGRecover(rxLSIG,chEstLLTF,noiseVar,ht.ChannelBandwidth);
failCRC
failCRC =

  logical

   0

failCRC = 0 indicates that CRC passed.

For the HT format, the L-SIG rate bits are constant and set to [1 1 0 1]. Inspect the L-SIG rate information and confirm that this constant sequence is recovered. For the HT format, the MCS setting in HT-SIG determines the actual data rate.

rate = recLSIG(1:4)'
rate =

  1x4 int8 row vector

   1   1   0   1

Extract the HT-SIG and confirm that the CRC check passed.

recHTSIG = rxPPDU(fieldInd.HTSIG(1):fieldInd.HTSIG(2),:);
[recHTSIG,failCRC] = wlanHTSIGRecover(recHTSIG,chEstLLTF,noiseVar,ht.ChannelBandwidth);
failCRC
failCRC =

  logical

   0

Extract the MCS setting from the HT-SIG. For HT, the MCS is located in HT-SIG bits 0 through 6.

recMCSbits = (recHTSIG(1:7))';
recMCS = bi2de(double(recMCSbits))
isequal(recMCS,ht.MCS)
recMCS =

     2


ans =

  logical

   1

The recovered MCS setting matches the MCS value in the configuration object.

Extract and demodulate the HT-LTF. Use the demodulated signal to perform channel estimation. Use the channel estimate to recover the HT-Data field.

rxHTLTF = rxPPDU(fieldInd.HTLTF(1):fieldInd.HTLTF(2),:);
demodHTLTF = wlanHTLTFDemodulate(rxHTLTF,ht);
chEstHTLTF = wlanHTLTFChannelEstimate(demodHTLTF,ht);

Recover HT-Data Contents from PPDU

Create a recovery configuration object.

cfgRec = wlanRecoveryConfig;

Recover the received equalized symbols using channel estimates from the HT-LTF.

[recPSDU] = wlanHTDataRecover(rxPPDU(fieldInd.HTData(1):fieldInd.HTData(2),:),...
    chEstHTLTF,noiseVar,ht,cfgRec);

Compare the transmitted and received PSDU bits, and confirm that the number of bit errors is zero.

numErr = biterr(txPSDU,recPSDU)
numErr =

     0