Handover¶
Learning objectives¶
After reading this page, you will be able to:
- Explain the Why (why handover is necessary) from the perspective of maintaining communication and preserving the session/IP during mobility.
- Contrast and explain the difference between Xn-based Handover and N2-based Handover (their applicability conditions and the degree of core involvement).
- Explain what Path Switch (the procedure that, after an Xn HO completes, re-points the N3 downlink path to the new gNB) does.
- Follow the flow of the N3 path switch in handover (updating the gNB-side TEID, the coordination of AMF→SMF→UPF).
- Explain, from the core's perspective, that the leading actors in handover are the AMF (N2 control) and the SMF/UPF (N3 path switch).
- Use Wireshark Display Filters to name the focal points for analyzing the NGAP Handover-family / Path Switch packets.
- Contrast the differences between 4G (EPC)'s X2-based HO / S1-based HO and 5G's Xn-based / N2-based HO.
Prerequisites¶
It will go more smoothly if you understand the following first. If you are not there yet, start from the Curriculum.
- Completion of Registration (the UE is registered = 5GMM-REGISTERED) → Initial Registration
- Establishment of a PDU Session (the user plane to be switched is set up) → PDU Session Establishment
- N2 / N3 (the gNB⇔AMF control path, and the gNB⇔UPF user-plane path) → N2 / N3
- The roles of the main NFs → AMF / SMF / UPF
What you'll learn in this chapter¶
This chapter focuses narrowly on Inter-gNB Handover (handover between base stations), and of that, it covers the two types Xn-based and N2-based. It is the procedure that switches a moving UE's connection from its current base station (Source gNB) to the next base station (Target gNB) without interrupting communication.
This chapter focuses on the involvement of the core (5GC). That is, it centers on:
- how the AMF mediates and controls handover with N2 control
- how the SMF/UPF switch the N3 user-plane path to the new gNB
The following are out of scope for this chapter (they are touched on, but not gone into in detail).
- The detailed radio (RRC) side procedures (handover execution via RRC Reconfiguration, the details of radio resource allocation)
- The details of the Measurement Report (the radio-side decision logic for how the UE measures neighbor cells and when it triggers the HO)
- Intra-gNB Handover (switching between cells within the same gNB), Inter-System Handover (between 5G and 4G), and the like are out of scope. Inter-System Handover is covered in 4G-5G Interworking.
These are topics on the radio access side (inside the gNB), and this chapter, which takes the core's perspective, keeps them at an overview level.
Why — why handover is necessary¶
Let's start from the Why (why it is needed). A UE (smartphone, etc.) moves. As it keeps communicating while walking or riding a train, the signal of the base station it is currently connected to (Source gNB) grows steadily weaker, while conversely the signal of another base station in the direction of travel (Target gNB) grows stronger.
If nothing were done here, sticking with the base station with the weak signal would cause calls to drop, videos to stall, and downloads to be interrupted. To prevent this, the connection must be switched over to a "base station with good signal" while communication continues. This switchover is Handover.
There are two things we want to preserve across a handover.
- Session continuity — carry over the already-established PDU Session (the pipe for data communication) without re-establishing it.
- IP address preservation — the UE's IP address as seen by the application does not change (so TCP connections and application sessions are not broken).
The purpose of handover is to switch only the radio segment and the core's user-plane path, as close to make-before-break (no interruption) as possible, while keeping these preserved.
Analogy: passing the baton in a relay while on a call
Handover is like a relay runner's baton pass. The runner (UE) keeps running (= keeps communicating), and passes the baton (the UE's connection context) from the runner currently holding it (Source gNB) to the next runner (Target gNB). If it goes well, the spectators (the user) do not notice that the run (communication) was interrupted. Coordinating the "handoff" directly between the runners is Xn-based; doing it through the coach (AMF) is N2-based. Once the pass is done, the runners tell course management (SMF/UPF) "this runner is running now," so the delivery destination of the cheering (downlink data) is switched to the new runner. This is Path Switch / N3 path switch.
Overview¶
The trigger for a handover is basically degradation of radio quality. Based on the UE's Measurement Report (the radio-side details are out of scope), the Source gNB judges "this should be moved to the Target gNB" and initiates the handover. The purpose is a make-before-break path switch that preserves the session/IP.
Inter-gNB Handover comes in two types, depending on whether there is an Xn interface between neighboring gNBs and whether core relocation is required.
| Aspect | Xn-based Handover | N2-based Handover |
|---|---|---|
| Applicability condition | There is an Xn between the Source and Target gNB, allowing direct coordination | There is no Xn, or AMF/UPF relocation is required |
| Coordinator of HO preparation/execution | The gNBs coordinate directly over Xn | The AMF mediates over N2 (Handover Required/Request/Command) |
| Core involvement | Only the post-execution Path Switch (N3 downlink path switch) | The AMF is involved from the preparation phase, with UPF relocation if needed |
| Main messages on the core side | NGAP Path Switch Request / Ack | NGAP Handover Required / Request / Command / Notify, etc. |
| Control protocol | XnAP (between gNBs) + NGAP (Path Switch) | NGAP (over N2) |
| Rough speed/weight | Lightweight and fast (minimal core involvement) | Heavier (the core is involved from preparation) |
(The applicability conditions and message names are based on the Handover procedures of TS 23.502. The finer details of individual message names/ordering are covered in Procedure, and some are marked to be confirmed.)
flowchart LR
UE([UE]) -.move.-> UE2([UE])
S["Source gNB"] -->|"Xn direct coordination
(Xn-based)"| T["Target gNB"]
S -->|"coordination via N2
(N2-based)"| AMF[AMF]
AMF --> T
T -->|"Path Switch / N3 switch"| CORE{AMF→SMF→UPF}
Basic Concept — a beginner-friendly explanation¶
To understand handover, grasp three keywords.
1. What handover is (What)¶
Handover is the procedure that moves a UE's radio connection from Source gNB → Target gNB while communication continues. What is mainly moved is the following two things.
- UE context — the information about who that UE is, and what security and what PDU Session/QoS Flow it has. The Target gNB takes this over.
- User-plane path — the route over which the actual data flows. Both the radio segment (UE⇔gNB) and the core-side N3 (gNB⇔UPF) are switched toward the new gNB.
The switching of the radio segment (RRC Reconfiguration) is handled by the gNB and the UE, and its details are out of scope for this chapter. This chapter concentrates on the core-side (N3) switch.
2. How to choose between Xn-based and N2-based¶
- Xn-based — when there is an Xn interface (a link connecting gNBs directly) between the Source and Target gNB. The gNBs coordinate directly with XnAP — "get ready to accept this from now" / "preparation OK." The core (AMF) is not involved in the preparation and handles only the post-execution Path Switch. Its advantage is being light and fast.
- N2-based — when there is no Xn, or when AMF/UPF relocation is required. Since the gNBs cannot talk directly, the AMF mediates over N2. It becomes a three-party coordination of Source gNB → AMF → Target gNB, with the core involved from the preparation phase.
Try Xn first, fall back to N2
Generally, an Xn is set up between neighboring gNBs, and the lightweight Xn-based HO is tried first. When there is no Xn (unconfigured, a different domain, etc.), or when a core-side relocation is required, the N2-based HO is used. Which one is used depends on the radio and core configuration and the operator's design (implementation dependent).
3. Path Switch and the N3 path switch¶
Even after the radio segment moves to the Target gNB in a handover, the delivery destination of the downlink data as seen from the core (UPF) is still the Source gNB. Unless this is re-pointed to the new gNB, downlink packets will arrive at the old base station.
- Path Switch — after an Xn-based HO completes, the Target gNB sends an NGAP Path Switch Request to the AMF, requesting "please point this UE's downlink path to me (the new gNB)." That is the procedure.
- N3 path switch — upon receiving this, the AMF passes it to the SMF, and the SMF updates the UPF's forwarding rule (the destination of the downlink FAR) to the new gNB's N3 TEID/address via N4 (PFCP). This makes the downlink N3 (GTP-U) flow to the new gNB.
In other words, think of Path Switch = "the new gNB notifies the core of its new address", and N3 path switch = "the UPF rewrites the downlink delivery destination to the new address." In an N2-based HO too, an equivalent N3 switch is performed within the Handover procedure.
The IP does not change (when the anchor UPF is maintained)
In many cases, the IP address assigned to the UE does not change. This is because the anchor UPF that terminates the IP (PDU Session Anchor) is maintained, and only the segment between that UPF and the gNB (N3) is re-pointed. This does not hold when UPF relocation is involved (see FAQ; for the SSC mode discussion, see PDU Session).
Architecture¶
The elements involved in Inter-gNB Handover and the interfaces that connect them. The Xn path (direct between gNBs) and the N2 path (AMF-mediated) are drawn separately.
flowchart LR
UE([UE])
S["Source gNB"]
T["Target gNB"]
AMF[AMF]
SMF[SMF]
UPF[UPF]
DN[(Data Network)]
UE -. "move" .-> T
UE -- "radio (RRC)" --> S
S == "Xn (XnAP): HO preparation/execution (Xn-based)" ==> T
S -- "N2 (NGAP): Handover Required, etc. (N2-based)" --> AMF
AMF -- "N2 (NGAP): Handover Request/Command" --> T
T -- "N2 (NGAP): Path Switch Request" --> AMF
AMF -- "Nsmf (N11-equivalent)" --> SMF
SMF -- "N4 (PFCP)" --> UPF
S -. "N3 (old path)" .-> UPF
T == "N3 (GTP-U new path)" ==> UPF
UPF == "N6" ==> DN
The role of each element is as follows.
- UE — the moving terminal. It switches over to the Target gNB on the radio side (the RRC procedure is radio-side, out of scope). The session/IP is maintained.
- Source gNB (old base station) — the current connection source. It initiates the HO, and coordinates with the Target gNB over Xn in Xn-based, or via N2 (the AMF) in N2-based. After the switch it may forward residual data on the old N3 path (data forwarding).
- Target gNB (new base station) — the move destination. It accepts the UE context, and in Xn-based sends a Path Switch Request to the AMF after completion.
- AMF — the N2 command center. In N2-based it controls the preparation/execution of the Handover; in Xn-based it receives the Path Switch and bridges to the SMF.
- SMF — session management. Upon receiving the notification from the AMF, it updates the UPF's N3 downlink path to the new gNB via N4 (PFCP). It judges whether UPF relocation is needed.
- UPF — the actual user-plane forwarder. On the SMF's instruction, it rewrites the destination of the downlink N3 (the gNB-side TEID/address). If the anchor UPF is maintained, the IP is unchanged.
- Xn — the interface that directly connects neighboring gNBs (the protocol is XnAP).
For the details of the interfaces, see the Interface Dictionary.
Network Function (the NFs that appear)¶
The roles of the core-side NFs that appear in handover. The gNB is on the radio access side and is not a core NF (since the leading actors in this chapter are viewed from the core's perspective, the gNB is treated as radio-side).
| NF | Role in this procedure | Information held/retrieved | Main APIs/IFs used in this procedure | Impact on failure |
|---|---|---|---|---|
| AMF | The command center of N2 control. In N2-based it mediates HO preparation/execution; in Xn-based it receives the Path Switch and bridges to the SMF | UE context, the N2 information of the Source/Target gNB | NGAP (Handover-family / Path Switch), Nsmf_PDUSession (consumes) | HO control does not proceed, risking switch failure / call drop |
| SMF | Upon the AMF's notification, updates the UPF's N3 downlink path via N4. Judges whether UPF relocation is needed | PDU Session/QoS Flow, UPF information, old and new N3 TEID | Nsmf_PDUSession (provides), N4 (PFCP) | The N3 path switch does not complete, and downlink data goes to the old gNB |
| UPF | Rewrites the destination of the downlink N3 (the gNB-side TEID/address). With the anchor maintained, the IP is unchanged | PDR/FAR/QER, N3 TEID, UE IP | Controlled by the SMF over N4 (PFCP) | Downlink data does not reach the new gNB / packet loss |
(The HO preparation/execution between gNBs themselves is a role on the radio access side, and this table is limited to core NFs.)
Interface / Protocol¶
The interfaces and protocols used in this procedure.
| Interface | Segment | Protocol | Transport | Use in this procedure |
|---|---|---|---|---|
| N2 | gNB⇔AMF | NGAP | SCTP (port 38412) | The Handover-family procedures of N2-based, and the Path Switch Request/Ack of Xn-based |
| Xn | gNB⇔gNB | XnAP | SCTP | HO preparation/execution of Xn-based (direct coordination between gNBs) |
| N3 | gNB⇔UPF | GTP-U | UDP (port 2152) | The new user-plane path. Switches the downlink destination by updating the TEID |
| N4 | SMF⇔UPF | PFCP | UDP | Updating the UPF's downlink FAR (the new gNB N3 TEID). → Interface Dictionary / Protocol Dictionary |
| N11-equivalent (Namf/Nsmf) | AMF⇔SMF | SBI (HTTP/2, TLS, JSON) | TCP/TLS | The HO/path-switch notification from AMF→SMF (Nsmf_PDUSession_UpdateSMContext, etc.) |
The details of Xn (XnAP) are on a dedicated page
Xn (XnAP) is one of the leading actors in handover. For the details of its positioning as an interface, its protocol, and its procedures, see the dedicated Xn (between gNBs) page. This chapter covers an overview limited to the context of Inter-gNB HO, and the fine details of XnAP's individual message names/procedures are based on 3GPP TS 38.423 (some are to be confirmed).
For the details of protocols, see the Protocol Dictionary; for the list of interfaces, see the Interface Dictionary.
Procedure — Call Flow¶
This is the heart of this page. The main steps of Inter-gNB Handover, conforming to 3GPP TS 23.502 §4.9.1 (Handover procedures), are shown split into Xn-based and N2-based using Mermaid sequenceDiagrams.
Prerequisite: Registration / PDU Session must be established
The premise is that the UE is already 5GMM-REGISTERED (Registration), and the PDU Session (user plane) to be switched is set up (CM-CONNECTED). The HO initiation decision based on radio quality degradation (Measurement Report, etc.) is radio-side and out of scope for this chapter.
The radio (RRC) side details are simplified
In the diagrams below, the RRC Reconfiguration (radio handover execution) between the UE and the gNB is simplified into a single step as an outline. The detailed radio-side procedures are out of scope for this chapter. Focus on the involvement of the core (AMF/SMF/UPF).
Xn-based Handover¶
The case where there is an Xn between the Source and Target gNB and the gNBs coordinate directly. The core's involvement centers on the post-execution Path Switch (N3 downlink path switch).
sequenceDiagram
autonumber
participant UE
participant S as Source gNB
participant T as Target gNB
participant AMF
participant SMF
participant UPF
Note over UE,S: radio quality degradation → HO decision (Measurement Report, etc. / radio-side / out of scope)
S->>T: Handover Request (XnAP)
Note right of S: TS 38.423 (XnAP)
T-->>S: Handover Request Acknowledge (XnAP)
Note over S,T: Target prepares UE context/resources
S->>UE: HO execution instruction (RRC Reconfiguration / outline / out of scope)
Note over UE,T: UE radio-syncs and switches to the Target gNB
UE->>T: HO complete (RRC Reconfiguration Complete / outline / out of scope)
opt Data forwarding (optional)
S-->>T: forward undelivered data over Xn
end
Note over T,AMF: from here, the core's Path Switch (N3 downlink path switch)
T->>AMF: Path Switch Request (NGAP)
Note right of T: notify the new gNB's N3 TEID/address
AMF->>SMF: Nsmf_PDUSession_UpdateSMContext (new gNB N3 info)
SMF->>UPF: N4 Session Modification Request (PFCP)
(update downlink FAR to the new gNB N3 TEID)
UPF-->>SMF: N4 Session Modification Response
Note over T,UPF: downlink N3 (GTP-U) switched to the new gNB
opt End Marker (a marker for the end of the old path)
UPF-->>S: End Marker (indicates the end of the old N3 path)
end
SMF-->>AMF: UpdateSMContext Response
AMF-->>T: Path Switch Request Acknowledge (NGAP)
T->>S: UE Context Release (XnAP)
Note over UE,UPF: switch complete / communication continues
N2-based Handover¶
The case where there is no Xn, or AMF/UPF relocation is required. The AMF mediates preparation/execution over N2.
sequenceDiagram
autonumber
participant UE
participant S as Source gNB
participant AMF
participant SMF
participant UPF
participant T as Target gNB
Note over UE,S: radio quality degradation → HO decision (radio-side / out of scope)
S->>AMF: Handover Required (NGAP)
Note right of S: specify the Target gNB / TS 23.502 §4.9.1.3
Note over AMF,SMF: preparation phase (SMF judges UPF relocation if needed)
AMF->>SMF: Nsmf_PDUSession_UpdateSMContext (HO preparation)
SMF->>UPF: N4 Session Modification (prepare required resources)
UPF-->>SMF: N4 Response
SMF-->>AMF: UpdateSMContext Response
AMF->>T: Handover Request (NGAP)
T-->>AMF: Handover Request Acknowledge (NGAP)
Note over AMF,T: Target prepares accept resources / N3 TEID
AMF->>S: Handover Command (NGAP)
S->>UE: HO execution instruction (RRC Reconfiguration / outline / out of scope)
Note over UE,T: UE switches to the Target gNB
UE->>T: HO complete (radio-side / out of scope)
T->>AMF: Handover Notify (NGAP)
Note over AMF,UPF: execution phase (finalize the N3 downlink path to the new gNB)
AMF->>SMF: Nsmf_PDUSession_UpdateSMContext (HO completion notification)
SMF->>UPF: N4 Session Modification Request (PFCP)
(update downlink FAR to the new gNB N3 TEID)
UPF-->>SMF: N4 Session Modification Response
opt End Marker
UPF-->>S: End Marker (end of the old N3 path)
end
SMF-->>AMF: UpdateSMContext Response
Note over AMF,S: release the old resources
AMF->>S: UE Context Release Command (NGAP)
Note over UE,UPF: switch complete / communication continues
Step-by-step explanation (numbers correspond to each diagram)¶
Xn-based (upper diagram)
- S→T: Handover Request (XnAP). The Source gNB directly asks the Target gNB "please accept this UE" (TS 38.423).
- T→S: Handover Request Acknowledge (XnAP). The Target prepares the UE context/radio resources and consents. 3-5. Radio-side HO execution (outline / out of scope): the Source instructs the UE to execute over RRC, and the UE syncs and switches to the Target gNB and completes. (Data forwarding is optional, forwarding undelivered data S→T.)
- T→AMF: Path Switch Request (NGAP). The Target gNB requests the AMF "point the downlink path to me." It notifies the new gNB's N3 TEID/address.
- AMF→SMF: conveys the new gNB's N3 info via Nsmf_PDUSession_UpdateSMContext.
- SMF→UPF: updates the destination of the downlink FAR to the new gNB's N3 TEID via N4 Session Modification (PFCP). → the downlink N3 (GTP-U) is switched to the new gNB (an End Marker may be sent as a marker for the end of the old path).
- AMF→T: Path Switch Request Acknowledge (NGAP).
- T→S: UE Context Release (XnAP). Releases that UE's resources on the old gNB.
N2-based (lower diagram)
- S→AMF: Handover Required (NGAP). Since Xn cannot be used, it asks the AMF to mediate. Specifies the Target gNB.
- Preparation phase: AMF→SMF UpdateSMContext, SMF→UPF N4 Modification to arrange the required resources (if UPF relocation is needed, prepare the new UPF).
- AMF→T: Handover Request (NGAP) / T→AMF Handover Request Acknowledge (NGAP). The Target prepares the accept resources and the N3 TEID.
- AMF→S: Handover Command (NGAP). Instructs the Source "you may execute."
- Radio-side HO execution (outline / out of scope) → the UE switches to the Target.
- T→AMF: Handover Notify (NGAP). Notifies that the switch is complete on the Target side.
- Execution phase: AMF→SMF UpdateSMContext (HO complete) → SMF→UPF N4 Modification to update the downlink FAR to the new gNB N3 TEID (an End Marker may be sent).
- Release the old resources: AMF→S UE Context Release Command (NGAP).
Message names and ordering have spec/implementation-dependent parts
The names Handover Required / Handover Request / Handover Command / Handover Notify (N2-based, NGAP), Handover Request / Handover Request Acknowledge (Xn-based, XnAP), and Path Switch Request / Acknowledge (NGAP) are based on TS 23.502 §4.9.1, TS 38.413 (NGAP), and TS 38.423 (XnAP). However, the fine step-division of the preparation/execution phases, the exact operation names for the SMF/UPF coordination (UpdateSMContext, etc.) / their counts / optional steps, the presence and timing of UPF relocation, and the handling of data forwarding and End Markers differ by version, configuration, and implementation, and some are to be confirmed. In particular, the internal sequence of N2-based preparation/execution is a simplification of the multiple steps of TS 23.502 §4.9.1.3.
Reference: TS 23.502 §4.9.1 (Handover procedures. Xn-based around §4.9.1.2, N2-based around §4.9.1.3. The fine-grained section numbers are to be confirmed), TS 38.413 (NGAP: Handover-family / Path Switch), TS 38.423 (XnAP: Handover-family).
Signal Flow¶
The key Messages / service operations organized in a table. The IEs are made consistent with the Message Dictionary.
| Message / Operation | Protocol | Source→Destination | Purpose | Key IEs (rough) | Result |
|---|---|---|---|---|---|
| Handover Request | XnAP | Source gNB→Target gNB | HO preparation request of Xn-based | UE context, PDU Session/QoS Flow info | The Target prepares resources |
| Handover Request Acknowledge | XnAP | Target gNB→Source gNB | Consent that preparation is complete | prepared resources, Target N3 info | Proceed to radio-side HO execution |
| Path Switch Request | NGAP | Target gNB→AMF | Request for the N3 downlink path switch after Xn-based completion | new gNB N3 TEID/address, PDU Session ID | The AMF bridges to the SMF |
| Path Switch Request Acknowledge | NGAP | AMF→Target gNB | Response that the path switch is complete | updated U-Plane info | The downlink N3 is finalized to the new gNB |
| Handover Required | NGAP | Source gNB→AMF | HO mediation request of N2-based | Target gNB identification, HO type | The AMF starts the preparation phase |
| Handover Request | NGAP | AMF→Target gNB | Accept request of N2-based | UE context, PDU Session info | The Target prepares to accept |
| Handover Request Acknowledge | NGAP | Target gNB→AMF | Accept preparation complete | Target N3 TEID/address | The AMF proceeds to the execution phase |
| Handover Command | NGAP | AMF→Source gNB | HO execution instruction | information needed for execution | The Source instructs the UE to execute |
| Handover Notify | NGAP | Target gNB→AMF | Switch completion notification | UE arrival notification | Finalizes the N3 switch |
| Nsmf_PDUSession_UpdateSMContext | SBI (HTTP/2) | AMF→SMF | SMF notification for HO/path switch | new gNB N3 info, PDU Session ID | The SMF triggers the N4 update |
| N4 Session Modification Request | PFCP | SMF→UPF | Update the downlink FAR to the new gNB N3 TEID | new gNB N3 TEID (FAR update) | The downlink N3 is switched to the new gNB |
| UE Context Release (Command) | XnAP / NGAP | (Src⇔Tgt) / AMF→Source gNB | Release the old gNB resources | UE identification | The old-side resources are released |
For the detailed IEs and reference specs of each Message, see the Message Dictionary (the individual IE names of the Handover-family / Path Switch are version dependent and some are to be confirmed).
State Machine¶
The state picture during a handover is conceptualized from the perspective of the UE's connection (CM: Connection Management) and from the perspective of the progress of the N2 HO procedure (basis: TS 23.501 §5.3 (CM states) / TS 23.502 §4.9.1 (HO procedures). Some of the state names are conceptual expressions for understanding and are to be confirmed).
stateDiagram-v2
[*] --> CONNECTED_SOURCE
CONNECTED_SOURCE --> HO_PREPARATION: HO initiation (radio quality degradation)
HO_PREPARATION --> HO_EXECUTION: Target preparation complete (Ack / Command)
HO_EXECUTION --> PATH_SWITCHING: UE switch to Target complete
PATH_SWITCHING --> CONNECTED_TARGET: N3 downlink path switch complete (Path Switch Ack / N4 update)
HO_PREPARATION --> CONNECTED_SOURCE: preparation failure (HO abort)
HO_EXECUTION --> CONNECTED_SOURCE: execution failure / fallback
CONNECTED_TARGET --> [*]
- CONNECTED_SOURCE — connected to the Source gNB and in data communication (CM-CONNECTED).
- HO_PREPARATION — HO in preparation (Xn-based: Handover Request/Ack; N2-based: Handover Required→Request/Ack). Returns to Source on preparation failure.
- HO_EXECUTION — radio-side HO in execution (RRC switch. outline / out of scope). May fall back on failure.
- PATH_SWITCHING — core-side N3 downlink path switch in progress (Path Switch / N4 Modification).
- CONNECTED_TARGET — switch to the Target gNB complete. Communication continues.
State names are conceptual expressions, to be confirmed
The state names in the diagram above (HO_PREPARATION, etc.) are concepts for understanding. They do not correspond one-to-one with the strict state machines in the 3GPP spec (the procedure states of NGAP/XnAP, the UE's CM/RM states), and some of the state names and transition triggers are to be confirmed. Note that they are a concept at a different layer from the CM states (IDLE/CONNECTED, TS 23.501 §5.3).
Packet Analysis (Wireshark)¶
Because Inter-gNB Handover spans N2 (NGAP) / Xn (XnAP) / N3 (GTP-U), you use different filters per segment.
Key Display Filters¶
| Filter | Meaning | Segment observed |
|---|---|---|
ngap |
NGAP messages in general (Handover-family / Path Switch) | N2 |
xnap |
XnAP messages in general (HO preparation/execution of Xn-based) | Xn |
gtp |
GTP-U (the N3 user plane. TEID changes before and after the path switch) | N3 |
sctp.port == 38412 |
The SCTP port of N2 (NGAP) | N2 |
pfcp |
PFCP (the UPF update on N4) | N4 |
Specific values such as procedureCode are environment dependent and to be confirmed
The ngap.procedureCode values of the NGAP Handover-family / Path Switch, the XnAP xnap procedure codes, and the various NAS/GTP-U numeric values are based on 3GPP's assignments, but how they are displayed and matched may differ depending on the Wireshark version and dissector implementation. Treat the specific numbers as to be confirmed, and on real equipment it is more reliable to check them in the GUI's protocol hierarchy display (the procedureCode name). This page does not assert fictitious numbers.
Points to note when decoding (key points)¶
- NGAP Handover-family procedureCode — Handover Required / Request / Command / Notify (N2-based). Identify the message type by the procedureCode name.
- NGAP Path Switch Request / Acknowledge — the key messages of the N3 downlink path switch that reach the core after an Xn-based completion.
- XnAP Handover procedure — the direct coordination between gNBs of Xn-based (Handover Request / Acknowledge). Observable only when you can capture the Xn segment.
- TEID changes — the way the destination TEID/address of the downlink tunnel of N3 (GTP-U) switches from Source gNB → Target gNB. Comparing
gtp.teidjust before and after the switch lets you observe the effect of the path switch. The End Marker also lets you confirm the end of the old path.
The structure in which information nests inside NGAP¶
The NGAP Handover-family messages carry UE context and PDU Session/QoS Flow information nested inside. In Path Switch, the new gNB's U-Plane (N3 TEID) information is included.
NGAP-PDU
└─ HandoverRequired / PathSwitchRequest, etc.
└─ PDU Session Resource (QoS Flow / N3 TEID info)
└─ (the old and new gNB's U-Plane transport info)
Actual pcaps are environment dependent (implementation dependent)
The filters and IE names on this page are guidelines for analysis. The Xn (XnAP) segment and N4 (PFCP)/N3 (GTP-U) may not be visible depending on the capture point. If you build a testbed combining Open5GS or free5GC with multiple gNBs (or gNB simulators), you can actually observe the Path Switch and the N3 TEID changes (implementation dependent).
Configuration¶
The structural-level key points of the configuration for making a handover work. Specific values and vendor-specific details (Cisco, etc.) are implementation dependent, and no fictitious values are written here. Much of the HO preparation, execution decision, and Xn neighbor relations are radio access side (gNB) configuration, and the core (5GC) side configuration is limited.
On the gNB side (radio access / out of scope, but key points only)¶
- Xn neighbor relations — with which neighboring gNBs to set up an Xn (the premise of Xn-based HO). For a counterpart with no Xn, it falls back to N2-based.
- Measurement / HO decision parameters — thresholds and hysteresis for neighbor cell measurements, etc. (radio-side, details out of scope).
Xn/HO decisions are radio-side configuration (out of scope for this site)
The Xn neighbor configuration and the HO initiation thresholds are configuration on the gNB (radio access) side, and cannot be completed with a core implementation alone such as Open5GS / free5GC. They depend on the configuration of a radio-side simulator/real equipment (implementation dependent / out of scope).
On the core (AMF/SMF/UPF) side¶
- AMF — the N2 (NGAP) must be established, and it must be able to process the Handover-family / Path Switch procedures. It must accommodate multiple gNBs and hold the context of the target UE.
- SMF/UPF — the PDU Session must be established, the N4 (PFCP) association must be established, and the configuration must be able to update the destination of the downlink FAR (the gNB-side N3 TEID).
- UPF relocation (when needed in N2-based) — if switching to a new UPF, the SMF's UPF selection and the handling between the old and new UPF depend on the configuration.
Specific values and vendor-specific details are implementation dependent
The configuration key names, hierarchy, and mandatory items differ across Open5GS / free5GC / commercial vendors (Cisco, etc.). The above are structural-level key points; check the actual key names and values in each implementation's documentation (implementation dependent). No fictitious configuration values are written.
Trouble Shooting¶
Isolating typical handover failures. For the details of Cause values, see the Cause Dictionary.
| Symptom | Presumed cause | What to check | Related logs/Packets | Direction of remedy |
|---|---|---|---|---|
| (a) HO preparation failure (the Target cannot accept) | Resource shortage at the Target gNB, Xn not established, context transfer failure | Success/failure of Xn (XnAP) / N2 (NGAP) Handover Request/Ack, resources at the Target | XnAP/NGAP Handover Request responses, gNB/AMF logs | Check the Xn neighbor configuration, check the Target's capacity, check the fallback to N2-based |
| (b) Path Switch failure (the downlink path does not switch) | The Path Switch Request does not reach the AMF/SMF/UPF, N4 update failure | NGAP Path Switch Request/Ack, Nsmf/UpdateSMContext, N4 Modification | NGAP Path Switch, PFCP (pfcp), AMF/SMF/UPF logs | Check the reachability of AMF→SMF→UPF coordination, check success/failure of the downlink FAR update |
| (c) Large data loss / packet interruption | Data forwarding not performed, End Marker not processed, switch timing inconsistency | Xn/N3 forwarding, End Marker, TEID before and after the switch | GTP-U (gtp) gaps, End Marker, UPF counters | Check the forwarding configuration, check the timing of the switch sequence |
| (d) Downlink data keeps arriving at the old gNB | The UPF's downlink FAR is still the old gNB N3 TEID | The downlink FAR update via N4 Modification, the UPF's forwarding destination | PFCP Session Modification, the destination TEID of GTP-U | Check completion of the N4 Session Modification, check SMF→UPF coordination |
Comparison with EPC¶
A comparison so that those experienced with 4G (EPC) can bridge to 5G's handover. 4G also has two types — "direct between base stations" and "core-mediated" — and 5G is a design that maps these to Xn / N2.
| Aspect | 4G / EPC | 5G / 5GC |
|---|---|---|
| Direct HO between base stations | X2-based Handover (X2AP, TS 36.423) | Xn-based Handover (XnAP, TS 38.423) |
| Core-mediated HO | S1-based Handover (S1AP, TS 36.413) | N2-based Handover (NGAP, TS 38.413) |
| Inter-base-station IF | X2 (eNB⇔eNB) | Xn (gNB⇔gNB) |
| Core control NF | MME | AMF |
| Notification of U-Plane switch | Path Switch Request (eNB→MME, after X2-based completion) | Path Switch Request (gNB→AMF, after Xn-based completion) |
| U-Plane forwarding | GTP-U (S1-U/S5, etc.) | GTP-U (N3/N9) |
| Session/QoS unit | EPS bearer | PDU Session / QoS Flow |
The way of thinking is continuous from 4G; the names and separated design have evolved
The dichotomy of "coordinate directly with the neighboring base station (X2/Xn)" versus "coordinate via the core (S1/N2)" is continuous from 4G. 5G's main evolution is the naming (X2→Xn, S1→N2, MME→AMF) and the fact that control (AMF), session management (SMF), and forwarding (UPF) are separated, so that the N3 path switch is done through SMF/UPF coordination (N4/PFCP). The idea of a Path Switch Request is carried over as-is from 4G (X2 HO).
Release differences¶
The main topics related to handover. Uncertain items are marked to be confirmed and not asserted.
- Rel-15 — the basics of 5GC's core handover (Xn-based / N2-based Inter-gNB HO, Path Switch, N3 path switch) were established.
- Rel-16 — said to be the generation in which mobility enhancements such as Conditional Handover (CHO) were introduced (the extent to which they were woven into the HO procedure itself / core involvement is to be confirmed). CHO is a mechanism that prepares multiple Target candidates in advance and has the UE execute autonomously when a condition is met, thereby reducing HO failures (call drops).
- Rel-17 / Rel-18 (5G-Advanced) — further extensions of mobility continue (the specific differences to the HO procedure are to be confirmed).
Release differences are to be confirmed
Exactly which features were woven into the "handover procedure itself," and to what extent, in each Release must be checked against the version differences of the relevant TS individually. In particular, the positioning of CHO in Rel-16 and the scope of its impact on the core (N3 path switch) are an overview, and the specific items are to be confirmed.
3GPP Specification¶
| Spec | Section | Content |
|---|---|---|
| TS 23.502 | §4.9.1 | Handover procedures (Xn-based around §4.9.1.2 / N2-based around §4.9.1.3. The basis for this chapter's Call Flow. The fine-grained section numbers are to be confirmed) |
| TS 38.413 | (various NGAP sections) | NGAP (Handover Required/Request/Command/Notify, Path Switch Request/Ack. Individual section numbers to be confirmed) |
| TS 38.423 | (various XnAP sections) | XnAP (the Handover procedure of Xn-based. Individual section numbers to be confirmed) |
| TS 38.300 | (HO overview section) | The overall NR architecture / handover overview (the radio-side positioning. Section number to be confirmed) |
| TS 23.501 | §4 / §5.3 | System architecture and reference points (N2/N3/Xn) / CM and RM states (some section numbers to be confirmed) |
| TS 29.244 | — | PFCP (N4: the N3 path switch via downlink FAR update) |
| TS 29.281 | — | GTP-U (the N3 user plane, TEID/End Marker) |
Handling of section numbers
TS 23.502 §4.9.1 is referenced as the backbone of this chapter's Call Flow. The fine-grained section numbers of Xn-based / N2-based (§4.9.1.2 / §4.9.1.3, etc.), the individual section numbers of TS 38.413/38.423/38.300, and the relevant section number of TS 23.501 may differ by version, and some are marked to be confirmed.
FAQ¶
Q1. What happens if there is no Xn?
If there is no Xn between the Source and Target gNB, the gNBs cannot coordinate directly, so an N2-based Handover is used. In this case the AMF mediates the preparation/execution of the Handover via N2 (Handover Required → Handover Request/Ack → Handover Command). The procedure is heavier than Xn-based, but the handover succeeds even without an Xn.
Q2. Does the IP address change in a handover?
In most cases it does not change. This is because the anchor UPF (PDU Session Anchor) that terminates the UE's IP is maintained, and only the segment between that UPF and the gNB (N3) is re-pointed to the new gNB. Therefore TCP connections and application sessions are not broken. However, in a configuration involving UPF relocation (depending on the policy such as SSC mode), it may change (see PDU Session. The details are to be confirmed).
Q3. Is a handover truly make-before-break?
It is not fully make-before-break; it is a design that minimizes interruption. During the brief moment of the radio switch, and until the downlink path switch (Path Switch) completes, some packet delay/loss can occur. To mitigate this, data forwarding from Source→Target and the End Marker indicating the end of the old path are used. The goal is that the interruption is hard to perceive in practice (the actual performance depends on the radio and core configuration = implementation dependent).
Q4. Who requests the Path Switch, and to whom?
After an Xn-based HO completes, the Target gNB sends an NGAP Path Switch Request to the AMF. It is a request that "please point this UE's downlink path to the new me (not the old gNB)." The AMF conveys this to the SMF, and the SMF updates the UPF's downlink forwarding destination (the destination of the FAR = the new gNB N3 TEID) via N4 (PFCP). In an N2-based HO, this downlink path switch is done within the Handover procedure (after Handover Notify).
Q5. How does the involvement of the core (AMF/SMF/UPF) differ between Xn-based and N2-based?
In Xn-based, the gNBs complete the HO directly, and the core is involved only in the post-execution Path Switch (N3 downlink path switch) (lightweight). In N2-based, the AMF is involved from the preparation phase, and performs UPF relocation if needed (heavier). What both have in common is that ultimately the SMF/UPF switch the N3 downlink path to the new gNB.
Summary¶
- Handover is the procedure that switches a moving UE's connection from Source gNB → Target gNB, while preserving the session/IP, in a near-make-before-break manner. The trigger is degradation of radio quality.
- Inter-gNB HO comes in two types, depending on the presence of Xn and whether core relocation is required — Xn-based (direct between gNBs + Path Switch) and N2-based (AMF-mediated).
- From the core's perspective, the leading actors are the AMF (N2 control) and the SMF/UPF (N3 path switch). The radio (RRC) side details and the Measurement Report are out of scope for this chapter.
- Path Switch is the procedure by which, after an Xn-based completion, the Target gNB requests the AMF for a downlink path switch. AMF→SMF→UPF update the downlink FAR to the new gNB N3 TEID via N4 (PFCP) (the N3 path switch).
- If the anchor UPF is maintained, the IP is unchanged. Data forwarding / End Marker mitigate packet loss.
- Corresponding to 4G's X2-based / S1-based HO, 5G has Xn-based / N2-based. The idea of a Path Switch Request continues from 4G.
- The basis is TS 23.502 §4.9.1 / TS 38.413 (NGAP) / TS 38.423 (XnAP) / TS 38.300 / TS 23.501 (the fine-grained section numbers and some message ordering are to be confirmed).
Practice — comprehension check and exercises¶
Comprehension check¶
Q1. What is the single biggest difference between Xn-based and N2-based? (answer)
The coordinator of HO preparation/execution. In Xn-based, the Source and Target gNBs coordinate directly with Xn (XnAP), and the core is involved only in the post-execution Path Switch. In N2-based, the AMF mediates with N2 (NGAP), and the core is involved from the preparation phase (used when there is no Xn / UPF relocation is required).
Q2. Who sends the Path Switch to whom, and for what? (answer)
After an Xn-based completion, the Target gNB sends an NGAP Path Switch Request to the AMF. The purpose is to switch the N3 downlink path to the new gNB. AMF→SMF→UPF update the downlink FAR via N4.
Q3. In the N3 path switch, what is ultimately rewritten? (answer)
The UPF's destination of the downlink FAR is updated from the Source gNB's N3 TEID/address → the Target gNB's N3 TEID/address (the SMF instructs this via N4/PFCP).
Q4. What normally happens to the UE's IP address in a handover? (answer)
It does not change (when the anchor UPF is maintained). This is because the UPF that terminates the IP is maintained, and only the N3 between the gNB and the UPF is re-pointed. It may change when UPF relocation is involved (to be confirmed).
Q5. What do 4G's X2-based / S1-based HO correspond to in 5G? (answer)
X2-based → Xn-based (X2AP→XnAP), S1-based → N2-based (S1AP→NGAP). The control NF is MME→AMF. The idea of a Path Switch Request continues from 4G.
Exercises¶
Problem: Reorder the following main Xn-based Handover steps into the correct order.
A. Target gNB → AMF: Path Switch Request (NGAP)
B. Source gNB → Target gNB: Handover Request (XnAP)
C. SMF → UPF: N4 Session Modification (downlink FAR to the new gNB N3 TEID)
D. Target gNB → Source gNB: Handover Request Acknowledge (XnAP)
E. AMF → Target gNB: Path Switch Request Acknowledge (NGAP)
F. Radio-side HO execution (UE switches to the Target gNB / outline / out of scope)
G. AMF → SMF: Nsmf_PDUSession_UpdateSMContext
Answer
B → D → F → A → G → C → E
- B: Source→Target accept request (XnAP)
- D: Target→Source consent that preparation is complete (XnAP)
- F: Radio-side HO execution (out of scope / outline)
- A: Target→AMF Path Switch Request (NGAP)
- G: AMF→SMF UpdateSMContext (new gNB N3 info)
- C: SMF→UPF N4 Modification (downlink FAR update = N3 path switch)
- E: AMF→Target Path Switch Request Acknowledge (NGAP)
※ The radio-side RRC procedure (F) is an outline. Data forwarding / End Marker may be inserted optionally (implementation dependent).
Next Step¶
The next steps to deepen your understanding.
- Paging chapter (calling a CM-IDLE UE — the other pillar of mobility)
- Service Request chapter (re-establishing the U-Plane on CM-IDLE→CM-CONNECTED)
- Prerequisites for the procedure: Initial Registration / PDU Session Establishment
- Related NFs: AMF / SMF / UPF
- Related Interfaces: N2 / N3 / Xn
- Dictionaries: Message Dictionary / Timer Dictionary / Cause Dictionary / Protocol Dictionary / NF Dictionary / Interface Dictionary