暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

N0003: 软件定义的Radio?自己建个基站玩~

zartbot 2020-09-04
567

>>请自觉遵守无线电管理法规,依法设置和使用无线电设备<<

先讲个笑话,前几天我去搜索了一下稀疏矩阵的书,然后这几天某购物App就天天跟我推荐植发了。。。。人工智能真有趣~ 

于是为了头发稀疏一点,我来主动接受辐射了
年某个创新项目有一笔灵活的经费,刚好有个小圈子在说Software Defined Radio的事,于是就买了一块AD9361和一个Zedboard来玩了一小会儿,主要是在做一个Multidomain Assurance通过SDR构造一些WiFi的干扰信号供机器学习模型使用,不过水平太烂,大概就是看着人家教程依葫芦画瓢都画不像的水平。
今年年初同事在问我如何在实验室弄个基站因为有个项目要测LTE的模块,自然就想到了SDR,但是真的没啥能力也没精力去写适配zedboard+AD9361,干脆又买了一块B210直接装srsLTE吧,正好还可以用它以后来跟zedboard+9361那套互相通信用:


找一台物理机(千万别虚拟机,时钟飘到你哭~),最好找带AVX2指令集的CPU,安装一个干净的ubuntu 18.04,然后安装基本的编译环境:

sudo apt install git cmake g++ libboost-all-dev libgmp-dev swig python3-numpy \
python3-mako python3-sphinx python3-lxml doxygen libfftw3-dev \
libsdl1.2-dev libgsl-dev libqwt-qt5-dev libqt5opengl5-dev python3-pyqt5 \
liblog4cpp5-dev libzmq3-dev python3-yaml python3-click python3-click-plugins \
python3-zmq python3-scipy libfftw3-dev libmbedtls-dev \
libboost-program-options-dev libconfig++-dev libsctp-dev


sudo apt-get install python-pip python-apt python3-pip


安装PyBOMBS和GNURadio可以玩很多SDR的东西

sudo -H pip install PyBOMBS


mkdir ~/sdr
cd ~/sdr
pybombs auto-config
pybombs recipes add gr-recipes git+https://github.com/gnuradio/gr-recipes.git
pybombs recipes add gr-etcetera git+https://github.com/gnuradio/gr-etcetera.git


pybombs prefix init 


安装GNURadio

source ~/sdr/setup_env.sh
pybombs install gnuradio 
gnuradio-companion 


当然还以玩点其他的东西,有些东西就不说明了


pybombs install gr-osmosdr rtl-sdr  hackrf bladeRF airspy gr-iqbal libosmo-dsp osmo-sdr gr-usrp2 armadillo gflags glog gnutls gnss-sdr gqrx gr-bluetooth gr-ieee-80211


UHD:

sudo add-apt-repository ppa:ettusresearch/uhd -y
sudo apt-get update
sudo apt-get -y --allow-unauthenticated install python python-tk libboost-all-dev libusb-1.0-0-dev
sudo apt-get -y --allow-unauthenticated install libuhd-dev libuhd003 uhd-host
sudo uhd_images_downloader


kevin@ZartNode:~$ uhd_find_devices
[INFO] [UHD] linux; GNU C++ version 7.4.0; Boost_106501; UHD_3.14.1.1-release
[INFO] [B200] Loading firmware image: /usr/share/uhd/images/usrp_b200_fw.hex...
--------------------------------------------------
-- UHD Device 0
--------------------------------------------------
Device Address:
serial: 8000057
name: xx-wireless_B210
product: B210
type: b200


LowLatency

sudo apt-get -y install linux-lowlatency 
sudo apt-get -y install linux-image-`uname -r | cut -d- -f1-2`-lowlatency
sudo apt-get -y install linux-headers-`uname -r | cut -d- -f1-2`-lowlatency

Install srsLTE:

git clone https://github.com/srsLTE/srsLTE.git
cd srsLTE
mkdir build
cd build
cmake ../
make
make test
sudo make install
sudo ldconfig

eNB和EPC配置都抄作业:

enb:


cp srsenb/enb.conf.example srsenb/enb.conf
cp srsenb/rr.conf.example srsenb/rr.conf
cp srsenb/sib.conf.example srsenb/sib.conf
cp srsenb/drb.conf.example srsenb/drb.conf


epc:


cp srsepc/epc.conf.example srsepc/epc.conf
cp srsepc/user_db.csv.example srsepc/user_db.csv

当然注意mcc和mnc,epc.conf的配置需要改:


[mme]
mme_code = 0x1a
mme_group = 0x0001
tac = 0x0007
mcc = 001
mnc = 01
mme_bind_addr = 127.0.1.100
apn = ia
dns_addr = 8.8.8.8
encryption_algo = EEA0
integrity_algo = EIA1
paging_timer = 2

同理enb的配置,还有RF的band,因为是一个北美版的LTE路由器,所以。。

[enb]
mcc = 001
mnc = 01
mme_addr = 127.0.1.100
gtp_bind_addr = 127.0.1.1
s1c_bind_addr = 127.0.1.1
n_prb = 50
[rf]
dl_earfcn = 2110
tx_gain = 80
rx_gain = 40



SIM卡烧卡:

烧卡软件:

然后填写user_db.csv

#                                                                                           
# .csv to store UE's information in HSS
# Kept in the following format: "Name,Auth,IMSI,Key,OP_Type,OP,AMF,SQN,QCI,IP_alloc"
#
# Name: Human readable name to help distinguish UE's. Ignored by the HSS
# IMSI: UE's IMSI value
# Auth: Authentication algorithm used by the UE. Valid algorithms are XOR
# (xor) and MILENAGE (mil)
# Key: UE's key, where other keys are derived from. Stored in hexadecimal
# OP_Type: Operator's code type, either OP or OPc
# OP/OPc: Operator Code/Cyphered Operator Code, stored in hexadecimal
# AMF: Authentication management field, stored in hexadecimal
# SQN: UE's Sequence number for freshness of the authentication
# QCI: QoS Class Identifier for the UE's default bearer.
# IP_alloc: IP allocation stratagy for the SPGW.
# With 'dynamic' the SPGW will automatically allocate IPs
# With a valid IPv4 (e.g. '172.16.0.2') the UE will have a statically assigned IP.
#
# Note: Lines starting by '#' are ignored and will be overwritten
ue4,mil,001010000001234,7dbab53f6569b7588734007d6c5ce783,opc,4ddb98237b1f6b3e64d74bf85b51bf76,8000,00000000206e,7,dynamic
ue3,mil,001010000008856,7dbab53f6569b7588734007d6c5ce783,opc,4ddb98237b1f6b3e64d74bf85b51bf76,8000,00000000202c,7,dynamic
ue2,mil,001010123456780,00112233445566778899aabbccddeeff,opc,63bfa50ee6523365ff14c1f45f88737d,8000,000000001234,7,dynamic
ue1,xor,001010123456789,00112233445566778899aabbccddeeff,opc,63bfa50ee6523365ff14c1f45f88737d,9001,000000001234,7,dynamic

启动srsLTE:

cd ~/srs/LTE/srsenb
sudo srsenb enb.conf


cd ~/srs/LTE/srsepc
sudo srsepc epc.conf
sudo ./srsepc_if_masq.sh enp1s0f0



然后UE用了一台某司的测试路由器,上线成功~


文章转载自zartbot,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论