注意:如果读者有兴趣部署具有更多日志的调试器/开发人员核心网络环境,请按照本教程进行操作
目录
- 在此演示中,下面列出了使用的图像标记和提交,请按照构建映像以使用以下标记构建映像。
本教程是上一教程的扩展:使用 dsTester 测试基本
部署。在前面的教程中,我们已经看到了高级测试工具 dsTester,它对于验证更复杂的场景非常有用。
此外,还有各种其他开源 gnb/ue 模拟器工具可用于 SA5G 测试。在本教程中,我们使用一个名为 UERANSIM
工具,我们可以通过模拟一个GNB和多个ue来执行非常基本的SA5G测试。
关于UERANSIM-
UERANSIM是开源的最先进的5G UE和RAN(gNodeB)实现。从基本意义上讲,它可以被视为5G手机和基站。该项目可用于测试5G核心网和研究5G系统。UERANSIM可以模拟多个UE,它也旨在模拟无线电。此外,有关详细的功能集,请参阅其官方页面。
让我们开始吧!!
- 步骤 1 到 5 类似于前面关于 vpp-upf 的教程。请按照以下步骤部署OAI 5G核心网组件。
- 我们将 ueransim docker 服务部署在与核心网络相同的主机上,因此无需创建额外的路由 我们为dsTest-host做了。
- 在我们进一步进行端到端 SA5G 测试之前,请确保您为 OAI cn5g 提供健康的 docker 服务
步骤1-5略
步骤 1 到 5 类似于前面关于 vpp-upf 的教程。请按照以下步骤部署OAI 5G核心网组件。
注意:
UERANSIM目前不支持集成和加密算法NIA0,NEA0。因此,我们必须在 docker-compose 中更新 AMF 配置,如下所示
修改方法如下:
首先进入dockercompose需要启动的ymal文件
docker-compose# vim docker-compose-basic-vpp-nrf.yaml
在对应的amf字段中添加配置:
然后,我们像往常一样遵循部署过程
oai-cn5g-fed/docker-compose$ docker-compose -f docker-compose-basic-vpp-nrf.yaml up -d
Creating mysql ... done
Creating oai-nrf ... done
Creating vpp-upf ... done
Creating oai-udr ... done
Creating oai-udm ... done
Creating oai-ext-dn ... done
Creating oai-ausf ... done
Creating oai-amf ... done
Creating oai-smf ... done
有关更多详细信息,请参阅基本 vpp 教程的第 5 节。 部署核心网络后,请确保所有服务都正常运行。
oai-cn5g-fed/docker-compose$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
4349e8808902 oai-smf:latest "/bin/bash /openair-…" 49 seconds ago Up 48 seconds (healthy) 80/tcp, 9090/tcp, 8805/udp oai-smf
62e774768482 oai-amf:latest "/bin/bash /openair-…" 49 seconds ago Up 48 seconds (healthy) 80/tcp, 9090/tcp, 38412/sctp oai-amf
0302e6a3d2b3 oai-ausf:latest "/bin/bash /openair-…" 50 seconds ago Up 49 seconds (healthy) 80/tcp oai-ausf
fb3249a5ade7 ubuntu:bionic "/bin/bash -c ' apt …" 51 seconds ago Up 49 seconds oai-ext-dn
4f114039c218 oai-udm:latest "/bin/bash /openair-…" 51 seconds ago Up 49 seconds (healthy) 80/tcp oai-udm
c0838aff8796 oai-udr:latest "/bin/bash /openair-…" 51 seconds ago Up 50 seconds (healthy) 80/tcp oai-udr
99ab1b23862c oai-upf-vpp:latest "/openair-upf/bin/en…" 51 seconds ago Up 50 seconds (healthy) 2152/udp, 8085/udp vpp-upf
3469f853e26d mysql:8.0 "docker-entrypoint.s…" 52 seconds ago Up 51 seconds (healthy) 3306/tcp, 33060/tcp mysql
ab06bd3104ef oai-nrf:latest "/bin/bash /openair-…" 52 seconds ago Up 51 seconds (healthy) 80/tcp, 9090/tcp oai-nrf
6. 获取UERANSIM
镜像
您可以选择(两种拉取镜像方式,选其一即可):
- 构建
UERANSIM
镜像
$ git clone -b docker_support https://github.com/orion-belt/UERANSIM.git
$ cd UERANSIM
$ docker build --target ueransim --tag ueransim:latest -f docker/Dockerfile.ubuntu.18.04 .
(自己构建的话大约会花费10min)
- 或者您可以拉取预构建的 docker
UERANSIM
映像(较简单)
docker pull rohankharade/ueransim
docker image tag rohankharade/ueransim:latest ueransim:latest
7 UERANSIM的部署和启动
- 配置参数在docker-compose-basic-vpp-nrf.yaml和 docker-compose-ueransim-vpp.yaml
中预先配置,对其进行修改以进行测试。 - 启动 ueransim docker 服务
oai-cn5g-fed/docker-compose$ docker-compose -f docker-compose-ueransim-vpp.yaml up -d
Creating ueransim ... done
确保所有容器工作健康
oai-cn5g-fed/docker-compose$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cb206b9b0a25 ueransim:latest "/ueransim/bin/entry…" 14 seconds ago Up 13 seconds (healthy) ueransim
4349e8808902 oai-smf:latest "/bin/bash /openair-…" About a minute ago Up About a minute (healthy) 80/tcp, 9090/tcp, 8805/udp oai-smf
62e774768482 oai-amf:develop "/bin/bash /openair-…" About a minute ago Up About a minute (healthy) 80/tcp, 9090/tcp, 38412/sctp oai-amf
0302e6a3d2b3 oai-ausf:latest "/bin/bash /openair-…" About a minute ago Up About a minute (healthy) 80/tcp oai-ausf
fb3249a5ade7 ubuntu:bionic "/bin/bash -c ' apt …" About a minute ago Up About a minute oai-ext-dn
4f114039c218 oai-udm:latest "/bin/bash /openair-…" About a minute ago Up About a minute (healthy) 80/tcp oai-udm
c0838aff8796 oai-udr:latest "/bin/bash /openair-…" About a minute ago Up About a minute (healthy) 80/tcp oai-udr
99ab1b23862c oai-upf-vpp:latest "/openair-upf/bin/en…" About a minute ago Up About a minute (healthy) 2152/udp, 8085/udp vpp-upf
3469f853e26d mysql:8.0 "docker-entrypoint.s…" About a minute ago Up About a minute (healthy) 3306/tcp, 33060/tcp mysql
ab06bd3104ef oai-nrf:latest "/bin/bash /openair-…" About a minute ago Up About a minute (healthy) 80/tcp, 9090/tcp oai-nrf
我们可以使用 UERANSIM 容器日志进行验证,如下所示 -
$ docker logs ueransim
Now setting these variables '@GTP_IP@ @IGNORE_STREAM_IDS@ @LINK_IP@ @MCC@ @MNC@ @NCI@ @NGAP_IP@ @NGAP_PEER_IP@ @SD@ @SST@ @TAC@'
Now setting these variables '@AMF_VALUE@ @APN@ @GNB_IP_ADDRESS@ @IMEI@ @IMEI_SV@ @IMSI@ @KEY@ @MCC@ @MNC@ @OP@ @OP_TYPE@ @PDU_TYPE@ @SD@ @SD_C@ @SD_D@ @SST@ @SST_C@ @SST_D@'
Done setting the configuration
### Running ueransim ###
Running gnb
UERANSIM v3.2.4
[2021-12-01 07:46:01.772] [sctp] [info] Trying to establish SCTP connection... (192.168.70.132:38412)
[2021-12-01 07:46:01.776] [sctp] [info] SCTP connection established (192.168.70.132:38412)
[2021-12-01 07:46:01.776] [sctp] [debug] SCTP association setup ascId[105]
[2021-12-01 07:46:01.776] [ngap] [debug] Sending NG Setup Request
[2021-12-01 07:46:01.780] [ngap] [debug] NG Setup Response received
[2021-12-01 07:46:01.780] [ngap] [info] NG Setup procedure is successful
Running ue
UERANSIM v3.2.4
[2021-12-01 07:46:02.759] [nas] [info] UE switches to state [MM-DEREGISTERED/PLMN-SEARCH]
[2021-12-01 07:46:02.759] [rrc] [debug] UE[1] new signal detected
[2021-12-01 07:46:02.759] [rrc] [debug] New signal detected for cell[1], total [1] cells in coverage
[2021-12-01 07:46:02.759] [nas] [info] Selected plmn[208/95]
[2021-12-01 07:46:02.759] [rrc] [info] Selected cell plmn[208/95] tac[40960] category[SUITABLE]
[2021-12-01 07:46:02.759] [nas] [info] UE switches to state [MM-DEREGISTERED/PS]
[2021-12-01 07:46:02.759] [nas] [info] UE switches to state [MM-DEREGISTERED/NORMAL-SERVICE]
[2021-12-01 07:46:02.759] [nas] [debug] Initial registration required due to [MM-DEREG-NORMAL-SERVICE]
[2021-12-01 07:46:02.759] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
[2021-12-01 07:46:02.759] [nas] [debug] Sending Initial Registration
[2021-12-01 07:46:02.760] [nas] [info] UE switches to state [MM-REGISTER-INITIATED]
[2021-12-01 07:46:02.760] [rrc] [debug] Sending RRC Setup Request
[2021-12-01 07:46:02.760] [rrc] [info] RRC Setup for UE[1]
[2021-12-01 07:46:02.760] [rrc] [info] RRC connection established
[2021-12-01 07:46:02.760] [rrc] [info] UE switches to state [RRC-CONNECTED]
[2021-12-01 07:46:02.760] [nas] [info] UE switches to state [CM-CONNECTED]
[2021-12-01 07:46:02.760] [ngap] [debug] Initial NAS message received from UE[1]
[2021-12-01 07:46:02.787] [nas] [debug] Authentication Request received
[2021-12-01 07:46:02.799] [nas] [debug] Security Mode Command received
[2021-12-01 07:46:02.799] [nas] [debug] Selected integrity[1] ciphering[1]
[2021-12-01 07:46:02.804] [ngap] [debug] Initial Context Setup Request received
[2021-12-01 07:46:02.805] [nas] [debug] Registration accept received
[2021-12-01 07:46:02.805] [nas] [info] UE switches to state [MM-REGISTERED/NORMAL-SERVICE]
[2021-12-01 07:46:02.805] [nas] [debug] Sending Registration Complete
[2021-12-01 07:46:02.805] [nas] [info] Initial Registration is successful
[2021-12-01 07:46:02.805] [nas] [debug] Sending PDU Session Establishment Request
[2021-12-01 07:46:02.805] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
[2021-12-01 07:46:03.036] [ngap] [info] PDU session resource(s) setup for UE[1] count[1]
[2021-12-01 07:46:03.037] [nas] [debug] PDU Session Establishment Accept received
[2021-12-01 07:46:03.037] [nas] [info] PDU Session establishment is successful PSI[1]
[2021-12-01 07:46:03.055] [app] [info] Connection setup for PDU session[1] is successful, TUN interface[uesimtun0, 12.2.1.2] is up.
显而易见,UERANSIM的gNB和UE全部成功部署,同时虚拟隧道TUN 接口 ueransimtun0成功打开,ip地址为12.1.1.2(虚拟隧道的ip不是静态ip,可能在每次启动之后其ip地址会有变动)。
连接测试
现在我们准备执行一些流量测试。
- 互Ping 测试
这里我们从外部 DN 容器(oai-ext-dn) ping UE的uesimtun0接口
$ docker exec -it oai-ext-dn ping -c 3 12.1.1.2
PING 12.1.1.2 (12.2.1.2) 56(84) bytes of data.
64 bytes from 12.2.1.2: icmp_seq=1 ttl=64 time=0.235 ms
64 bytes from 12.2.1.2: icmp_seq=2 ttl=64 time=0.145 ms
64 bytes from 12.2.1.2: icmp_seq=3 ttl=64 time=0.448 ms
--- 12.1.1.2 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2036ms
rtt min/avg/max/mdev = 0.145/0.276/0.448/0.127 ms
#其中docker exec -it imageID cmd表示在正在运行容器中运行cmd程序,所以cmd是不能省略的
#因此docker exec -it oai-ext-dn ping -c 3 12.1.1.2表示在oai-ext-dn容器中运行ping命令
- 接着我们通过进入ueransim容器来ping外部DN(如百度)
oai-cn5g-fed/docker-compose$ docker exec ueransim ping -c 3 -I uesimtun0 google.com
PING google.com (172.217.18.238) from 12.2.1.2 : 56(84) bytes of data.
64 bytes from par10s10-in-f238.1e100.net (172.217.18.238): icmp_seq=1 ttl=115 time=5.12 ms
64 bytes from par10s10-in-f238.1e100.net (172.217.18.238): icmp_seq=2 ttl=115 time=7.52 ms
64 bytes from par10s10-in-f238.1e100.net (172.217.18.238): icmp_seq=3 ttl=115 time=7.19 ms
--- google.com ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 4ms
rtt min/avg/max/mdev = 5.119/6.606/7.515/1.064 ms
- iperf test
在这里,我们在 UERANSIM UE 和外部 DN 节点之间进行 iperf 流量测试。
首先我们可以将任何节点作为 iperf 服务器/客户端。在外部 DN 容器上运行 iperf 服务器,对监听5021端口监听,若客户端发起请求,将会显示实时的带宽
$ docker exec -it oai-ext-dn iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
#Iperf可以运行在任何IP网络上,包括本地以太网、接入因特网、Wi-Fi网络等。在工作模式上,iperf运行于服#务器、客户端模式下,其服务器端主要用于监听到达的测试请求,而客户端主要用于发起测试连接会话,因此要##使用iperf至少需要两台服务器,一台运行在服务器模式下,另一台运行在客户端模式下。
#在完成iperf安装后,执行“iperf3 –h”即可显示iperf的详细用法。iperf的命令行选项共分为三类,分别是客#户端与服务器端公用选项、服务器端专用选项和客户端专用选项。
#Iperf常用参数(测试够用)
#-s,–server:iperf服务器模式,默认启动的监听端口为5201,eg:iperf -s
然后在打开另外一个终端,在ueransim容器中运行iperf的客户端
$ docker exec -it ueransim iperf3 -c 192.168.73.135 -B 12.2.1.2
Connecting to host 192.168.73.135, port 5201
[ 4] local 12.2.1.2 port 58455 connected to 192.168.73.135 port 5201
[ ID] Interval Transfer Bandwidth Retr Cwnd
[ 4] 0.00-1.00 sec 5.07 MBytes 42.5 Mbits/sec 318 34.2 KBytes
[ 4] 1.00-2.00 sec 2.34 MBytes 19.7 Mbits/sec 268 22.4 KBytes
[ 4] 2.00-3.00 sec 2.72 MBytes 22.8 Mbits/sec 276 34.2 KBytes
[ 4] 3.00-4.00 sec 2.10 MBytes 17.6 Mbits/sec 234 38.2 KBytes
[ 4] 4.00-5.00 sec 2.22 MBytes 18.6 Mbits/sec 303 13.2 KBytes
[ 4] 5.00-6.00 sec 2.16 MBytes 18.1 Mbits/sec 240 38.2 KBytes
[ 4] 6.00-7.00 sec 2.72 MBytes 22.8 Mbits/sec 307 60.6 KBytes
[ 4] 7.00-8.00 sec 2.16 MBytes 18.1 Mbits/sec 325 35.5 KBytes
[ 4] 8.00-9.00 sec 2.16 MBytes 18.1 Mbits/sec 223 56.6 KBytes
[ 4] 9.00-10.00 sec 2.47 MBytes 20.7 Mbits/sec 349 26.3 KBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth Retr
[ 4] 0.00-10.00 sec 26.1 MBytes 21.9 Mbits/sec 2843 sender
[ 4] 0.00-10.00 sec 25.2 MBytes 21.1 Mbits/sec receiver
iperf Done.
此时iperf服务端的输出如下
$ docker exec -it oai-ext-dn iperf3 -s
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
Accepted connection from 12.2.1.2, port 49925
[ 5] local 192.168.73.135 port 5201 connected to 12.2.1.2 port 58455
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-1.00 sec 4.13 MBytes 34.6 Mbits/sec
[ 5] 1.00-2.00 sec 2.33 MBytes 19.5 Mbits/sec
[ 5] 2.00-3.00 sec 2.68 MBytes 22.5 Mbits/sec
[ 5] 3.00-4.00 sec 2.10 MBytes 17.6 Mbits/sec
[ 5] 4.00-5.00 sec 2.26 MBytes 19.0 Mbits/sec
[ 5] 5.00-6.00 sec 2.14 MBytes 17.9 Mbits/sec
[ 5] 6.00-7.00 sec 2.71 MBytes 22.8 Mbits/sec
[ 5] 7.00-8.00 sec 2.19 MBytes 18.4 Mbits/sec
[ 5] 8.00-9.00 sec 2.12 MBytes 17.8 Mbits/sec
[ 5] 9.00-10.00 sec 2.53 MBytes 21.2 Mbits/sec
[ 5] 10.00-10.00 sec 0.00 Bytes 0.00 bits/sec
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval Transfer Bandwidth
[ 5] 0.00-10.00 sec 0.00 Bytes 0.00 bits/sec sender
[ 5] 0.00-10.00 sec 25.2 MBytes 21.1 Mbits/sec receiver
-----------------------------------------------------------
Server listening on 5201
-----------------------------------------------------------
实际测试如下
- 注意:- iperf 测试仅用于说明目的,测试结果可能会因 docker 服务可用的资源而异
8. 分析情景结果
pcap/日志文件 |
---|
5gcn-deployment-ueransim.pcap |
- 有关消息的详细分析,请参阅前面的教程。
9. 尝试一些高级的东西(多用户接入)
在这里,我们尝试使用ueransim进行一些小规模用户测试。在数据库中添加了其他 IMSI (208950000000031-208950000000131)可以最多支持100个用户接入。 现在我们使用 ueransim 注册 10个 UE。(这种多用户情况下,基站只有一个,但是用户有多个,通过不同的IMSI来进行识别)
注意:我们必须更新 docker 组合中的参数 ueransim;方法如下
NUMBER_OF_UE=10
#范围1~100均可
修改如下
稍等片刻
现在,我们可以验证是否已从 AMF 或 SMF 日志成功注册所有 UE。
oai-cn5g-fed/docker-compose$ docker logs
[2021-12-23T22:14:40.065447] [AMF] [amf_app] [info ] |----------------------------------------------------gNBs' information-------------------------------------------|
[2021-12-23T22:14:40.065450] [AMF] [amf_app] [info ] | Index | Status | Global ID | gNB Name | PLMN |
[2021-12-23T22:14:40.065457] [AMF] [amf_app] [info ] | 1 | Connected | 0x1 | UERANSIM-gnb-208-95-1 | 208, 95 |
[2021-12-23T22:14:40.065460] [AMF] [amf_app] [info ] |----------------------------------------------------------------------------------------------------------------|
[2021-12-23T22:14:40.065463] [AMF] [amf_app] [info ]
[2021-12-23T22:14:40.065465] [AMF] [amf_app] [info ] |----------------------------------------------------------------------------------------------------------------|
[2021-12-23T22:14:40.065468] [AMF] [amf_app] [info ] |----------------------------------------------------UEs' information--------------------------------------------|
[2021-12-23T22:14:40.065471] [AMF] [amf_app] [info ] | Index | 5GMM state | IMSI | GUTI | RAN UE NGAP ID | AMF UE ID | PLMN |Cell ID|
[2021-12-23T22:14:40.065477] [AMF] [amf_app] [info ] | 1| 5GMM-REGISTERED| 208950000000031| | 50| 50| 208, 95 | 256|
[2021-12-23T22:14:40.065481] [AMF] [amf_app] [info ] | 2| 5GMM-REGISTERED| 208950000000032| | 61| 61| 208, 95 | 256|
[2021-12-23T22:14:40.065486] [AMF] [amf_app] [info ] | 3| 5GMM-REGISTERED| 208950000000033| | 82| 82| 208, 95 | 256|
[2021-12-23T22:14:40.065490] [AMF] [amf_app] [info ] | 4| 5GMM-REGISTERED| 208950000000034| | 32| 32| 208, 95 | 256|
[2021-12-23T22:14:40.065494] [AMF] [amf_app] [info ] | 5| 5GMM-REGISTERED| 208950000000035| | 23| 23| 208, 95 | 256|
[2021-12-23T22:14:40.065499] [AMF] [amf_app] [info ] | 6| 5GMM-REGISTERED| 208950000000036| | 87| 87| 208, 95 | 256|
[2021-12-23T22:14:40.065504] [AMF] [amf_app] [info ] | 7| 5GMM-REGISTERED| 208950000000037| | 30| 30| 208, 95 | 256|
实际结果如下
- ping两个随机的UE ip
首先需要知道每一个UE对应的虚拟tun接口的ip,查看ueransim的日志即可得到每一个接入ue的ueransimtun0接口信息
$ docker logs ueransim
即可查看到每一个用户的uerantun0信息,实际结果如下如所示:
接着使用外部DN容器来ping不同用户
$ docker exec oai-ext-dn ping -c 2 12.2.1.101
PING 12.2.1.101 (12.2.1.101) 56(84) bytes of data.
64 bytes from 12.2.1.101: icmp_seq=1 ttl=63 time=0.896 ms
64 bytes from 12.2.1.101: icmp_seq=2 ttl=63 time=1.53 ms
--- 12.2.1.101 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.896/1.216/1.537/0.322 ms
$ docker exec oai-ext-dn ping -c 2 12.2.1.88
PING 12.2.1.88 (12.2.1.88) 56(84) bytes of data.
64 bytes from 12.2.1.88: icmp_seq=1 ttl=63 time=0.977 ms
64 bytes from 12.2.1.88: icmp_seq=2 ttl=63 time=0.687 ms
--- 12.2.1.88 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.687/0.832/0.977/0.145 ms
DIY:借助 UE 控制台,可以进一步调查子命令的用法和帮助信息(传送门)
$ docker exec -it ueransim ./nr-cli imsi-208950000000130
--------------------------------------------------------------------------------------------
$ commands
info | Show some information about the UE
status | Show some status information about the UE
timers | Dump current status of the timers in the UE
rls-state | Show status information about RLS
coverage | Dump available cells and PLMNs in the coverage
ps-establish | Trigger a PDU session establishment procedure
ps-list | List all PDU sessions
ps-release | Trigger a PDU session release procedure
ps-release-all | Trigger PDU session release procedures for all active sessions
deregister | Perform a de-registration by the UE
--------------------------------------------------------------------------------------------
取消部署
- UERANSIM
oai-cn5g-fed/docker-compose$ docker-compose -f docker-compose-ueransim-vpp.yaml down
Stopping ueransim ... done
Removing ueransim ... done
Network demo-oai-public-net is external, skipping
Network oai-public-access is external, skipping
- 核心网
oai-cn5g-fed/docker-compose$ python3 ./core-network.py --type stop-basic-vpp --fqdn no --scenario 1
...
[2021-09-14 16:47:44,070] root:DEBUG: OAI 5G core components are UnDeployed....
参考:docs/DEPLOY_SA5G_WITH_UERANSIM.md · master · oai / cn5g / oai-cn5g-fed · GitLab (eurecom.fr)