官网:openairinterface
开启网站 : cn5g代码位置
参考视频: OAI(Open Air Interface)开源5G核心网部署方案
虚拟机VMware :16.2.0 build-18760230
百度网盘链接:
https://pan.baidu.com/s/1TfDdb4gczyURrrqAhqKO0Q?pwd=0518
提取码:0518
Ubuntu是常见的Linux平台之一,OAI目前的部署只支持Ubuntu
Ubuntu 18.04安装参考教程1
Ubuntu 18.04安装参考教程2
安装完后下载各种镜像的时候可能速度很慢,将下载源改为阿里或清华的镜像。
详见链接 :更换镜像下载源
VMware tools 可以实现主机与虚拟机之间文件的自由拖拽与文本复制粘贴等功能
安装vmwaretools
vmwaretools复制粘贴修复
环境安装
安装docker
以上教程执行到hello world可以执行就行
安装docker compose 参照其中docker-compose安装部分
安装python3 3.6.9版本
myusername 改成主机ubuntu虚拟机的名字
需要一个docker hub 账号,可以去创建一个docker hub
$ sudo docker login
$ docker pull ubuntu:bionic
$ docker pull mysql:5.7
再输入如下代码
$ sudo sysctl net.ipv4.conf.all.forwarding=1
$ sudo iptables -P FORWARD ACCEPT
官方构建核心网链接
下载前需登陆 docker,下载过程可能有些慢,可换不同的源尝试,或试一下阿里的源加速链接: 使用阿里源加速docker pull
参考链接
有时候不管怎么改都很慢,待解决
docker pull oaisoftwarealliance/oai-amf:latest
docker pull oaisoftwarealliance/oai-spgwu-tiny:latest
docker pull oaisoftwarealliance/oai-smf:latest
docker pull oaisoftwarealliance/trf-gen-cn5g:latest
然后修改tag
docker image tag oaisoftwarealliance/oai-amf:latest oai-amf:latest
docker image tag oaisoftwarealliance/oai-smf:latest oai-smf:latest
docker image tag oaisoftwarealliance/oai-spgwu-tiny:latest oai-spgwu-tiny:latest
docker image tag oaisoftwarealliance/trf-gen-cn5g:latest trf-gen-cn5g:latest
makir OAI
cd OAI
git clone https://gitlab.eurecom.fr/oai/cn5g/oai-cn5g-fed.git
#若第一次启动不成功,试一下下面代码
cd oai-cn5g-fed
git checkout -f v1.3.0
./scripts/syncComponents.sh
docker network create --driver=bridge --subnet=192.168.70.128/26 -o
"com.docker.network.bridge.name"="demo-oai" demo-oai-public-net
#查询是否有demo-oai的网口
ifconfig
#查询网关地址
docker network ls
#ping 一下网关看是否通了
ping 192.168.70.129
#根据不同需要输入启动代码
python3 core-network.py --type start-mini --fqdn no --scenario 2
#启动后查看容器运行状况
docker ps
#观察amf里可改字段的信息
vim docker-compose-mini-nonrf.yaml
关闭核心网时保存日志
docker logs oai-amf > amf.log
docker logs oai-smf > smf.log
docker logs oai-nrf > nrf.log
docker logs oai-spgwu > spgwu.log
python3 ./core-network.py --type stop-mini
#保存位置为 docker compose
root@yinzhao6-virtual-machine:/home/yinzhao6/OAI/oai-cn5g-fed/docker-compose# python3 core-network.py --type start-mini --fqdn no --scenario 2
usage: core-network.py [-h] --type
{start-mini,start-basic,start-basic-vpp,stop-mini,stop-basic,stop-basic-vpp}
[--scenario {1,2}] [--capture CAPTURE]
core-network.py: error: unrecognized arguments: --fqdn no
第一次尝试启动,报错启动代码错误,未识别 --fqdn no
root@yinzhao6-virtual-machine:/home/yinzhao6/OAI/oai-cn5g-fed/docker-compose# python3 core-network.py --type start-mini --scenario 2
[2022-09-08 12:23:46,515] root:DEBUG: Starting 5gcn components... Please wait....
[2022-09-08 12:23:46,515] root:DEBUG: docker-compose -f docker-compose-mini-nonrf.yaml up -d
Pulling oai-amf (oai-amf:v1.4.0)...
ERROR: The image for the service you're trying to recreate has been removed. If you continue, volume data could be lost. Consider backing up your data before continuing.
ERROR: pull access denied for oai-amf, repository does not exist or may require 'docker login': denied: requested access to the resource is denied
Incorrect/Unsupported executing command docker-compose -f docker-compose-mini-nonrf.yaml up -d
第二次启动,要拉取 oai-amf,但是拉取失败了,错误原因是存储卡不存在或 docker login未登陆
root@yinzhao6-virtual-machine:/home/yinzhao6/OAI/oai-cn5g-fed/docker-compose# docker login
Authenticating with existing credentials...
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store
Login Succeeded
于是我登陆了 docker login
root@yinzhao6-virtual-machine:/home/yinzhao6/OAI/oai-cn5g-fed/docker-compose# python3 core-network.py --type start-mini --scenario 2
[2022-09-08 12:25:27,696] root:DEBUG: Starting 5gcn components... Please wait....
[2022-09-08 12:25:27,696] root:DEBUG: docker-compose -f docker-compose-mini-nonrf.yaml up -d
Pulling oai-amf (oai-amf:v1.4.0)...
ERROR: The image for the service you're trying to recreate has been removed. If you continue, volume data could be lost. Consider backing up your data before continuing.
^CERROR: Aborting.
Incorrect/Unsupported executing command docker-compose -f docker-compose-mini-nonrf.yaml up -d
登陆后再次尝试没有成功,应该是image oai-amf出了问题
root@yinzhao6-virtual-machine:/home/yinzhao6/OAI/oai-cn5g-fed# docker pull oaisoftwarealliance/oai-amf:latest
latest: Pulling from oaisoftwarealliance/oai-amf
Digest: sha256:4db13a12f1ca89689f7acf68e27129641bc1118c9da2bb21beb197c43fca4888
Status: Image is up to date for oaisoftwarealliance/oai-amf:latest
docker.io/oaisoftwarealliance/oai-amf:latest
将 amf的镜像再pull一次
#这是我中间进行的另一个操作,不知道和解决问题有没有关,待验证
root@yinzhao6-virtual-machine:/home/yinzhao6/OAI/oai-cn5g-fed# git checkout -f v1.3.0 #输入代码
Note: checking out 'v1.3.0'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 212f92f Merge branch 'prepare-nssf-public-release' into 'master' #输入代码显示的内容
经过上诉的几个简单操作后,再次尝试时发现启动成功了!
python3 core-network.py --type start-mini --fqdn no --scenario 2