5G SA Mobile Networks

My first 5G Core: Open5Gs and UERANSIM

Note: As this space develops so quickly I’ve refreshed the original post from November 2021 in March 2021 with updated instructions.

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.yaml, so we’ll change the ngap addr to bind the AMF to the machine’s IP, for me this is,

  - addr:

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. I’m doing this on an Ubuntu system as we’re using Snaps.

$ sudo apt update 
$ sudo apt upgrade 
$ sudo apt install make g++ libsctp-dev lksctp-tools 
$ iproute2 sudo snap install cmake --classic

With all the prerequisites installed we’ll clone the Git repository and make everything from source;

We’ll clone the Github repository, move into it and make from source.

$ git clone
$ make

Now we wait for everything to compile,

XKCD – Compiling

Once we’ve got the software installed we’ll need to put together the basic settings.

You should see these files in the /build/ directory and they should be executable.

Running the Simulator (UERANSIM)

UERANSIM has two key parts, like any RAN,

The first is the gNodeB, that connects to our AMF and handles subscriber traffic over our (simulated) radio link,

The other is our subscribers themselves – the UEs.

Both are defined and setup through config files in the config/ directory,

Configuring & Starting the gNodeB

While we’re not actually going to bring anything “on air” in the RF sense, we’ll still need to configure and start our gNodeB.

All the parameters for our gNodeB are set in the config/open5gs-gnb.yaml file,

