While 5G SA devices are still in their early stages, and 5G RAN hardware / gNodeBs are hard to come by, so today we’ll cover using UERANSIM to simulate UEs and 5G RAN, to put test calls through our 5GC.
Bringing your 5G Core Online
We’ll use Open5Gs for all the 5GC components, and install on any recent Ubuntu distribution.
Installation is nice and easy;
$ sudo apt update
$ sudo apt install software-properties-common
$ sudo add-apt-repository ppa:open5gs/latest
$ sudo apt update
$ sudo apt install open5gs
The first point of contact we’ll need to talk about is the AMF,
The AMF – the Access and Mobility Function is reached by the gNodeB over the N2 interface. The AMF handles our 5G NAS messaging, which is the messaging used by the UEs / Devices to request data services, manage handovers between gNodeBs when moving around the network, and authenticate to the network.
By default the AMF binds to a loopback IP, which is fine if everything is running on the same box, but becomes an issue for real gNodeBs or if we’re running UERANSIM on a different machine. This means we’ll need to configure our AMF to bind to the IP of the machine it’s running on, by configuring the AMF in /etc/open5gs/amf.conf, so we’ll change the ngap addr to bind the AMF to the machine’s IP, for me this is 10.0.1.99,
ngap: - addr: 10.0.1.99
In the amf.conf there’s a number of things we can change and configure; such as the PLMN and network name, the NRF parameters, however for now we’ll keep it simple and leave everything else as default.
To allow the changes to take effect, we’ll restart the Open5GS AMF service to make our changes take effect;
$ sudo systemcl restart open5gs-amfd
Setting up the Simulator
We’re using UERANSIM as our UE & RAN Simulator, so we’ll need to get it installed, you may need to adjust the Java path if you’re using a different version of Java or have it installed in a different directory.
sudo apt update$
sudo apt upgrade$
sudo apt install make g++ openjdk-11-jdk maven libsctp-dev lksctp-tools$ git clone https://github.com/aligungr/UERANSIM.git $ cd UERANSIM $ export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64/ $
Once we’ve got the software installed we’ll need to put together the basic settings. For now UERANSIM doesn’t implement the Network Repository Function (My current favorite function of 5GC), so we’ll need to manually define the AMF address, and populated the PLMN, tracking, areas, etc.
Configuring the Simulator
This is configured in the UERANSIM folder under config/ folder,
Quick note here – UERANSIM allows us to have different profiles with different settings, for testing different networks. Luckily for us, there’s a premade profile with settings that match what Open5GS has out of the box. To use it we’ll edit the profile.yaml file in the config/ folder, and ensure that the selected profile is open5gs:
Once that’s done we’ll open the folder in config called Open5Gs where we’ll enter our details,
We’ll start with the gnb.yaml file, where we set the parameters of our simulated gNodeb, we need to set the host to be the IP of our AMF, in my case it’s 10.0.1.99
You’ll also need to set the IP of the host machine (the machine running EURANSIM) so it can set the correct source address and listen on the right IP, my laptop’s IP is 10.0.1.252 so I’ve put that into the config
host: 10.0.1.252 gtpPort: 2152 ... amfConfigs: - guami: mcc: 901 mnc: 70 amfRegionId: hex: '2a' amfSetId: hex: '5580' amfPointer: hex: 'a8' host: 10.0.1.99 port: 38412
If you’d changed the PLMN (MCC/MNC) or the TAC setup in the AMF config on Open5GS you’d have to update the gnb.conf to reflect the changes.
Configuring a Subscriber to Simulate
Next we’ll need to configure our Subscribers, by default the ue.yaml file contains a subscriber identity, authentication keys and DNN (Like an APN) to use,
snn: '5G:mnc070.mcc901.3gppnetwork.org' key: '465B5CE8B199B49FAA5F0A2EE238A6BC' op: 'E8ED289DEBA952E4283B54E88E6183CA' amf: '8000' imei: '356938035643803' supi: 'imsi-901700000000003' smsOverNasSupported: true dnn: 'internet' requestedNssai: - sst: value: 1 sd: hex: '010203'
We’ll leave this as it is, but we’ll need to add that subscrber to the Open5GS UDM/UDR/HSS,
For this we’ll open the Open5GS WebUI, and add a subscriber,
We’ll enter the IMSI, K key and OP key (make sure you’ve selected OP and not OPc), and save. If you’re observant you may notice the values match the defaults in the Open5GS Web UI, just without the spaces.
Now for the fun part – Running it all!
UERANSIM is written in Java (That’s why we installed it earlier) and relies on the JAVA_HOME variable being set containing your Java home directory.
We’ll move back into the UERANSIM folder and run:
$ sh run.sh
From here if all goes well you’ll see UERANSIM register to the AMF as a gNodeB (using the N2 interface),
You’ll get some indication in the Open5Gs logs that a new gNodeB has connected as well:
==> /var/log/open5gs/amf.log <== 11/12 20:31:20.851: [amf] INFO: gNB-S1 accepted[10.0.1.252]:51410 in ng-path module (../src/amf/ngap-sctp.c:107) 11/12 20:31:20.851: [amf] INFO: gNB-N1 accepted[10.0.1.252] in master_sm module (../src/amf/amf-sm.c:555) 11/12 20:31:20.851: [amf] INFO: [Added] Number of gNBs is now 1 (../src/amf/context.c:866)
So next up let’s register a UE (this will use the N1 interface between the simulated UE and the AMF),
We’ll see the successful authentication, and presto, we’re registered on the 5GC,
At this point (November 2020) UERANSIM can create bearers, and is very close to being able to direct traffic down them, for now UERANSIM sets up the bearer, does a DNS request to google.com and tries to ping it. More advanced functionality is in the works though, so keep an eye on the UERANSIM GitHub page and contribute code if you can, and consider supporting them on Patreon if you can’t, they’re doing great work.
I’ll do a follow up from this post when the functionality is supported, and on the protocols you’ll want to trace in Wireshark for 5G, but kick back safe in the knowledge you’ve got a 5G core operational before anyone else!