ByteGuideHub
Telecom/Networking • • 11 min read

Building a Private 5G Network with OpenAirInterface and SDRs: A Step-by-Step Guide

Learn how to build a private 5G standalone network using OpenAirInterface and software-defined radios. Step-by-step guide covering hardware, software, configuration, and testing.

Sponsored / Ad Space

Building a Private 5G Network with OpenAirInterface and SDRs: A Step-by-Step Guide

Quick Summary (TL;DR) This guide walks you through building a private 5G standalone (SA) network using OpenAirInterface (OAI) and software-defined radios (SDRs). You’ll learn the architecture, hardware requirements, and step-by-step configuration for the 5G core (5GC), the radio access network (gNB), and user equipment (UE). We cover testing, troubleshooting, and a comparison with commercial solutions. By the end, you’ll have a functional private 5G network ideal for research, prototyping, and specialized enterprise use cases. Time to complete: 2–3 days (including hardware setup and debugging).


Introduction to Private 5G Networks

Private 5G networks are dedicated cellular networks that provide enhanced security, low latency, and reliable connectivity for enterprises, industrial IoT, and research. Unlike public networks, they offer full control over the infrastructure and data. This guide focuses on building a private 5G standalone (SA) network using OpenAirInterface (OAI), an open-source software implementation of 3GPP standards, and software-defined radios (SDRs) for the radio front-end.

The appeal of OAI lies in its flexibility: you can modify the protocol stack, experiment with new features, and deploy on commodity hardware. This makes it an ideal platform for research labs, universities, and enterprises that need a customizable 5G testbed without the prohibitive costs of commercial equipment.

Understanding the Architecture

A 5G SA network consists of two main components: the core network (5GC) and the radio access network (RAN). The 5GC handles authentication, mobility, and session management, while the RAN provides the radio interface. In our setup, OAI provides both the 5GC and the gNB (base station) software, running on general-purpose servers. The SDRs (e.g., USRP) act as the radio front-end, transmitting and receiving 5G NR signals.

graph LR
    A[UE: Smartphone or SDR] -->|5G NR Radio Link| B[gNB: OAI + USRP]
    B -->|NG-C/N3 Interface| C[5G Core Network: OAI]
    C --> D[AMF: Access & Mobility]
    C --> E[SMF: Session Management]
    C --> F[UPF: User Plane]
    C --> G[NRF: Network Repository]
    D --> H[Data Network: Internet/Intranet]

The gNB connects to the 5GC via the NG interface (split into NG-C for control plane and NG-U for user plane). The UE communicates with the gNB over the 5G NR air interface, using the SDR as the physical layer transceiver.

Prerequisites and Hardware Requirements

To build a private 5G network, you need:

  • Two servers (or powerful PCs) with Ubuntu 20.04/22.04 LTS, one for the 5GC and one for the gNB. Recommended specs: Intel i7 or Xeon, 16 GB RAM, 256 GB SSD.
  • SDR hardware: USRP B210 or X310 (with appropriate daughterboards) for the gNB, and a second SDR for the UE if not using a commercial phone.
  • A 5G-capable UE (smartphone or a second SDR with OAI UE software).
  • RF cables, antennas, and possibly a GPSDO for synchronization.
  • Network interfaces: Ethernet connections between servers and SDRs (USB 3.0 for B210, 10GbE for X310).
  • Software: OAI 5G core (oai-cn5g) and OAI gNB (oai-gnb) from the OpenAirInterface GitHub repository.

Hardware Sizing Tip: For the gNB server, use a CPU with high single-thread performance (e.g., Intel Core i7-12700K) and ensure your USRP has sufficient bandwidth for the desired channel width (e.g., 20 MHz on B210, up to 100 MHz on X310).

