Installation Guide
Many people said they did not successfully get the logged CSI data. Here I summarize some common problems and provide tested solutions.
prerequisite:
Hardware:
- (1)Intel 5300 WiFi NIC card.
- (2)Intel PC with PCIe socket.
- (3)WiFi hostspots with no password
Software:
- ubuntu 14.04 with kernel version 3.13 or 3.16.
I have test the above hardware and software and successfully obtain CSI data. Some scholars said they successfully retrieved CSI on 2.6.36 ![][1] and 3.5.7 ![][2]. I didn’t verify it yet. Some people may trying to implement this CSI tool on other platform like raspberry pi. Well, I have to say this will not work. This CSI tool can only expose CSI on PCIe bus. Raspberry pi or other embedded systems that do not has PCIe bus will not run this code successfully. While boards like hammingboard or HT83, which has PCIe bus, can run this tool. Some scholars have verify it on hammngboard ![][3].
step 1: Install the modified driver
After you install the ubuntu, please “sudo update”. Then follow the instruction here. Do not run the commands in the tips.
I have extracted the neccessary steps in the following:
1. Prerequisites
sudo apt-get install gcc make linux-headers-$(uname -r) git-core
2. Build and Install the Modified Wireless Driver
CSITOOL_KERNEL_TAG=csitool-$(uname -r | cut -d . -f 1-2)
git clone https://github.com/dhalperi/linux-80211n-csitool.git
cd linux-80211n-csitool
git checkout ${CSITOOL_KERNEL_TAG}
make -C /lib/modules/$(uname -r)/build M=$(pwd)/drivers/net/wireless/iwlwifi modules
sudo make -C /lib/modules/$(uname -r)/build M=$(pwd)/drivers/net/wireless/iwlwifi INSTALL_MOD_DIR=updates modules_install
sudo depmod
cd ..
3. Install the Modified Firmware
git clone https://github.com/dhalperi/linux-80211n-csitool-supplementary.git
for file in /lib/firmware/iwlwifi-5000-*.ucode; do sudo mv $file $file.orig; done
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
4. Build the Userspace Logging Tool
make -C linux-80211n-csitool-supplementary/netlink
step 2: Test the driver
Following the instruction here. For convenience, I have wrote a script. Run like this, “./run.sh YouWiFiName”.
#!/bin/bash
sudo /etc/init.d/networking stop
echo "stop networking"
sleep 1
sudo modprobe -r iwlwifi mac80211
sleep 1
sudo modprobe iwlwifi connector_log=0x1
sleep 1
echo "set hotspot essid $1"
sudo iwconfig wlan0 essid $1
sleep 1
echo "connecting to the wifi, please wait"
sudo dhclient wlan0
echo "successfully connected to the wifi hotspot"
Noted that the first command “sudo /etc/init.d/networking stop” may not work on 3.13 if you have “sudo update”. It will output “Job failed …”. Ignore this output.
step 3: log the CSI data
run the following code
./log_to_file csi.dat
Problem 1: Can not connect to the AP
You can check it by running the iwconfig. Normally, you can see wlan0 in the output. But sometimes, by some uncertain reason, wlan0 is gone. This is because the wlan0 may be software blocked. Check it by running “rfkill list” and unblock the wifi by running “rfkill unblock wifi”.
Problem 2: CSI.dat is empty when ping
The cause for this one is that you driver is corrupt, you have to reinstall.
I think two clues can help you to check whether the driver is successfully installed.
- In the second step in step 1, “2. Build and Install the Modified Wireless Driver”. When you run the last command, you should see “can’t access private key”. This can indicate that the driver is successfully installed.
- After you run my “run.sh” bash scripte. Run the command “dmesg | grep -5 -i iwlwifi | grep connector_log”. Search the output to see whether there is one line that says “unknown parameter “connector_log=0x1” is ignored”. If there is no such line, then it will be ok, otherwise, the driver is corrupted. Reinstall the driver.
I have write a check script:
#!/usr/bin/sudo /bin/bash
b=`iwconfig | grep -i wlan0 | wc -l`
echo "$b"
if [ $b == '1' ]
then
echo "wifi is opened"
elif [ $b == '0' ]
then
echo "wifi is soft blocked"
exit 0
fi
sleep 1
b=`iwconfig | grep -i Not-Associated | wc -l`
echo "$b"
if [ $b == '1' ]
then
echo "You have not connected to the wifi ap"
exit 0
elif [ $b == '0' ]
then
echo "You have connected to the wifi AP"
fi
sleep 1
a=`dmesg | grep -5 -i iwlwifi | grep connector_log | wc -l`
if [ a == '1' ]
then
echo "driver is not OK!!! please reinstall"
else
echo "driver is OK! Congratuation."
fi
##Problem 3: Could not setup monitor or inject mode
The default script to setup monitor or inject mode is not ok. If you run it on, the console may output “Device or resource busy”. I have altered the sequence of some commands and successfully get the csi data.
For the transmitter:
#!/usr/bin/sudo /bin/bash
echo "start configure---------------------"
modprobe -r iwlwifi mac80211 cfg80211
modprobe iwlwifi debug=0x40000
sleep 1
ifconfig wlan0 2>/dev/null 1>/dev/null
while [ $? -ne 0 ]
do
ifconfig wlan0 2>/dev/null 1>/dev/null
done
echo "setting injection mode ok"
sleep 1
iw dev wlan0 interface add mon0 type monitor
ifconfig mon0 up
echo "setting injection mon0"
sleep 1
iw mon0 set channel $1 $2
echo "configuration is over-------------------------"
For the receiver:
#!/usr/bin/sudo /bin/bash
sleep 1
modprobe -r iwlwifi mac80211 cfg80211
modprobe iwlwifi connector_log=0x1
echo "step 1---------------"
# Setup monitor mode, loop until it works
iwconfig wlan0 mode monitor 2>/dev/null 1>/dev/null
while [ $? -ne 0 ]
do
iwconfig wlan0 mode monitor 2>/dev/null 1>/dev/null
done
sleep 1
echo "monitor mode successfully set"
ifconfig wlan0 up
sleep 1
echo "open wlan0"
iw wlan0 set channel $1 $2
sleep 1
echo "setting wlan channel parameters"
echo "successfully--------------------------"
Remember to install the driver for this follow the instruction here.
Some other problems are addressed here
[1]: J. Liu, Y. Wang, Y. Chen, J. Yang, X. Chen, and J. Cheng. Tracking vital signs during sleep leveraging off-the-shelf wifi. In Proceedings of the 16th ACM International Symposium on Mobile Ad Hoc Networking and Computing (MobiHoc), 2015.
[2]: S. Kumar, S. Gil, D. Katabi, and D. Rus. Accurate indoor localization with zero start-up cost. In Proceedings of the 20th Annual International Conference on Mobile Computing and Networking (MobiCom), 2014.
[3]: BodyScan: Enabling Radio-based Sensing on Wearable Devices for Contactless Activity and Vital Sign Monitoring. Mobisys 2016.