Inside here we’ll need to set the the parameters of our simulated gNodeB, for us this means (unless you’ve changed the PLMN etc) just changing the Link IPs that the gNodeB binds to, and the IP of the AMFs (for me it’s – you’ll need to substitute these IPs with your own of course.

Now we should be able to start the gNodeB service and see the connection, let’s take a look,

We’ll start the gNodeB service from the UERANSIM directory by running the nr-gnb service with the config file we just configured in config/open5gs-gnb.yaml

$ build/nr-gnb -c config/open5gs-gnb.yaml

All going well you’ll see something like:

[2021-03-08 12:33:46.433] [ngap] [info] NG Setup procedure is successful

And if you’re running Wireshark you should see the NG-AP (N2) traffic as well;

If we tail the logs on the Open5GS AMF we should also see the connection too:

Configuring the UE Simulator

So with our gNodeB “On the air” next up we’ll connect a simulated UE to our simulated gNodeB.

We’ll leave the nr-gnb service running and open up a new terminal to start the UE with:

$ build/nr-gnb -c config/open5gs-gnb.yaml

But if you run it now, you’ll just see errors regarding the PLMN search failing,

So why is this? We need to tell our UE the IP of the gNodeB (In reality the UE would scan the bands to find a gNB to serve it, but we’re simulating hre).

So let’s correct this by updating the config file to point to the IP of our gNodeB, and trying again,

So better but not working, we see the RRC was released with error “FIVEG_SERVICES_NOT_ALLOWED”, so why is this?

A quick look at the logs on Open5Gs provides the answer,

Of course, we haven’t configured the subscriber in Open5Gs’s UDM/UDR.

So we’ll browse to the web interface for Open5GS HSS/UDR and add a subscriber,

We’ll enter the IMSI, K key and OP key (make sure you’ve selected OPc and not OP), and save. You may notice the values match the defaults in the Open5GS Web UI, just without the spaces.

Running the UE Simulator

So now we’ve got all this configured we can run the UE simulator again, this time as Sudo, and we should get a very different ouput;

$ build/nr-gnb -c config/open5gs-gnb.yaml

Now when we run it we should see the session come up, and a new NIC is present on the machine, uesimtun0,

We can now run commands like Ping and Curl and by specifying our special uesimtun0 interface, and the traffic will be encapsulated in GTP and pop out the other end.

Supporting UERANSIM

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.

38 replies on “My first 5G Core: Open5Gs and UERANSIM”

Hi Nick,

Thank you for the guide that you have provided. I have installed Open5gs and the simulator in a single Linux box and I managed to start all the services correctly. However, when I try to start the simulator, I got the following message;

WARNING: All global logs are written to: logs/global.log
WARNING: All logs of UEs and gNBs are written to their own log files: logs/*
WARNING: All load testing logs are written to: logs/loadtest.log
INFO: Selected profile: “open5gs”
[2020-11-18 13:09:15.419] [INFO] [CONNECTION] [air] TUN Bridge has been started.
[2020-11-18 13:09:15.523] [INFO] [CONNECTION] [gnb-1] Trying to establish SCTP connection… (
[2020-11-18 13:09:15.539] [INFO] [CONNECTION] [gnb-1] SCTP connection established
Exception in thread “main” tr.havelsan.ueransim.mts.MtsException: no constructor found for given parameter names for type UeConfig
at tr.havelsan.ueransim.mts.MtsConstruct.construct(
at tr.havelsan.ueransim.mts.MtsConstruct.construct(
[2020-11-18 13:09:16.606] [SUCCESS] [PROCEDURE_RESULT] [gnb-1] NGSetup procedure is successful

So I am not getting the prompt for “list of possible test”. May I know if you happened to have such an issue?


Hi Luke,
I haven’t had the issue, UERANSIM is evolving quickly, many commits per day, so maybe best to try the latest version today, or go back to a commit from a few weeks ago and see if you have the same issue.

I’m also binding the AMF IP, I haven’t tried all on the same machine,but may be worth binding the AMF IP to the IP of the machine it’s running on incase there’s some issues with using Loopbacks.

If that doesn’t work just open an issue on the UERANSIM Github issues page,


Hi Nick,
Thanks for your guidances which totally helps me a lot.But after following all your steps from the article,sadly the SCTP connections couldn’t established.I got the following message:

WARNING: All global logs are written to: logs/global.log

WARNING: All logs of UEs and gNBs are written to their own log files: logs/*

WARNING: All load testing logs are written to: logs/loadtest.log

INFO: Selected profile: “open5gs”

[2020-11-19 15:22:47.403] [INFO] [CONNECTION] [air] TUN Bridge has been started.

[2020-11-19 15:22:47.490] [INFO] [CONNECTION] [gnb-1] Trying to establish SCTP connection… (

[2020-11-19 15:28:28.901] [ERROR] [CONNECTION] [gnb-1] SCTP connection could not established:connetion time out.

I built OPEN5Gs and UERANSIM on two different virtual machines.Have you met the same issue?
Thanks a lot.

Hi Nick…good instructive. I deployed UESIM on one machine and 5GC on the other. I changed the ngap_server to my interfaces IP and the log reflects that:

11/19 20:47:45.533: [app] INFO: Configuration: ‘/etc/open5gs/amf.yaml’ (../src/main.c:54)
11/19 20:47:45.533: [app] INFO: File Logging: ‘/var/log/open5gs/amf.log’ (../src/main.c:57)
11/19 20:47:45.535: [app] INFO: AMF initialize…done (../src/amf/app.c:33)
11/19 20:47:45.535: [sbi] INFO: sbi_server() []:7777 (../lib/sbi/server.c:297)
11/19 20:47:45.536: [amf] INFO: ngap_server() []:38412 (../src/amf/ngap-sctp.c:55)

However SCTP keeps failing with an ABORT from UESIM. Any idea what could cause that?
21:17:40.137207 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 68) > chia1848TB.38412: sctp
1) [INIT] [init tag: 1322236571] [rwnd: 106496] [OS: 10] [MIS: 65535] [init TSN: 4088205810]
21:17:40.137288 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 292)
chia1848TB.38412 > sctp
1) [INIT ACK] [init tag: 2281304756] [rwnd: 106496] [OS: 30] [MIS: 10] [init TSN: 3721079048]
21:17:40.137591 IP (tos 0x2,ECT(0), ttl 64, id 0, offset 0, flags [DF], proto SCTP (132), length 36) > chia1848TB.38412: sctp
1) [ABORT]

Hi Carlos,
I’m not sure if UERANSIM uses a user-plane SCTP stack, but if so it could be that the kernel SCTP stack is interfering. To be sure, use the following IPTABLES command to stop this:
iptables -t filter -I OUTPUT -p sctp –chunk-types any ABORT -j DROP

Hi Nick,thanks for your guidance.I have done all the steps in your article,but I can’t establish SCTP connection.There is the response I got: [email protected]:~/UERANSIM# ./
WARNING: All global logs are written to: logs/global.log
WARNING: All logs of UEs and gNBs are written to their own log files: logs/*
WARNING: All load testing logs are written to: logs/loadtest.log
INFO: Selected profile: “open5gs”
[2020-11-20 12:11:18.805] [INFO] [CONNECTION] [air] TUN Bridge has been started.
[2020-11-20 12:11:18.886] [INFO] [CONNECTION] [gnb-1] Trying to establish SCTP connection… (
[2020-11-20 12:16:59.951] [ERROR] [CONNECTION] [gnb-1] SCTP connection could not established: 连接超时. I notice that in your article’s picture there is no Tun Bridge while running UERANSIM and I wonder does the Tun Bridge make the error happen.Any help will be grateful.

For those having issues with connection timeout do a basic check that you have communication between the 2 machines. I had opn5gs and EURANSIM running on different VMs and the issue was down to connectivity between the two. If you are using VMs for this, ensure internal network is set in networks settings (virtualbox).

Worth noting that in the setup described in this blog post, to get the payload to work (the google ping), the gtpu address needs to point to the 5GC VM, e.g. edit /etc/open5gs/upf.yaml:

– addr:

Now the transportLayerAddress in the PDUSessionResourceSetupRequest message from the AMF will be correct. is not present UERANSIM folder. Please let me know where to get this file

Is it actually possible to run both open5GS and UERANSIM in the same host/VM? Or do they need to be in separate VMs?

Hi Prad,
It’s possible to run both, but splitting them across to VMs makes it a bit clearer which Network Function is doing what,

Dear Experts,
I could not find the “” nor “” file in the UERANSIM folder downloaded?
Would you please help?

Thanks Nick.
I got 2 other issues.

1. If I use 2 VMs: 1 for 5GS and 1 for UERANSIM
I could not run the “nr-gnb”: properly.
Error message is: “Trying to establish SCTP connection… (

PS: The IP Address is the IP Add of my 5GS VM which is set in the “amfConfigs” of the “/config/open5gs-gnb.yaml” file

2. If I use both 5GS and UERANSIM in the same VM:
I still got this error Message:
[nas] [error] Initial Registration failed FIVEG_SERVICES_NOT_ALLOWED]

Even though I add the IMSI at the UDR/ HSS already

Could you comment/ advise on those errors?

Thanks alot

Brs// KGH

Hi Khong Gioi Han,
Take a look in your Open5GS logs (/var/log/open5gs/*.log) when you try and register, that will tell you why the FIVEG_SERVICES_NOT_ALLOWED message was seen,

Thanks Nick

Yes, these logfiles helped as they give me the clues on why/ how “5G Service is not allowed”. From that, I fixed the Point Number2.

Hoping I can find the way to fix the Point Number 1 too 🙂


I think I fixed this Point Number 1 too.
Route Cause: the “sd: 1” under “s_nssai” in the “amf.yaml” and under “slices” in “open5gs-gnb.yaml” files.

We can either use or remove this, but make sure that the same setting are done in both “amf.yaml” and “open5gs-gnb.yaml” configure files above. Then it will work

Hope this will help anybody who face this issue

Hi Khong Gioi Han,

I am having exactly the same problem of 2 (PLMN searched failed…) though I have added the IMSI to the UDR. Could you please help me to sort it out?


no matter which slicing config i use (SST 1 or SST1 and SD 1), i always get this error on NSSF:
03/20 01:53:55.570: [nssf] ERROR: Cannot find NSI by S-NSSAI[SST:1 SD:0xffffff] (../src/nssf/nnssf-handler.c:89)
i did not alter any configs, just removed the SD from the UE, so all UE, GNb, AMF and Mongo use only SST 1.
Any hints on what to check or change are much appreciated.

He Daniel,

Iwas having the same problem. But, I commented the SD from both UE (n.b. you have to remove/comment it 3 times from ue file) and gNB and it was successful. Now, I am having the issue of pinging google.

Hello Nick,

Why is the AMF IP different form the gNodeB IP? Are you running on two separate VMs?

Best Regards,

Hi Nick and Team,
I tried the Virtualized versions of Open5gs and UERANSIM as your instruction, and it works
I just also try the Containerized versions of Open5gs EPC/5gc + that of srs-RAN for eNB and UE on the Kubernetes cluster. It’s also OK.
I recorded some results on my Youtube for the latter option so if anyone is interested on the Native cloudification of the Telecom CNF, please join. Its quite fun too.

Thank you!

Hi Nick,
I am testing Open5GS with real gNB and 5G UE. I assume that I need to bind both the IP addresses of ngar (AMF) and gtpu (UPF) to the IP of Open5GS machine that has only one NIC. Is this correct?

Can having separate NIC cards for AMF and UPF increase system throughput? The gNB has separate ports for AMF and UPF.


Vincent Chu

Hi Vincent,
That’s right, same process for physical gNB,
Because the AMF only handles signling you won’t get much additional throughput by putting that on a dedicated NIC, currently Open5Gs doens’t support DPDK or SR-IOV, so you won’t get quite line speed but with a powerful box should be able to crack 1Gbps.

Be curious to know which gNB vendor you’re using, Nokia Airscale and Huawei 5900 has been tested using Open5Gs.

Hi Nick,

Thanks for the awesome instructions! They are really helpful 🙂
When I tried to test my 5g Core, uesimtun0 cannot ping to google and no error messages pop up. I was wondering how you test your network.
Really grateful if you could reply me.


Yes, I meet the same problem as Wendy. I installed the open5gs on a Ubuntu Server PC. Will you show the NAT config on the open5gs PC/VM?

The Nat Network make sure you applied it to each VM in the virtual box settings. (Pretty self explanatory, lots of clips online too for general Nat Network) I thought this was my issues too, but check your IPV4 forwarding settings. This was the main issue why I wasn’t able to ping google from the simulator.

Hi Nick.
my gnb located on VM1 and Open5Gs is on VM2. when i run gnb, sctp connection with AMF established but gtp getting this error:
[error] GTP/UDP task could not be created. Socket bind failed: Address already in use.


Leave a Reply

Your email address will not be published. Required fields are marked *