Building a Personal Open-Source 5G Network

First, I wanted to let everyone know that I have uploaded by Open5GS and srsRAN_Project configs to Github. These are configured for my network, if you want to use this yourself then change any IP address of 100.122.126.173 to the computer your 5GC is running on, or if you are running both srsRAN and Open5GS on the same computer, then you can change that IP to its default of 127.0.0.5 – also your gNB config file will need to be modified as follows… 

amf:

  addr: 100.122.126.173  (change to 127.0.0.5 or 5GC computer IP)                                             

  bind_addr: 100.122.128.121  (change to any 127.0.0.X not being used or gNB computer IP) 


I have been working with and characterizing 5G networks since they first deployed in the United States in 2018. For the last 5 years, I have watched different carriers slowly deploy 5G technologies. First with Verizon’s FR2 mmWave NSA networks, then AT&T and T-Mobile FR1 NSA Networks, and more recently with T-Mobile deploying nationwide Standalone 5G on multiple bands, and now Dish following close behind. Still unsure of when Verizon and AT&T are planning to launch their Standalone services to the masses… 

5G has been a technology that has transformed how I look at technology in many ways. First learning the technology from the ground up… Figuring out the 3GPP specs, reading Layer 3 messages, analyzing handset Diagnostic data, memorizing the processes, interfaces, radio parameters, network functions, and more. I started using Test Networks at work and learning Linux and became fascinated with how much you could do with minimal equipment. 

Fast forward to today… I stumbled upon a couple of open-source software packages that could enable me to customize (to an extent) my own 5G network. At this point, I have deployed 5G networks on a single laptop, virtual machines, virtual machines connected to physical servers, and multiple laptops. All that I can control from anywhere that I bring my laptop. I have installed it on Ubuntu, Debian, and Arch Linux.

For my initial blog post, I am going to walk you through my latest 5G network configuration and hopefully help guide anyone (with the right tools) through the process. 


All requirements listed are for my specific 5G network configuration. 

VPN

  • NordVPN with MeshNet on each computer 
  • Allows remote connection to srsRAN gNB and Open5gs 5GC 

Computer 1 (Macbook Pro M1 14″ 2021) *Internet access for SSH

  • Purpose: Remote SSH connection to the gNB and 5GC computers, scp logs to this computer for analysis
  • OS: macOS Monterey 12.6.2
  • RAM: 16GB
  • Software: iTerm2, NordVPN with MeshNet, Wireshark, Sublime Text

Computer 2 (Dell Inspiron 14 7430) *Internet access for SSH

  • Purpose: srsRAN_Project gNB
  • OS: Debian 12
  • RAM: 16GB
  • Software: UHD (for USRP), srsRAN_Project, NordVPN with MeshNet

Computer 3 (Beelink SEi12 Mini PC) *Internet access for SSH and UE data services

  • Purpose: Open5gs 5G Core
  • OS: Debian 11
  • RAM: 16GB
  • Software: Open5gs, tcpdump, MongoDB, NordVPN with MeshNet

Software Defined Radio (Ettus Research USRP B210)

User Equipment (UE) 

Test SIM Cards

  • Known IMSI
  • Known k and OPc values

I followed the installation process outline from each developer’s instructions. There are several dependencies you may need to install based on whether you are installing from source or using a package manager. The installation process also varies depending on what Linux distribution you are using and your computer or virtual machine architecture. 

UHD:  https://files.ettus.com/manual/page_install.html 

UHD (from source)https://files.ettus.com/manual/page_build_guide.html

srsRANhttps://docs.srsran.com/projects/project/en/latest/user_manuals/source/installation.html#manual-installation

Open5GShttps://open5gs.org/open5gs/docs/guide/01-quickstart/

Open5GS (from source)https://open5gs.org/open5gs/docs/guide/02-building-open5gs-from-sources/

Some notes to consider…

  • Currently only UHD is supported as an RF Driver for srsRAN_Project
  • Install the RF drivers (UHD) before you install srsRAN_Project
  • I installed UHD and srsRAN_Project on one laptop and Open5GS on another
  • Open5GS requires MongoDB to run the WebUI – the WebUI is accessed from your web browser and is used to input subscriber information

My 5G Network
My 5G Network

Example configration
Example configration

VPN 

Using NordVPN and configuring each computer that you would like to control with the MeshNet capability. 

If using separate computers for the gNB and 5GC, then you will need to enable “traffic routing through your device/traffic routing through the linked device” 

https://meshnet.nordvpn.com/features/routing-traffic-in-meshnet/traffic-routing-linux

SSH 

systemctl sshd command output
systemctl sshd command output

Login to your 5GC and gNB computers 

At this point, you should have installed the required software… Open5gs, srsRAN_Project, UHD RF Drivers, etc. 

User Equipment (UE)

