Deploy a 5G Environment using UERANSIM and Free5GC - 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 Free5GC. 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="10.1.3.106"
export FREE5GC_N2_IP="10.1.3.152" # In this case is the IP of the ens160 interface.
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 20.04 LTS |
vCPU | 2 |
RAM (GB) | 4 |
Disk (GB) | 40 |
Home user | ubuntu |
Number of NICs | 1 (ens160) |
UERANSIM branch | master |
Reference: Deploy the free5GC on Kubernetes
The hardware and software for the free5GC was tested on this:
Feature | Value |
---|---|
Kubernetes Cluster | Kubespray (single node) |
free5GC deployment | Helm Charts |
free5GC version | towards5gs-helm (master) |
OS Used | Ubuntu 20.04.3 LTS |
vCPU | 8 |
RAM (GB) | 16 |
Disk (GB) | 150 |
Home User | ubuntu |
Kubernetes Version | Client: v1.22.1, Server: v1.21.2 |
Helm Version | v3.8.2+g6e3701e |
Number of NICs | 2 (ens160, ens192) |
The contents of the page are:
After the installation of Free5GC and UERANSIM, and after adding the default user in the Free5GC Web-UI, the connection between them is made from the server where UERANSIM is hosted. For this, go to the ~/UERANSIM/config
folder and consider editing the free5gc-gnb.yaml
and free5gc-ue.yaml
with the following information.
Consider this content for the file:
mcc: '208' # Mobile Country Code value
mnc: '93' # 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: $FREE5GC_N2_IP
port: 31412
# List of supported S-NSSAIs by this gNB
slices:
- sst: 0x1
sd: 0x010203
# Indicates whether or not SCTP stream number errors should be ignored.
ignoreStreamIds: true
NOTE: Replace
$UERANSIM_IP
and$FREE5GC_N2_IP
with your values.
Consider this content for the file:
# IMSI number of the UE. IMSI = [MCC|MNC|MSISDN] (In total 15 digits)
supi: 'imsi-208930000000003'
# Mobile Country Code value of HPLMN
mcc: '208'
# Mobile Network Code value of HPLMN (2 or 3 digits)
mnc: '93'
# Permanent subscription key
key: '8baf473f2f8fd09487cccbd7097c6862'
# Operator code (OP or OPC) of the UE
op: '8e27b6af0e692e750f32667a3b14605d'
# 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: 'internet'
slice:
sst: 0x01
sd: 0x010203
# Configured NSSAI for this UE by HPLMN
configured-nssai:
- sst: 0x01
sd: 0x010203
# Default Configured NSSAI for this UE
default-nssai:
- sst: 1
sd: 1
# 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/free5gc-gnb.yaml
# UERANSIM v3.2.6
# [2022-05-03 22:29:23.064] [sctp] [info] Trying to establish SCTP connection... (10.1.3.152:31412)
# [2022-05-03 22:29:23.069] [sctp] [info] SCTP connection established (10.1.3.152:31412)
# [2022-05-03 22:29:23.069] [sctp] [debug] SCTP association setup ascId[10]
# [2022-05-03 22:29:23.069] [ngap] [debug] Sending NG Setup Request
# [2022-05-03 22:29:23.072] [ngap] [debug] NG Setup Response received
# [2022-05-03 22:29:23.072] [ngap] [info] NG Setup procedure is successful
# [2022-05-03 22:30:17.101] [rrc] [debug] UE[1] new signal detected
# [2022-05-03 22:30:19.602] [rrc] [info] RRC Setup for UE[1]
# [2022-05-03 22:30:19.602] [ngap] [debug] Initial NAS message received from UE[1]
# [2022-05-03 22:30:19.719] [ngap] [debug] Initial Context Setup Request received
# [2022-05-03 22:30:20.018] [ngap] [info] PDU session resource(s) setup for UE[1] count[1]
For the UE:
cd ~/UERANSIM/build
sudo ./nr-ue -c ../config/free5gc-ue.yaml
# UERANSIM v3.2.6
# [2022-05-03 22:30:17.101] [rrc] [debug] New signal detected for cell[1], total [1] cells in coverage
# [2022-05-03 22:30:17.101] [nas] [info] UE switches to state [MM-DEREGISTERED/PLMN-SEARCH]
# [2022-05-03 22:30:17.101] [nas] [info] Selected plmn[208/93]
# [2022-05-03 22:30:19.602] [rrc] [info] Selected cell plmn[208/93] tac[1] category[SUITABLE]
# [2022-05-03 22:30:19.602] [nas] [info] UE switches to state [MM-DEREGISTERED/PS]
# [2022-05-03 22:30:19.602] [nas] [info] UE switches to state [MM-DEREGISTERED/NORMAL-SERVICE]
# [2022-05-03 22:30:19.602] [nas] [debug] Initial registration required due to [MM-DEREG-NORMAL-SERVICE]
# [2022-05-03 22:30:19.602] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
# [2022-05-03 22:30:19.602] [nas] [debug] Sending Initial Registration
# [2022-05-03 22:30:19.602] [rrc] [debug] Sending RRC Setup Request
# [2022-05-03 22:30:19.602] [rrc] [info] RRC connection established
# [2022-05-03 22:30:19.602] [rrc] [info] UE switches to state [RRC-CONNECTED]
# [2022-05-03 22:30:19.603] [nas] [info] UE switches to state [MM-REGISTER-INITIATED]
# [2022-05-03 22:30:19.603] [nas] [info] UE switches to state [CM-CONNECTED]
# [2022-05-03 22:30:19.622] [nas] [debug] Authentication Request received
# [2022-05-03 22:30:19.629] [nas] [debug] Security Mode Command received
# [2022-05-03 22:30:19.629] [nas] [debug] Selected integrity[2] ciphering[0]
# [2022-05-03 22:30:19.720] [nas] [debug] Registration accept received
# [2022-05-03 22:30:19.720] [nas] [info] UE switches to state [MM-REGISTERED/NORMAL-SERVICE]
# [2022-05-03 22:30:19.720] [nas] [debug] Sending Registration Complete
# [2022-05-03 22:30:19.720] [nas] [info] Initial Registration is successful
# [2022-05-03 22:30:19.720] [nas] [debug] Sending PDU Session Establishment Request
# [2022-05-03 22:30:19.720] [nas] [debug] UAC access attempt is allowed for identity[0], category[MO_sig]
# [2022-05-03 22:30:20.018] [nas] [debug] PDU Session Establishment Accept received
# [2022-05-03 22:30:20.018] [nas] [info] PDU Session establishment is successful PSI[1]
# [2022-05-03 22:30:20.027] [app] [info] Connection setup for PDU session[1] is successful, TUN interface[uesimtun0, 10.1.0.6] is up.
NOTE: You can simulate more users using
-n
flag. For example, to simulate 10 users, usesudo ./nr-ue -c ../config/free5gc-ue.yaml -n 10
.
To verify the connection between UERANSIM and Free5GC, 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 10.1.0.6 netmask 255.255.255.255 destination 10.1.0.6
# inet6 fe80::9787:f602:2138:d158 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
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.
Enjoy UERANSIM + Free5GC!