Inside a 5G Core: Registration, a PDU Session, and the SBI Calls Behind Them

Reading a capture taken inside a running 5G core, where the network functions talk to each other over HTTP/2 and every call is visible. The core is free5GC, an open-source implementation, with one gNB attached. The capture comes from a public free5GC issue about QoS flow markings on N3, and was decoded and annotated with VisualEther, which turns a Wireshark PCAP into a sequence diagram.

💡 Read the walkthrough and the diagram side by side: open the interactive diagram in a split-screen window, or open it in a new tab and snap the two windows side by side.

Overview

Most 5G call-flow diagrams stop at the AMF. Behind it, a registration and a PDU session set off dozens of calls between the core's network functions (NFs), and those calls usually go unseen. In this capture every NF runs on one machine and talks over loopback in clear HTTP/2, so every call is on the wire. The capture is 880 packets taken on 28 August 2020. VisualEther draws 191 messages from it:

  1. Bootstrap. Seven NFs register with the NRF, the SMF opens a PFCP association with the UPF, and the PCF tries to subscribe to the AMF eighteen times.
  2. NG Setup. The gNB connects to the AMF.
  3. Registration. One UE registers and authenticates with 5G-AKA.
  4. Subscription data and policy. The AMF fetches the UE's data from the UDM and policy from the PCF, then accepts the registration.
  5. PDU session. The SMF sets up a session, programs the UPF, and the gNB gets its tunnel.
  6. User plane. Five pings travel up the N3 tunnel.
  7. Deregistration and shutdown. The UE leaves, the SMF never confirms the session release, and the UE's deregistration is answered only when the core shuts down 25 seconds later.

The page cross-references the spec view of 5G standalone registration, which draws the same procedure from TS 23.502. For the radio side of a registration, see the 5G NR attach on the air interface and its NAS-5GS walkthrough.

The network functions

The core uses a service-based architecture: each NF exposes HTTP/2 APIs, called SBI (service-based interface) services, and NFs call each other directly. Each operation has a 3GPP name such as Nausf_UEAuthentication_Authenticate, and every SBI arrow in the diagram carries that name.

NFJobServices used here
AMF (Access and Mobility Management Function)Terminates NAS from the UE and NGAP from the gNB; runs registrationNamf_Communication
AUSF (Authentication Server Function)Runs 5G-AKA for the home networkNausf_UEAuthentication
UDM (Unified Data Management)Holds the keys, computes vectors, serves subscription dataNudm_UEAuthentication, Nudm_UECM, Nudm_SDM
UDR (Unified Data Repository)The database behind the UDM and PCFNudr_DM
PCF (Policy Control Function)Access and session policyNpcf_AMPolicyControl, Npcf_SMPolicyControl
NSSF (Network Slice Selection Function)Picks the slice instanceNnssf_NSSelection
SMF (Session Management Function)Runs PDU sessions and controls the UPFNsmf_PDUSession
UPF (User Plane Function)Forwards user packets; programmed over PFCP(N4, not SBI)
NRF (Network Repository Function)The directory: NFs register with it and discover each other through itNnrf_NFManagement, Nnrf_NFDiscovery

The diagram's lanes follow the signaling path, gNB → AMF → SMF → UPF, with each helper NF placed between the callers that use it. The NRF is on the right edge because every NF calls it. There is no UE lane: the capture holds no UE-side packets. NAS messages ride NGAP from the gNB, and user data rides inside GTP-U.

What the UE goes through

The two state machines below are the UE's, from TS 24.501, mapped onto the messages in the capture. The 5GMM machine handles registration; the 5GSM machine handles the PDU session.