Now you should set up your handset to work with the 5G network when it is turned on. The process to do this can vary by handset, model, and operating system. At a minimum that handset requires 

  • 5G Standalone capable 
  • Network Unlocked (or else the phone will not accept the test SIM) 
  • Test SIM with known IMSI and K/OPc values
  • You should note what bands the handset is capable of so you can configure your gNB appropriately
  • You may need to RAT lock your handset to 5G only (Some Android phones have engineering mode – enter *#*#4636#*#* in the dialer and then select “phone information” and select “NR Only” from the “Set Preferred Network Type” drop-down menu) or download the Force LTE or 5G Network Manager apps from the Play Store.
  • Data Services and Data Roaming are turned ON
  • VoLTE is turned OFF 
  • APN needs to be set up in Settings > Network & Internet > Mobile Network > Access Point Names – Name and APN = apn (or whatever is defined in your user database in the WebUI), APN Protocol/APN Roaming Protocol = IPv4, then save the configured APN. 
RAT Locking to NR Only, Data Service & VoLTE settings, APN Configuration
RAT Locking to NR Only, Data Service & VoLTE settings, APN Configuration
  • Some handsets require 5G Standalone to be enabled
  • Once your network is running, you may need to manually select the network from the a list of visible networks. Usually in Settings > Network & Internet > Mobile Network > Choose Network 
Manually selecting Open5GS network
Manually selecting Open5GS network

There are a few things that I configure to make starting and stopping the 5GC more optimal. When Open5GS is installed, it also includes LTE core network components. I made two bash scripts that start only the Network Functions I need for 5G Standalone as well as one that will stop the 5G Network Functions. Once the script is written, I make it executable and add it to my /usr/bin/ directory. Now, I can use 5gc to start the 5GC and stop_5gc  to stop the 5GC. 

5gc and stop_5gc scripts
5gc and stop_5gc scripts

Don’t mind the ip addr add and ip link set commands in the 5gc script right now. We will get to that shortly… 

Now is the time to start your 5GC, followed by the gNB. It may seem simple, but there will be some more configuration necessary when running your network for the first time (unless you use the default configurations and are running the 5GC and gNB on the same computer). 

My 5G Network flowchart
My 5G Network flowchart

Verify that Open5GS is running using the command ps aux | grep open5gs 

ps aux | grep open5gs output when 5GC is running
ps aux | grep open5gs output when 5GC is running


Open5gs stores log files in the /var/log/open5gs directory. When the 5GC is running, you can view the logs of a specific Network Function in real time… For example, if I would like to see the AMF logs, I would use the command sudo tail -f /var/log/open5gs/amf.log 

amf.log
amf.log

In the AMF log example above you can see a lot of information. 

  1. The gNB connects to the AMF 
  2. UE attempts to Register with the Network receiving its S_TMSI, followed by a REGISTRATION REQUEST from the UE
  3. 5GC requests the UE identity (SUCI)
  4.  UE Registers with the Network after receiving the REGISTRATION ACCEPT message 
  5. UE is assigned an APN 
smf.log
smf.log

The SMF log shows little information but is important to see the UE establishing a PDU Session with APN and IP Address as well as a GTP-U connection with the UPF. 

upf.log
upf.log

The UPF log shows information about establishing the UE’s User Plane data session. 

It is also useful to collect pcaps from the 5GC. Use the commands sudo tcpdump -i any -w 5gc.pcap to capture traffic on all interfaces or sudo tcpdump -i any sctp -w 5gc.pcap if you would like to capture only SCTP traffic. 

5gc SCTP pcap
5gc SCTP pcap

The SCTP pcap will also capture NGAP and NAS-5GS data. 

gNB logs are stored in the /tmp directory and are replaced each time the gNB is run. The logging configuration is set within the specific gnb.yml file and includes the logging level for the gnb.log and if you would like to collect pcaps on specific protocols that pass through the gNB. 

gnb.yml logging configuration
gnb.yml logging configuration

A full list of currently available gnb.yml configuration parameters is listed here 

List of available log and pcap configurations
List of available log and pcap configurations

At this point, you should be able to have your UE connect to your network and receive an end-to-end data session. Open5GS and srsRAN_Project are continually developing new features so expect more advanced guides on future development such as VoNR support with Open Source IMS server, Other System Information (OSI), and using srsUE as a UE emulator to connect to 5G services (currently available, but limited in band support to n3). 

Email nuradio@nuradioconcepts.io for requests on future blog subjects 

Currently in line for future blog topics 

  • UE architecture (commercial and software defines) 
  • Open Source 5G applications for network testing (NSG, Scat, NetMonster, etc)
  • 5G Network Test Tools (Open Source and Commercial)
  • Commercial 5G Network analysis 
  • Using adb with Android phones
  • Using bladeRF and USRP 
  • 5G Radio and Air Interface deep dive
  • 5G Core deep dive
  • 5G Identifiers 
  • 5G Network pcap analysis 
  • Using DragonOS for cellular/telecom requirements 
  • Linux essentials for network configuration, operations, and analysis 

Leave a Reply

Discover more from

Subscribe now to keep reading and get access to the full archive.

Continue reading