Main Content

wlanPacketDetect

Estimate timing offset of OFDM packet using L-STF

Description

startOffset = wlanPacketDetect(rxSig,cbw) estimates the timing offset between the start of received signal rxSig and the start of the detected preamble for channel bandwidth cbw. The function uses the legacy short training field (L-STF) for this estimation. For more information, see Packet Detection Processing.

Note

This function supports packet detection of OFDM modulated signals only.

example

startOffset = wlanPacketDetect(rxSig,cbw,offset) specifies the sample at which the function begins autocorrelation processing relative to the start of the received signal.

example

startOffset = wlanPacketDetect(rxSig,cbw,offset,threshold) specifies the threshold that the decision statistic must meet or exceed to detect a packet.

example

startOffset = wlanPacketDetect(___,OversamplingFactor=osf) specifies an oversampling factor in addition to any input argument combination from the previous syntaxes. Use this syntax to perform packet detection on an oversampled signal.

[startOffset,M] = wlanPacketDetect(___) also returns the decision statistics of the packet detection algorithm for any of the input argument combinations in previous syntaxes.

example

Examples

collapse all

Create an HT configuration object and TGn channel object. Generate a transmit waveform.

cfgHT = wlanHTConfig;
tgn = wlanTGnChannel('LargeScaleFadingEffect','None');
txWaveform = wlanWaveformGenerator([1;0;0;1],cfgHT);

Pass the waveform through a TGn channel with an SNR of 20 dB. Detect the start of the packet.

snr = 20;
fadedSig = tgn(txWaveform);
rxWaveform = awgn(fadedSig,snr,0);
startOffset = wlanPacketDetect(rxWaveform,cfgHT.ChannelBandwidth)
startOffset = 
4

Create a VHT configuration object and generate the transmit waveform.

cfgVHT = wlanVHTConfig;
txWaveform = wlanWaveformGenerator([1;0;0;1],cfgVHT,...
    WindowTransitionTime=0);

Delay the signal by appending zeros at the start. Specify an offset of 25 for the beginning of autocorrelation processing. Detect the start of the packet.

rxWaveform = [zeros(100,1);txWaveform];
offset = 25;
startOffset = wlanPacketDetect(rxWaveform,cfgVHT.ChannelBandwidth,offset)
startOffset = 
48

Calculate the detected packet offset by adding the returned startOffset and the input offset. This coarse approximation of the packet-start offset is useful for determining where to begin autocorrelation for the first packet and for subsequent packets when a multipacket waveform is transmitted.

pktOffset = offset + startOffset
pktOffset = 
73

Create a non-HT configuration object. Generate the transmit waveform.

cfgNonHT = wlanNonHTConfig;
txWaveform = wlanWaveformGenerator([1;0;0;1],cfgNonHT,...
    'WindowTransitionTime',0);

Delay the signal by appending zeros at the start. Set an initial offset of 5 and a threshold very close to 1. Detect the delayed packet.

rxWaveform = [zeros(20,1);txWaveform];
offset = 5;
threshold = 1-10*eps;
startOffset = wlanPacketDetect(rxWaveform,...
    cfgNonHT.ChannelBandwidth,offset,threshold)
startOffset = 
15

Calculate the detected packet offset by adding the returned startOffset and the input offset.

totalOffset = offset + startOffset
totalOffset = 
20

Return the decision statistics of a WLAN waveform that consists of five 802.11a packets.

Create a non-HT configuration object and a five-packet waveform. Delay the waveform by 4000 samples.

cfgNonHT = wlanNonHTConfig;
txWaveform = wlanWaveformGenerator([1;0;0;1],cfgNonHT, ...
    'NumPackets',5,'IdleTime',20e-6);
rxWaveform = [zeros(4000,1);txWaveform];

Generate and plot packet decision statistics for the waveform. The decision statistics show five peaks, which correspond to the first sample of each packet detected.

offset = 0;
threshold = 1;
[startOffset,M] = wlanPacketDetect(rxWaveform,cfgNonHT.ChannelBandwidth,...
    offset,threshold);
plot(M)
xlabel('Samples')
ylabel('Decision Statistics')

Figure contains an axes object. The axes object with xlabel Samples, ylabel Decision Statistics contains an object of type line.

Input Arguments

collapse all

Received time-domain signal, specified as a complex-valued matrix of size NS-by-NR matrix. NS is the number of time-domain samples in the received signal. NR is the number of receive antennas.

Data Types: single | double
Complex Number Support: Yes

Channel bandwidth, specified as one of these values.

  • 'CBW5' — Channel bandwidth of 5 MHz

  • 'CBW10' — Channel bandwidth of 10 MHz

  • 'CBW20' — Channel bandwidth of 20 MHz

  • 'CBW40' — Channel bandwidth of 40 MHz

  • 'CBW80' — Channel bandwidth of 80 MHz

  • 'CBW160' — Channel bandwidth of 160 MHz

  • 'CBW320' — Channel bandwidth of 320 MHz

Data Types: char | string

Starting sample for the autocorrelation process, in samples after the start of the received signal, specified as a nonnegative integer. To detect startOffset for successive packets in multipacket waveforms, specify this input.

Note

Since the packet detection searches forward in time, the function cannot detect the first packet if the value of offset indicates a sample after the first L-STF.

Data Types: double

Decision statistic threshold that must be met or exceeded for the function to detect a packet, specified as a scalar in the interval (0, 1].

Data Types: double

Oversampling factor, specified as a scalar greater than or equal to 1. The oversampled cyclic prefix length must be an integer number of samples.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Timing offset, in samples, between the start of the received signal and the start of the detected preamble, returned as a nonnegative integer. This value, shifted by offset, indicates the detected start of a packet from the first sample of rxSig.

  • The function returns this output as [] if it does not detect a packet, or if the threshold input is 1.

  • The function returns this output as 0 if it detects the packet at the first sample of the waveform.

Data Types: double

Decision statistics based on autocorrelation of the input signal, returned as a real-valued column vector of length N. The value of N depends on the starting location of the autocorrelation process and the number of samples before which the function detects a packet. When threshold is 1, the function returns this output as the decision statistics of the full waveform and the startOffset output as [].

For more information, see Packet Detection Processing.

Data Types: double

More About

collapse all

Algorithms

collapse all

References

[1] Terry, J., and J. Heiskala. OFDM Wireless LANs: A Theoretical and Practical Guide. Indianapolis, IN: Sams, 2002.

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced in R2016b

expand all