WORKINGPROJECTCHAPTER 16

Project: run an open-source core and attach a simulated phone

Stand up a 5G core from a clean checkout, add two phones and a voice network, prove each with a command, change one speed, and write the runbook you would hand to a night-shift engineer

150 MINHOW MOBILE NETWORKS WORKUPDATED 2026-11-13

This is the last chapter of module 2. You use all of it: the packet core and its functions, the subscriber database, the signalling between them, the data session and its policy, the identifiers on the SIM, and the usage the user plane records. The input is the lab in labs/telecoms. The output is a running network, a recorded capture of it, and one file, runbook.md.

What you build

The network is the lab’s nameless test network, code 999/70. Kolanut and Lumora are the story: they give the lab’s parts real owners so that you can say who would run each part.

You finish with five things you can show:

  1. The core up from a clean checkout: 14 services running, the cell connected to the core.
  2. Two subscribers, each with its own IMSI and number, and two phones attached at the same time, each with a data session and each fetching the lab’s web page.
  3. A voice network for one subscriber: the second data network, ims, allowed in the subscriber’s record and opened by the phone, with the quality-of-service value that IMS signalling uses, 5QI 5 (the 5G QoS identifier). The voice media itself would later get its own flow with 5QI 1.
  4. A speed change for one subscriber, shown on the phone, and the proof that it does not touch a session already up.
  5. runbook.md: one page with five headings, start, provision, check, capture and stop, and a table of the six failures you are most likely to meet, each with its symptom, its cause and its fix.

Who would own what

The licence tiers come from the Nigerian Communications Commission (NCC) framework for virtual operators. A Tier 2 operator (Simple Facilities Virtual Operator) may take on any of: owning and issuing its SIM, owning and operating its own intelligent network, and owning and operating its equipment register, home location register, authentication centre and home subscriber server; it has no core switching or interconnect and relies on the host’s number rangesas of 2026-11. In this lab you run every function yourself, because that is the only way to see them work. Kolanut at Tier 2 would run only the subscriber side: the database, its provisioning, and the SIM keys. In 5G terms that is the UDM, the UDR and the AUSF, which do the work of the HLR, HSS and authentication centre. That mapping is this course’s reading of the framework, as in module 1; the licence is the authority, and Kolanut would confirm it with the NCC before relying on it. The AMF, SMF, UPF, PCF and the cell stay Lumora’s. Your runbook says so in a column, because the night-shift engineer must know which failures Kolanut can fix and which it can only report.

Two phones from one SIM file

A phone is two things: the SIM’s identity and secrets, and the simulated handset that uses them. The first phone’s SIM is ran/ue.yaml. The second is a copy with a new identity, ran/ue2.yaml, and a new Compose service, ue2, at the fixed address 10.32.0.61 on the air network (the first phone is 10.32.0.60, the cell 10.32.0.50). The new service goes into compose.override.yaml, which Compose reads automatically beside compose.yaml, so you add a service without editing the lab’s own file. The service is in the phone profile, like ue, so it starts only when you ask.

The core does not take a phone’s word for who it is. It looks the identity up in MongoDB, where scripts/subscriber.sh stores subscribers, and runs authentication with the keys it finds there. So the second phone needs a second record. The lab gives both subscribers the same secret key and operator key (K and OPc) so that you can copy the SIM file. A live network never does: every SIM has its own key, as the SIM chapter explained.

Where each fact lives

What you change Where it lives When it takes effect
Who the phone is (IMSI, K, OPc, IMEI) ran/ue.yaml, ran/ue2.yaml When the phone container starts
Who the core accepts the subscribers collection in MongoDB, written by subscriber.sh At the phone’s next registration
A data network a subscriber may use (ims) the subscriber’s slice.session list At registration: add it before the phone switches on
A subscriber’s speed limit (AMBR, the aggregate maximum bit rate) slice.0.session.0.ambr in the same record At the next data session set-up (step 7 shows it after a phone restart)
Where phones find the cell gnbSearchList in the SIM file; linkIp in ran/gnb.yaml When the phone starts

Six failures to expect

You will meet these. Each is taught in an earlier chapter or in the lab’s README, under “Things that differ from a live network”. Your runbook row for each has the symptom you see, the cause, and the fix.

