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 6baca0e72SJiao XianjunThis repository includes Linux driver and software. [openwifi-hw](https://github.com/open-sdr/openwifi-hw) repository has the FPGA design. [[Detailed 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 10a984b3fbSJiao 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. 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 39*89e3e0fbSXianjun Jiaoadrv9361z7035|ADRV9361Z7035 SOM + ADRV1CRR-BOB carrier board|done. wait for test 40*89e3e0fbSXianjun 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 45*89e3e0fbSXianjun 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 50*89e3e0fbSXianjun Jiao* Download pre-built [openwifi Linux img file](https://users.ugent.be/~xjiao/openwifi-1.0.0-ghent.zip) (depends on board_name as well). 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``` 56*89e3e0fbSXianjun 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 63*89e3e0fbSXianjun Jiaocp rf_init_board_name.sh rf_init.sh 64*89e3e0fbSXianjun 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 95*89e3e0fbSXianjun Jiao* Real-time control/config via "sdrctl" (register, time slice config, etc), please go to openwifi/doc. 9602d858a7SJiao Xianjun 9702d858a7SJiao Xianjun* ***Note***: The files (BOOT.BIN, drivers, etc) in pre-built SD card img might not have the latest bug-fixes/features. Check related section in this README on how to generate them and update them if needed. 9802d858a7SJiao Xianjun 992ee67178SXianjun 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: 1002ee67178SXianjun Jiao 1012ee67178SXianjun Jiao root@analog:~/openwifi# ./sdrctl dev sdr0 get reg rx 20 1022ee67178SXianjun Jiao SENDaddr: 00040050 1032ee67178SXianjun Jiao reg val: 34be0123 1042ee67178SXianjun Jiao (If the last number of reg val is always 3, that means the Viterbi decoder stops working) 1052ee67178SXianjun Jiao 1062ee67178SXianjun Jiao**Build openwifi Linux img based on openwifi FPGA and driver:** 1072ee67178SXianjun Jiao 1085ae382e0SJiao Xianjun* Install Vivado/SDK 2017.4.1 (If you don't need to re-compile FPGA, WebPack version without license is enough) 1095ae382e0SJiao Xianjun* Get pre-built FPGA files from openwifi-hw repository. 1102ee67178SXianjun Jiao``` 1112ee67178SXianjun Jiaogit submodule init openwifi-hw 1122ee67178SXianjun Jiaogit submodule update openwifi-hw 1132ee67178SXianjun Jiaocd openwifi-hw 11496be0adbSJiao Xianjungit checkout master 1152ee67178SXianjun Jiaogit pull 1162ee67178SXianjun Jiao``` 1172ee67178SXianjun Jiao* Build Linux kernel and modules: 1182ee67178SXianjun Jiao``` 1192ee67178SXianjun Jiaoexport XILINX_DIR=your_Xilinx_directory 1202ee67178SXianjun Jiaocd openwifi 1212ee67178SXianjun Jiaogit submodule init adi-linux 1222ee67178SXianjun Jiaogit submodule update adi-linux 1232ee67178SXianjun Jiao(Will take a while) 1242ee67178SXianjun Jiaocd adi-linux 1252ee67178SXianjun Jiaogit reset --hard 4220d5d24c6c7589fc702db4f941f0632b5ad767 1262ee67178SXianjun Jiaocp ../kernel_boot/kernel_config ./.config 1272ee67178SXianjun Jiaosource $XILINX_DIR/SDK/2017.4/settings64.sh 1282ee67178SXianjun Jiaoexport ARCH=arm 1292ee67178SXianjun Jiaoexport CROSS_COMPILE=arm-linux-gnueabihf- 1302ee67178SXianjun Jiaomake -j12 UIMAGE_LOADADDR=0x8000 uImage 1312ee67178SXianjun Jiao(Answer "y" to Xilinx DMA Engines (XILINX_DMA_ENGINES) [N/y/?] (NEW)) 1322ee67178SXianjun Jiaomake modules 1332ee67178SXianjun Jiao``` 1342ee67178SXianjun Jiao* Build openwifi Linux driver modules: 1352ee67178SXianjun Jiao``` 1362ee67178SXianjun Jiaoexport OPENWIFI_DIR=your_openwifi_directory 1372ee67178SXianjun Jiaocd $OPENWIFI_DIR/driver 1382ee67178SXianjun Jiao./make_all.sh $XILINX_DIR/SDK/2017.4/ $OPENWIFI_DIR/adi-linux/ 1392ee67178SXianjun Jiao``` 1402ee67178SXianjun Jiao* Build openwifi Linux devicetree: 1412ee67178SXianjun Jiao``` 142*89e3e0fbSXianjun Jiaoexport BOARD_NAME=your_board_name 143*89e3e0fbSXianjun Jiao(Check the board_name in the table of supported SDR platforms) 144*89e3e0fbSXianjun Jiaocd $OPENWIFI_DIR/kernel_boot/boards/$BOARD_NAME 1452ee67178SXianjun Jiaodtc -I dts -O dtb -o devicetree.dtb devicetree.dts 146*89e3e0fbSXianjun Jiaocp devicetree.dtb $OPENWIFI_DIR/kernel_boot/ 1472ee67178SXianjun Jiao``` 1482ee67178SXianjun Jiao* Build openwifi BOOT.BIN based on FPGA files generated in openwifi-hw: 1492ee67178SXianjun Jiao``` 1502ee67178SXianjun Jiaocd $OPENWIFI_DIR/kernel_boot 151c017e305SJiao Xianjunsource $XILINX_DIR/SDK/2017.4/settings64.sh 152*89e3e0fbSXianjun Jiao./build_boot_bin.sh ../openwifi-hw/boards/$BOARD_NAME/sdk/system_top_hw_platform_0/system.hdf ./boards/$BOARD_NAME/u-boot.elf 153*89e3e0fbSXianjun Jiao(u-boot.elf is renamed from the compressed file in the board directory of original Analog Devices SD card boot partition) 154*89e3e0fbSXianjun Jiao``` 155*89e3e0fbSXianjun Jiao* Prepare correct rf_init.sh in host openwifi/user_space 156*89e3e0fbSXianjun Jiao``` 157*89e3e0fbSXianjun Jiaocd $OPENWIFI_DIR/user_space 158*89e3e0fbSXianjun Jiaocp rf_init_board_name.sh rf_init.sh 159*89e3e0fbSXianjun 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) 1602ee67178SXianjun Jiao``` 1612ee67178SXianjun 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. 1629e8d5e4aSJiao 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): 1632ee67178SXianjun Jiao``` 1642ee67178SXianjun Jiaoexport SDCARD_DIR=sdcard_mount_point 165*89e3e0fbSXianjun Jiaocp $OPENWIFI_DIR/kernel_boot/boards/$BOARD_NAME/devicetree.dtb $SDCARD_DIR/BOOT 1662ee67178SXianjun Jiaocp $OPENWIFI_DIR/kernel_boot/output_boot_bin/BOOT.BIN $SDCARD_DIR/BOOT 1672ee67178SXianjun Jiaocp $OPENWIFI_DIR/adi-linux/arch/arm/boot/uImage $SDCARD_DIR/BOOT 1682ee67178SXianjun Jiaocd $SDCARD_DIR/BOOT 1692ee67178SXianjun Jiaosync 1702ee67178SXianjun Jiao 1712ee67178SXianjun Jiaosudo mkdir $SDCARD_DIR/rootfs/root/openwifi 1722ee67178SXianjun Jiaosudo find $OPENWIFI_DIR/driver -name \*.ko -exec cp {} $SDCARD_DIR/rootfs/root/openwifi/ \; 173*89e3e0fbSXianjun Jiaosudo cp $OPENWIFI_DIR/user_space/* $SDCARD_DIR/rootfs/root/openwifi/ -rf 1742ee67178SXianjun Jiao 1752ee67178SXianjun Jiaosudo mkdir $SDCARD_DIR/rootfs/lib/modules 176*89e3e0fbSXianjun Jiaosudo mkdir $SDCARD_DIR/rootfs/lib/modules/4.14.0-g4220d5d 177*89e3e0fbSXianjun Jiaosudo find $OPENWIFI_DIR/adi-linux -name \*.ko -exec cp {} $SDCARD_DIR/rootfs/lib/modules/4.14.0-g4220d5d/ \; 178*89e3e0fbSXianjun Jiaosudo rm $SDCARD_DIR/rootfs/lib/modules/4.14.0-g4220d5d/{axidmatest.ko,xilinx_dma.ko,adi_axi_hdmi.ko,ad9361_drv.ko} -f 1792ee67178SXianjun Jiao 1802ee67178SXianjun Jiaosudo rm $SDCARD_DIR/rootfs/etc/udev/rules.d/70-persistent-net.rules 1812ee67178SXianjun Jiaosudo cp $OPENWIFI_DIR/kernel_boot/70-persistent-net.rules $SDCARD_DIR/rootfs/etc/udev/rules.d/ 1822ee67178SXianjun Jiao(Above rule will auto-rename wlan0 to sdr0 which is the openwifi NIC name) 1832ee67178SXianjun Jiaocd $SDCARD_DIR/rootfs 1842ee67178SXianjun Jiaosync 1852ee67178SXianjun Jiao``` 1862ee67178SXianjun Jiao**Run Linux and do some post-config:** 1872ee67178SXianjun Jiao 1882ee67178SXianjun 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: 1892ee67178SXianjun Jiao``` 1902ee67178SXianjun Jiaodepmod 1912ee67178SXianjun Jiao(Ignore the error messages) 1922ee67178SXianjun Jiaomodprobe mac80211 19331ae0e6cSXianjun 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) 194*89e3e0fbSXianjun Jiaoln -s /lib/modules/4.14.0-g4220d5d /lib/modules/4.14.0XXXYYYZZZ 19531ae0e6cSXianjun Jiaodepmod 19631ae0e6cSXianjun Jiaomodprobe mac80211 19731ae0e6cSXianjun Jiao 1982ee67178SXianjun Jiaocd openwifi 199*89e3e0fbSXianjun Jiaocp rf_init_board_name.sh rf_init.sh 200*89e3e0fbSXianjun Jiao(rename your board rf script, such as rf_init_adrv9361z7035.sh, to rf_init.sh for wgd.sh to call) 2012ee67178SXianjun Jiao./wgd.sh 20286bab9c1SJiao Xianjun(For fmcomms4, you need an extra command: ./set_ant.sh rx1 tx1) 2032ee67178SXianjun Jiao(Wait for the completion) 2042ee67178SXianjun Jiaoifconfig 2052ee67178SXianjun Jiao(You should see sdr0 interface) 2062ee67178SXianjun Jiaoiwlist sdr0 scan 2072ee67178SXianjun Jiao(You should see the Wi-Fi scan results) 2082ee67178SXianjun Jiao``` 2092ee67178SXianjun Jiao* Config ssh server and ethernet IP address of the board. In the PC serial console: 2102ee67178SXianjun Jiao``` 2112ee67178SXianjun Jiaopasswd 2122ee67178SXianjun Jiao(ssh server needs a password, such as "openwifi") 2132ee67178SXianjun JiaoAdd "UseDNS no" to /etc/ssh/sshd_config, otherwise ssh login takes too long time 2142ee67178SXianjun JiaoSet static IP to board (If you have DHCP server on PC, you can skip this step) 2152ee67178SXianjun JiaoAdd following content to /etc/network/interfaces 2162ee67178SXianjun Jiao auto lo eth0 2172ee67178SXianjun Jiao iface lo inet loopback 2182ee67178SXianjun Jiao iface eth0 inet static 2192ee67178SXianjun Jiao address 192.168.10.122 2202ee67178SXianjun Jiao netmask 255.255.255.0 2212ee67178SXianjun JiaoAdd following content to /etc/resolv.conf 2222ee67178SXianjun Jiao nameserver 8.8.8.8 2232ee67178SXianjun Jiao nameserver 4.4.4.4 2242ee67178SXianjun Jiao 2252ee67178SXianjun JiaoDisable update (long time hang) on boot or ssh session: 2262ee67178SXianjun Jiao sudo chmod -x /etc/update-motd.d/90-updates-available 2272ee67178SXianjun Jiao sudo chmod -x /etc/update-motd.d/91-release-upgrade 2282ee67178SXianjun Jiao 2299e8d5e4aSJiao Xianjunreboot the board, and set proper IP (192.168.10.1) of the connected PC, then from the PC: 2302ee67178SXianjun Jiaossh [email protected] 2312ee67178SXianjun Jiao(password: openwifi) 2322ee67178SXianjun Jiao``` 2339e8d5e4aSJiao Xianjun* Make on board file update easier: 2349e8d5e4aSJiao 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: 2359e8d5e4aSJiao Xianjun 2369e8d5e4aSJiao Xianjun mount /dev/mmcblk0p1 /sdcard 2379e8d5e4aSJiao Xianjun (Create /sdcard directory firstly if it doesn't exist) 2389e8d5e4aSJiao Xianjun cp file /sdcard 2399e8d5e4aSJiao Xianjun cd /sdcard 2409e8d5e4aSJiao Xianjun sync 2419e8d5e4aSJiao Xianjun cd / 2429e8d5e4aSJiao Xianjun umount /sdcard 2439e8d5e4aSJiao Xianjun (Remember to power cycle the board) 2449e8d5e4aSJiao 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: 2459e8d5e4aSJiao Xianjun 2469e8d5e4aSJiao Xianjun ./sdcard_boot_update.sh 2479e8d5e4aSJiao Xianjun (Above command downloads uImage, BOOT.BIN and devicetree.dtb, then copy them into boot partition. Remember to power cycle) 2489e8d5e4aSJiao Xianjun ./wgd.sh remote 2499e8d5e4aSJiao Xianjun (Above command downloads driver files, and brings up sdr0) 25086bab9c1SJiao Xianjun (For fmcomms4, you need an extra command: ./set_ant.sh rx1 tx1) 2519e8d5e4aSJiao Xianjun 25286bab9c1SJiao Xianjun**Compile sdrctl on the board** ("On the board" means that you login to the board via ssh) 2532ee67178SXianjun Jiao``` 2542ee67178SXianjun Jiaosudo apt-get install libnl-3-dev 2552ee67178SXianjun Jiaosudo apt-get install libnl-genl-3-dev 256ffe9541bSJiao Xianjun(Please find the next section to see how to connect board to the internet via your PC) 2572ee67178SXianjun Jiao(or find out .deb files by above commands and copy .deb to the board, if you do not have internet) 2582ee67178SXianjun Jiao 25986bab9c1SJiao Xianjuncopy $OPENWIFI_DIR/user_space/sdrctl_src to the board, then on the board: 2602ee67178SXianjun Jiaocd sdrctl_src 2612ee67178SXianjun Jiaochmod +x version.sh 2622ee67178SXianjun Jiaomake 2632ee67178SXianjun Jiao``` 264ecb4f4f9SXianjun Jiao 2652ee67178SXianjun Jiao**Internet config** 26686bab9c1SJiao Xianjun* Connect board to internet. Topology: board|(eth0) -- (***ethX***)|PC|(***ethY***) -- internet 26786bab9c1SJiao Xianjun * Enable IPv4 **IP forwarding** on both **board** and **PC** 26886bab9c1SJiao Xianjun * On board: 26986bab9c1SJiao Xianjun ``` 27086bab9c1SJiao Xianjun route add default gw 192.168.10.1 27186bab9c1SJiao Xianjun ``` 2722ee67178SXianjun Jiao * On PC. After this your board should have internet via NAT through your PC. 2732ee67178SXianjun Jiao 2742ee67178SXianjun Jiao ``` 2752ee67178SXianjun Jiao sudo iptables -t nat -A POSTROUTING -o ethY -j MASQUERADE 2762ee67178SXianjun Jiao ``` 27786bab9c1SJiao Xianjun* Setup AP for Wi-Fi client. Topology: client -- (sdr0)|board|(eth0) -- (***ethX***)|PC|(***ethY***) -- internet 2782ee67178SXianjun Jiao * On board: Install dhcp server preparing for serving your openwifi clients via hostapd. 2792ee67178SXianjun Jiao ``` 2802ee67178SXianjun Jiao sudo apt-get install isc-dhcp-server 2812ee67178SXianjun Jiao sudo apt-get install Haveged 28286bab9c1SJiao Xianjun sudo apt-get install hostapd 2832ee67178SXianjun Jiao ``` 2842ee67178SXianjun Jiao * Put user_space/dhcpd.conf into (overwrite) /etc/dhcp/dhcpd.conf on board. 2852ee67178SXianjun Jiao * On board: 2862ee67178SXianjun Jiao ``` 2872ee67178SXianjun Jiao cd openwifi 2882ee67178SXianjun Jiao service network-manager stop 2892ee67178SXianjun Jiao ./wgd.sh 29086bab9c1SJiao Xianjun (For fmcomms4, you need an extra command: ./set_ant.sh rx1 tx1) 2912ee67178SXianjun Jiao ifconfig sdr0 up 2922ee67178SXianjun Jiao ifconfig sdr0 192.168.13.1 2932ee67178SXianjun Jiao route add default gw 192.168.10.1 2942ee67178SXianjun Jiao service isc-dhcp-server restart 2952ee67178SXianjun Jiao hostapd hostapd-openwifi.conf 2962ee67178SXianjun Jiao ``` 2972ee67178SXianjun Jiao * On PC: 2982ee67178SXianjun Jiao ``` 2992ee67178SXianjun Jiao sudo ip route add 192.168.13.0/24 via 192.168.10.122 dev ethX 3002ee67178SXianjun Jiao ``` 301ffe9541bSJiao Xianjun * Now you can connect openwifi hotspot from your phone/laptop and access the internet. 30244dff4bdSJiao Xianjun 303e17fdc17Smmehari**Connecting a client to openwifi AP in 2.4GHz** 304e17fdc17Smmehari 305e17fdc17SmmehariOpenwifi 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. 306e17fdc17Smmehari 307e17fdc17SmmehariAs a solution to this problem, openwifi can be fully controlled only if communicating with APs/clients instantiated using hostapd/wpa_supplicant userspace programs respectively. 308e17fdc17Smmehari 309e17fdc17SmmehariFor 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. 310e17fdc17Smmehari 311e17fdc17SmmehariOn 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. 312e17fdc17Smmehari``` 313e17fdc17Smmeharicd openwifi/user_space 314e17fdc17Smmehariwget http://w1.fi/releases/wpa_supplicant-2.1.tar.gz 315e17fdc17Smmeharitar xzvf wpa_supplicant-2.1.tar.gz 316e17fdc17Smmeharipatch -d wpa_supplicant-2.1/src/drivers/ < driver_nl80211.patch 317e17fdc17Smmeharicd wpa_supplicant-2.1/wpa_supplicant/ 318e17fdc17Smmeharicp defconfig .config 319e17fdc17Smmeharised -i 's/#CONFIG_LIBNL32.*/CONFIG_LIBNL32=y/g' .config 320e17fdc17Smmeharimake -j16 321e17fdc17Smmeharisudo make install 322e17fdc17Smmeharicd ../../ 323e17fdc17Smmeharirm -r wpa_supplicant-2.1/ wpa_supplicant-2.1.tar.gz 324e17fdc17Smmehari``` 325e17fdc17Smmehari 32644dff4bdSJiao Xianjun## cite openwifi project 32744dff4bdSJiao Xianjun 32844dff4bdSJiao XianjunAny use of openwifi project which results in a publication should include a citation via (bibtex example): 32944dff4bdSJiao Xianjun``` 33044dff4bdSJiao Xianjun@electronic{openwifigithub, 33144dff4bdSJiao Xianjun author = {Xianjun, Jiao and Wei, Liu and Michael, Mehari}, 33244dff4bdSJiao Xianjun title = {open-source IEEE802.11/Wi-Fi baseband chip/FPGA design}, 33344dff4bdSJiao Xianjun url = {https://github.com/open-sdr/openwifi}, 33444dff4bdSJiao Xianjun year = {2019}, 33544dff4bdSJiao Xianjun} 33644dff4bdSJiao Xianjun``` 337