永不消逝的電波 -GSM空口訊號的接收與解碼
對應Ubuntu 14.04
安裝pip
$ sudo apt-get install python-pippython-dev build-essential
$ sudo pip install --upgrade pip
修改軟體源
pipy國內映象目前有:
http://pypi.douban.com/ 豆瓣
http://pypi.hustunique.com/ 華中理工大學
http://pypi.sdutlinux.org/ 山東理工大學
http://pypi.mirrors.ustc.edu.cn/ 中國科學技術大學
一次性
如果想手動指定源,可以在pip後面跟-i 來指定源,比如用豆瓣的源來安裝web.py框架:
pip install web.py -ihttp://pypi.douban.com/simple
注意後面要有/simple目錄!!!
永久
可以配製成預設:
linux下,修改~/.pip/pip.conf,如果沒這檔案則建立。
內容為:
[global]
trusted-host = mirrors.aliyun.com
安裝PyBOMBS
$ [sudo] pip install PyBOMBS
安裝UHD
安裝依賴
sudo apt-get install libboost-all-dev libusb-1.0-0-dev python-makodoxygen python-docutils cmake build-essential
$ pybombs install uhd
找不到uhd,不知為何
沒有新增倉庫,參考一下連結
https://github.com/EttusResearch/ettus-pybombs
獲取原始碼
會在SDR資料夾下產生uhd資料夾
cd SDR
git clone git://github.com/EttusResearch/uhd.git
需要FPGA原始碼的話用下面這個(FPFGA原始碼在UHD使用中不需要)
git clone --recursivegit://github.com/EttusResearch/uhd.git
編譯安裝
Generate Makefiles with CMake
cd <uhd-repo-path>/host
mkdir build
cd build
cmake ../
Additionally, configuration variables canbe passed into CMake via the command line. The following common-useconfiguration variables are listed below:
- For a custom install prefix: -DCMAKE_INSTALL_PREFIX=<install-path>
- To install libs into lib64: cmake -DLIB_SUFFIX=64
Example usage:
cmake -DCMAKE_INSTALL_PREFIX=/opt/uhd ../
Build and install
make
make test
sudo make install
Setup the library path (Linux)
Make sure that libuhd.so is inyour LD_LIBRARY_PATH, or add it to /etc/ld.so.conf and make sureto run:
sudo ldconfig
LD_LIBRARY_PATH: 動態庫的查詢路徑
設定:
方法一: export LD_LIBRARY_PATH=LD_LIBRARY_PATH:/XXX 但是登出後就失效
方法二: 修改~/.bashrc或~/.bash_profile或系統級別的/etc/profile
1. 在其中新增例如exportPATH=/opt/ActiveP/lib:$LD_LIBRARY_PATH
2. source .bashrc (Source命令也稱為“點命令”,也就是一個點符號(.)。source命令通常用於重新執行剛修改的初始化檔案,使之立即生效,而不必登出並重新登入)
方法三:這個沒有修改LD_LIBRARY_PATH但是效果是一樣的實現動態庫的查詢,
1. /etc/ld.so.conf下面加一行/usr/local/MySQL/lib
2. 儲存過後ldconfig一下(ldconfig 命令的用途,主要是在預設搜尋目錄(/lib和/usr/lib)以及動態庫配置檔案/etc/ld.so.conf內所列的目錄下,搜尋出可共享的動態連結庫(格式如前介紹,lib*.so*),進而創建出動態裝入程式(ld.so)所需的連線和快取檔案.快取檔案預設為/etc/ld.so.cache,此檔案儲存已排好序的動態連結庫名字列表.)
下載FPGA映象
uhd_images_downloader
查詢UHD裝置
uhd_find_devices
確保成功
安裝RTL-SDR
git clone git://git.osmocom.org/rtl-sdr.git
cd rtl-sdr/
mkdir build
cd build
cmake ../ -DINSTALL_UDEV_RULES=ON
make
sudo make install
cd rtl-sdr/
autoreconf -i
./configure
make
sudo make install
sudo ldconfig
/etc/ld.so.conf中新增build/src,連結librtlsdr.so檔案
sudo ldconfig
典型錯誤
usb_claim_interface error -6, Failed toopen rtlsdr device #0.
You should either blacklistthe dvb_usb_rtl28xxu kernel module, or solve it quickly (will have torepeat it on every reboot):
sudo rmmod dvb_usb_rtl28xxu
解決辦法:禁止UBUNTU自動啟動rtl-sdr核心模組
方法一
在/etc/modprobe.d/blacklist.conf中新增blacklistdvb_usb_rtl28xxu
方法二
creating "rtlsdr.conf" in"/etc/modprobe.d" and put
blacklist dvb_usb_rtl28xxu
重啟之後這個kernel model就不再自動運行了
安裝Gnuradio
安裝依賴
下載最新原始碼
$ git clone --recursivehttp://git.gnuradio.org/git/gnuradio.git
使用PyBOMBS安裝
更新源:
pybombs recipes add gr-recipesgit+https://github.com/gnuradio/gr-recipes.git
pybombs recipes add gr-etceteragit+https://github.com/gnuradio/gr-etcetera.git
使用官方預設引數安裝:
pybombs prefix init ~/prefix -a myprefix -Rgnuradio-default
此時,所有依賴會安裝到 ~/prefix 目錄下
報錯了
直接刪掉 ~/prefix 目錄,
給git新增代理:
git config --global http.proxy'socks5://127.0.0.1:1080'
git config --global https.proxy'socks5://127.0.0.1:1080'
重新安裝:
pybombs prefix init ~/prefix -a myprefix -Rgnuradio-default
取消git代理
git config --global --unset http.proxy
git config --global --unset https.proxy
修改本地GRC搜尋路徑
在gnuradio的etc目錄下
~/SDR/gnuradio/etc/gnuradio/conf.d/grc.conf
local_blocks_path = /usr/local/share/gnuradio/grc/blocks
新增動態連結庫so搜尋路徑(GQRX需要使用)
/home/xujie/SDR/gnuradio/lib
新增到
/etc/ld.so.conf
再更新
sudo ldconfig
執行
Run GNU Radio Companion from your newprefix:
$source ~/SDR/gnuradio/setup_env.sh
$gnuradio-companion
or execute it without changing the currentenvironment:
$pybombs run gnuradio-companion
問題
No module name OpenGL
sudo pip install pyopengl
安裝 gr-somosdr Gnuradio Block
Building with cmake (as described inthe gr-osmosdrwiki page):
git clone git://git.osmocom.org/gr-osmosdr
cd gr-osmosdr/
mkdir build
cd build/
cmake ../
Now cmake should print out a summary ofenabled/disabled components. You may disable certain components by followingguidelines shown by cmake. Make sure the device of your interest is listedhere. Check your dependencies and retry otherwise.
Now build & install
make
sudo make install
sudo ldconfig
gr-gsm 安裝 GSM receiveGnuradio Block
sudo pybombs install gr-gsm
GQRX安裝 RTL-SDR GUI
安裝加速庫
sudo apt install libvolk1-bin
cmake的時候出現 qt5的錯誤
sudo apt-get install qt5-default
接著安裝了libqt5svg5和 libqt5svg5-dev
For command line builds:
$ cd gqrx
$ mkdir build
$ cd build
$ cmake ..
$ make
On some systems, the default cmake releasebuilds are "over optimized" and perform poorly. In that case tryforcing -O2 using
export CXXFLAGS=-O2
before the cmake step.
二進位制執行檔案在
At this point, you should find the gqrxexecutable in ~/src/gqrx directory. Start upvia ./gqrx and you’ll get the screen below (or set your values toequal this):
安裝
新增路徑和快捷方式
sudo make install
下載uhd FPGA映象
uhd_images_downloader
使用UHD需要sudo許可權
sudo gqrx –r
使用-r 引數啟動,不會載入預配置引數
安裝wireshark
sudo apt install wireshark
安裝kalibrate(for UHD)
chmod a+x bootstrap
./bootstrap
./configure
make
sudo make install
版本都和UHD不相容
安裝kalibrate-rtl
掃描GSM基站,給出頻偏,計算本地晶振頻偏
編譯安裝
git clone https://github.com/steve-m/kalibrate-rtl
cdkalibrate-rtl
./bootstrap&& CXXFLAGS='-W -Wall -O3'
./configure
make
sudomake install
用法
搜尋附近的GSM基站資訊:
可以用-g設定增益
kal -s GSM900 -g 40
chan後面的數字是基站編號,power值越小,功率越大。
繼續使用kalibrate幫助我們校準電視棒的偏頻,使用 -c 引數加我們基站的頻道號(channel)來計算出這個誤差值:
理論上,你用頻率值減去偏頻值得到的數字
在頻率附件移動一下,頻偏不是很準確
GSM訊號解碼
GSM射頻訊號的解碼使用gr-gsm完成。其GitHub地址在這裡。 最重要的是GSM Receiver模組。配合時鐘校正,輸入取樣率的適配,構成的基本的GSM訊號接收部分。
對於邏輯通道的解碼,由於我的目的是解出不加密的SMS資訊,而點對點簡訊業務,在移動終端(MT)空閒期間利用GSM網的無線獨立專用通道(SDCCH)收/發簡訊,在通話期間利用慢速伴隨通道(SACCH)收/發,故在移動終端空閒或通話期間都可收/發簡訊。
因此,這裡解碼SDCCH/8通道。
成功接收到8個碎片包組成了一條完整的SMS