Step 1: Setting Up the Core Network (5GC)

  1. Install Docker and Docker Compose on the core server:

    sudo apt update && sudo apt install docker.io docker-compose
    sudo systemctl enable --now docker
    
  2. Clone the OAI 5G core repository:

    git clone https://github.com/OPENAIRINTERFACE/openairinterface5g.git
    # For the dedicated core repo, use:
    git clone https://github.com/OPENAIRINTERFACE/oai-cn5g.git
    cd oai-cn5g
    
  3. Build the core network components using the provided Docker images:

    docker-compose build
    

    This will create images for the AMF, SMF, UPF, NRF, and other network functions.

  4. Configure the core network by editing the docker-compose.yml and configuration files (e.g., amf.conf, smf.conf). Key parameters to set:

    • PLMN (MCC/MNC): e.g., MCC=001, MNC=01 (test network)
    • Network slices: Define SST/SD values (e.g., SST=1 for eMBB)
    • IP ranges: Set the UE subnet (e.g., 192.168.70.0/24) and data network (e.g., 192.168.70.135)

    Example snippet from amf.conf:

    amf:
      plmn:
        mcc: "001"
        mnc: "01"
      network_slices:
        - sst: 1
          sd: "000001"
    
  5. Start the core network:

    docker-compose up -d
    
  6. Verify that all core components are running:

    docker ps
    

    You should see containers for oai-amf, oai-smf, oai-upf, oai-nrf, and others.

Step 2: Setting Up the Radio Access Network (gNB)

  1. On the gNB server, install the OAI software:

    git clone https://github.com/OPENAIRINTERFACE/openairinterface5g.git
    cd openairinterface5g
    # Build the gNB executable (this may take 30-60 minutes)
    ./build_oai --gNB --build-lib "phy"
    
  2. Install the UHD driver for your USRP:

    sudo apt install uhd-host
    # Download and install FPGA images
    uhd_images_downloader
    
  3. Configure the gNB by editing the configuration file. A typical file is gnb.sa.band78.fr1.106PRB.usrpb210.conf. Key parameters:

    • PLMN: Must match the core network (MCC/MNC)
    • Tracking area code (TAC): e.g., 1
    • Frequency band: e.g., n78 (3.5 GHz)
    • Bandwidth: e.g., 20 MHz (106 PRBs)
    • SDR settings: Device arguments, gain, and sample rate

    Example snippet:

    gNBs:
      - gNB_ID: 1
        cell_id: 0
        plmn:
          mcc: "001"
          mnc: "01"
        tracking_area_code: 1
        rf:
          band: 78
          bandwidth: 20
          dl_freq: 3500000000
          ul_freq: 3500000000
    
  4. Connect the USRP to the server via USB 3.0 (for B210) or 10GbE (for X310). Verify detection:

    uhd_find_devices
    
  5. Start the gNB:

    sudo ./nr-softmodem -O gnb.conf --gNBs.[0].min_rxtxtime 6
    

    Adjust options as needed (e.g., --usrp-tx-threads 4 for better performance).

  6. Monitor the logs to ensure the gNB starts successfully and connects to the core network. Look for messages like:

    [gNB] Initializing...
    [gNB] Sending NG Setup Request to AMF...
    [gNB] NG Setup Response received
    

Step 3: Configuring the User Equipment (UE)

For testing, you can use a commercial 5G phone with a SIM card that matches your PLMN. Alternatively, use a second SDR with OAI UE software.

  • For commercial phone: Insert a SIM card programmed with your PLMN (MCC/MNC) and authentication keys. Use a SIM card programmer (e.g., sysmocom SIMtrace) to write the IMSI and Ki. Ensure the phone supports the frequency band (e.g., n78) and is unlocked.

  • For OAI UE: Build the UE software on a third server with an SDR:

    cd openairinterface5g
    ./build_oai --UE --build-lib "phy"
    

    Configure the UE with the same PLMN and network credentials. Start the UE:

    sudo ./nr-uesoftmodem -O ue.conf --rrc-rnti 0x1234
    
  • Ensure the UE is in the coverage area of the gNB and attempt to attach to the network. For commercial phones, you may need to enter the APN (e.g., oai.ipv4) and set the network mode to “5G only” in the phone settings.

Pro Tip: When using a commercial smartphone, check the “About Phone” section to confirm it’s registered on your private network (look for the MCC/MNC you configured). Some phones require disabling “Auto network selection” and manually choosing the network.

