Deploy a 5G Environment using UERANSIM and OAI 5GCN - caprivm/virtualization GitHub Wiki
caprivm ([email protected])
Updated: January 2, 2023
This page explains all the steps required to connect the UERANSIM (UE+gNB) simulation to a 5GC (5G Core) based on OAI-5GCN. The following specifications show the hardware and software used to deploy the environment.
Before executing the step-by-step of this guide, it is important to install the next tools:
The list of environment variables used for this implementation are summarized in the following exports
:
export UERANSIM_IP="192.168.20.85"
export OAI5GC_N2_IP="192.168.70.132"
NOTE: Replace or configure each of the variables according to your environment.
Reference: Install UERANSIM (UE+gNB) in a Single Machine
The hardware and software it was tested on a single-machine with the next considerations:
Feature | Value |
---|---|
OS Used | Ubuntu Server 22.04 LTS |
vCPU | 2 |
RAM (GB) | 4 |
Disk (GB) | 40 |
Home user | ubuntu |
Number of NICs | 1 (enp0s3) |
UERANSIM branch | master |
Reference: Deploy OAI-5GCN using Docker
The hardware and software for the OAI-5GCN was tested on this:
Feature | Value |
---|---|
OS Used | Ubuntu Server 22.04 LTS |
vCPU | 4 |
RAM (GB) | 8 |
Disk (GB) | 80 |
Home User | ubuntu |
Docker Version | Client: 20.10.22, Server: 20.10.22 |
Docker Compose Version | v2.14.2 |
Number of NICs | 2 (enp0s3, enp0s8) |
The contents of the page are:
After the installation of OAI-5GCN and UERANSIM, the connection between them is made from the server where UERANSIM is hosted. For this, go to the ~/UERANSIM/config
folder and consider create and edit the oai5gc-gnb.yaml
and oai5gc-ue.yaml
with the following information.
Consider this content for the file:
mcc: '001' # Mobile Country Code value
mnc: '01' # 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: 1 # Tracking Area Code
linkIp: $UERANSIM_IP # gNB's local IP address for Radio Link Simulation (Usually same with local IP)
ngapIp: $UERANSIM_IP # gNB's local IP address for N2 Interface (Usually same with local IP)
gtpIp: $UERANSIM_IP # gNB's local IP address for N3 Interface (Usually same with local IP)
# List of AMF address information
amfConfigs:
- address: $OAI5GC_N2_IP
port: 38412
# List of supported S-NSSAIs by this gNB
slices:
- sst: 1
sd: 0x1
# Indicates whether or not SCTP stream number errors should be ignored.
ignoreStreamIds: true
NOTE: Replace
$UERANSIM_IP
and$OAI5GC_N2_IP
with your values.
Use the information available in the AuthenticationSubscription
database of the OAI-5GCN. Consider this content for the file:
# IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)
supi: 'imsi-001010000000001'
# Mobile Country Code value of HPLMN
mcc: '001'
# Mobile Network Code value of HPLMN (2 or 3 digits)
mnc: '01'
# Permanent subscription key
key: 'fec86ba6eb707ed08905757b1bb44b8f'
# Operator code (OP or OPC) of the UE
op: 'C42449363BBAD02B66D16BC975D77CC1'
# 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: '4370816125816151'
# List of gNB IP addresses for Radio Link Simulation
gnbSearchList:
- $UERANSIM_IP
# 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: 'oai'
slice:
sst: 1
sd: 0x1
# Configured NSSAI for this UE by HPLMN
configured-nssai:
- sst: 1
sd: 0x1
# Default Configured NSSAI for this UE
default-nssai:
- sst: 1
sd: 0x1
# 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'
NOTE: Replace
$UERANSIM_IP
with your value.
With the UERANSIM files configured, run in different terminals the gNB first, and then UE (with sudo
permissions) to generate the connection. For the gNB:
cd ~/UERANSIM/build
./nr-gnb -c ../config/oai5gc-gnb.yaml
# UERANSIM v3.2.6
# [2023-01-03 04:40:58.178] [sctp] [info] Trying to establish SCTP connection... (192.168.70.132:38412)
# [2023-01-03 04:40:58.181] [sctp] [info] SCTP connection established (192.168.70.132:38412)
# [2023-01-03 04:40:58.183] [sctp] [debug] SCTP association setup ascId[23]
# [2023-01-03 04:40:58.183] [ngap] [debug] Sending NG Setup Request
# [2023-01-03 04:40:58.186] [ngap] [debug] NG Setup Response received
# [2023-01-03 04:40:58.186] [ngap] [info] NG Setup procedure is successful
In another tab, for the UE:
cd ~/UERANSIM/build
sudo ./nr-ue -c ../config/oai5gc-ue.yaml
# UERANSIM v3.2.6
# [2023-01-03 04:41:16.461] [nas] [info] UE switches to state [MM-DEREGISTERED/PLMN-SEARCH]
# [2023-01-03 04:41:16.463] [rrc] [debug] New signal detected for cell[1], total [1] cells in coverage
# [2023-01-03 04:41:16.464] [nas] [info] Selected plmn[001/01]
# [2023-01-03 04:41:16.465] [rrc] [info] Selected cell plmn[001/01] tac[1] category[SUITABLE]
# [2023-01-03 04:41:16.465] [nas] [info] UE switches to state [MM-DEREGISTERED/PS]
# [2023-01-03 04:41:16.465] [nas] [info] UE switches to state [MM-DEREGISTERED/NORMAL-SERVICE]
# [2023-01-03 04:41:16.465] [nas] [debug] Initial registration required due to [MM-DEREG-NORMAL-SERVICE]
# [2023-01-03 04:41:16.465] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
# [2023-01-03 04:41:16.465] [nas] [debug] Sending Initial Registration
# [2023-01-03 04:41:16.465] [nas] [info] UE switches to state [MM-REGISTER-INITIATED]
# [2023-01-03 04:41:16.465] [rrc] [debug] Sending RRC Setup Request
# [2023-01-03 04:41:16.467] [rrc] [info] RRC connection established
# [2023-01-03 04:41:16.467] [rrc] [info] UE switches to state [RRC-CONNECTED]
# [2023-01-03 04:41:16.467] [nas] [info] UE switches to state [CM-CONNECTED]
# [2023-01-03 04:41:16.487] [nas] [debug] Authentication Request received
# [2023-01-03 04:41:16.508] [nas] [debug] Security Mode Command received
# [2023-01-03 04:41:16.508] [nas] [debug] Selected integrity[1] ciphering[1]
# [2023-01-03 04:41:16.516] [nas] [debug] Registration accept received
# [2023-01-03 04:41:16.516] [nas] [info] UE switches to state [MM-REGISTERED/NORMAL-SERVICE]
# [2023-01-03 04:41:16.516] [nas] [debug] Sending Registration Complete
# [2023-01-03 04:41:16.516] [nas] [info] Initial Registration is successful
# [2023-01-03 04:41:16.517] [nas] [debug] Sending PDU Session Establishment Request
# [2023-01-03 04:41:16.517] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
# [2023-01-03 04:41:16.732] [nas] [debug] PDU Session Establishment Accept received
# [2023-01-03 04:41:16.732] [nas] [info] PDU Session establishment is successful PSI[1]
# [2023-01-03 04:41:16.755] [app] [info] Connection setup for PDU session[1] is successful, TUN interface[uesimtun0, 12.1.1.3] is up.
NOTE: You can simulate more users using
-n
flag. For example, to simulate 10 users, usesudo ./nr-ue -c ../config/oai5gc-ue.yaml -n 10
.
To verify the connection between UERANSIM and OAI-5GCN, in another UERANSIM terminal check if the interface uesimtun0
was created and has an IP assigned:
ifconfig uesimtun0
# uesimtun0: flags=369<UP,POINTOPOINT,NOTRAILERS,RUNNING,PROMISC> mtu 1400
# inet 12.1.1.3 netmask 255.255.255.255 destination 12.1.1.3
# inet6 fe80::da28:4fa5:b0f4:f3ae 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 4 bytes 336 (336.0 B)
# RX errors 0 dropped 0 overruns 0 frame 0
# TX packets 11 bytes 712 (712.0 B)
# TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
You can use that interface to test on the N6 interface of the 5G Core. For example, you can perform ping -I uesimtun0 www.google.com
or curl --interface uesimtun0 www.google.com
to generate some traffic in the core. To get more details about UERANSIM usage, you can consult it in this link:
ping -c 3 -I uesimtun0 google.com
# PING (172.217.28.110) from 12.1.1.3 uesimtun0: 56(84) bytes of data.
# 64 bytes from gru06s09-in-f110.1e100.net (172.217.28.110): icmp_seq=1 ttl=115 time=38.8 ms
# 64 bytes from gru06s09-in-f110.1e100.net (172.217.28.110): icmp_seq=1 ttl=115 time=38.9 ms
# 64 bytes from bog02s07-in-f14.1e100.net (172.217.28.110): icmp_seq=2 ttl=115 time=40.8 ms
You can also validate the operation using a traffic generator provided in the Core 5G installation:
docker exec -it oai-ext-dn iperf3 -s -p 5201
# -----------------------------------------------------------
# Server listening on 5201
# -----------------------------------------------------------
iperf3 -c 192.168.70.135 -p 5201 -B 12.1.1.3
# Connecting to host 192.168.70.135, port 5201
# [ 5] local 12.1.1.3 port 60539 connected to 192.168.70.135 port 5201
# [ ID] Interval Transfer Bitrate Retr Cwnd
# [ 5] 0.00-1.00 sec 14.0 MBytes 117 Mbits/sec 61 103 KBytes
# [ 5] 1.00-2.00 sec 13.5 MBytes 113 Mbits/sec 7 90.8 KBytes
# [ 5] 2.00-3.00 sec 12.2 MBytes 103 Mbits/sec 0 161 KBytes
# [ 5] 3.00-4.00 sec 16.5 MBytes 138 Mbits/sec 29 124 KBytes
# [ 5] 4.00-5.00 sec 13.3 MBytes 112 Mbits/sec 10 128 KBytes
# [ 5] 5.00-6.00 sec 14.4 MBytes 121 Mbits/sec 12 116 KBytes
# [ 5] 6.00-7.00 sec 10.7 MBytes 89.4 Mbits/sec 5 137 KBytes
# [ 5] 7.00-8.00 sec 10.5 MBytes 88.2 Mbits/sec 9 120 KBytes
# [ 5] 8.00-9.00 sec 11.6 MBytes 97.3 Mbits/sec 6 113 KBytes
# [ 5] 9.00-10.00 sec 12.2 MBytes 102 Mbits/sec 19 137 KBytes
# - - - - - - - - - - - - - - - - - - - - - - - - -
# [ ID] Interval Transfer Bitrate Retr
# [ 5] 0.00-10.00 sec 129 MBytes 108 Mbits/sec 158 sender
# [ 5] 0.00-10.00 sec 128 MBytes 107 Mbits/sec receiver
Enjoy ~108 Mbps of UERANSIM + OAI-5GCN!