# Symptom Cause Fix
1 docker compose logs gnb shows “SCTP socket could not be created”; the AMF and the gNB restart in a loop The kernel has no SCTP Use a machine or engine with SCTP
2 The phone starts and gets no registration or no data session It started before the functions had found each other, which takes 20 to 30 s after up docker compose stop ue, wait, start it again
3 Registration reject, “PLMN not allowed”, 0.19 s after the request (traces/unknown-subscriber.pcapng) The core has no record for the IMSI subscriber.sh add, then restart the phone
4 Authentication failure, “Synch failure”, then a Registration reject (traces/wrong-key.pcapng) The key in the core differs from the key on the SIM Correct the record or the SIM file. A real phone reports a MAC failure; this UERANSIM version reports “Synch failure”
5 After the AMF restarts, the gNB keeps logging “Could not find a suitable AMF” UERANSIM 3.2.6’s cell does not reconnect to a restarted AMF docker compose restart gnb, then restart the phones
6 A data session is missing, and the phone log says “No response from RRC from UAC checks” A session request was dropped in the simulated radio; the phone’s T3580 timer resends it 8 s later Wait 15 s after ps-establish before ps-list

Two more failures are not in the table because the lab shows them to you in other chapters: a data network the core does not serve (traces/wrong-dnn.pcapng, “DNN not supported or not subscribed in the slice”) and the missing uplink in the usage report. Add either to your runbook if you want eight rows.

LAB Run a 5G core, attach two phones, and write the runbook ~150 MIN
YOU NEEDDocker with Compose v2 or laterA terminal in labs/telecoms from a fresh copy of the lab (the links above)A kernel with SCTP: Linux, or Docker Desktop. About 2 GB of free memory and 2 GB of diskPython 3 (for the check in step 1 only)

Every step in this lab needs the live core, so you need a machine with SCTP. If yours has none, read the recorded outputs in the expected boxes and do the trace-based parts: step 6’s trace check, and step 8 on traces/morning.pcapng. All commands run from labs/telecoms. Timestamps, addresses, TMSIs and function instance identifiers differ on every run; the expected boxes say which.

1. Check the machine. On a Linux host, ask the kernel for an SCTP socket. On Docker Desktop the check runs inside its VM, so skip this command and read the gNB log in step 2 instead.

docker compose version
python3 -c "import socket; socket.socket(socket.AF_INET, socket.SOCK_STREAM, 132); print('sctp ok')"
Docker Compose version v and a number (v2 or later; recent installs show v5), then sctp ok. Where the kernel has no SCTP the second command ends with OSError: [Errno 93] Protocol not supported. That is failure 1 in your table, caught before it costs you ten minutes: stop here and use another machine.

2. Start the core. Fourteen services, then wait for them to find each other.

docker compose up -d
sleep 30
docker compose ps --format 'table {{.Service}}\t{{.Image}}\t{{.Status}}'
docker compose logs gnb | grep "NG Setup"

Fourteen rows, all Up: amf ausf bsf gnb internet mongo nrf nssf pcf scp smf udm udr upf. The image is gradiant/open5gs:2.7.2 for the core functions, gradiant/ueransim:3.2.6 for gnb, mongo:6.0 and busybox:1.36 for the other two. Then these lines (with a gnb-1 | prefix and different times):

[ngap] [debug] Sending NG Setup Request
[ngap] [debug] NG Setup Response received
[ngap] [info] NG Setup procedure is successful

The recorded run showed the gNB’s Up time five seconds below the core’s. “NG Setup successful” means the cell has an SCTP link to the AMF. If it does not appear, read docker compose logs gnb for failure 1 or failure 5.

3. Provision two subscribers, and give the first one ims. Both get the lab’s shared key; only the first gets the voice network. Add ims now, before the phone registers: the AMF checks a session request against the subscription it reads at registration.

scripts/subscriber.sh add 999700000000001 465B5CE8B199B49FAA5F0A2EE238A6BC E8ED289DEBA952E4283B54E88E6183CA 2340000000001
scripts/subscriber.sh add 999700000000002 465B5CE8B199B49FAA5F0A2EE238A6BC E8ED289DEBA952E4283B54E88E6183CA 2340000000002
scripts/subscriber.sh add-ims 999700000000001
scripts/subscriber.sh list
provisioned: 999700000000001
provisioned: 999700000000002
ims added: 999700000000001
999700000000001 2340000000001
999700000000002 2340000000002

If a subscriber is already there, add prints already provisioned: and stops. That is not an error to fix. Run scripts/subscriber.sh show 999700000000001 and find the ims entry in the session list beside internet: 5QI (qos.index) 5 for ims, 9 for internet.

