LTE attach流程及apn作用

在通過AT+CGDCONT=1,"IP","ctnet"設置pdp時發現,無論apn設置成什麼,都可正常激活網絡,並進行撥號上網,

 現分析LTE網絡附着流程,具體的消息流過程還是按照3GPP 23.401。針對attach過程的某些流程和具體消息展開解釋。並給出相對應的規範出處。

     

 

 

1. 首先第一條initial Attach 消息: 從具體的wireshark的包來看, 這個intial attach包含了兩個事件, attach Req+PDN connectivity Req

    一個是EMM 層面的消息,一個是ESM 層面的消息。

    Attach Req 無需多講,這是終端登陸網絡側所必須的過程。而PDN Conncetivity Req的出現是爲了建立default Bearer。

   在NAS 規範24.301 6.5.1.1 中就是很明確的提出在attach req中所包含的PDN Con Req 是爲了最初的default bearer建立所發(這個獨立於可能還會和其他APN 所建立的default bearer),在這個PDN Connect Req裏UE 側不需要提交APN的地址,換句話講, 這個initial default bearer所連向的APN 應該由網絡側來決定。終端只提供了UE 所支持的IP地址類型。 

   (但是也有例外,雖然規範裏要求是這樣,但是也有觀點認爲,UE提供了APN 更有利於UE 對業務需求,例如UE想直接連入企業網,那得需要UE 提供APN,但是這個APN的提供得在鑑權和NAS安全關聯建立之後,因爲default APN的提供應該估計應該根據實際運營商的業務實現或者客戶需求來做)

      When the PDN CONNECTIVITY REQUEST message is sent together with an ATTACH REQUEST message, the UE
shall not include the APN.

 

    而把PDN Connectivity Req和Attach Req綁定的考慮出自於 3GPP2 24.301, 4.2節,LTE 中實現了the ip of UE alwanys online的想法。

  

a. 具體來看這個消息體。 在這條消息中,在S1AP 層面上,暫時還只有eNB-UE-S1AP-ID的value,網絡側的S1AP 的 ID 需要等MME 來回復。

     

 

 

b. 在NAS 層(如圖2所示):其中 EPS mobility message 的地方出現了兩次。 ESM PDN Connet Req的消息被包含在EMM 消息中,通過ESM Message container這個IE ,EMM 包含了ESM的內容。

  

   EPS Mobility Message 出現兩次的原因是: 這條消息採取了24.301中 9.1 節 所列出的消息編碼格式----- a security protected NAS message. 如圖3 所示:

  隨後具體到每條NAS 的Message, NAS message 本身又有Protocol discriminator 和 Security header type 的IEI. 所以造成 EPS Mobility managerment message 這個header出現了兩次的情況。 (但是爲什麼要出現兩次呢? NAS 具體的Message 的Security header不夠麼? 爲什麼還要再加一層Security header上去呢?)

  

  那麼如果UE 側已經有一個valid NAS security context  存在了,那麼UE 需要在attach Req 中置上intergrity protect。 對應於3GPP 24301:

 

1) Except for the case described in item 3 below, the UE shall transmit the initial NAS message integrity protected with the current EPS security context, but unciphered. The UE shall include the eKSI indicating the current EPS security context value in the initial NAS message. The MME shall check whether the eKSI included in the initial

NAS message belongs to an EPS security context available in the MME, and shall verify the MAC of the NAS message. If the verification is successful, the MME may re-establish the secure exchange of NAS messages:

 

- by replying with a NAS message that is integrity protected and ciphered using the current EPS security context. From this time onward, all NAS messages exchanged between the UE and the MME are sent integrity protected and except for the messages specified in subclause 4.4.5, all NAS messages exchanged between the UE and the MME are sent ciphered; or

 

- by initiating a security mode control procedure. This can be used by the MME to take a non-current EPS security context into use or to modify the current EPS security context by selecting new NAS security algorithms;

 

