xref: /openwifi/README.md (revision db5fcd350686dc21e906327bfaa0d6a8a5ece40a)
10df4ca4dSimoerman# openwifi
22ee67178SXianjun Jiao<img src="./openwifi-arch.jpg" width="900">
32ee67178SXianjun Jiao
438f76c01SJiao Xianjun**openwifi:** Linux mac80211 compatible full-stack IEEE802.11/Wi-Fi design based on SDR (Software Defined Radio).
52ee67178SXianjun Jiao
6*db5fcd35SJiao XianjunThis repository includes Linux driver and software. [openwifi-hw](https://github.com/open-sdr/openwifi-hw) repository has the FPGA design. [[Project document](https://github.com/open-sdr/openwifi/tree/master/doc)]
72ee67178SXianjun Jiao
844dff4bdSJiao Xianjun[Demo [video](https://youtu.be/NpjEaszd5u4) and video [download](https://users.ugent.be/~xjiao/openwifi-low-aac.mp4)]   [openwifi [maillist](https://lists.ugent.be/wws/subscribe/openwifi)] [[Cite openwifi project](#cite-openwifi-project)]
92ee67178SXianjun Jiao
102c8fb6e0SJiao XianjunOpenwifi code has dual licenses. AGPLv3 is the opensource license. For non-opensource license, please contact [email protected]. Openwifi project also leverages some 3rd party modules. It is user's duty to check and follow licenses of those modules according to the purpose/usage. You can find [an example explanation from Analog Devices](https://github.com/analogdevicesinc/hdl/blob/master/LICENSE) for this compound license conditions. [[How to contribute]](https://github.com/open-sdr/openwifi/blob/master/CONTRIBUTING.md).
112ee67178SXianjun Jiao
122ee67178SXianjun JiaoOpenwifi was born in [ORCA project](https://www.orca-project.eu/) (EU's Horizon2020 programme under agreement number 732174).
132ee67178SXianjun Jiao
142ee67178SXianjun Jiao**Features:**
152ee67178SXianjun Jiao
16a20313b8SJiao Xianjun* 802.11a/g
17a20313b8SJiao Xianjun* 802.11n MCS 0~7 (Only PHY rx for now. Full system support of 802.11n will come soon)
18a20313b8SJiao Xianjun* 20MHz bandwidth; 70 MHz to 6 GHz frequency range
19149fafc0SJiao Xianjun* Mode tested: Ad-hoc; Station; AP, Monitor
20836d8a87SJiao Xianjun* DCF (CSMA/CA) low MAC layer in FPGA (10us SIFS is achieved)
212ee67178SXianjun Jiao* Configurable channel access priority parameters:
222ee67178SXianjun Jiao  * duration of RTS/CTS, CTS-to-self
232ee67178SXianjun Jiao  * SIFS/DIFS/xIFS/slot-time/CW/etc
242ee67178SXianjun Jiao* Time slicing based on MAC address
252ee67178SXianjun Jiao* Easy to change bandwidth and frequency:
262ee67178SXianjun Jiao  * 2MHz for 802.11ah in sub-GHz
272ee67178SXianjun Jiao  * 10MHz for 802.11p/vehicle in 5.9GHz
282ee67178SXianjun Jiao* On roadmap: **802.11ax**
292ee67178SXianjun Jiao
302ee67178SXianjun Jiao**Performance (AP: openwifi at channel 44, client: TL-WDN4200 N900 Wireless Dual Band USB Adapter. iperf test):**
312ee67178SXianjun Jiao* AP --> client: 30.6Mbps(TCP), 38.8Mbps(UDP)
322ee67178SXianjun Jiao* client --> AP: 17.0Mbps(TCP), 21.5Mbps(UDP)
332ee67178SXianjun Jiao
342ee67178SXianjun Jiao**Supported SDR platforms:**
352ee67178SXianjun Jiao
369e696164SXianjun Jiaoboard_name|actual boards used|status
379e696164SXianjun Jiao-------|-------|----
389e696164SXianjun Jiaozc706_fmcs2|Xilinx ZC706 dev board + FMCOMMS2/3/4|done
3989e3e0fbSXianjun Jiaoadrv9361z7035|ADRV9361Z7035 SOM + ADRV1CRR-BOB carrier board|done. wait for test
4089e3e0fbSXianjun Jiaoadrv9361z7035_fmc|ADRV9361Z7035 SOM + ADRV1CRR-FMC carrier board|done
419e696164SXianjun Jiaoadrv9364z7020|ADRV9364Z7020 SOM + ADRV1CRR-BOB carrier board|future
429e696164SXianjun Jiaozcu102_fmcs2|Xilinx ZCU102 dev board + FMCOMMS2/3/4|future
439e696164SXianjun Jiaozcu102_9371|Xilinx ZCU102 dev board + ADRV9371|future
449e696164SXianjun Jiao
4589e3e0fbSXianjun Jiao* board_name is used to identify FPGA design in openwifi-hw/boards/ and rf script in user_space/rf_init_board_name.sh
462ee67178SXianjun Jiao* Don't have any boards? Or you like JTAG boot instead of SD card? Check our test bed [w-iLab.t](https://doc.ilabt.imec.be/ilabt/wilab/tutorials/openwifi.html) tutorial.
472ee67178SXianjun Jiao
482ee67178SXianjun Jiao**Quick start:** (Example instructions are verified on Ubuntu 16/18)
492ee67178SXianjun Jiao
50d9b0a1d0SJiao Xianjun* Download pre-built [openwifi Linux img file](https://users.ugent.be/~xjiao/openwifi-1.0.0-ghent.zip) (It might not have the latest bug-fixes/features. Check related sections on how to udpate files in img if needed). Burn the img file to a 16G SD card:
512ee67178SXianjun Jiao```
5286bab9c1SJiao Xianjunsudo dd bs=4M if=openwifi-1.0.0-ghent.img of=/dev/mmcblk0
532ee67178SXianjun Jiao(mmcblk0 is the dev name of sdcard in Linux. Make sure you use the correct one in your situation!)
542ee67178SXianjun Jiao(Above command takes a while)
552ee67178SXianjun Jiao```
5689e3e0fbSXianjun Jiao* Connect RX/TX antenna to RX1A/TX2A ports(For fmcomms4/ad9364, you may connect antennas to TXA/RXA), and make two antennas orthogonal to each other for good isolation. Config the board to SD card boot mode by switches (Read the board spec on internet). Insert the SD card to the board.
572ee67178SXianjun Jiao
582ee67178SXianjun Jiao* Connect the board to PC. (PC IP address should be 192.168.10.1). Power on the board. Then from PC:
592ee67178SXianjun Jiao```
602ee67178SXianjun Jiaossh [email protected]
612ee67178SXianjun Jiao(password: openwifi)
622ee67178SXianjun Jiaocd openwifi
6389e3e0fbSXianjun Jiaocp rf_init_board_name.sh rf_init.sh
6489e3e0fbSXianjun Jiao(If there isn't rf_init.sh, rename your board rf script, such as rf_init_adrv9361z7035.sh, to rf_init.sh for wgd.sh to call)
652ee67178SXianjun Jiaoservice network-manager stop
662ee67178SXianjun Jiao./wgd.sh
6786bab9c1SJiao Xianjun(For fmcomms4, you need an extra command: ./set_ant.sh rx1 tx1)
682ee67178SXianjun Jiaoifconfig sdr0 up
692ee67178SXianjun Jiaoiwlist sdr0 scan
702ee67178SXianjun Jiao(you should see the Wi-Fi scan result)
712ee67178SXianjun Jiao```
7286bab9c1SJiao Xianjun* Setup openwifi hotspot over topology: client -- (sdr0)|board|(eth0) -- (***ethX***)|PC|(***ethY***) -- internet
7386bab9c1SJiao Xianjun  * Enable IPv4 **IP forwarding** on both **board** and **PC**
742ee67178SXianjun Jiao  * Then, on board:
752ee67178SXianjun Jiao
762ee67178SXianjun Jiao        ifconfig sdr0 192.168.13.1
772ee67178SXianjun Jiao        route add default gw 192.168.10.1
782ee67178SXianjun Jiao        service isc-dhcp-server restart
792ee67178SXianjun Jiao        hostapd hostapd-openwifi.conf
802ee67178SXianjun Jiao  * Then, on PC:
812ee67178SXianjun Jiao
822ee67178SXianjun Jiao        sudo iptables -t nat -A POSTROUTING -o ethY -j MASQUERADE
832ee67178SXianjun Jiao        sudo ip route add 192.168.13.0/24 via 192.168.10.122 dev ethX
842ee67178SXianjun Jiao  * Now you can connect openwifi by your devices (phone, laptop, etc)
852ee67178SXianjun Jiao* Connect openwifi to another hotspot. Terminate hostapd, edit wpa-connect.conf properly, then:
862ee67178SXianjun Jiao
872ee67178SXianjun Jiao        ./wgd.sh
8886bab9c1SJiao Xianjun        (For fmcomms4, you need an extra command: ./set_ant.sh rx1 tx1)
892ee67178SXianjun Jiao        route del default gw 192.168.10.1
902ee67178SXianjun Jiao        wpa_supplicant -i sdr0 -c wpa-connect.conf
912ee67178SXianjun Jiao        (Wait for connection done, then open another ssh terminal)
922ee67178SXianjun Jiao        dhclient sdr0
93da62eb45SJiao Xianjun        (Wait for its done, then you should have connection)
942ee67178SXianjun Jiao
9589e3e0fbSXianjun Jiao* Real-time control/config via "sdrctl" (register, time slice config, etc), please go to openwifi/doc.
9602d858a7SJiao Xianjun
972ee67178SXianjun Jiao* ***Note***: If openwifi stops working after ~2 hours, it means the evaluation license of Xilinx Viterbi decoder has expired. You need to power cycle the board. Run this command several times on board to confirm:
982ee67178SXianjun Jiao
992ee67178SXianjun Jiao        root@analog:~/openwifi# ./sdrctl dev sdr0 get reg rx 20
1002ee67178SXianjun Jiao        SENDaddr: 00040050
1012ee67178SXianjun Jiao        reg  val: 34be0123
1022ee67178SXianjun Jiao        (If the last number of reg val is always 3, that means the Viterbi decoder stops working)
1032ee67178SXianjun Jiao
1042ee67178SXianjun Jiao**Build openwifi Linux img based on openwifi FPGA and driver:**
1052ee67178SXianjun Jiao
1065ae382e0SJiao Xianjun* Install Vivado/SDK 2017.4.1 (If you don't need to re-compile FPGA, WebPack version without license is enough)
1075ae382e0SJiao Xianjun* Get pre-built FPGA files from openwifi-hw repository.
1082ee67178SXianjun Jiao```
1092ee67178SXianjun Jiaogit submodule init openwifi-hw
1102ee67178SXianjun Jiaogit submodule update openwifi-hw
1112ee67178SXianjun Jiaocd openwifi-hw
11296be0adbSJiao Xianjungit checkout master
1132ee67178SXianjun Jiaogit pull
1142ee67178SXianjun Jiao```
1152ee67178SXianjun Jiao* Build Linux kernel and modules:
1162ee67178SXianjun Jiao```
1172ee67178SXianjun Jiaoexport XILINX_DIR=your_Xilinx_directory
1182ee67178SXianjun Jiaocd openwifi
1192ee67178SXianjun Jiaogit submodule init adi-linux
1202ee67178SXianjun Jiaogit submodule update adi-linux
1212ee67178SXianjun Jiao(Will take a while)
1222ee67178SXianjun Jiaocd adi-linux
1232ee67178SXianjun Jiaogit reset --hard 4220d5d24c6c7589fc702db4f941f0632b5ad767
1242ee67178SXianjun Jiaocp ../kernel_boot/kernel_config ./.config
1252ee67178SXianjun Jiaosource $XILINX_DIR/SDK/2017.4/settings64.sh
1262ee67178SXianjun Jiaoexport ARCH=arm
1272ee67178SXianjun Jiaoexport CROSS_COMPILE=arm-linux-gnueabihf-
1282ee67178SXianjun Jiaomake -j12 UIMAGE_LOADADDR=0x8000 uImage
1292ee67178SXianjun Jiao(Answer "y" to Xilinx DMA Engines (XILINX_DMA_ENGINES) [N/y/?] (NEW))
1302ee67178SXianjun Jiaomake modules
1312ee67178SXianjun Jiao```
1322ee67178SXianjun Jiao* Build openwifi Linux driver modules:
1332ee67178SXianjun Jiao```
1342ee67178SXianjun Jiaoexport OPENWIFI_DIR=your_openwifi_directory
1352ee67178SXianjun Jiaocd $OPENWIFI_DIR/driver
1362ee67178SXianjun Jiao./make_all.sh $XILINX_DIR/SDK/2017.4/ $OPENWIFI_DIR/adi-linux/
1372ee67178SXianjun Jiao```
1382ee67178SXianjun Jiao* Build openwifi Linux devicetree:
1392ee67178SXianjun Jiao```
14089e3e0fbSXianjun Jiaoexport BOARD_NAME=your_board_name
14189e3e0fbSXianjun Jiao(Check the board_name in the table of supported SDR platforms)
14289e3e0fbSXianjun Jiaocd $OPENWIFI_DIR/kernel_boot/boards/$BOARD_NAME
1432ee67178SXianjun Jiaodtc -I dts -O dtb -o devicetree.dtb devicetree.dts
14489e3e0fbSXianjun Jiaocp devicetree.dtb $OPENWIFI_DIR/kernel_boot/
1452ee67178SXianjun Jiao```
1462ee67178SXianjun Jiao* Build openwifi BOOT.BIN based on FPGA files generated in openwifi-hw:
1472ee67178SXianjun Jiao```
1482ee67178SXianjun Jiaocd $OPENWIFI_DIR/kernel_boot
149c017e305SJiao Xianjunsource $XILINX_DIR/SDK/2017.4/settings64.sh
15089e3e0fbSXianjun Jiao./build_boot_bin.sh ../openwifi-hw/boards/$BOARD_NAME/sdk/system_top_hw_platform_0/system.hdf ./boards/$BOARD_NAME/u-boot.elf
15189e3e0fbSXianjun Jiao(u-boot.elf is renamed from the compressed file in the board directory of original Analog Devices SD card boot partition)
15289e3e0fbSXianjun Jiao```
15389e3e0fbSXianjun Jiao* Prepare correct rf_init.sh in host openwifi/user_space
15489e3e0fbSXianjun Jiao```
15589e3e0fbSXianjun Jiaocd $OPENWIFI_DIR/user_space
15689e3e0fbSXianjun Jiaocp rf_init_board_name.sh rf_init.sh
15789e3e0fbSXianjun Jiao(If there isn't rf_init.sh, rename your board rf script, such as rf_init_adrv9361z7035.sh, to rf_init.sh for "wgd.sh remote" to download)
1582ee67178SXianjun Jiao```
1592ee67178SXianjun Jiao* Download [2017_R1-2018_01_29.img.xz](http://swdownloads.analog.com/cse/2017_R1-2018_01_29.img.xz) from [Analog Devices Wiki](https://wiki.analog.com/resources/tools-software/linux-software/zynq_images). Burn it into a SD card via your PC.
1609e8d5e4aSJiao Xianjun* Mount SD card BOOT/rootfs partitions to SDCARD_DIR directory of your PC (If it is mounted automatically, find the directory). Then copy built files to SD card via your PC. (You can also update files over ftp/ssh after your full system runs. Please check next section. Read carefully user_space/sdcard_boot_update.sh and set your ftp root directory to $OPENWIFI_DIR in your PC):
1612ee67178SXianjun Jiao```
1622ee67178SXianjun Jiaoexport SDCARD_DIR=sdcard_mount_point
16389e3e0fbSXianjun Jiaocp $OPENWIFI_DIR/kernel_boot/boards/$BOARD_NAME/devicetree.dtb $SDCARD_DIR/BOOT
1642ee67178SXianjun Jiaocp $OPENWIFI_DIR/kernel_boot/output_boot_bin/BOOT.BIN $SDCARD_DIR/BOOT
1652ee67178SXianjun Jiaocp $OPENWIFI_DIR/adi-linux/arch/arm/boot/uImage $SDCARD_DIR/BOOT
1662ee67178SXianjun Jiaocd $SDCARD_DIR/BOOT
1672ee67178SXianjun Jiaosync
1682ee67178SXianjun Jiao
1692ee67178SXianjun Jiaosudo mkdir $SDCARD_DIR/rootfs/root/openwifi
1702ee67178SXianjun Jiaosudo find $OPENWIFI_DIR/driver -name \*.ko -exec cp {} $SDCARD_DIR/rootfs/root/openwifi/ \;
17189e3e0fbSXianjun Jiaosudo cp $OPENWIFI_DIR/user_space/* $SDCARD_DIR/rootfs/root/openwifi/ -rf
1722ee67178SXianjun Jiao
1732ee67178SXianjun Jiaosudo mkdir $SDCARD_DIR/rootfs/lib/modules
17489e3e0fbSXianjun Jiaosudo mkdir $SDCARD_DIR/rootfs/lib/modules/4.14.0-g4220d5d
17589e3e0fbSXianjun Jiaosudo find $OPENWIFI_DIR/adi-linux -name \*.ko -exec cp {} $SDCARD_DIR/rootfs/lib/modules/4.14.0-g4220d5d/ \;
17689e3e0fbSXianjun Jiaosudo rm $SDCARD_DIR/rootfs/lib/modules/4.14.0-g4220d5d/{axidmatest.ko,xilinx_dma.ko,adi_axi_hdmi.ko,ad9361_drv.ko} -f
1772ee67178SXianjun Jiao
1782ee67178SXianjun Jiaosudo rm $SDCARD_DIR/rootfs/etc/udev/rules.d/70-persistent-net.rules
1792ee67178SXianjun Jiaosudo cp $OPENWIFI_DIR/kernel_boot/70-persistent-net.rules $SDCARD_DIR/rootfs/etc/udev/rules.d/
1802ee67178SXianjun Jiao(Above rule will auto-rename wlan0 to sdr0 which is the openwifi NIC name)
1812ee67178SXianjun Jiaocd $SDCARD_DIR/rootfs
1822ee67178SXianjun Jiaosync
1832ee67178SXianjun Jiao```
1842ee67178SXianjun Jiao**Run Linux and do some post-config:**
1852ee67178SXianjun Jiao
1862ee67178SXianjun Jiao* Insert the SD card to the board, power on and run serial console (such as minicom) from a PC via USB-UART cable to the board. After booting completes, in the PC serial console:
1872ee67178SXianjun Jiao```
1882ee67178SXianjun Jiaodepmod
1892ee67178SXianjun Jiao(Ignore the error messages)
1902ee67178SXianjun Jiaomodprobe mac80211
19131ae0e6cSXianjun Jiao(if you get error like: could not open moddep file 'lib/modules/4.14.0XXXYYYZZZ/modules.dep.bin', you could make a symbol link and modprobe again)
19289e3e0fbSXianjun Jiaoln -s /lib/modules/4.14.0-g4220d5d /lib/modules/4.14.0XXXYYYZZZ
19331ae0e6cSXianjun Jiaodepmod
19431ae0e6cSXianjun Jiaomodprobe mac80211
19531ae0e6cSXianjun Jiao
1962ee67178SXianjun Jiaocd openwifi
19789e3e0fbSXianjun Jiaocp rf_init_board_name.sh rf_init.sh
19889e3e0fbSXianjun Jiao(rename your board rf script, such as rf_init_adrv9361z7035.sh, to rf_init.sh for wgd.sh to call)
1992ee67178SXianjun Jiao./wgd.sh
20086bab9c1SJiao Xianjun(For fmcomms4, you need an extra command: ./set_ant.sh rx1 tx1)
2012ee67178SXianjun Jiao(Wait for the completion)
2022ee67178SXianjun Jiaoifconfig
2032ee67178SXianjun Jiao(You should see sdr0 interface)
2042ee67178SXianjun Jiaoiwlist sdr0 scan
2052ee67178SXianjun Jiao(You should see the Wi-Fi scan results)
2062ee67178SXianjun Jiao```
2072ee67178SXianjun Jiao* Config ssh server and ethernet IP address of the board. In the PC serial console:
2082ee67178SXianjun Jiao```
2092ee67178SXianjun Jiaopasswd
2102ee67178SXianjun Jiao(ssh server needs a password, such as "openwifi")
2112ee67178SXianjun JiaoAdd "UseDNS no" to /etc/ssh/sshd_config, otherwise ssh login takes too long time
2122ee67178SXianjun JiaoSet static IP to board (If you have DHCP server on PC, you can skip this step)
2132ee67178SXianjun JiaoAdd following content to /etc/network/interfaces
2142ee67178SXianjun Jiao  auto lo eth0
2152ee67178SXianjun Jiao  iface lo inet loopback
2162ee67178SXianjun Jiao  iface eth0 inet static
2172ee67178SXianjun Jiao          address 192.168.10.122
2182ee67178SXianjun Jiao          netmask 255.255.255.0
2192ee67178SXianjun JiaoAdd following content to /etc/resolv.conf
2202ee67178SXianjun Jiao  nameserver 8.8.8.8
2212ee67178SXianjun Jiao  nameserver 4.4.4.4
2222ee67178SXianjun Jiao
2232ee67178SXianjun JiaoDisable update (long time hang) on boot or ssh session:
2242ee67178SXianjun Jiao  sudo chmod -x /etc/update-motd.d/90-updates-available
2252ee67178SXianjun Jiao  sudo chmod -x /etc/update-motd.d/91-release-upgrade
2262ee67178SXianjun Jiao
2279e8d5e4aSJiao Xianjunreboot the board, and set proper IP (192.168.10.1) of the connected PC, then from the PC:
2282ee67178SXianjun Jiaossh [email protected]
2292ee67178SXianjun Jiao(password: openwifi)
2302ee67178SXianjun Jiao```
2319e8d5e4aSJiao Xianjun* Make on board file update easier:
2329e8d5e4aSJiao Xianjun  * Option 1: Access the board disk/rootfs from Ubuntu PC: "File manager --> Connect to Server...", input: sftp://[email protected]/root . Then you can operate files on board like normal files on your disk. To update files that need to be in boot partition (BOOT.BIN, uImage and devicetree.dtb), you can transfer those files to rootfs firstly, then on board:
2339e8d5e4aSJiao Xianjun
2349e8d5e4aSJiao Xianjun         mount /dev/mmcblk0p1 /sdcard
2359e8d5e4aSJiao Xianjun         (Create /sdcard directory firstly if it doesn't exist)
2369e8d5e4aSJiao Xianjun         cp file /sdcard
2379e8d5e4aSJiao Xianjun         cd /sdcard
2389e8d5e4aSJiao Xianjun         sync
2399e8d5e4aSJiao Xianjun         cd /
2409e8d5e4aSJiao Xianjun         umount /sdcard
2419e8d5e4aSJiao Xianjun         (Remember to power cycle the board)
2429e8d5e4aSJiao Xianjun  * Option 2: Setup [ftp server](https://help.ubuntu.com/lts/serverguide/ftp-server.html) on PC, allow anonymous and change ftp root directory to $OPENWIFI_DIR. Then on board:
2439e8d5e4aSJiao Xianjun
2449e8d5e4aSJiao Xianjun        ./sdcard_boot_update.sh
2459e8d5e4aSJiao Xianjun        (Above command downloads uImage, BOOT.BIN and devicetree.dtb, then copy them into boot partition. Remember to power cycle)
2469e8d5e4aSJiao Xianjun        ./wgd.sh remote
2479e8d5e4aSJiao Xianjun        (Above command downloads driver files, and brings up sdr0)
24886bab9c1SJiao Xianjun        (For fmcomms4, you need an extra command: ./set_ant.sh rx1 tx1)
2499e8d5e4aSJiao Xianjun
25086bab9c1SJiao Xianjun**Compile sdrctl on the board** ("On the board" means that you login to the board via ssh)
2512ee67178SXianjun Jiao```
2522ee67178SXianjun Jiaosudo apt-get install libnl-3-dev
2532ee67178SXianjun Jiaosudo apt-get install libnl-genl-3-dev
254ffe9541bSJiao Xianjun(Please find the next section to see how to connect board to the internet via your PC)
2552ee67178SXianjun Jiao(or find out .deb files by above commands and copy .deb to the board, if you do not have internet)
2562ee67178SXianjun Jiao
25786bab9c1SJiao Xianjuncopy $OPENWIFI_DIR/user_space/sdrctl_src to the board, then on the board:
2582ee67178SXianjun Jiaocd sdrctl_src
2592ee67178SXianjun Jiaochmod +x version.sh
2602ee67178SXianjun Jiaomake
2612ee67178SXianjun Jiao```
262ecb4f4f9SXianjun Jiao
2632ee67178SXianjun Jiao**Internet config**
26486bab9c1SJiao Xianjun* Connect board to internet. Topology: board|(eth0) -- (***ethX***)|PC|(***ethY***) -- internet
26586bab9c1SJiao Xianjun  * Enable IPv4 **IP forwarding** on both **board** and **PC**
26686bab9c1SJiao Xianjun  * On board:
26786bab9c1SJiao Xianjun  ```
26886bab9c1SJiao Xianjun  route add default gw 192.168.10.1
26986bab9c1SJiao Xianjun  ```
2702ee67178SXianjun Jiao  * On PC. After this your board should have internet via NAT through your PC.
2712ee67178SXianjun Jiao
2722ee67178SXianjun Jiao  ```
2732ee67178SXianjun Jiao  sudo iptables -t nat -A POSTROUTING -o ethY -j MASQUERADE
2742ee67178SXianjun Jiao  ```
27586bab9c1SJiao Xianjun* Setup AP for Wi-Fi client. Topology: client -- (sdr0)|board|(eth0) -- (***ethX***)|PC|(***ethY***) -- internet
2762ee67178SXianjun Jiao  * On board: Install dhcp server preparing for serving your openwifi clients via hostapd.
2772ee67178SXianjun Jiao  ```
2782ee67178SXianjun Jiao  sudo apt-get install isc-dhcp-server
2792ee67178SXianjun Jiao  sudo apt-get install Haveged
28086bab9c1SJiao Xianjun  sudo apt-get install hostapd
2812ee67178SXianjun Jiao  ```
2822ee67178SXianjun Jiao  * Put user_space/dhcpd.conf into (overwrite) /etc/dhcp/dhcpd.conf on board.
2832ee67178SXianjun Jiao  * On board:
2842ee67178SXianjun Jiao  ```
2852ee67178SXianjun Jiao  cd openwifi
2862ee67178SXianjun Jiao  service network-manager stop
2872ee67178SXianjun Jiao  ./wgd.sh
28886bab9c1SJiao Xianjun  (For fmcomms4, you need an extra command: ./set_ant.sh rx1 tx1)
2892ee67178SXianjun Jiao  ifconfig sdr0 up
2902ee67178SXianjun Jiao  ifconfig sdr0 192.168.13.1
2912ee67178SXianjun Jiao  route add default gw 192.168.10.1
2922ee67178SXianjun Jiao  service isc-dhcp-server restart
2932ee67178SXianjun Jiao  hostapd hostapd-openwifi.conf
2942ee67178SXianjun Jiao  ```
2952ee67178SXianjun Jiao  * On PC:
2962ee67178SXianjun Jiao  ```
2972ee67178SXianjun Jiao  sudo ip route add 192.168.13.0/24 via 192.168.10.122 dev ethX
2982ee67178SXianjun Jiao  ```
299ffe9541bSJiao Xianjun  * Now you can connect openwifi hotspot from your phone/laptop and access the internet.
30044dff4bdSJiao Xianjun
301e17fdc17Smmehari**Connecting a client to openwifi AP in 2.4GHz**
302e17fdc17Smmehari
303e17fdc17SmmehariOpenwifi only applies OFDM as its modulation scheme and as a result, it is not backward compatible with 802.11b clients or modes of operation. This is usually the case during beacon transmission, connection establishment, and robust communication.
304e17fdc17Smmehari
305e17fdc17SmmehariAs a solution to this problem, openwifi can be fully controlled only if communicating with APs/clients instantiated using hostapd/wpa_supplicant userspace programs respectively.
306e17fdc17Smmehari
307e17fdc17SmmehariFor hostapd program, 802.11b rates can be suppressed using configuration commands (i.e. supported_rates, basic_rates) and an example configuration file is provided (i.e. hostapd-openwifi.conf). One small caveat to this one comes from fullMAC Wi-Fi cards as they must implement the *NL80211_TXRATE_LEGACY* NetLink handler at the device driver level.
308e17fdc17Smmehari
309e17fdc17SmmehariOn the other hand, the wpa_supplicant program on the client side (commercial Wi-Fi dongle/board) cannot suppress 802.11b rates out of the box in 2.4GHz band, so there will be an issue when connecting openwifi (OFDM only). A patched wpa_supplicant should be used at the client side.
310e17fdc17Smmehari```
311e17fdc17Smmeharicd openwifi/user_space
312e17fdc17Smmehariwget http://w1.fi/releases/wpa_supplicant-2.1.tar.gz
313e17fdc17Smmeharitar xzvf wpa_supplicant-2.1.tar.gz
314e17fdc17Smmeharipatch -d wpa_supplicant-2.1/src/drivers/ < driver_nl80211.patch
315e17fdc17Smmeharicd wpa_supplicant-2.1/wpa_supplicant/
316e17fdc17Smmeharicp defconfig .config
317e17fdc17Smmeharised -i 's/#CONFIG_LIBNL32.*/CONFIG_LIBNL32=y/g' .config
318e17fdc17Smmeharimake -j16
319e17fdc17Smmeharisudo make install
320e17fdc17Smmeharicd ../../
321e17fdc17Smmeharirm -r wpa_supplicant-2.1/ wpa_supplicant-2.1.tar.gz
322e17fdc17Smmehari```
323e17fdc17Smmehari
32444dff4bdSJiao Xianjun## cite openwifi project
32544dff4bdSJiao Xianjun
32644dff4bdSJiao XianjunAny use of openwifi project which results in a publication should include a citation via (bibtex example):
32744dff4bdSJiao Xianjun```
32844dff4bdSJiao Xianjun@electronic{openwifigithub,
32944dff4bdSJiao Xianjun            author = {Xianjun, Jiao and Wei, Liu and Michael, Mehari},
33044dff4bdSJiao Xianjun            title = {open-source IEEE802.11/Wi-Fi baseband chip/FPGA design},
33144dff4bdSJiao Xianjun            url = {https://github.com/open-sdr/openwifi},
33244dff4bdSJiao Xianjun            year = {2019},
33344dff4bdSJiao Xianjun}
33444dff4bdSJiao Xianjun```
335