核心网搭建:
视频:OAI(Open Air Interface)开源5G核心网部署方案_哔哩哔哩_bilibili
资料:含有核心网部署PDF,UERANSIM,WpcapSrc
压缩包等,视频中测试需要的工具。
链接:https://pan.baidu.com/s/1SMQ2Kwo7-pSpXLwxctG3zg
提取码:y6gp
gNB和UE搭建:
1. 系统准备
参考网址:https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop/doc/BUILD.md
- 安装
ubuntu18.04
- 安装设置低延时内核
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
CPU
超频设置
(1) 安装运维工具方便后续对配置文件修改等操作
sudo apt-get install git vim openssh-server i7z subversion cmake
(2) 检查是否加载了 GTP
内核模块
uname -a
#临时加载 gtp 模块
sudo modprobe gtp
dmesg | tail # You should see something that says about GTP kernel module
# e.g.
# [ 111.364332] gtp: GTP module loaded (pdp ctx size 104 bytes)
(3) 禁用 Intel CPU
的 P-state
驱动,这个是 Intel CPU
专用的频率调节器驱动
sudo gedit /etc/default/grub
#修改以下内容
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
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 update-grub
(4) 将 intel_powerclamp
(Intel 电源管理驱动程序)加入黑名单:
sudo gedit /etc/modprobe.d/blacklist.conf
末尾添加
blacklist intel_powerclamp
reboot
(5) 关闭 CPU 睿频
sudo apt-get install cpufrequtils
sudo gedit /etc/default/cpufrequtils
...
GOVERNOR="performance"
sudo update-rc.d ondemand disable
sudo /etc/init.d/cpufrequtils restart
查看睿频是否成功关闭,会看到所有频率都在 C0%
如果出现错误:update-rc.d: error: cannot find a LSB script for ondemand
则用下面代码:
sudo /etc/init.d/cpufrequtils restart
systemd reboot
sudo /etc/init.d/cpufrequtils restart
查看是否成功:
sudo cat /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor
显示performance
则设置成功。
2. 安装和构建gNB
下载OAI开源代码到当前目录
sudo git clone https://gitlab.eurecom.fr/oai/openairinterface5g.git
进入代码目录
cd <your oai installation directory>/openairinterface5g/
确保当前位于develop分支 git checkout -f develop
sudo git checkout develop
激活虚拟环境
source oaienv
cd cmake_targets
编译USRP驱动和依赖,此步骤可能需要科学上网
#for OAI first time installation only to install software dependencies
sudo ./build_oai -I -w USRP
成功截图:
参考网址:https://gitlab.eurecom.fr/oai/openairinterface5g/-/blob/develop/doc/NR_SA_Tutorial_OAI_nrUE.md
gNB端:
修改gnb配置文件
cd openairinterface5g/targets/PROJECTS/GENERIC-NR-5GC/CONF
sudo gedit gnb.sa.band78.fr1.106PRB.usrpb210.conf
#修改tracking_area_code
,mcc
,mnc
为核心网对应数据,核心网数据在
oai-cnfg-fed/docker-compose/ docker-compose-mini-nrf.yuml
#修改amf_ip_address
和NETWORK_INTERFACES
参数
amf_ip_address
:IPV4
是amf
的地址
NETWORK_INTERFACES
下面是基站的网口名字和IP地址
修改UE参数
修改 ue.conf
参数,同时在核心网端要执行对应操作(这个核心网操作每一次都重启了核心网后都需要执行),注意参数要匹配。
编译:
cd OAI/openairinterface5g/cmake_targets
sudo ./build_oai --gNB --nrUE -w SIMU
运行:
- 首先需要保证核心网主机和
gNB
主机在同一个局域网下,比如连在同一个路由器或者交换机下,即两台主机之间可以互相ping
通,建议使用网线链接主机和路由器。 - 如果能够
ping
通之后,就要在gNB
的主机上添加路由转发
gNB
侧增加路由:sudo ip route add 192.168.70.128/26 via 192.168.105.179 dev enps20
;
其中192.168.70.128/26
是核心网通过docker
创建的网桥的地址,一般如果不修改docker file
的参数,这个不用改.
192.168.105.179是核心网主机的地址
enps20是有线网卡的名字
另外注意一下添加路由的命令是一次性,即在关机重启之后就失效了,需要重新添加。
- 在核心网主机上设置网络参数
sudo sysctl net.ipv4.conf.all.forwarding=1
sudo iptables -P FORWARD ACCEPT
#同样要注意以上的命令也是一次性的,重启之后就需要重新添加。
-
分别设置完两台主机的参数后就可以测试一下,先把核心网主机的核心网启动起来,之后通过
gNB
主机来ping
核心网中的各个容器。
-
以上没有问题后启动gNB
cd OAI/openairinterface5g/cmake_targets/ran_build/build/
sudo ./nr-softmodem -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/my-gnb.sa.band78.fr1.106PRB.usrpb210.conf --gNBs.[0].min_rxtxtime 6 --sa -E --continuous-tx
成功截图:
- 启动UE
sudo ./nr-uesoftmodem -r 106 --band 78 -C 3619200000 --ue-fo-compensation --sa -E -O ../../../targets/PROJECTS/GENERIC-NR-5GC/CONF/my-ue.conf --nokrnmod 1 --numerology 1
- 在UE端检测虚拟网口
具体的流程和他的功能可以查看下面链接:
https://gitlab.eurecom.fr/oai/openairinterface5g