环境:
Ubantu | 18.04 |
OAI-5GC | v1.5.0 |
UERANSIM | v3.2.6 |
网络:
Host1:OAI-5GC | ens37:192.168.12.3 |
Host2:UERANSIM | ens40:192.168.12.33 |
确保两台宿主机之间互通!
网络配置
- Host1 网络:OAI
ens37: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.12.3 netmask 255.255.255.0 broadcast 192.168.12.255
inet6 fe80::20c:29ff:feed:a29d prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:ed:a2:9d txqueuelen 1000 (Ethernet)
RX packets 349 bytes 58585 (58.5 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 216 bytes 19769 (19.7 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
需要添加的命令(可选)
当我们基站和核心网分开部署时,大多数情况下,计算机未配置数据包转发。可以使用以下命令启用它。部署在一个虚拟机中时不需要。
sudo sysctl net.ipv4.conf.all.forwarding=1
sudo iptables -P FORWARD ACCEPT
- Host2 网络:UERANSIM
ens40: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.12.33 netmask 255.255.255.0 broadcast 192.168.12.255
inet6 fe80::20c:29ff:fe6a:9c3e prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:6a:9c:3e txqueuelen 1000 (Ethernet)
RX packets 2229 bytes 176319 (176.3 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 314 bytes 29557 (29.5 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
需要添加的命令
sudo ip route add 192.168.70.0/24 via 192.168.12.3 dev ens40
sudo ip route add 192.168.72.0/24 via 192.168.12.3 dev ens40
注意:跨设备的UERANSIM部署一定要添加除了到70.1的路由以外的72.1的路由,不然UERANSIM看起来接上了,其实nr-binder的用户数据无法传输!
UERANSIM配置
参考OAI官网给出的配置文件docker-compose-ueransim-vpp.yaml(见本文附录)
- gNB
mcc: '208' # Mobile Country Code value
mnc: '95' # Mobile Network Code value (2 or 3 digits)
nci: '0x000000010' # NR Cell Identity (36-bit)
idLength: 32 # NR gNB ID length in bits [22...32]
tac: 0xa000 # Tracking Area Code
linkIp: 192.168.12.33 # gNB's local IP address for Radio Link Simulation (与对应物理网卡ip一致)
ngapIp: 192.168.12.33 # gNB's local IP address for N2 Interface (与对应物理网卡ip一致)
gtpIp: 192.168.12.33 # gNB's local IP address for N3 Interface (与对应物理网卡ip一致)
# List of AMF address information
amfConfigs:
- address: 192.168.70.132 # OAI核心网amf网元对应ip
port: 38412
# List of supported S-NSSAIs by this gNB
slices:
- sst: 222
sd: 123
# Indicates whether or not SCTP stream number errors should be ignored.
ignoreStreamIds: true
- UE
# IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)
supi: 'imsi-208950000000033'
# Mobile Country Code value of HPLMN
mcc: '208'
# Mobile Network Code value of HPLMN (2 or 3 digits)
mnc: '95'
# Routing Indicator
routingIndicator: '0000'
# Permanent subscription key
key: '0C0A34601D4F07677303652C0462535B'
# Operator code (OP or OPC) of the UE
op: '63bfa50ee6523365ff14c1f45f88737d'
# This value specifies the OP type and it can be either 'OP' or 'OPC'
opType: 'OPC'
# Authentication Management Field (AMF) value
amf: '8000'
# IMEI number of the device. It is used if no SUPI is provided
imei: '356938035643803'
# IMEISV number of the device. It is used if no SUPI and IMEI is provided
imeiSv: '0035609204079514'
# List of gNB IP addresses for Radio Link Simulation
gnbSearchList:
- 192.168.12.33
# UAC Access Identities Configuration
uacAic:
mps: false
mcs: false
# UAC Access Control Class
uacAcc:
normalClass: 0
class11: false
class12: false
class13: false
class14: false
class15: false
# Initial PDU sessions to be established
sessions:
- type: 'IPv4'
apn: 'default'
slice:
sst: 222
sd: 123
# Configured NSSAI for this UE by HPLMN
configured-nssai:
- sst: 222
sd: 123
# Default Configured NSSAI for this UE
default-nssai:
- sst: 222
sd: 123
# Supported integrity algorithms by this UE
integrity:
IA1: true
IA2: true
IA3: true
# Supported encryption algorithms by this UE
ciphering:
EA1: true
EA2: true
EA3: true
# Integrity protection maximum data rate for user plane
integrityMaxRate:
uplink: 'full'
downlink: 'full'
启动
核心网启动
docker-compose -f docker-compose-basic-vpp-nrf.yaml up -d
ping测试
lab@lab-virtual-machine:~/UERANSIM/config$ ping 192.168.70.132 -c 4
PING 192.168.70.132 (192.168.70.132) 56(84) bytes of data.
64 bytes from 192.168.70.132: icmp_seq=1 ttl=63 time=0.906 ms
64 bytes from 192.168.70.132: icmp_seq=2 ttl=63 time=0.799 ms
64 bytes from 192.168.70.132: icmp_seq=3 ttl=63 time=0.761 ms
64 bytes from 192.168.70.132: icmp_seq=4 ttl=63 time=0.847 ms
--- 192.168.70.132 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3045ms
rtt min/avg/max/mdev = 0.761/0.828/0.906/0.057 ms
lab@lab-virtual-machine:~/UERANSIM/config$ ping 192.168.70.1 -c 4
PING 192.168.70.1 (192.168.70.1) 56(84) bytes of data.
64 bytes from 192.168.70.1: icmp_seq=1 ttl=64 time=0.779 ms
64 bytes from 192.168.70.1: icmp_seq=2 ttl=64 time=0.767 ms
64 bytes from 192.168.70.1: icmp_seq=3 ttl=64 time=0.603 ms
64 bytes from 192.168.70.1: icmp_seq=4 ttl=64 time=0.705 ms
--- 192.168.70.1 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3071ms
rtt min/avg/max/mdev = 0.603/0.713/0.779/0.074 ms
基站启动
cd ~/UERANSIM/build
./nr-gnb -c ../config/open5gs-gnb.yaml
./nr-ue -c ../config/open5gs-ue.yaml
amf日志:
数据流测试:
- 首先查看一下网络
uesimtun0: flags=369<UP,POINTOPOINT,NOTRAILERS,RUNNING,PROMISC> mtu 1400
inet 12.1.1.4 netmask 255.255.255.255 destination 12.1.1.4
inet6 fe80::7b49:fa87:b907:607b prefixlen 64 scopeid 0x20<link>
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10 bytes 592 (592.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
- ping测试
ping -I 12.1.1.3 192.168.70.1
容易发现通过tun0接口ping核心网网元是ping不通的
- nr-binder测试
lab@lab-virtual-machine:~/oai-cn5g-fed/docker-compose/gNB$ python3 TCPserve.py
lab@lab-virtual-machine:~/UERANSIM/build$ ./nr-binder 12.1.1.3 python3 TCPclient.py
结果
附录
version: '3.8'
services:
ueransim:
container_name: ueransim
image: ueransim:latest
privileged: true
environment:
# GNB Congig Parameters
- MCC=208
- MNC=95
- NCI=0x000000010
- TAC=0xa000
- LINK_IP=192.168.70.141
- NGAP_IP=192.168.70.141
- GTP_IP=192.168.72.141
- NGAP_PEER_IP=192.168.70.132
- SST=222
- SD=123
- IGNORE_STREAM_IDS=true
# UE Config Parameters
- NUMBER_OF_UE=1
- IMSI=208950000000031
- KEY=0C0A34601D4F07677303652C0462535B
- OP=63bfa50ee6523365ff14c1f45f88737d
- OP_TYPE=OPC
- AMF_VALUE=8000
- IMEI=356938035643803
- IMEI_SV=0035609204079514
- GNB_IP_ADDRESS=192.168.70.141
- PDU_TYPE=IPv4
- APN=default
- SST_0=222
- SD_0=123
- SST_C=222
- SD_C=123
- SST_D=222
- SD_D=123
networks:
public_net:
ipv4_address: 192.168.70.141
public_net_access:
ipv4_address: 192.168.72.141
healthcheck:
test: /bin/bash -c "ifconfig uesimtun0"
interval: 10s
timeout: 5s
retries: 5
networks:
public_net:
external:
name: demo-oai-public-net
public_net_access:
external:
name: oai-public-access