stateDiagram-v2 accTitle: 5GMM states of the UE in the capture accDescr: The UE starts deregistered. Sending the Registration Request moves it to registered-initiated. The Registration Accept moves it to registered. The Deregistration Request moves it to deregistered-initiated, where it waits 25 seconds until the Deregistration Accept returns it to deregistered. [*] --> DEREGISTERED DEREGISTERED --> REGISTERED_INITIATED: Registration Request REGISTERED_INITIATED --> REGISTERED: Registration Accept REGISTERED --> DEREGISTERED_INITIATED: Deregistration Request DEREGISTERED_INITIATED --> DEREGISTERED: Deregistration Accept, 25 s later
5GMM (mobility management) states this UE passes through. It sits in DEREGISTERED-INITIATED for 25 seconds, waiting for an accept the AMF holds back.
stateDiagram-v2 accTitle: 5GSM states of PDU session 5 accDescr: PDU session 5 starts inactive. The PDU Session Establishment Request moves it to active pending, and the accept moves it to active. Deregistration releases it, returning it to inactive. [*] --> INACTIVE INACTIVE --> ACTIVE_PENDING: PDU Session Establishment Request ACTIVE_PENDING --> ACTIVE: PDU Session Establishment Accept ACTIVE --> INACTIVE: released with deregistration
5GSM (session management) states of PDU session 5. Deregistration releases the session locally, without a 5GSM release exchange.

Phase 1: The core boots (frames 4–208)

Within 36 ms, six NFs register their profiles with the NRF using Nnrf_NFManagement_NFRegister, a PUT to /nnrf-nfm/v1/nf-instances/{id}. Each NF picks its own UUID and publishes its services, PLMNs, and slices; the NSSF follows 2 s later. The AMF's profile lists two GUAMIs (Globally Unique AMF Identifiers): PLMN 460/00 with AMF ID cafe00, and 460/11 with cafe11. In parallel, the SMF opens a PFCP (Packet Forwarding Control Protocol) association with the UPF over N4 (frames 51 and 55). It is set up once per node pair, before any subscriber exists.

The NRF remembers every run

Discovery is where this capture stops looking like a textbook. When an NF asks the NRF for, say, a UDM, it should get one profile back: the UDM that registered a moment ago. Instead it gets 125. Every discovery in the capture looks like this:

Asked forProfiles returnedWhere the live NF is
AMF30last
SMF33last
UDM125last
UDR, AUSF, PCF, NSSF123 eachlast

The extra profiles have other instance IDs and other PLMNs, including 460/00, 460/11, 406/11, and 208/93. They are leftovers from earlier runs of the lab: the NRF kept every profile ever registered, and nothing expired them. The calls still reach the right process because every run listened on the same loopback ports, so a stale profile points at the live NF just as the fresh one does. The cost is time: these discoveries take 20 to 100 ms. The one discovery that names a single instance (the SMF looking up the AMF by target-nf-instance-id in frame 775) returns one profile in 3 ms.

The AMF and SMF have about 30 leftovers each, while the NFs that never deregister in this capture have about 122. That fits the cleanup the AMF and SMF do at shutdown in phase 7, so their profiles pile up only when a run ends without it.

Eighteen subscriptions to one AMF

The stale profiles explain the strangest stretch of the bootstrap. The PCF discovers AMFs (frame 68), receives all 30 profiles, and subscribes to each one's GUAMI list with Namf_Communication_AMFStatusChangeSubscribe, so it hears if the AMF fails. All of those requests reach the one live AMF, which serves only 460/00 + cafe00 and 460/11 + cafe11:

GUAMI list in the requestRequestsAMF's answer
460/11 + cafe0011403 Forbidden ×10, one unanswered
208/93 + cafe001403 Forbidden
460/00 + cafe001201 Created
460/00 + cafe00, 460/00 + cafe114201 Created, echoing only 460/00 + cafe00
460/00 + cafe00, 460/11 + cafe111201 Created, echoing both

The 18 requests follow the 30 profiles in order. The PCF skips the 13 profiles that repeat a list it has already subscribed to, and resends the unanswered one on a new connection. The rule the AMF applies is visible in the answers: it refuses a list that names no GUAMI it serves, and accepts any list that names at least one, keeping only the GUAMIs it serves. Six accepted subscriptions to one AMF mean six identical notifications when it shuts down (frames 851–874).

