WARP Project Forums - Wireless Open-Access Research Platform

You are not logged in.

#1 2018-Jan-19 15:46:40

zhimeng
Member
Registered: 2015-Sep-30
Posts: 47

Preamble detection

Hi, we are working on the WiFi preamble detection now, and we have some problems understanding the code, while a relevant thread is https://www.warpproject.org/forums/view … hp?id=2633

For example, we are not clear about the parameters used in the function wlan_phy_init() in the file w3_phy_util.c, while these lines initialize the 802.11g preamble detection.

69        // WLAN_RX_PKT_DET_OFDM_CFG reg
70        // args: (corr_thresh, energy_thresh, min_dur, post_wait)
71        // Using defaults from set_phy_samp_rate(20)
72        wlan_phy_rx_pktDet_autoCorr_ofdm_cfg(100, 15, 4, 0x3F);

We have looked into the definition of wlan_phy_rx_pktDet_autoCorr_ofdm_cfg(), which is consisted of bit wise operations.
We can guess something from the parameter names, but are not very sure about the exact behaviors.
Could you please shed light upon their physical meanings and units please?

Thanks so much for your help in advance.

Offline

 

#2 2018-Jan-22 09:59:42

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 4979

Re: Preamble detection

We can guess something from the parameter names, but are not very sure about the exact behaviors.
Could you please shed light upon their physical meanings and units please?

The packet detection thresholds do not have meaningful units. The autocorrelation and amplitude calculations result in arbitrary units. These calculations are compared to these thresholds in order to assert a packet detection event. We select threshold values first in simulation, then confirm these choices with experiments in hardware.

If you want to study individual parameters the best option is to work with the PHY model in simulation. Each field in the config registers is also configured in the simulation model's init script.

Offline

 

#3 2018-Jan-22 15:42:05

zhimeng
Member
Registered: 2015-Sep-30
Posts: 47

Re: Preamble detection

Thanks so much for your timely help!

[1]
We are using the WARP v 1.4 to detect the packets at a university lab.
This picture shows the measurement from a logical analyzer, lasting 4ms.
https://imgur.com/a/XEeL6
It seems that WARP is likely to detect the STS preamble, while fails to pass the LTS detection.

This picture provides the measurement of 0.5s
https://imgur.com/a/GH7xk

We are really confused by this observation.


[2] We don't have much experience with the FPGA and XPS.
Does the 'simulation' mean the MATLAB simulink file?
Could you provide some suggestions for using the simulation please?

Thanks again for your help.

Offline

 

#4 2018-Jan-23 10:19:12

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 4979

Re: Preamble detection

First, please consider upgrading to the latest 802.11 Reference Design. The v1.4 design is very old - we have made *many* improvements since that release, including big improvements to the packet detection subsystem.

The "Packet Detection -> LTS Timeout" event is common. The packet detector looks for signals with auto-correlation properties above a given threshold. This search occurs before AGC is triggered. For a strong signal the received I/Q are often clipped. Many signals (especially when clipped) besides 802.11 OFDM preambles are auto-correlated. The LTS correlator is much more selective - it searches for a cross-correlation peak across 64 samples. A false-positive packet detection will occur often. The LTS correlator then accepts (likely 802.11) or rejects (likely not 802.11) the waveform for further Rx processing.

We don't have much experience with the FPGA and XPS.
Does the 'simulation' mean the MATLAB simulink file?
Could you provide some suggestions for using the simulation please?

The Tx and Rx PHY designs are built with Xilinx System Generator, an FPGA design tool which uses MATLAB/Simulink for design entry and simulation. You can can simulate the Rx PHY System Generator model in Simulink to explore how various parameters and subsystems work.

Offline

 

#5 2018-Jan-25 19:53:37

zhimeng
Member
Registered: 2015-Sep-30
Posts: 47

Re: Preamble detection

Thanks so much for your informative answer!
We have updated WARP to 1.7, while still detecting this behavior.

[1] I am not sure about this issue

For a strong signal, the received I/Q are often clipped

, which will lead to strong correlation.
Previously, I thought that a clipped signal could happen if it was above a certain energy level. In my experiment, the energy level of the received signal (measured using other devices) is less than -70dBm.
Could this lead to a clipped signal? Or the clipped signal is a common behavior

