本文以Ubuntu 16.04.3 LTS 为例,硬件环境为core i7 6500U,16GB DDR3@1600
…广告:…
OAI核心网搭建:https://blog.csdn.net/BUPTOctopus/article/details/81560514
srsLTE搭建:https://blog.csdn.net/BUPTOctopus/article/details/82997806
sudo apt-get install linux-lowlatency
sudo apt-get install linux-image-`uname -r | cut -d- -f1-2`-lowlatency
sudo apt-get install linux-headers-`uname -r | cut -d- -f1-2`-lowlatency
sudo reboot
sudo apt-get install cpufrequtils
sudo vi /etc/default/cpufrequtils
添加:GOVERNOR="performance"
sudo update-rc.d ondemand disable
sudo /etc/init.d/cpufrequtils restart
cpufreq-info
#查看睿频是否成功关闭(频率变动极小)
sudo vi /etc/default/grub
#在末尾添加:
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_pstate=disable"
GRUB_CMDLINE_LINUX_DEFAULT="quiet processor.max_cstate=1 intel_idle.max_cstate=0 idle=poll"
sudo vi /etc/modprobe.d/blacklist.conf
#在末未添加:(将Intel的电源管理加入黑名单)
blacklist intel_powerclamp
sudo reboot
sudo apt-get update
sudo apt-get install subversion git
echo -n | openssl s_client -showcerts -connect gitlab.eurecom.fr:443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt
sudo git config --global http.sslverify false
sudo git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git
cd ~/openairinterface5g
sudo git checkout develop //你想用的分支
source oaienv
cd cmake_targets
接下来一步需要科学上网,挂个代理 or换到清华源
测试代理有没有挂好可以手动装一下ppa uhd驱动
sudo -E add-apt-repository ppa:~ettusresearch/ubuntu/uhd
来测试。
更新:如果你在服务器上安装了搜狗输入法等需要某些连不上的源的软件……换了源连不上那个,不换源连不上这个,总之我懒得解决这个问题,先把那些软件的list删了吧……
科学上网有时候下ppa也太慢,
sudo vim ~/openairinterface5g/cmake_targets/tools/build_helper
然后注释掉这两句
$SUDO rm -rf /opt/ssh
$SUDO git clone https://gist/github.com/2190472.git /opt/ssh
相应的文件虽然没啥用……我下下来传百度云了:
链接:https://pan.baidu.com/s/1A2OZq1XrLzb89CVKYFxCyw
提取码:8sn7
(就一个文件,ssh.py)
为防止失效,源码附在最后面了;
此外手动装uhd驱动的话可以去http://files.ettus.com/binaries/uhd_stable/src/
./build_oai -I --eNB -x --install-system-files -w USRP
参数说明:(可以./build_oai -h查看所有的参数说明)
-I: installs required packages.ASN1和uhd驱动等都需要挂代理。
–eNB: installs eNB, i.e., lte-softmodem.编译成eNB。后面编译成UE这里改成–UE即可。
-x: adds a software oscilloscope feature to the produced binaries.装个软件示波器。
–install-system-files: installs OAI required files in Linux system.
-w: adds the hardware support, which is USRP in our case.
sudo vim ~/openairinterface5g/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
将mobile_country_code
和mobile_network_code
改为跟核心网一样
将mme_ip_address
中的ipv4改为运行核心网主机的IP
NETWORK_INTERFACES
中俩IP改为自己的IP
然后把它拷到~/openairinterface5g/cmake_targets/lte_build_oai/build目录下:
sudo cp ~/openairinterface5g/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf ~/openairinterface5g/cmake_targets/lte_build_oai/build/
sudo vi ~/openairinterface5g/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf
因为IMSI=MCC+MNC+MSIN ID,之前测试UE的IMSI设置为208930100001111,所以将某个PLMN的MCC改为208,MNC改为93(PLMN中保证有一个你配置的MCC、MNC就可以),UE0的MSIN改为0100001111.
注意:当换用其他的MCC MNC的时候,比如,如果MCC+MNC是6位,那么MSIN ID只需要9位。
其余的默认就可以,要改的话注意写卡和EPC数据库里都要改。
cd ~/openairinterface5g/cmake_targets/lte_build_oai/build
sudo ./lte-softmodem -O enb.band7.tm1.usrpb210.conf
Ki: 8BAF473F2F8FD09487CCCBD7097C6862 (即HSS数据库里的key,eNB里的USIM_API_K,不要改,除非HSS里也改)
OP: 11111111111111111111111111111111
OPc:e734f8734007d6c5ce7a0508809e7e9c
C1:00, C2: 01, C3: 02, C4: 04, C5: 08, R1: 40, R2: 00, R3: 20, R4: 40, R5: 60 all in hexa.
SPN (service provider Name): OpenAirInterface
MCC: 208 (FR)
MNC: 93 (new MNO MNC)
IMSI: 208930000000001 (MCC|MNC|id)
SQN (Sequence number): 000000000001 (不是IMSI)
IMEI:(可以不写,写的话注意匹配数据库)35609204079301
和接入网build的区别只有–eNB变成了–UE
同样要挂代理,或者像搭接入网时候一样注释掉一部分源码
cd ~/openairinterface5g/cmake_targets
sudo ./build_oai -I --UE --install-system-files -x -w USRP
通过运行sudo tee UE.log ,可以记录UE日志记录以用于进一步开发/测试。
安装ue_ip.ko
内核模块并调出OIP接口oip0
。MME将使用IP pool为该接口分配IP地址。
脚本:(注意需要修改一下路径)
sudo vim init_nas_s1
#!/bin/bash
LTEIF=oip0
OPENAIR_DIR=/home/m/openairinterface5g/
load_module() {
mod_name=${1##*/}
mod_name=${mod_name%.*}
if awk "/$mod_name/ {found=1 ;exit} END {if (found!=1) exit 1}" /proc/modules
then
echo "module $mod_name already loaded: I remove it first"
sudo rmmod $mod_name
fi
echo loading $mod_name
sudo insmod $1
}
load_module $OPENAIR_DIR/targets/bin/ue_ip.ko
if [ "$1" = "UE" ]; then
echo "bring up oip0 interface for UE"
ifconfig oip0 up
fi
ip route flush cache
sleep 1
sysctl -w net.ipv4.conf.all.log_martians=1
echo "Disabling reverse path filtering"
sysctl -w net.ipv4.conf.all.rp_filter=0
ip route flush cache
# Check table 200 lte in /etc/iproute2/rt_tables
fgrep lte /etc/iproute2/rt_tables > /dev/null
if [ $? -ne 0 ]; then
echo "200 lte " >> /etc/iproute2/rt_tables
fi
ip rule add fwmark 1 table lte
ip route add default dev $LTEIF table lte
执行完脚本之后,
cd ~/openairinterface5g/
sudo chmod +x init_nas_s1
sudo ./targets/bin/init_nas_s1 UE
cd targets/bin
sudo -E ./lte-uesoftmodem.Rel14 -U -C2685000000 -r50 --ue-scan-carrier --ue-txgain 70 --ue-rxgain 80 2>&1 | sudo tee UE.log
具体是lte-uesoftmodem.Rel几取决于下的代码的版本支持到Rel几,
现在(2018.9)的代码版本支持到Rel14,
参数意义:-U:UE数量, -C:设置所有子载波的下行链路频率,
-r:PRB, 目前接入网的可选值: 6, 25, 50, 100。
等待更新
不更新了,不用OAI UE了。太难用了。
换用srsUE了。见新的博客。2018.10.10
附 需要从gist上下载ssh.py的源码:
import paramiko
import socket
import os
from stat import S_ISDIR
class SSHSession(object):
def __init__(self,hostname,username='root',key_file=None,password=None):
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((hostname,22))
self.t = paramiko.Transport(self.sock)
self.t.start_client()
keys = paramiko.util.load_host_keys(os.path.expanduser('~/.ssh/known_hosts'))
key = self.t.get_remote_server_key()
if key_file is not None:
if isinstance(key,str):
key_file=open(key,'r')
key_head=key_file.readline()
key_file.seek(0)
if 'DSA' in key_head:
keytype=paramiko.DSSKey
elif 'RSA' in key_head:
keytype=paramiko.RSAKey
else:
raise Exception("Can't identify key type")
pkey=keytype.from_private_key(key_file)
self.t.auth_publickey(username, pkey)
else:
if password is not None:
self.t.auth_password(username,password,fallback=False)
else: raise Exception('Must supply either key_file or password')
self.sftp=paramiko.SFTPClient.from_transport(self.t)
def command(self,cmd):
chan = self.t.open_session()
chan.get_pty()
chan.invoke_shell()
chan.settimeout(20.0)
ret=''
try:
ret+=chan.recv(1024)
except:
chan.send('\n')
ret+=chan.recv(1024)
for line in cmd.split('\n'):
chan.send(line.strip() + '\n')
ret+=chan.recv(1024)
return ret
def put(self,localfile,remotefile):
self.sftp.put(localfile,remotefile)
def put_all(self,localpath,remotepath):
os.chdir(os.path.split(localpath)[0])
parent=os.path.split(localpath)[1]
for walker in os.walk(parent):
try:
self.sftp.mkdir(os.path.join(remotepath,walker[0]))
except:
pass
for file in walker[2]: self.put(os.path.join(walker[0],file),os.path.join(remotepath,walker[0],file))
def get(self,remotefile,localfile):
self.sftp.get(remotefile,localfile)
def sftp_walk(self,remotepath):
path=remotepath
files=[]
folders=[]
for f in self.sftp.listdir_attr(remotepath):
if S_ISDIR(f.st_mode):
folders.append(f.filename)
else:
files.append(f.filename)
print (path,folders,files)
yield path,folders,files
for folder in folders:
new_path=os.path.join(remotepath,folder)
for x in self.sftp_walk(new_path):
yield x
def get_all(self,remotepath,localpath):
self.sftp.chdir(os.path.split(remotepath)[0])
parent=os.path.split(remotepath)[1]
try:
os.mkdir(localpath)
except:
pass
for walker in self.sftp_walk(parent):
try:
os.mkdir(os.path.join(localpath,walker[0]))
except:
pass
for file in walker[2]:
self.get(os.path.join(walker[0],file),os.path.join(localpath,walker[0],file))
def write_command(self,text,remotefile):
self.sftp.open(remotefile,'w').write(text)
self.sftp.chmod(remotefile,755)