Xn Handover with Namespace
Note
Namespace provides an alternative to using a physical machine.
With namespaces, you can simulate isolated network environments on a single machine, making it possible to run both free5GC and free-ran-ue without the need for multiple physical devices.
For detailed namespace implementation, please refer to this implementation article: Namespace-Based GTP5G Conflict Resolution for free5GC and PacketRusher.
Architecture Overview
Since the GTP port and the routing table will get in conflict, we can set up four namespaces for free5GC/RAN1/RAN2/UE, which means you don't need to bring up real machines.
The topology is the same as the Dynamic NR-DC with Namespace, with RAN1 in the place of Master RAN and RAN2 in the place of Secondary RAN:

A. Prerequisites
-
Golang / Node.js / Yarn
Bashwget https://dl.google.com/go/go1.26.2.linux-amd64.tar.gz sudo tar -C /usr/local -zxvf go1.26.2.linux-amd64.tar.gz mkdir -p ~/go/{bin,pkg,src} # The following assume that your shell is bash: echo 'export GOPATH=$HOME/go' >> ~/.bashrc echo 'export GOROOT=/usr/local/go' >> ~/.bashrc echo 'export PATH=$PATH:$GOPATH/bin:$GOROOT/bin' >> ~/.bashrc echo 'export GO111MODULE=auto' >> ~/.bashrc source ~/.bashrc curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - sudo apt update sudo apt install -y nodejs sudo corepack enable -
gtp5g
-
MongoDB
Bashsudo apt install -y gnupg curl curl -fsSL https://www.mongodb.org/static/pgp/server-7.0.asc | \ sudo gpg -o /usr/share/keyrings/mongodb-server-7.0.gpg --dearmor echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-7.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/7.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-7.0.list sudo apt update sudo apt install -y mongodb-org sudo systemctl enable mongod --now
B. Namespace Setup
-
Clone and build free-ran-ue
-
Bring up namespaces (under
free-ran-ue)After using, there is
downcommand to clean up the namespaces:
C. Configure free5GC
-
Clone free5GC and build
-
Modify NF configuration:
-
~/free5gc/config/amfcfg.yaml
Replace
ngapIpListIP from127.0.0.18to10.0.1.1: -
~/free5gc/config/smfcfg.yaml
Replace N3 interface's endpoints IP from
127.0.0.8to your10.0.1.1: -
~/free5gc/config/upfcfg.yaml
Replace N6 interface address IP from
127.0.0.8to10.0.1.1:
-
-
Check IP Forward is enabled
If you have rebooted your machine, remember to run these command with setting your export network interface:
-
Run free5GC (under
free5gc) -
Run webconsole and create a subscriber by default (under
free5gc)For creating a subscriber, please refer to: Create Subscriber via Webconsole
D. Start gNBs
The configuration files config/gnb-ho-1.yaml and config/gnb-ho-2.yaml have already been set up with the environment values. No need to modify the configuration.
No xnDialIp / xnDialPort is configured. The target gNB is selected in the console, and the console passes its Xn address (xnListenIp / xnListenPort) to the source gNB.
-
gNB-ho-1
-
Enter the RAN1 namespace (under
free-ran-ue) -
Start gNB-ho-1
-
-
gNB-ho-2
-
Enter the RAN2 namespace (under
free-ran-ue) -
Start gNB-ho-2
-
E. Start UE
The configuration file config/ue-ho.yaml has already been set up with the environment values. No need to modify the configuration.
-
Enter the UE-namespace (under
free-ran-ue) -
Start UE
F. Start Console
- Run in the host namespace
-
Start Console
-
Add gNB
-
Sign in the console:
- username:
admin - password:
free-ran-ue

- username:
-
Add gNB-ho-1 and gNB-ho-2:
-
gNB-ho-1
- IP Address:
10.0.1.2 - Port:
40104
- IP Address:
-
gNB-ho-2
- IP Address:
10.0.1.3 - Port:
40104
- IP Address:

-
-
Check add success:

-
G. ICMP Test
-
Enter the UE-namespace (under
free-ran-ue) -
Check the
ueTun0interfaceExpected output included:
BashueTun0: flags=4305<UP,POINTOPOINT,RUNNING,NOARP,MULTICAST> mtu 1500 inet 10.60.0.1 netmask 255.255.255.255 destination 10.60.0.1 inet6 fe80::b1e9:2933:3c64:b981 prefixlen 64 scopeid 0x20<link> unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 500 (UNSPEC) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 3 bytes 144 (144.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 -
Before handover:
ICMP test with
ueTun0via gNB-ho-1:Expected successful output:
BashPING 1.1.1.1 (1.1.1.1) from 10.60.0.2 ueTun0: 56(84) bytes of data. 64 bytes from 1.1.1.1: icmp_seq=1 ttl=49 time=4.51 ms 64 bytes from 1.1.1.1: icmp_seq=2 ttl=49 time=4.46 ms 64 bytes from 1.1.1.1: icmp_seq=3 ttl=49 time=4.27 ms 64 bytes from 1.1.1.1: icmp_seq=4 ttl=49 time=3.97 ms 64 bytes from 1.1.1.1: icmp_seq=5 ttl=49 time=4.64 ms --- 1.1.1.1 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4007ms rtt min/avg/max/mdev = 3.972/4.371/4.644/0.232 ms -
Use console to hand over the UE from gNB-ho-1 to gNB-ho-2:
-
Enter gNB-ho-1's information page (click
Openon its card in the gNB page), the UE is listed in the RAN UEs list:
-
Click the
Handoverbutton of the UE, select gNB-ho-2 as the target gNB and clickHandover:
-
-
After handover:
ICMP test with
ueTun0via gNB-ho-2:Expected successful output:
BashPING 1.1.1.1 (1.1.1.1) from 10.60.0.2 ueTun0: 56(84) bytes of data. 64 bytes from 1.1.1.1: icmp_seq=1 ttl=49 time=4.51 ms 64 bytes from 1.1.1.1: icmp_seq=2 ttl=49 time=4.46 ms 64 bytes from 1.1.1.1: icmp_seq=3 ttl=49 time=4.27 ms 64 bytes from 1.1.1.1: icmp_seq=4 ttl=49 time=3.97 ms 64 bytes from 1.1.1.1: icmp_seq=5 ttl=49 time=4.64 ms --- 1.1.1.1 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4007ms rtt min/avg/max/mdev = 3.972/4.371/4.644/0.232 ms -
Use console to hand over the UE back from gNB-ho-2 to gNB-ho-1:
- Enter gNB-ho-2's information page, the UE is listed in the RAN UEs list.
- Click the
Handoverbutton of the UE, select gNB-ho-1 as the target gNB and clickHandover.
-
After handover back:
ICMP test with
ueTun0via gNB-ho-1:Expected successful output:
BashPING 1.1.1.1 (1.1.1.1) from 10.60.0.2 ueTun0: 56(84) bytes of data. 64 bytes from 1.1.1.1: icmp_seq=1 ttl=49 time=4.51 ms 64 bytes from 1.1.1.1: icmp_seq=2 ttl=49 time=4.46 ms 64 bytes from 1.1.1.1: icmp_seq=3 ttl=49 time=4.27 ms 64 bytes from 1.1.1.1: icmp_seq=4 ttl=49 time=3.97 ms 64 bytes from 1.1.1.1: icmp_seq=5 ttl=49 time=4.64 ms --- 1.1.1.1 ping statistics --- 5 packets transmitted, 5 received, 0% packet loss, time 4007ms rtt min/avg/max/mdev = 3.972/4.371/4.644/0.232 ms