Phase 2: NG Setup (frames 211–212)

Thirteen seconds later the gNB opens N2 over SCTP. Its NG Setup Request announces gNB ID 0, PLMN 460/00, tracking area code 1, and slices SST 1, 2, and 3. The NG Setup Response names the AMF, gives it relative capacity 255, and lists its two served GUAMIs, the same pair the PCF struggled with. Both use AMF region 0xCA and AMF set 1016; pointer 0 gives AMF ID cafe00 and pointer 17 gives cafe11.

Phase 3: Registration and 5G-AKA (frames 213–343)

sequenceDiagram accTitle: 5G-AKA in the capture accDescr: The gNB forwards the Registration Request to the AMF. The AMF calls the AUSF, which calls the UDM, which reads the authentication subscription from the UDR. The AUSF returns RAND, AUTN and HXRES star to the AMF. The AMF sends the Authentication Request, the UE answers with RES star, and the AMF passes RES star to the AUSF for confirmation. The AUSF returns the SUPI and K SEAF, and the AMF starts NAS security. participant gNB participant AMF participant AUSF participant UDM participant UDR gNB->>AMF: Registration Request (SUCI, null scheme) AMF->>AUSF: Nausf UEAuthentication Authenticate AUSF->>UDM: Nudm UEAuthentication Get UDM->>UDR: Nudr DM Query (authentication subscription) AUSF-->>AMF: 201 RAND, AUTN, HXRES* AMF->>gNB: Authentication Request gNB->>AMF: Authentication Response (RES*) AMF->>AUSF: Authenticate (5G-AKA confirmation, RES*) AUSF-->>AMF: 200 success, SUPI, K_SEAF AMF->>gNB: Security Mode Command (5G-EA0, 128-5G-IA2)
5G-AKA across the core (frames 213–343). The AMF never sees the expected response: it gets a hash of it, and the AUSF makes the final comparison.

The Registration Request (frame 213) arrives in an NGAP Initial UE Message. It is an initial registration with the Follow-On Request bit set, which tells the AMF that the UE has more to send once registered; that turns out to be a PDU session request. The UE identifies itself with a SUCI (Subscription Concealed Identifier). SUCI exists to hide the subscriber's permanent identity, but this one uses the null protection scheme, so the MSIN 0012200000 travels in clear.

The AMF cannot authenticate the UE itself. It calls the AUSF with the SUCI and the serving network name 5G:mnc000.mcc460.3gppnetwork.org, which is bound into the keys so a vector made for one network cannot be used in another. The AUSF calls the UDM, the only NF that holds the subscriber's long-term key. The UDM converts the SUCI to the permanent identity, the SUPI imsi-460000012200000, and reads the credentials from the UDR.

The vector splits on its way back. The UDM gives the AUSF RAND, AUTN, and XRES*, the response a genuine UE will produce. The AUSF passes the AMF only RAND, AUTN, and HXRES*, a hash of XRES*. The AMF can check the UE's answer against the hash, but only the home network's AUSF can confirm it. That split, new in 5G, keeps a visited network from claiming it authenticated a roaming UE when it did not.

The UE answers with RES* in 2 ms (frame 310). The AMF sends it to the AUSF in the confirmation step (frame 312), the AUSF finds it equal to XRES*, and only then does the AMF receive the SUPI and K_SEAF (frame 337), the anchor key for the NAS keys.

The Security Mode Command (frame 340) selects 5G-EA0, the null cipher, with 128-5G-IA2 integrity. The UE supports EA1 to EA3, so encryption was available and not chosen. NAS messages from here on are integrity protected but readable, which is why this walkthrough can decode every one. The Security Mode Complete carries the full Registration Request again, so the AMF can check that the unprotected first copy was not altered.

Phase 4: Subscription data and policy (frames 345–615)

With the UE authenticated, the AMF collects what it needs to accept the registration. Each call to the UDM sets off a call from the UDM to the UDR, often after a fresh NRF discovery:

