2016年1月30日 星期六

LAPD

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 格式
AddressControlInformationFCS
21~20~2

LAPD 運作在 Asynchronous Balanced Mode (ABM),也就是兩端是對等的、沒有主從之分,雙向各自獨立運作。2-byte FCS 檢查資料有沒有錯誤,通常用硬體計算,以下說明省略。重送時,每個 octet 的 bit 1 先送。

Address:2-byte
87654321octet
SAPIC/REA
0
1
TEIEA
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
PRI 和點對點 BRI 使用 SAPI 0 TEI 0,點對多點 BRI 使用 SAPI 63 TEI 127。

Control 欄位包括 Q.921 的 frame type、序號等。
Control87654321octet
I FrameN(S)01Information Frame:連線狀態正常及序號正確後往上層丟
N(R)P2

S Frame0000SS011Supervisory Frame:datalink 本身 supervisory 用,看 SS 2-bit
N(R)P/F2

U FrameMMMP/FMM111Unnumbered Frame:Unnumbered 就是沒序號,看 MMM 及 MM 共 5-bit

P/F 在 command 是 poll,在 response 是 final。

IN(S)0I-Frame,有 Information 欄位
S00000001RR (Receive Ready):I Frame 的 acknowledgement,可以再收。
00000101RNR:Indicates a state of temporary occupation of station (e.g., window full)
00001001REJ:重傳給定的序號之後
U000x0011UI (Unnumbered Information),有 Information 欄位 => Q.931。P/F = 0 [Q.921 5.1.1]
010P0011DISC (Disconnect command)
011F0011UA (Unnumbered Acknowledgement response)
100Fx0111FRMR (Framer reject response)
000F1111DM (Disconnected Mode response)
101P/F1111XID (eXchange IDentification):不支援?
011P1111SABME (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
範例:02 01 01 03:RR for Q.931

範例: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 CodeError ConditionActionError Type
ASupervisory (F=1)Error LogReceipt of unsolicited response
BDM (F=1)Error LogReceipt of unsolicited response
CUA (F=1)TEI removal procedure or 
TEI check procedure, then if TEI:

free: remove TEI
single: no action
multiple: TEI removal procedure

Receipt of unsolicited response
DUA (F=0)TEI removal procedure or 
TEI check procedure, then if TEI:

free: remove TEI
single: no action
multiple: TEI removal procedure

Receipt of unsolicited response
EDM (F=0)Error LogReceipt of unsolicited response
FSABMEError LogPeer initiated re-establish.
GSABMETEI check procedure, then if TEI:

free: remove TEI
single: no action
multiple: TEI removal procedure

Unsuccessful retransmission (N200 times)
HDISCTEI check procedure, then if TEI:

free: remove TEI
single: no action
multiple: TEI removal procedure

Unsuccessful retransmission (N200 times)
IStatus EnquiryError LogUnsuccessful retransmission (N200 times)
JN(R) errorError LogOther
KReceipt of FRMRError LogOther
LReceipt of frame with undefined control fieldError LogOther
MReceipt of I field not permittedError LogOther
NReceipt of frame with wrong sizeError LogOther
ON201 errorError LogOther

參考

  1. Q.921 ISDN user-network interface – Data link layer specification
  2. http://www.freesoft.org/CIE/Topics/125.htm
  • ISDN Q.921-User Adaptation (IUA):透過 IP 傳送 ISDN Q.921 訊息

沒有留言:

張貼留言

SIP header Via

所有 SIP 訊息 都要有 Via,縮寫 v。一開始的 UAC 和後續途經的每個 proxy 都會疊加一個 Via 放傳送的位址,依序作為回應的路徑。 格式 sent-protocol sent-by [ ;branch= branch ][ ; 參數 ...] s...