ISDN 的 datalink 層是 Q.921,也就是 LAPD (Link Access Procedure on the D-channel),是 HDLC 的 close cousin。
在 frame 之間及閒置時送 Flag (0x7E, 01111110b),而原本 0x7E 的資料為避免和 Flag 混淆,使用了 bit stuffing 機制,也就是資料在傳送端會每遇到 5 個連續 1 會插入一個 0,接收端再移除。如果出現連續 7 個以上的 1,則視為 abort 而忽略收到的資料。LAPD 格式
| Address | Control | Information | FCS |
| 2 | 1~2 | 0~ | 2 |
LAPD 運作在 Asynchronous Balanced Mode (ABM),也就是兩端是對等的、沒有主從之分,雙向各自獨立運作。2-byte FCS 檢查資料有沒有錯誤,通常用硬體計算,以下說明省略。重送時,每個 octet 的 bit 1 先送。
Address:2-byte
| 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | octet |
| SAPI | C/R | EA 0 | 1 | |||||
| TEI | EA 1 | 2 | ||||||
- EA:Address field extension bit,0 表示有下個 byte、1 則沒有。由於固定 2-byte,所以第一個 EA 為 0,第二個 EA 為 1。
- C/R:0 表示用戶端是發出的指令及網路端的回覆,1 則表示網路端發出的指令及用戶端的回覆。
- SAPI:Service Access Point Identifier
- 0:上層是 Q.931 呼叫控制 (GR303 TMC call proc)
- 1:I.451 封包模式的呼叫控制 (GR303 EOC, TMC switching)
- 12:teleaction
- 16:X.25 level 3 封包
- 63:自己本身 Layer 2 管理
- TEI:Terminal End Indentifier,在 SAPI = 0 時
- 0~63:用於非自動指定 TEI 的設備,PRI 使用 0
- 64~126:用於自動指定 TEI 的設備
- 127:廣播給所有 Terminal Endpoints
Control 欄位包括 Q.921 的 frame type、序號等。
| Control | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | octet | |
|---|---|---|---|---|---|---|---|---|---|---|
| I Frame | N(S) | 0 | 1 | Information Frame:連線狀態正常及序號正確後往上層丟 | ||||||
| N(R) | P | 2 | ||||||||
| S Frame | 0000 | SS | 01 | 1 | Supervisory Frame:datalink 本身 supervisory 用,看 SS 2-bit | |||||
| N(R) | P/F | 2 | ||||||||
| U Frame | MMM | P/F | MM | 11 | 1 | Unnumbered Frame:Unnumbered 就是沒序號,看 MMM 及 MM 共 5-bit | ||||
P/F 在 command 是 poll,在 response 是 final。
| I | N(S) | 0 | I-Frame,有 Information 欄位 | ||||||
| S | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | RR (Receive Ready):I Frame 的 acknowledgement,可以再收。 |
| 0 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | RNR:Indicates a state of temporary occupation of station (e.g., window full) | |
| 0 | 0 | 0 | 0 | 1 | 0 | 0 | 1 | REJ:重傳給定的序號之後 | |
| U | 0 | 0 | 0 | x | 0 | 0 | 1 | 1 | UI (Unnumbered Information),有 Information 欄位 => Q.931。P/F = 0 [Q.921 5.1.1] |
| 0 | 1 | 0 | P | 0 | 0 | 1 | 1 | DISC (Disconnect command) | |
| 0 | 1 | 1 | F | 0 | 0 | 1 | 1 | UA (Unnumbered Acknowledgement response) | |
| 1 | 0 | 0 | Fx | 0 | 1 | 1 | 1 | FRMR (Framer reject response) | |
| 0 | 0 | 0 | F | 1 | 1 | 1 | 1 | DM (Disconnected Mode response) | |
| 1 | 0 | 1 | P/F | 1 | 1 | 1 | 1 | XID (eXchange IDentification):不支援? | |
| 0 | 1 | 1 | P | 1 | 1 | 1 | 1 | SABME (Set Asynchronous Balanced Mode Extended):command。在連線初始化時決定 window 大小,最大是 128,也就是可以有 128 個 frame 未完成 ACK。由 Address 的 C/R 可看出遠端是 Network 端還是 User 端 | |
window size:modulo 8 待 acknowledge 的 outstanding frames
extended window size:modulo 128,使用不同的 link initialization frame type,frame type 名稱再加上 E,例如 SABM 變成 SABME。
範例:02 01 7f
- 02 01 (Address):C/R = 1 = network command 或 user response,SAPI = 0 = Q.931,TEI = 0 = PRI or PTP
- 7F (Control):U frame SABME,P/F = 1
範例:FC FF 03 0F 5D 72 01 FF F7 6E:TEI Request
- FC FF (Address):C/R = 0 = user command 或 network response,SAPI = 63 = Layer 2 Management,TEI = 127 = Broadcast connection for all TEs
- 03 (Control):UI,P/F = 0
- 0F (Management entity identifier):固定為 0x0F。
- 5D 72 (Ri):Request number,一個亂數
- 01 (message type = REQUEST):請求 64 ~ 126 的 TEI,成功的話回覆 2 = ASSIGNED,失敗的話回覆 3 = DENIED。另外還有 4 = CHECK_REQUEST、5 = CHECK_RESPONSE、6 = REMOVE、7 = VERIFY。
- FF (Ai 及 E-bit):bit 1 為 E-bit,Ai 欄位的 externsion。剩下 7-bit 為 Ai = Action Indicator = 127 = 任何 TEI。
- F7 6E (FCS)
沒其他訊息時,每 10 秒送 RR 等回應。沒回應,每秒重送最多共四次,之後改送 SABME,也是每秒重送,直到收到 UA。
MDL-ERROR() 錯誤表
| Error Code | Error Condition | Action | Error Type |
|---|---|---|---|
| A | Supervisory (F=1) | Error Log | Receipt of unsolicited response |
| B | DM (F=1) | Error Log | Receipt of unsolicited response |
| C | UA (F=1) | TEI removal procedure or TEI check procedure, then if TEI: free: remove TEI | Receipt of unsolicited response |
| D | UA (F=0) | TEI removal procedure or TEI check procedure, then if TEI: free: remove TEI | Receipt of unsolicited response |
| E | DM (F=0) | Error Log | Receipt of unsolicited response |
| F | SABME | Error Log | Peer initiated re-establish. |
| G | SABME | TEI check procedure, then if TEI: free: remove TEI | Unsuccessful retransmission (N200 times) |
| H | DISC | TEI check procedure, then if TEI: free: remove TEI | Unsuccessful retransmission (N200 times) |
| I | Status Enquiry | Error Log | Unsuccessful retransmission (N200 times) |
| J | N(R) error | Error Log | Other |
| K | Receipt of FRMR | Error Log | Other |
| L | Receipt of frame with undefined control field | Error Log | Other |
| M | Receipt of I field not permitted | Error Log | Other |
| N | Receipt of frame with wrong size | Error Log | Other |
| O | N201 error | Error Log | Other |
參考
- Q.921 ISDN user-network interface – Data link layer specification
- http://www.freesoft.org/CIE/Topics/125.htm
- ISDN Q.921-User Adaptation (IUA):透過 IP 傳送 ISDN Q.921 訊息
沒有留言:
張貼留言