---
# System prepended metadata

title: 蔡瀚興-讀書會-21/08/11

---

# 蔡瀚興-讀書會-21/08/11
## <font color="ff0000">Introduction</font>
在使用服務后，當在ECM/RRC-connected狀態或者ECM/RRC-idle狀態下使用者可能被網路或者UE去附著。



## <font color="ff0000">Cases of Detach</font>
- If the user is properly detached, GUTI, a NAS-level user ID, and the security context that he used to access the network are kept valid in the UE and the MME
- Detach can be triggered by UE or a network. Network-triggered detach is caused by either MME or HSS.

(Detach 可以分為以下幾種)

### <font color="0000ff">1) Detach Case 1: UE-initiated Detach</font>
- if UE is turned off
- if a USIM card is removed from UE
- if UE is attempting to use a non-EPS service (e.g. CS fallback, SMS, etc.)

### <font color="0000ff">2) Detach Case 2: MME-initiated Detach</font>
#### **1. Explicit Detach (MME會先通知UE)**
- for an operator’s O&M (Operation & Maintenance) purposes
- if re-authentication fails
- if it cannot provide the resources allocated to a user
#### **2. Implicit Detach (MME不會先通知UE)**
- if it is not able to communicate with a user

### <font color="0000ff">3) Detach Case 3: HSS-initiated Detach</font>
HSS can initiate detach: 
- if the user profile provisioned in HSS is changed, and thus the one saved in MME also has to be changed
- if an operator is trying to restrict access by an illegal UE (e.g. a stolen device) to its network

![](https://i.imgur.com/jdlM0EN.png)



## <font color="ff0000">UE-initiated Detach</font>
![](https://i.imgur.com/79dLkUH.png)

### <font color="0000ff">1. Detach Triggering by UE</font>
#### **(1) [UE -> MME] Detach Request**
Detach Request message的內容會根據傳遞方向有所不同，以下為UE向MME
![](https://i.imgur.com/hv0wZF0.png)
#### **(2) [UE] Handling Security and Bearer Contexts**
UE儲存current的NAS security context，GUTI和TA information，然後刪除EPS bearer context
#### **(3) [MME] Noticing Detach Intent and Handling Security Context**
在收到Detach Request message後，MME儲存user’s current NAS security context，然後確認是哪一種Detach

### <font color="0000ff">2. EPS Session Termination</font>
一旦MME感知到UE發起的detach並存儲使用者當前NAS安全上下文，請求對已經啟動EPS會話的終止。 這個請求觸發PCEF（PGW）發起EPS終止，釋放所有分配給使用者的網路/無線資源。
#### **(1) EPS Bearer Release and PCC Rule Removal**
#### **(2) S1 Signaling Connection Release**



## <font color="ff0000">MME-initiated Detach</font>
圖3顯示了MME發起的 **explicit detach** 是怎麼執行的。
![](https://i.imgur.com/0yi2Low.png)

### <font color="0000ff">1. Detach Triggering by MME</font>
If the user is in Idle state at this time, the MME performs paging to establish S1 signaling connection
#### **(1) [UE <- MME] Detach Request**
![](https://i.imgur.com/vskAFjG.png)
#### **(2) [MME] Handling Security Context**
#### **(3) [UE] Noticing Detach Intent and Handling Security and Bearer Contexts**
`在接收到MME發送的detach request后，UE獲知MME detach的意圖。 UE檢查detach的類型是否需要在detach之後重新attach。`
### <font color="0000ff">2. EPS Session Termination</font>
一旦MME存儲NAS安全上下文，MME請求PGW終止使用者的EPS會話。
#### **(1) EPS Bearer Release and PCC Rule Removal**
`通過4）~13），MME請求終止使用者EPS會話，PCEF一旦接收到請求刪除PCC規則，刪除S5承載資源。 在MME發起的detach中需要重新attach時，MME可以保存當前的UE-AMBR，在下次重新attach時UE可以更快的建立EPS承載。`
##### **14) [UE -> MME] Acknowledging Detach**
一旦接收到detach request消息，在存儲NAS安全上下文和刪除EPS承載上下文之後，UE發送detach accept消息作為detach request像愛惜的回應。
:::info
**Note：** 對於implicit detach的情況，1）14）16）步驟是跳過的。
:::
#### **(2) S1 Signaling Connection Release**



## <font color="ff0000">HSS-initiated Detach</font>
![](https://i.imgur.com/wVEDte2.png)
### <font color="0000ff">1. Detach Triggering by HSS</font>
#### **1) [MME <- HSS] Detach Request**
![](https://i.imgur.com/z6ozjQy.png)
### <font color="0000ff">2. EPS Session Termination</font>
一旦從HSS接收到Cancel Location Request （CLR） 消息，MME釋放之前分配給UE的所有資源。 這個步驟和MME發起detach的過程是一樣的，**除了在 2）中描述的額外的步驟**。

#### 2) [MME -> HSS] Responding to Detach Request
`一旦從UE接收到detach accept消息，和從SGW接收到delete session response消息，MME會發送給HSS Cancel Location Answer消息作為Cancel Location Request消息的回應。`



## <font color="ff0000">EPS Entity Information: Before/After Detach</font>
### <font color="0000ff">Before Detach</font>
![](https://i.imgur.com/ApiMOtF.png)
### <font color="0000ff">After Detach</font>
- After detach, information that can be used for the user’s fast and secured attach next time is stored in UE and MME
- All other contexts related to the user, such as NAS security context, GUTI and TAI information allocated by MME, etc., are deleted.

![](https://i.imgur.com/FN01EFn.png)
![](https://i.imgur.com/ZdRuC9o.png)