4. Switch on phone 1 and prove it works. Registration, a data session, a page.

docker compose --profile phone up -d ue
sleep 15
docker compose logs --no-log-prefix ue | grep -E "Registration is successful|PDU Session establishment|TUN interface"
docker compose exec -T ue curl -s --interface uesimtun0 http://10.34.0.80/
docker compose exec -T ue nr-cli imsi-999700000000001 --exec ps-list

Three log lines, each timestamped:

[nas] [info] Initial Registration is successful
[nas] [info] PDU Session establishment is successful PSI[1]
[app] [info] Connection setup for PDU session[1] is successful, TUN interface[uesimtun0, 10.45.0.2] is up.

Then Hello from the data network. Your packets came through the UPF. Then the session: state: PS-ACTIVE, session-type: IPv4, apn: internet, address: 10.45.0.2 and ambr: up[50000Kb/s] down[100000Kb/s]. The first phone gets the pool’s first address, 10.45.0.2. These are the numbers from the subscriber record you stored: 100 Mbit/s down, 50 up.

5. Add the second phone. Create its SIM file by copying the first and changing the identity and the IMEI (the handset’s own number), then create the Compose override. The ue2 service below is the one the lab’s checked run used.

sed -e "s/imsi-999700000000001/imsi-999700000000002/" \
    -e "s/356938035643803/356938035643809/" ran/ue.yaml > ran/ue2.yaml
grep -E "^(supi|imei):" ran/ue2.yaml

cat > compose.override.yaml <<'EOF'
# A second phone. Compose reads this file automatically, beside compose.yaml.
services:
  ue2:
    image: gradiant/ueransim:3.2.6
    entrypoint: []
    command: ["nr-ue", "-c", "/etc/atlas/ue2.yaml"]
    profiles: [phone]
    tmpfs: [/tmp]
    cap_add: [NET_ADMIN]
    devices: ["/dev/net/tun"]
    volumes: ["./ran:/etc/atlas:ro"]
    networks: { air: { ipv4_address: 10.32.0.61 } }
    depends_on: [gnb]
EOF

docker compose --profile phone up -d ue2
sleep 15
docker compose logs --no-log-prefix ue2 | grep -E "successful|TUN"

The grep prints supi: 'imsi-999700000000002' and imei: '356938035643809'. The phone’s log shows the same three lines as phone 1, with its own address:

[nas] [info] Initial Registration is successful
[nas] [info] PDU Session establishment is successful PSI[1]
[app] [info] Connection setup for PDU session[1] is successful, TUN interface[uesimtun0, 10.45.0.3] is up.

The address is the next free one in 10.45.0.0/16. The imeiSv line is still the first phone’s; the core does not check it. Now ask the cell what it sees. The first command saves the cell’s name (UERANSIM-gnb-999-70-1), as in module 1:

G=$(docker compose exec -T gnb nr-cli -d | head -1)
docker compose exec -T gnb nr-cli "$G" --exec ue-count
docker compose exec -T gnb nr-cli "$G" --exec ue-list
docker compose exec -T ue2 curl -s --interface uesimtun0 http://10.34.0.80/

2, then a list of two UEs with ran-ngap-id and amf-ngap-id (their numbers depend on how many times the phones have started, so do not compare them with this page), then the page text again, fetched by phone 2. Do not test phone-to-phone traffic. In the recorded run a ping from phone 2 to phone 1 through the UPF got 1 reply of 2; the lab does not promise it. Test each phone against 10.34.0.80.

6. Open the voice network on phone 1. Phone 1 is allowed ims (step 3). Ask for a second session to it, wait for the resend timer, and look.

docker compose exec -T ue nr-cli imsi-999700000000001 --exec "ps-establish IPv4 --sst 1 --dnn ims"
sleep 15
docker compose exec -T ue nr-cli imsi-999700000000001 --exec ps-list

ps-list now shows two sessions (recorded run, 2026-11-13):

PDU Session1: 
 state: PS-ACTIVE
 session-type: IPv4
 apn: internet
 ...
 address: 10.45.0.2
 ambr: up[50000Kb/s] down[100000Kb/s]
 data-pending: false
PDU Session2: 
 state: PS-ACTIVE
 session-type: IPv4
 apn: ims
 ...
 address: 10.46.0.2
 ambr: up[1530Kb/s] down[3850Kb/s]
 data-pending: false

ps-list does not show the 5QI; the trace below and subscriber.sh show do: 5. If the second session still says PS-ACTIVE-PENDING after 15 s, look in docker compose logs ue for failure 6, and wait for the resend.