而一個Scurity Context 是通過NAS COUNT 來標示的。 NAS Count對應於NAS Header呢,就是Sequence Number。 MME 通過Sequence Number來找到相對應的Security Context (如果存在的話), 然後再使用 Message Authentication Code來完成檢查.

   

                                   圖3

 

c. 隨後再打開 ESM Message Container 這個IEI。

   可以看到:

 

在這段消息體內,值得注意的是這幾個header: EPS bearer identity , Procedure transaction id。 

copy from 24.007:

The EPS bearer identity is used to identify a message flow。 這個 NAS 中的EPS bearer id 和隨後在GTP-C 上建立的Bearer Context ID 相互對應。

Procedure transaction:  A L3 protocol may define that the second octet of a standard L3 message of the protocol contains the proceduretransaction identity (PTI). The PTI allows distinguishing up to 254 different bi-directional messages flows for a given PD and a given SAP. Such a message flow is called a transaction. The procedure transaction identity is released when the procedure is completed.

對於這兩個heder在LTE 中的運用,24.301 又給出了詳細的描述。 參看 6.3.2.

並且通過24.007 中的routing model來看, PTI+PD 是EMM 用來routing消息給ESM 的。 而一旦bearer context 建立完,ESM 能夠分配出context id後,後續的消息就不需要PTI了。

例如: PDN Context Req (from UE to MME)  中需要有PTI, EPS default Bearer req (from MME to UE) 需要有(PTI,EBI) , 隨後的 EPS default bearer Resp (from UE to MME)只需要有EBI了,就不需要PTI了。

  在這個過程中,EMM層需要爲ESM 提供一個routing服務,EMM 通過PTI來區分向ESM 建立不同的transcription, MME 收到req之後,回出的 Default Bearer Req 中,也需要PTI,是因爲它需要向UE 標明 它是爲了之前那條ESM transaction分配了EBI, UE 收到之後,雙方在ESM 上達成了統一,就不需要PTI的配合了,因爲Bearer ID 的唯一性就足夠EMM 在隨後的過程中,將ESM的消息路由給相對應的EMS layer來處理。

   這個default Beraer的的建立在MME 被pending在那邊,因爲要完成EMM的過程之後, MME 纔會去處理ESM 的狀態機。NAS 的PTI,EBI的再次出現要等到MME-SGW-PGW之間的bearer context 建立完成後。

2) 隨後New MME 向 UE 要求獲取IMSI, MME 可以根據IMSI 向 HSS 要求鑑權數據以及隨後的用戶數據。但這個時候因爲security mode還未建立,所以NAS 層面的消息是

Plain NAS message, not security protected, 應該也算危險的地方。

 

3) MME 收到IMSI 之後,和HSS 通過diameter 的AIR/AIA 完成鑑權五元組的交互。

4) MME 向UE 發送 RAND ,AUTN value, 要求UE上報鑑權數據。

5) MME 收到 NAS Authentication Resp,鑑權通過之後, 開始security mode 的建立。

      按照 24.301 中4.4.2.4 的規定,

      The SECURITY MODE COMMAND message sent by the MME includes the eKSI of the new EPS security context to be used. The MME shall send the SECURITY MODE COMMAND message integrity protected with the new EPS security context, but unciphered. When the UE responds with a SECURITY MODE COMPLETE, it shall send the message integrity protected and ciphered with the new EPS security context.

     MME 下發的Security Command 只是integrity protected and unciphered. 但是UE 隨後的Security Complete 消息應該是被cipher過的。

      但是如果MME 對於cipher的規則選擇的是“ null ciphering alogrithm“ EEA0, 雖然隨後UE 和MME 之間的NAS 沒有經過cipher,但是在security header也必須置上ciphered。

     (參見24.301 - 4.4.5, ” If the "null ciphering algorithm" EEA0 has been selected as a ciphering algorithm, the NAS messages with the security header indicating ciphering are regarded as ciphered”)

      具體見圖:(還是不理解爲啥要插兩層EMM 的 Security header 進去, 第一層的Security header 可以理解, 但是第二層對於具體的EMM ,爲啥還需要一個security header呢,直接被包含在第一層不行麼?)

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章