srsRAN experiments with SDR
- Setting up Debian networking for srsRAN depends on which component you're running (srsRAN Project for 5G, or srsRAN 4G)
- The core networking requirements are similar. Here's a comprehensive guide:
sudo apt update
sudo apt install iproute2 net-tools iptables tun-tools bridge-utilssrsRAN uses a TUN interface (srs_spgw_sgi or ogstun) to route UE traffic:
# Create TUN interface (usually done automatically by srsEPC or Open5GS)
sudo ip tuntap add name srs_spgw_sgi mode tun
sudo ip addr add 45.45.0.1/24 dev srs_spgw_sgi
sudo ip link set srs_spgw_sgi up# Temporary
sudo sysctl -w net.ipv4.ip_forward=1
# Permanent — add to /etc/sysctl.conf or /etc/sysctl.d/99-srsran.conf:
net.ipv4.ip_forward = 1
sudo sysctl -pSo UEs can reach the internet through your host:
# Replace eth0 with your actual uplink interface
sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i srs_spgw_sgi -j ACCEPT
sudo iptables -A FORWARD -o srs_spgw_sgi -j ACCEPTTo make iptables rules persist across reboots:
sudo apt install iptables-persistent
sudo netfilter-persistent saveCommunication happens over loopback by default — no special config needed. Just confirm:
# epc.conf
[spgw]
gtpu_bind_addr = 127.0.0.1
# enb.conf
[epc]
mme_addr = 127.0.0.1# gnb.yml — AMF N2 interface
amf:
addr: 127.0.0.5 # AMF address
bind_addr: 127.0.0.1 # gNB local address
# N3 (user plane GTP-U)
gtpu:
bind_addr: 127.0.0.1If running on separate machines, replace loopback addresses with actual interface IPs and ensure the firewall allows:
- N2: SCTP port 38412
- N3: UDP port 2152 (GTP-U)
- S1-MME: SCTP port 36412
# Open SCTP/UDP ports if using ufw
sudo ufw allow 38412/sctp
sudo ufw allow 2152/udpsrsRAN is latency-sensitive — network stack tuning helps:
# Increase socket buffer sizes in /etc/sysctl.d/99-srsran.conf
net.core.rmem_max = 25165824
net.core.wmem_max = 25165824
net.core.rmem_default = 25165824
net.core.wmem_default = 25165824
sudo sysctl -p /etc/sysctl.d/99-srsran.confAlso disable offloading on your uplink NIC to reduce latency variance:
sudo ethtool -K eth0 gso off gro off tso off# Check TUN is up
ip link show srs_spgw_sgi
# Watch GTP-U tunnel traffic
sudo tcpdump -i srs_spgw_sgi
# Verify forwarding rules
sudo iptables -t nat -L -v -n
sudo iptables -L FORWARD -v -n
# Check SCTP support (needed for N2/S1)
modprobe sctp
lsmod | grep sctp| Problem | Fix |
|---|---|
| UE gets IP but no internet | Check NAT masquerade rule and IP forwarding |
| gNB can't reach AMF | Check SCTP is loaded (modprobe sctp) |
| High latency / packet loss | Tune socket buffers; disable NIC offloading |
| TUN device missing | Run srsEPC/Open5GS as root or with CAP_NET_ADMIN |