[2] The auto correlation detection algorithm
I looked into the wlan_phy_rx_pmd/sync & antenna sel/Pkt Det/ RF A Det/ Autho-corr pkt det
It seems that the computation is based on the multiplication between x and x*(t+16) (the conjugate), while this value is compared with a threshold.
But I have some difficulties understanding this part.
I have two questions
    <1> why do we have the corr_20? corr_16 is likely due to the reason of the 0.8us period in STS. I am not sure about the meaning of corr_20
    <2> In

Code:

 wlan_phy_rx_pktDet_autoCorr_ofdm_cfg(100, 15, 4, 0x3F);

We have two thresholds here. One is the corr_thresh while the other is energy_thresh. Could you please tell me the functions of these two variables please?

Thanks so much for your help!

Offline

 

#6 2018-Jan-26 10:18:56

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 4979

Re: Preamble detection

Previously, I thought that a clipped signal could happen if it was above a certain energy level. In my experiment, the energy level of the received signal (measured using other devices) is less than -70dBm.
Could this lead to a clipped signal?

Yes. -70dBm is a mid-SNR signal; the Rx PHY is able to receive much weaker signals than this (see Rx characterization in the user guide).

why do we have the corr_20? corr_16 is likely due to the reason of the 0.8us period in STS. I am not sure about the meaning of corr_20

The Rx PHY implements separate calculations for detecting OFDM waveforms (periodic in 16 samples) and DSSS waveforms (periodic in 20 samples). These detectors use the same basic algorithm but are use correlation/magnitude calculations of different durations.

We have two thresholds here. One is the corr_thresh while the other is energy_thresh. Could you please tell me the functions of these two variables please?

The packet detector asserts a detection event when it observes:
- Incoming samples have high-enough auto-correlation, where "high enough" is controlled by the correlation threshold
- The same incoming samples have high-enough magnitude, controlled by the energy threshold
- The correlation/magnitude conditions are met for a minimum number of consecutive samples, controlled by the min_dur parameter.

The magnitude requirement avoids false positive detections for very low magnitude signals which might exhibit high autocorrelation but aren't actually OFDM waveforms. As an extreme example, consider a small, non-zero constant-valued input. It has very high autocorrelation (samples x[31:16] == x[15:0]) but is definitely not an OFDM waveform.

Offline

 

#7 2018-Jan-29 17:31:07

zhimeng
Member
Registered: 2015-Sep-30
Posts: 47

Re: Preamble detection

Your answers are really helpful!
Based on your comments, I am re-reading the matlab simulink file these days.

Due to my limited knowledge of simulink and xilinx, I have the following questions which may be naive
[1] I tried to run the wlan_phy_rx_pmd, the original simulink file under SysGen_Reference, but I have errors like "Unable to read file rx_sigs/wlan_tx_HTMF_MCS7_549B.mat. No such file or directory". I looked into the folder, and couldn't find the exact file.
Based on the readme, it seems that I need to generate the corresponding mat file for the wlan_phy_rx_pmd.
So I just changed the filename in wlan_phy_init.m from MCS7_549B.mat to "MCS7_52B.mat"

I am not quite clear about the relationship between the wlan_phy_init.m and wlan_phy_rx_pmd.mdl.
My current understanding is that I need to run wlan_phy_rx_init.m first and then use the system generator to simulate wlan_phy_rx_pmd.mdl
I have tried this, and it seems to be working - I could have the output observed at the simulink output.

Could you please tell me if this is the right way to start?


[2] Since I am focusing on the preamble detection, I think a good way is to extract the preamble detection block and just observe the behaviors, while the whole simulink file is too heavy for my computer.
For example, I just observe the auto correlation, and how the auto correlation interacts with the thresholds.
Could you comment on this please?

[3] Based on the readme.txt at the rx_sigs, "", I think it might be possible to generate I/Q samples using other software or we can sample the channel via USRP. With the stored I/Q samples, we can feed the samples to matlab simulink and observe the auto correlation.
This can be very helpful.
Could you please tell me if this idea is feasible or not?

Thanks so much for your precious support!
Sincerely,
Zhimeng

Offline

 

#8 2018-Jan-30 14:25:53

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 4979

Re: Preamble detection

The 'rx_sigs' folder is part of the Rx PHY model in the repository. You can copy that rx_sigs folder into your Rx PHY folder, or just run the Rx PHY model from the repository folder directly.

