One super power of the openwifi platform is "**Full Duplex**" which means that openwifi baseband can receive its own TX signal.
This makes the IQ sample and WiFi packet self loopback test possible. Reading the normal IQ sample capture [app note](iq.md) will help if you have issue or
want to understand openwifi side channel (for IQ and CSI) deeper.
[[Check the packet loopback on board](#Check-the-packet-loopback-on-board)]
[[Self loopback config](#Self-loopback-config)]
## IQ self loopback quick start
(Please replace the IQ length **8187** by **4095** if you use low end FPGA board: zedboard/adrv9464z7020/antsdr/zc702)
- Power on the SDR board.
- Put the Tx and Rx antenna as close as possible.
- Connect a computer to the SDR board via Ethernet cable. The computer should have static IP 192.168.10.1. Open a terminal on the computer, and then in the terminal:
# Setup monitor mode in WiFi channel 44. You should find a channel as clean as possible in your location. Note that some channels don't work, so stick to 44 or 48 for now.
# Turn off CCA by setting a very high threshold that make the CSMA engine always think the channel is idle (no incoming signal is higher than this threshold)
./sdrctl dev sdr0 set reg xpu 8 1000
# Put the receiver into reset state, so it won't affect our system in case it runs into dead state
./sdrctl dev sdr0 set reg rx 0 1
# Load side channel kernel module with buffer lenght of 8187 (replace this with 4095 when using low end FPGA board)
Normally in the previous ssh session, the count becomes 1. It means one packet (of IQ sample) is sent and captured via loopback over the air.
- On your computer (NOT ssh onboard!), run:
```
cd openwifi/user_space/side_ch_ctl_src
python3 iq_capture.py 8187
```
You might need to install beforehand: "sudo apt install python3-numpy", and "sudo apt install python3-matplotlib".
- Leave the above host session untouched. Let's go to the second ssh session (packet injection), and do single packet Tx again:
```
./inject_80211 -m n -r 5 -n 1 sdr0
```
Normally in the 1st ssh session, the count becomes 2. You should also see IQ sample capture figures like this:
![](./openwifi-iq-loopback.jpg)
- Stop the python3 script, which plots above, in the host session. A file **iq.txt** is generated. You can use the Matlab script test_iq_file_display.m
to do further offline analysis, or feed the IQ sample to the openwifi receiver simulation, etc.
## Check the packet loopback on board
- While signal/packet is looped back, you can capture it on board via normal sniffer program for further check/analysis on the packet (bit/byte level instead of IQ level), such as tcpdump or tshark.
A new ssh session to the board should be opened to do this before running the packet injection:
Run the packet injection "./inject_80211 -m n -r 5 -n 1 sdr0" in another session, you should see the packet information printed by tcpdump from self over-the-air loopback.
- By default, the loopback is via the air (from Tx antenna to Rx antenna). FPGA inernal loopback option is offered to have IQ sample and packet without
- Lots of packet injection parameters can be set: number of packet, type (data/control/management), MCS/rate, size, interval, etc. Please run the packet injection
program without any arguments to see the help.
- Besides the packet Tx via injection over monitor mode for loopback test, normal WiFi mode (AP/Client/ad-hoc) can also run together with self loopback.
For instance, run **fosdem.sh** instead of **wgd.sh** to setup an openwifi AP that will transmit beacons. The wgd.sh can also be replaced with other scenario
- To understand deeper of all above commands/settings, please refer to [Capture IQ sample, AGC gain, RSSI with many types of trigger condition](iq.md) and
[Capture dual antenna TX/RX IQ for multi-purpose (capture collision)](iq_2ant.md)