# 陳毅 - 讀書會 - 21/08/11
:::info
- [x] 閱讀 Netmanias-12-EMM Procedure 2. Detach
:::
本篇文章主要介紹了 LTE 的 Detach Procedure。
## Cases of Detach
通過 Initial attach procedures 會建立起 EPS 會話與預設的 EPS Bearer 供使用者連線至 LTE 服務。
在某些情況下,使用者會在服務完成時 Detach,亦或是被 Network 端主動 Detach。
當 Detach 發生,所有分配給 EPS Session/Bearer 的網路與無線資源都會被回收。
同時,EMM state 也會由 Registered 轉為 De-Registered。
此外,如果 User 適當的 Detach,GUTI, NAS-Level user ID 以及 security context 都可以被有效保留供使用者下次連線時使用。
說了這麼多,就來看看 Detach 有哪幾類吧!
### Detach Case 1: UE-initiated Detach
在這些情況下,UE 可以發起 detach:
- UE 關機
- USIM 被拔除
- UE 嘗試使用 non-EPS service
### Detach Case 2: MME-initiated Detach
由 MME 所發起的 Detach 可分為顯性 (explicit) 和隱性 (implicit)。
#### 1. Explicit Detach
- for an operator's O&M (Operation & Maintenance) purposes
- if re-authentication fails
- if it connot provide the resources allocated to a user
#### 2. Implicit Detach
- if it is not able to communicate with a user because of poor radio link quality (e.g. radio link failure)
### Detach Case 3: HSS-initiated Detach
在這些情況下,HSS 可以發起 detach:
- if the user profile provisioned in HSS is changed, and thus the one saved in MME alse has to be changed
- if an operator is trying to restrict access by an illegal UE (e.g. stolen device) to its network
After detach, the default EPS bearer and all the signaling connections are released, and the user enters EMM-Deregistered, ECM-Idle and RRC-Idle state.

## UE-initiated Detach

## MME-initiated Detach

補充:
1. [UE <- MME] Detach Request
Detach Request 的格式如下:

## HSS-initiated Detach

補充:
1. [MME <- HSS] Detach Request
The HSS and the MME communicate with each other over S6a interface using Diameter protocol. The HSS requests the MME for detach of the user by sending a Cancel Location Request (CLR) message with the following parameters:

## EPS Entity Information: Before/After Detach
### Before Detach

### After Detach
