# Linux 802.11n CSI Tool in Ubuntu 18.04
## Environment:
- Operating System: Ubuntu18.04.0 (kernel 4.15)
- Download link:https://old-releases.ubuntu.com/releases/18.04.5/
- Must make sure that your kernel version is 4.15, and the default kernel version of ubuntu18.04.0 is 4.15.
- Wireless Network Interface Card: Intel Corporation Ultimate N WiFi Link 5300
- Install dual system in Windows10 if you need:
- Use `rufus.exe` to transfer the .iso file into USB
- Basically follow https://www.youtube.com/watch?v=yMHOpOuyjdc&ab_channel=%E5%A2%9E%E5%BB%A3%E5%BB%BA%E6%96%87
- **Warning: Don't try to use a virtual machine. The wireless NIC works differently on any virtual machine and you will never get the CSI signals.**
## Tool Installation
Reference to https://github.com/spanev/linux-80211n-csitool
Bascically just follow the steps in above github and it will work.
### First download the essential packages:
> sudo apt-get install build-essential linux-headers-$(uname -r) git-core
> sudo add-apt-repository ppa:ubuntu-toolchain-r/test
> sudo apt-get update
> sudo apt-get install gcc-8 g++ -8(notes that there is no space between g++ and -8)
Newer kernels require compilers with retpoline supports. GCC and G++ version 7.3 , and I have tried version 8 and it works.
This command show the gcc version that your OS is using.
>ls -l /usr/bin/gcc /usr/bin/g++
And output of mine is:
> lrwxrwxrwx 1 root 5 Mar 27 2018 /usr/bin/g++ -> g++ -7(notes that there is no space between g++ and -7)
> lrwxrwxrwx 1 root 5 Mar 27 2018 /usr/bin/gcc -> gcc-7
Now change the version of gcc/g++ to version 8:
> sudo rm /usr/bin/gcc
> sudo rm /usr/bin/g++
> sudo ln -s /usr/bin/gcc-8 /usr/bin/gcc
> sudo ln -s /usr/bin/g++-8 /usr/bin/g++
Again show the gcc version that your OS is using:
>ls -l /usr/bin/gcc /usr/bin/g++
Output should be like this:
> lrwxrwxrwx 1 root 5 Mar 27 2018 /usr/bin/g++ -> g++-8
> lrwxrwxrwx 1 root 5 Mar 27 2018 /usr/bin/gcc -> gcc-8
### Build and Install the Modified Wireless Driver
Clone the modified Linux kernel code
> git clone https://github.com/spanev/linux-80211n-csitool.git
> cd linux-80211n-csitool
Checkout the correct release version
> CSITOOL_KERNEL_TAG=csitool-$(uname -r | cut -d . -f 1-2)
> git checkout ${CSITOOL_KERNEL_TAG}
Build the modified driver for the existing kernel
> make -j `nproc` -C /lib/modules/$(uname -r)/build M=$(pwd)/drivers/net/wireless/intel/iwlwifi modules
> sudo make -C /lib/modules/$(uname -r)/build M=$(pwd)/drivers/net/wireless/intel/iwlwifi INSTALL_MOD_DIR=updates modules_install
- Remark: If during the execution of the command above you get error messages similar to
> SSL error:02001002:system library:fopen:No such file or directory: bss_file.c:175
> SSL error:2006D080:BIO routines:BIO_new_file:no such file: bss_file.c:178
>sign-file: certs/signing_key.pem: No such file or directory
<font color="#f00">Don't worry.</font> The operating system complains, because the driver doesn't have a SSL signature. That won't interfere with the driver installation. Therefore, simply ignore the messages and continue with the installation process.
> sudo depmod
> cd ..
### Install the Modified Firmware
Obtain the CSI Tool supplementary material:
> git clone https://github.com/dhalperi/linux-80211n-csitool-supplementary.git
Relocate any existing firmware for Intel Wi-Fi Link 5000 Series adapters:
> for file in /lib/firmware/iwlwifi-5000-*.ucode; do sudo mv $file $file.orig; done
Install the modified firmware:
>sudo cp linux-80211n-csitool-supplementary/firmware/iwlwifi-5000-2.ucode.sigcomm2010 /lib/firmware/
>sudo ln -s iwlwifi-5000-2.ucode.sigcomm2010 /lib/firmware/iwlwifi-5000-2.ucode
### Build the Userspace Logging Tool
>make -C linux-80211n-csitool-supplementary/netlink
### Enable Logging and Test
>sudo modprobe -r iwlwifi mac80211
This command would let you out of internet.
But don' worry. DO:
>sudo modprobe iwlwifi connector_log=0x1
make sure that the AP you want to connect must be unencrepted.
## Starting log CSI signals
On one terminal, type:
> sudo linux-80211n-csitool-supplementary/netlink/log_to_file csi.dat
On another terminal, type:
> ping 192.168.0.101 -i 0.5
- Remark:
- 192.168.0.101 is my AP's address. You can use `ifconfig` command to check your AP's address.
- `-i 0.5` repersents that ping one signal each 0.5 second. If you want the speed to be lower than 0.2(not sure), it will need root authority.
And if your first terminal(typing log_to_file one) start to show some information like this:

then you made it!
If it helps you, then it's great.
If there is something worng, please correct me.
# Reference
https://github.com/spanev/linux-80211n-csitool
https://dhalperi.github.io/linux-80211n-csitool/installation.html