The 'rx_sigs' folder has .mat files which contain raw I/Q waveforms saved from simulating the Tx PHY. These are "perfect" waveforms - no noise, channel degradations, etc. You can also use other waveforms for the Rx PHY sim. Look at the wlan_phy_rx_init.m script to customize how the 'sim_sig' variable is assigned. We use a perfect waveform by default, but frequently use other waveforms during testing (i.e. real I/Q waveforms captured in hardware with ChipScope).

Since I am focusing on the preamble detection, I think a good way is to extract the preamble detection block and just observe the behaviors, while the whole simulink file is too heavy for my computer.
For example, I just observe the auto correlation, and how the auto correlation interacts with the thresholds.
Could you comment on this please?

This might be possible, but would require lots of hacking of the Sysgen model. The packet detection subsystem is tightly integrated with other subsystems in the Rx PHY, like the software-controlled registers for config/status values, the LTF correlator, the OFDM/DSSS reset blocks, etc. I would recommend getting comfortable with the full Rx PHY model in simulation first, then maybe try extracting subsystems.

Offline

 

#9 2018-Feb-05 18:38:01

zhimeng
Member
Registered: 2015-Sep-30
Posts: 47

Re: Preamble detection

Thanks a lot for your suggestions!
I have been following you recommendations these days, while I are being troubled by the following issues.

It will be great if you can shed light upon my problems
[1] How the correlation threshold is assigned
I tracked the regRx_PktDet_corrThresh_A, and found its value to be 0.4297 shown in the wlan_phy_rx_pmd/Sync & Antenna Sel/PktDet/Rf A Det/ Auto-Corr Pkt Det/Decision. This corresponds to 110/256.
I also found the assignment of regRx_pktDet_corrthresh_A with the parameter Corr_Thresh in the Registers/Fanout.
Then I went to the Registers folder. The Register4 PKTDET_AUTOCORR_CONFIG assigns the registers (corr_thresh E_thresh and MinDur).
I think this understanding is correct. Could you please verify it? (I am new to Matlab simulink and I am not sure about my understanding)

[2] I am not clear about the data format
In this matlab simulink, we have data type UFix_8_8, which is converted from UFix8_0 in the wlan_phy_rx_pmd/Registers folder.
I think the UFix8_0 means an unsigned 8-bit integer, like the common UFix8 in matlab, while UFix8_8 means a float value, whose integer part is 8-bit, and the fraction part is also 8-bit.
Based on the example of '0 1 1 1 0 1 1 0' for the register Corr_Thresh, and the final value of 0.4297 (corresponds to the 110/256, where 110 is the decimal value for '01110110') for regRx_PktDet_corrThresh_A. I think this conversion copies the register value to the fraction part.
Could you please tell me if this is correct or not?


[3] My goal is to work on the autocorrelation in WiFi. For this purpose, I am trying to write the formula of autocorrelation, while I found it very difficult to do so.
For example, in the wlan_phy_rx_pmd/Sync & Antenna Sel/Pkt Det/ Rf A Det/Auto-Corr Pkt Det/ Auto Corr
We have a Conj Mult block
I think this is a conjugate multiplication based on the name, like this a(t) X conjugate[a(t+16)]. But I couldn't find the conjugate operation, and the code seems to be a(t) X a(t+16).
Could you please tell me the formula for computing autocorrelation please?


[4] The autocorrelation value for the ideal WiFi signal.
I ran the wlan_phy_rx_pmd with the ideal signal under the folder rx_sigs.
I observed the autocorrelation value for corr_16 at wlan_phy_rx_pmd/Sync & Antenna Sel/ rf A Det /Auto-Corr Pkt Det.
The auto correlation value is only around 0.7 for STS signal
Strangely, if I observe the autocorrelation at different blocks, the autocorrelation values are different.
For example, in the wlan_phy_rx_pmd/Sync & Antenna Sel/ rf A Det /Auto-Corr Pkt Det/Decision, the corr_16 is around 0.2 for STS signal.




Sorry for these questions.
I have tried to solve them but didn't make it.
It will be great if you give me a hand.
Thanks so much for your help in advance!
Sincerely,
Zhimeng

Offline

 

#10 2018-Feb-06 13:34:47

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 4979