Step 4: Testing and Verifying the Network

  1. Check the core network logs to see the UE registration and session establishment:

    docker logs oai-amf | tail -50
    docker logs oai-smf | tail -50
    

    Look for “UE registration accepted” and “PDU session establishment success” messages.

  2. Use ping from the UE to the core network’s data network (e.g., 192.168.70.135) to test connectivity:

    ping 192.168.70.135
    
  3. Use iperf to measure throughput and latency:

    # On the data network server
    iperf3 -s
    # On the UE
    iperf3 -c 192.168.70.135 -t 30
    

    Expect 20-80 Mbps uplink/downlink depending on bandwidth and SDR hardware.

  4. Verify handover and mobility if you have multiple gNBs. Configure Xn interfaces between gNBs and test inter-gNB handover.

  5. Use Wireshark to capture and analyze 5G NR signaling messages. Install Wireshark on the core server and capture on the NG-C interface to inspect NAS and NGAP messages.

Troubleshooting Common Issues

  • SDR not detected: Ensure UHD drivers are installed and the USRP is recognized (uhd_find_devices). Check USB connections and try a different port.
  • gNB fails to start: Check configuration file for correct band, bandwidth, and SDR settings. Ensure the USRP is not in use by another process (uhd_find_devices will show if busy). Review the logs for RF errors.
  • UE cannot attach: Verify PLMN and authentication parameters. Check that the core network is reachable from the gNB (ping the AMF IP). Ensure the SIM card is properly programmed.
  • Low throughput: Adjust bandwidth, antenna placement, and check for interference. Try increasing the TDD pattern ratio for more downlink slots. Verify the SDR’s gain settings.
  • Synchronization issues: Use a GPSDO or external clock for better timing. For B210, ensure the clock reference is set correctly in the configuration.

Comparison: OpenAirInterface vs. Commercial Solutions

FeatureOpenAirInterfaceCommercial (e.g., Nokia, Ericsson)
CostLow (open-source)High (licensing and hardware)
CustomizationHigh (full control)Limited (vendor-specific)
SupportCommunity-basedProfessional support
PerformanceModerate (depends on hardware)High (optimized)
DeploymentRequires technical expertiseTurnkey solutions
Use CasesResearch, prototyping, niche deploymentsEnterprise, industrial, public networks

When to choose OAI: If you need a flexible, low-cost testbed for research or training, or if you require deep protocol-level customization. When to choose commercial: For production deployments where reliability, performance, and support are critical.


Conclusion

Building a private 5G network with OpenAirInterface and SDRs is a complex but rewarding project that offers deep insights into 5G technology. It is ideal for research, education, and specialized enterprise applications where cost and customization are priorities. With the right hardware and careful configuration, you can have a functional private 5G network. As the ecosystem matures, open-source solutions are becoming more viable for production use.

Remember to start with a simple setup (single gNB, one UE) and gradually add features like multiple cells, network slicing, and advanced mobility. The OAI community and mailing lists are excellent resources if you encounter issues. Happy building!


FAQ

Q: What is OpenAirInterface? A: OpenAirInterface (OAI) is an open-source software project that provides a complete implementation of 3GPP standards for 4G and 5G networks, including the core network (EPC/5GC) and the radio access network (eNodeB/gNB). It allows researchers and enterprises to build and experiment with cellular networks using general-purpose hardware and SDRs.

Q: What SDR hardware is recommended for a private 5G network? A: Common choices are Ettus Research USRP B210 (for lower frequency bands and lower bandwidth) and USRP X310 (for higher performance and wider bandwidth). Other SDRs like the NI USRP-2944R or Analog Devices ADRV9002-based boards can also be used. The choice depends on the desired frequency band, bandwidth, and performance.

Q: Can I use a commercial smartphone as a UE in this setup? A: Yes, you can use a commercial 5G smartphone if it supports the frequency band and bandwidth used by your gNB. You will need a SIM card programmed with the correct PLMN (MCC/MNC) and authentication keys (Ki/OPc) that match your core network configuration. Some phones may require specific firmware or settings to work with private networks.

Q: What are the main challenges in building a private 5G network with OAI? A: Key challenges include: hardware synchronization (using GPSDO or external clocks), RF interference and antenna placement, complex configuration of the core network and gNB, and the need for deep technical knowledge in telecom and networking. Additionally, performance may be limited by the SDR hardware and general-purpose processors.

Q: Is OpenAirInterface suitable for production use? A: While OAI is primarily used for research and prototyping, it is increasingly being used in pilot deployments and niche production environments. However, it requires significant expertise to deploy and maintain, and may not offer the same level of performance, reliability, and support as commercial solutions. For mission-critical applications, commercial solutions are often preferred.

Sponsored / Ad Space