OperationWhat the AMF learns or does
Nudm_SDM_Get (nssai)Subscribed slices: S-NSSAI 1/010203 and 1/112233, both default
Nudm_UECM_RegistrationRecords itself as the UE's serving AMF for 3GPP access
Nudm_SDM_Get (am-data)Subscribed UE-AMBR (aggregate maximum bit rate) of 1000 kbps each way
Nudm_SDM_Get (smf-select-data)DNN internet is allowed on both slices
Nudm_SDM_Get (ue-context-in-smf-data)The UE has no existing PDU sessions
Nudm_SDM_SubscribeThe AMF will hear about later subscription changes
Npcf_AMPolicyControl_CreateAn access and mobility policy, imsi-460000012200000-1

The Registration Accept (frame 612) rides an NGAP Initial Context Setup Request, which also gives the gNB the UE's security context. It assigns 5G-GUTI 460/00 with 5G-TMSI 1, allows both slices, lists 460/11 as an equivalent PLMN, and sets the periodic registration timer T3512 to 60 minutes. The UE answers with Registration Complete 665 ms after its first message.

Phase 5: The PDU session (frames 616–808)

sequenceDiagram accTitle: PDU session establishment in the capture accDescr: The UE's PDU Session Establishment Request reaches the AMF, which creates an SM context on the SMF. The SMF sets up a PFCP session on the UPF with the uplink tunnel endpoint, then asks the AMF to deliver the accept to the UE and the tunnel to the gNB. The gNB returns its downlink tunnel endpoint, the AMF passes it to the SMF, and the SMF updates the UPF. participant gNB participant AMF participant SMF participant UPF gNB->>AMF: PDU Session Establishment Request (session 5) AMF->>SMF: Nsmf PDUSession CreateSMContext SMF->>UPF: PFCP Session Establishment (uplink TEID 1) SMF->>AMF: Namf Communication N1N2MessageTransfer AMF->>gNB: PDU Session Resource Setup Request + Accept gNB->>AMF: PDU Session Resource Setup Response (downlink TEID 1) AMF->>SMF: Nsmf PDUSession UpdateSMContext SMF->>UPF: PFCP Session Modification (downlink tunnel)
PDU session establishment (frames 616–808). The SMF never speaks NAS or NGAP directly: the AMF carries both for it, and the SMF programs the UPF over PFCP.

The request (frame 616) asks for PDU session 5, IPv4, SSC mode 1, on DNN internet. It names no slice, so the AMF picks one from the subscription, 1/112233. The AMF asks the NSSF which slice instance serves it (nsiId 23), then discovers an SMF that serves that DNN and slice.

The SMF never speaks NAS. The AMF's Nsmf_PDUSession_CreateSMContext is a multipart/related POST: a JSON part with the SUPI, session ID, DNN, and slice, and a binary part holding the UE's 5GSM message unchanged. The SMF then reads the UE's session subscription from the UDM (5QI 9, session-AMBR 1000 kbps) and gets a session policy from the PCF with Npcf_SMPolicyControl_Create. It has already allocated the UE address 100.64.50.1 by this point.

The SMF programs the UPF with a PFCP Session Establishment Request (frame 773). PFCP describes forwarding as rules: a PDR (packet detection rule) matches packets, and a FAR (forwarding action rule) says what to do with them.

The answer goes back through the AMF. Namf_Communication_N1N2MessageTransfer carries two binary parts: the PDU Session Establishment Accept for the UE (N1) and an NGAP transfer for the gNB (N2) holding the UPF's uplink endpoint. The AMF sends both to the gNB in one PDU Session Resource Setup Request (frame 792). The gNB replies with its own downlink endpoint, and the SMF adds it to FAR 2 with a PFCP Session Modification (frame 806). The tunnel is complete 279 ms after the UE asked.