Read the same facts from the reference trace, which works on any machine:

scripts/ladder.sh traces/ims-session.pcapng --filter 'nas-5gs.sm.message_type == 0xc1 || nas-5gs.sm.message_type == 0xc2'

The internet session’s request is at 9.941 s and its accept at 10.247 s. The ims request reaches the AMF at 36.882 s and the accept goes to the cell at 37.543 s. The first ims request was dropped inside the simulated phone and resent by the T3580 timer, which is failure 6. No P-CSCF address was sent, because UERANSIM does not ask for one. That is where this lab stops and SIP would start.

7. Change one subscriber’s speed, and show it. Set phone 1 to 20 Mbit/s down and 10 up, in the subscriber’s record (both the subscriber-level limit and the session limit), and look without restarting first.

docker compose exec -T mongo mongosh --quiet open5gs --eval "db.subscribers.updateOne({imsi: '999700000000001'}, {\$set: {'ambr.downlink.value': NumberInt(20), 'ambr.uplink.value': NumberInt(10), 'slice.0.session.0.ambr.downlink.value': NumberInt(20), 'slice.0.session.0.ambr.uplink.value': NumberInt(10)}})"
docker compose exec -T ue nr-cli imsi-999700000000001 --exec ps-list | grep ambr
docker compose restart ue
sleep 15
docker compose exec -T ue nr-cli imsi-999700000000001 --exec ps-list
docker compose exec -T ue2 nr-cli imsi-999700000000002 --exec ps-list | grep ambr

The update prints a MongoDB acknowledgement with matchedCount: 1 and modifiedCount: 1. The first ps-list still shows the old limit on the first session, up[50000Kb/s] down[100000Kb/s] (the ims session’s own line is unchanged too): nothing changes for a session that is already up. After the restart the phone’s session shows ambr: up[10000Kb/s] down[20000Kb/s] (the recorded run got address 10.45.0.4; yours may differ), and the ims session is gone, because a restarted phone starts with its SIM file’s one session. Phone 2 is untouched at up[50000Kb/s] down[100000Kb/s]. Two phones on one core, with different speeds, because the limit lives in each subscriber’s record. At Tier 2 this record is Kolanut’s.

8. Record both phones, then read the capture. Record from before the phones start, so the registrations are in it.

scripts/capture.sh start mine
docker compose restart ue ue2
sleep 15
docker compose exec -T ue curl -s --interface uesimtun0 http://10.34.0.80/
docker compose exec -T ue2 curl -s --interface uesimtun0 http://10.34.0.80/
docker compose exec -T ue nr-cli imsi-999700000000001 --exec "deregister switch-off"
docker compose exec -T ue2 nr-cli imsi-999700000000002 --exec "deregister switch-off"
sleep 4
scripts/capture.sh stop
scripts/ladder.sh captures/mine.pcapng --filter 'ngap.procedureCode == 15'
scripts/ladder.sh captures/mine.pcapng | grep -o 'suci-0-999-70-0000-0-0-[0-9]*' | sort | uniq -c
scripts/usage.sh captures/mine.pcapng

A line starting recording to captures/mine.pcapng, two lines of page text, then stopped; files in captures/. The first ladder command lists the InitialUEMessage frames: one Registration request from each phone (a phone that retried would add a line). The recorded run:

   6.541  gNB        -> AMF        NGAP/NAS-5GS   InitialUEMessage, Registration request
   6.652  gNB        -> AMF        NGAP/NAS-5GS   InitialUEMessage, Registration request

The second prints each concealed identity once: 1 suci-0-999-70-0000-0-0-0000000001 and 1 suci-0-999-70-0000-0-0-0000000002. The usage report has one row for each session that ended during the recording. The recorded run had four: two right after the restart (when a phone registers again, the core ends the session it still held from the phone’s previous life) and two at switch-off:

time_s,seid,urr_id,message,uplink_bytes,downlink_bytes,total_bytes
6.581,0x00000000000007d2,1,Session Deletion Response,0,0,0
6.679,0x0000000000000e3e,1,Session Deletion Response,0,541,541
27.716,0x00000000000009e7,1,Session Deletion Response,0,541,541
30.983,0x0000000000000e64,1,Session Deletion Response,0,541,541

Times and session identifiers (seid) differ every run. The uplink_bytes column is 0 on every row, even though each phone sent a request upwards: the Open5GS 2.7.2 quirk. Keep captures/mine.pcapng: it is the evidence for the runbook’s capture heading.