Re: Preamble detection

How the correlation threshold is assigned

You followed it correctly - the thresholds are sliced from the PKTDET_AUTOCORR_CONFIG register.

In the current Rx PHY (v1.7.5) the auto-correlation threshold has range [0, 1). The 16-sample correlation is compared to a magnitude taken over 2x (32) samples. Thus a correlation threshold of 0.5 corresponds to a "perfect" correlation. Our default of ~0.42 is based on experiments in hardware.

[2] I am not clear about the data format

These are fixed point representations (not floats), sometimes called Q format. UFixM_N means an M-bit unsigned number with N fractional bits.

[3] My goal is to work on the autocorrelation in WiFi. For this purpose, I am trying to write the formula of autocorrelation, while I found it very difficult to do so.
For example, in the wlan_phy_rx_pmd/Sync & Antenna Sel/Pkt Det/ Rf A Det/Auto-Corr Pkt Det/ Auto Corr
We have a Conj Mult block
I think this is a conjugate multiplication based on the name, like this a(t) X conjugate[a(t+16)]. But I couldn't find the conjugate operation, and the code seems to be a(t) X a(t+16).
Could you please tell me the formula for computing autocorrelation please?

The packet detection logic in the current (v1.7.5) Rx PHY uses just the real part of the complex auto-correlation value. This helps reject detection of waveforms with strong auto-correlation but large frequency shifts, such as interfering off-channel transmissions. Frequency shifts manifest as a fixed phase difference between samples in consecutive training symbols. The phase of a conjugate product (like in the auto-correlation computation) is equal to the phase difference of the multiplicands. Thus the auto-correlation of a signal with only a small frequency shift will have small phase (imaginary part near 0). I don't have rigorous analysis to support this scheme, but we've seen good results in simulation and hardware.

Offline

 

#11 2018-Feb-06 21:14:27

zhimeng
Member
Registered: 2015-Sep-30
Posts: 47

Re: Preamble detection

Thanks so much for your timely comments!

For the autocorrelation value part, I am not quite clear about the correlation threshold of 0.5 which corresponds to a perfect waveform.
In my test, I can indeed observe the peak autocorrelation with the stable value of 0.6966.
If 0.5 is for the perfect correlation, then the maximum possible correlation should be 0.5

Could you help me resolve this please?

Offline

 

#12 2018-Feb-06 22:54:16

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 4979

Re: Preamble detection

0.5 is the value for the correlation threshold that corresponds to perfect auto-correlation. The correlation threshold is used to compare the raw correlation value to the raw magnitude value. Both the raw values are dependent on the IQ magnitude. Think of the correlation threshold as the requirement for "how correlated" the signal is, independent of amplitude. 0.5 means "perfect" here because the magnitude calculation sums over twice as many samples as the correlation.

Offline

 

#13 2018-Feb-06 23:13:47

zhimeng
Member
Registered: 2015-Sep-30
Posts: 47

Re: Preamble detection

My bad.
When autocorrelation > mag * threshold, we detect the signal.
In this example, autocorrelation is 0.7, while threshold needs to be less than 0.5. This formula depends on the magnitude of the input signal.
Thanks so much for your help!

Offline

 

#14 2018-Jun-06 23:39:01

zhimeng
Member
Registered: 2015-Sep-30
Posts: 47

Re: Preamble detection

Hi, I am curious about how commodity receivers detect the STS preamble in practice.
I searched online, but most of the sources are research papers, which seem to be distant.

Could you please comment on this?
Thanks so much for your help in advance!

Offline

 

#15 2018-Jun-07 09:13:01

murphpo
Administrator
From: Mango Communications
Registered: 2006-Jul-03
Posts: 4979

Re: Preamble detection

We don't know what commodity Wi-Fi devices do; the signal processing in commercial chipsets is rarely disclosed. I would guess it's built around autocorrelation for tolerance to multipath, CFO, etc.

Offline

 

#16 2018-Jun-07 09:50:33

zhimeng
Member
Registered: 2015-Sep-30
Posts: 47

Re: Preamble detection

Thanks a lot for your timely feedback.
We were trying to figure out the behaviors of commodity NICs, but this seems to be very difficult.
In contrast, WARP is really a good platform for understanding and analyzing the wireless protocols.
Thanks so much for this platform!

Offline

 

Board footer