星期日, 4月 04, 2021

SIP Session Timers

RFC4028 提供 SIP session expiration 機制,週期送 re-INVITE 或 UPDATE 作為 session 持續的請求。雖然 UA 可以知道,但 Proxy 不知道 session 是否還活著,例如 BYE 沒收到。 session timer,週期經過協調,如在週期內沒收到 refresh,視為 session 已經結束,Proxy 或 UA 可以清除狀態,結束 NAT session。

新增

  • Option Tag:timer
    • 支援的 UAC 必須放 Supported: timer,即使目前 session 不使用,或者 Required 或 Proxy-Required 已經有了。
    • UAC 並不建議放 Required 或 Proxy-Required,因為只要 UAC 支援就能運作。
  • Session-Expires (x): session 逾時的秒數,不能低於 Min-SE。只放在 INVITE 和 UPDATE,或者其 200 回應。建議 1800 秒 (30 分),95% 的通話低於此值。
    • UAC 一開始可以加 refresher=uac,但就不能協調決定。
  • Min-SE:session 逾時最短的秒數,沒有的話預設 90 秒,SIP transaction 逾時兩倍時間多一點。讓 UA 在一半時間嘗試 refresh 前,能夠結束 transaction。只用在 INVITE 和 UPDATE,或其 422 回應則必須要有。
  • 422 Session Interval Too Small:當 proxy 或 UAS 收到請求的 Session-Expires 時間太短時回應,必須包含 Min-SE

一開始 UAC 送 INVITE 含 Supported: timer,可放 Session-Expires 或 Min-SE。之後 Proxy 或 UAS 可減小 Session-Expires 或加大 Min-SE,沒有的話可插入。如果要求的 Session-Expires 小於自己允許的週期,回 422 含 Min-SE 說明最小允許的週期。最後協調成功決定的週期,放在 200 OK 回應的 Session-Expires,並含 'refresher' 參數表示目前的 uac 或 uas 那邊進行 refreshing。

在過期前,refresher 產生 re-INVITE 或 UPDATE session refresh request。如果 refresher 沒收到回應,送 BYE 結束 session。另一邊到過期一直沒收到 refresh 請求,同樣送 BYE。

有一種較複雜的情況,只有一端 UA 支援,一個 Proxy may need to insert the Session-Expires header field into the response, in the event that the UAS doesn't support the extension. The negotiation of the role of refresher is also affected by this capability; it takes into consideration which participants support the extension.

 

Session-Expires  = ("Session-Expires" / "x") HCOLON delta-seconds
                     *(SEMI se-params)
se-params        = refresher-param / generic-param
refresher-param  = "refresher" EQUAL  ("uas" / "uac")
 Min-SE  =  "Min-SE" HCOLON delta-seconds *(SEMI generic-param)

待整理

RFC4028 Section 7.2 以後