9. Write runbook.md, then stop cleanly. The runbook has five headings and the failure table. Copy the skeleton and fill every cell from your own steps; a command you did not run does not go in.

# Runbook: the lab core (999/70)

## Start      (commands, the 30 s wait, the check that NG Setup succeeded)
## Provision  (subscriber.sh add / add-ims / list / show; why ims is added first)
## Check      (registration, session, page, ue-count, ps-list: what each should say)
## Capture    (capture.sh start/stop, ladder.sh, usage.sh and the uplink quirk)
## Stop       (the two ways, and what each deletes)

| # | Symptom | Cause | Fix | Who fixes it at Tier 2: Kolanut or Lumora |
|---|---|---|---|---|

Then stop the network. This leaves the lab on your machine:

docker compose --profile phone down

The phones, the cell and the core stop and their containers are removed; docker compose ps is empty. The subscribers are kept in the mongo volume, so the next up still knows both of them. To wipe the subscriber database as well, add -v: docker compose --profile phone down -v. Your runbook’s Stop heading says which of the two to use and why. In the “who fixes it” column, failures 3 and 4 are subscriber-database failures that Kolanut would own at Tier 2; failures 1, 2, 5 and 6 are the platform’s and the cell’s. Failure 1 is yours only in the lab.

Self-check

Compare your runs with these values. Times and addresses vary; counts and limits do not.

Check Expected
Services after docker compose up -d 14, all Up
Cell log NG Setup procedure is successful
subscriber.sh list 999700000000001 2340000000001 and 999700000000002 2340000000002
Phone 1’s first address 10.45.0.2
curl through either phone Hello from the data network. Your packets came through the UPF.
ue-count on the cell with both phones on 2
Second phone’s address the next free one in 10.45.0.0/16 (10.45.0.3 on a fresh run)
ims session address in 10.46.0.0/16, 5QI 5, 3,850 kbit/s down and 1,530 up
Session limit before the change up[50000Kb/s] down[100000Kb/s]
Session limit after the change and a restart up[10000Kb/s] down[20000Kb/s]
Uplink bytes in usage.sh 0
Usage rows in step 8 4 (2 at the restart, 2 at switch-off)
Registration request to accept, one phone (lab traces) about 0.6 s (attach-and-browse) to 0.849 s (morning)

Break it: delete a subscriber and watch the phone fail. Put subscriber 2 back to the state of someone the network has never heard of, then bring the phone back. Run this before step 9’s down, or start the core again first.

scripts/subscriber.sh remove 999700000000002
docker compose restart ue2
sleep 15
docker compose logs --no-log-prefix ue2 | grep -i -E "reject|registration"
docker compose exec -T ue2 nr-cli imsi-999700000000002 --exec status | grep -E "rm-state|mm-state"
scripts/subscriber.sh add 999700000000002 465B5CE8B199B49FAA5F0A2EE238A6BC E8ED289DEBA952E4283B54E88E6183CA 2340000000002
docker compose restart ue2

The phone’s log ends with the failure, and its status shows it deregistered (recorded run; times vary):

[nas] [debug] Sending Initial Registration
[nas] [error] Initial Registration failed [PLMN_NOT_ALLOWED]
rm-state: RM-DEREGISTERED
mm-state: MM-DEREGISTERED/NO-CELL-AVAILABLE

The grep also shows the phone’s earlier, successful registrations above these lines. The reject carries the cause “PLMN not allowed” (5GMM cause 11): Open5GS’s choice of answer for an unknown subscriber, and a misleading one, because the network is allowed and the subscriber is not. The reference trace unknown-subscriber shows the reject 0.19 s after the request (8.844 s to 9.035 s), after the AMF has asked the AUSF, the UDM and the UDR. Copy the failure line into failure 3. After you add the subscriber back and restart the phone it registers again. Now the question for the runbook: a trader’s SIM is rejected like this. At Tier 1, whose database is it? At Tier 2? Write both answers in failure 3’s “who fixes it” cell. Then try the other half: change the first subscriber’s k in MongoDB, restart ue, and compare what you see with failure 4 and traces/wrong-key.pcapng.

All companies and people in these examples are fictional. Any resemblance to a real business or person is unintended.

RECALL CARDS Tap to flip. They join your review deck when you mark the lesson complete.
NEXT: Interconnect: how networks carry each other's calls and texts →