UA (User Agent) 分成 User Agent Client (UAC) 和 User Agent Server (UAS)。UAC 產生 SIP 請求,而 UAS 回應 SIP 請求。UAC 因某個事件 (如用戶按按鍵、 PSTN 上的一個訊號) 產生 SIP 請求,然後等候 UAS 的處理和回應。UAS 接受請求後,基於用戶輸入、外部 stimulus、程式執行結果、或其它機制,產生回應給 UAC。
當 UAC 傳送請求,請求訊息經過一些 proxy server 來轉送到 UAS。當 UAS 產生回應,會轉送到 UAC。
UAC 和 UAS 處理的程序主要取決於兩個因素:
- 是否請求或回應是在 dialog 內或 dialog 外。
- 請求的 Method。
UAC 行為
產生請求
所有 SIP 請求至少必須包含請求行和 6 種信頭:
- 請求行 (Method、Request-URI 和 SIP version)
- Request-URI:一般設成 To URI,但未必,如 REGISTER。 事先存在的 Route Set (如 Outbound Proxy) 會影響 Request-URI。
- To
- 邏輯上的接受者,但未必是最終的接受者。
- 至少要支援 sip: URI,可用 sips:、tel:、或其它 URI。
- 允許 display name
- To tag:此時 Dialog 未建立,所以不能有。
- From
- CSeq
- Call-ID
- Max-Forward
- Via
這些信頭欄位提供訊息 routing 服務所需要的基本資料,包括位址、順序、回應怎麼走、propagation 限制、 以及 transaction 識別。其它信頭欄位視 Method 需要增加。可以包含 MIME 編碼的訊息體,需要加 Content-Type 等信頭欄位來表示是什麼內容。
8 Contact
9 Supported and Require
傳送請求
Sending the Request處理回應
Processing Responses1 Transaction Layer Errors
2 Unrecognized Responses
3 Vias
4 Processing 3xx Responses
5 Processing 4xx Responses
UAS Behavior
請求認證過 (或跳過認證) 後,UAS 應該按照下列步驟來處理請求:- Method Inspection:檢查請求的 Method 支援繼續處理。不支援則回 405 (Method Not Allowed) (產生方式見 6),並加 Allow 信頭 列出支援的 Method。
- Header Inspection:不認得的信頭跳過,忽略請求處理不是必要的格式錯誤信頭。
- To and Request-URI:To 是 From 指定的原始接受者,但未必是處理的 UAS,由於 call forwarding 或其它 Proxy 操作,UAS 可以選擇接受,即使 URI scheme 不認得。否則回應 403 Forbidden、404 Not Found 或 416 Unsupported URI Scheme 來拒絕請求。 Typically, a UA that 使用 REGISTER 來 bind its address-of-record 到 a specific contact address, will see requests whose Request-URI equals that contact address. Other potential sources of received Request-URIs include the Contact header fields of requests and responses sent by the UA that establish or refresh dialogs.
- Merged Requests
- Require
- Content Processing
- Applying Extensions:UAS 只能對 Supported 有列的 SIP 擴充是否採用產生回應,在回應的 Require 放採用的 option-tag。如果一定要用某個不支援的 SIP 擴充,回 421 Extension Required 用 Require 表示需要的 SIP 擴充,但不建議,因為可能會破壞互通性。
- Processing the Request:針對不同 Method 有不同處理。
- Generating the Response
- Sending a Provisional Response
- Headers and Tags
沒有留言:
張貼留言