N3 tunnel endpointAddressTEIDAllocated byDelivered in
Uplink (UPF side)172.17.1.501SMFPFCP (773), NGAP (792)
Downlink (gNB side)172.17.1.2311gNBNGAP (796), PFCP (806)

Both endpoints use TEID 1. They are still different tunnels: a TEID identifies a tunnel only together with its IP address.

A session-AMBR with its bytes swapped

The subscription and the PCF both authorize a session-AMBR of 1000 kbps. The PDU Session Establishment Accept tells the UE 59,395 kbps. In hexadecimal, 1000 is 0x03E8 and 59,395 is 0xE803: the same two bytes in the opposite order. The SMF wrote the value in the wrong byte order, so the UE was told it could send almost sixty times its subscribed rate.

Two smaller departures from the specs show up in the same messages. FAR 1, the uplink rule, names Access as its destination interface, where TS 29.244 expects Core for traffic headed to the data network. And the NGAP QoS flow carries ARP priority level 15, while the policy authorized 8.

Phase 6: User data on N3 (frames 811–815)

One second after the tunnel completes, the first user packet goes up it: a GTP-U T-PDU from the gNB to the UPF on TEID 1, marked QFI 9 (the session's default QoS flow). Inside is an ICMP Echo Request from 100.64.50.1 to 8.8.8.8. Four more follow at one-second intervals.

No reply comes back, and no downlink GTP-U appears at all. The capture cannot show whether the UPF forwarded the pings or dropped them, but the uplink FAR's Access destination is the first place to look.

Phase 7: A deregistration that waits 25 seconds (frames 816–880)

Twelve seconds after the last ping, the UE sends a Deregistration Request: a normal one, not a switch-off, so it expects a Deregistration Accept. The AMF asks the SMF to release the session with Nsmf_PDUSession_ReleaseSMContext (frame 818). The SMF deletes the PFCP session on the UPF within 10 ms (frames 825–826). Then it never answers the AMF's HTTP/2 request.

TS 23.502 has the AMF send the Deregistration Accept after the session's SM context is released. The AMF waits. Twenty-four seconds pass with nothing on the wire, and then the core is shut down:

  1. The AMF and SMF delete their own NRF profiles (Nnrf_NFManagement_NFDeregister, frames 828 and 833).
  2. The AMF sends the gNB an AMF Status Indication listing both GUAMIs as unavailable (frame 840).
  3. The AMF deletes the UE's access and mobility policy (Npcf_AMPolicyControl_Delete, frame 843).
  4. The AMF sends the PCF six AMF_UNAVAILABLE notifications, one per subscription from phase 1 (frames 851–874). None of them names a GUAMI, so the PCF cannot tell which one changed.
  5. Finally, 25 seconds after the request, the AMF sends the Deregistration Accept. The same SCTP packet (frame 879) carries a second NGAP message, a UE Context Release Command with cause nas: deregister, and the gNB confirms the release.

Two calls a clean deregistration would include never appear: Nudm_UECM_Deregistration and Nudm_SDM_Unsubscribe. When the capture ends, the UDM still lists this AMF as the UE's serving AMF.

Takeaways

  1. A registration is mostly SBI traffic. Eleven NAS messages on N2 set off 45 SBI requests: 31 for the registration, 13 for the PDU session, and one release.
  2. The AMF never sees the expected response. 5G-AKA gives the serving network HXRES*, and the AUSF makes the final check.
  3. The SMF works through other NFs. NAS and NGAP reach it through the AMF as multipart bodies, and it reaches the user plane only through PFCP rules on the UPF.
  4. A TEID means nothing without its address. Both N3 directions use TEID 1 on different endpoints.
  5. Check discovery responses. An NRF that keeps stale profiles turns a one-profile answer into a hundred, slows every lookup, and multiplies subscriptions.
  6. A missing SBI response can stall a NAS procedure. One unanswered ReleaseSMContext held the UE's Deregistration Accept for 25 seconds.
  7. Compare encoded values with their source. The session-AMBR the UE received was the subscribed value with its bytes swapped.