RFC 6228 Session Initiation Protocol (SIP) Response Code for Indication of Terminated Dialog
作者:互联网
RFC 6228 ASCII, PDF, HTML Session Initiation Protocol (SIP) Response Code for Indication of Terminated Dialog C. Holmberg May 2011 Errata Proposed Standard
RFC 6228 引入了一个新的 response code, 199 Early Dialog Terminated, 给 SIP forking proxy and UAS 用来通知上游 SIP UA, 主要就是 proxy 跟 UAC, 我终止了一个 early dialog,你那边也可以删掉它了。
协议地址:https://www.rfc-editor.org/rfc/rfc6228.html
为什么要引进 199 Early Dialog Terminated?
在有些场景下,比如 SIP forking, proxy 会把 INVITE 转发给多个 UAS,并给 UAC 回复每个 UAS 发来的 1xx response,这导致 UAC 端会维护多个 early dialog.
随后一些 UAS 可能会拒绝并回复 4xx, 这时对应的这些 dialog 以后不会再用了,由于 Proxy 仍在等其他 UAS 的答复,没法给 UAC 回复,这就有点费资源了。
为了能在收到 4xx 后及时通知 UAC, 于是引入了 199 response code.
首先明确下 dialog 的概念。
ref. RFC 3261,
Dialog: A dialog is a peer-to-peer SIP relationship between two
UAs that persists for some time. A dialog is established by
SIP messages, such as a 2xx response to an INVITE request. A
dialog is identified by a call identifier, local tag, and a
remote tag. A dialog was formerly known as a call leg in RFC
2543.
A dialog is identified at each UA with a dialog ID, which consists of
a Call-ID value, a local tag and a remote tag.
Dialogs are created through the generation of non-failure responses
to requests with specific methods. Within this specification, only
2xx and 101-199 responses with a To tag, where the request was
INVITE, will establish a dialog. A dialog established by a non-final
response to a request is in the "early" state and it is called an
early dialog.
也就是 dialog 是由 Call-ID, From tag, To tag 三个一起来标识的。
对于 UAC 来说,它发出 request 后收到了 1xx/2xx response 后,会维护一个 dialog.
对于 UAS/proxy 等来说,它收到 request 后,会发出 response 并维护一个 dialog.
那什么是 early dialog 呢?同样是参考前面的描述,由于收到 1xx 这种 non-final response 后生成的 dialog, 叫做 early dialog.
1, UAC 行为规范
When a UAC sends an initial dialog initiation request, and if it is
willing to receive 199 responses, it MUST insert a "199" option-tag
in the Supported header field [RFC3261] of the request. The option-
tag indicates that the UAC supports, and is willing to receive, 199
responses. A UAC SHOULD NOT insert a "199" option-tag in the Require
or the Proxy-Require header field [RFC3261] of the request, since in
many cases it would result in unnecessary session establishment
failures.
UAC 如果支持 199,它需要在 INVITE Supported header 里加上 199 tag.
When a UAC receives a 199 response, it might release resources
associated with the terminated early dialog.
NOTE: The 199 response indicates that the early dialog has been
terminated, so there is no need for the UAC to send a BYE request
in order to terminate the early dialog when it receives the 199
response.
UAC 收到 199 后,可以释放掉对应 early dialog 的资源,并且不需要再通知 UAS/Proxy 了,比如说不需要发 Bye了。
If a UAC receives an unreliably sent 199 response on a dialog that
has not previously been established (this can happen if a 199
response reaches the client before the 18x response that would
establish the early dialog) it SHALL discard the 199 response. If a
UAC receives a reliably sent 199 response on a dialog that has not
previously been created, it MUST acknowledge the 199 response, as
described in RFC 3262 [RFC3262].
另外,如果 UAC 收到 unreliable 199 并且发现它对应的 dialog 不存在,直接 ignore 就行。
如果 UAC 收到 reliable 199, 那么 UAC 需要遵循 RFC3262 标准,回复 PRACK 给 UAS/proxy等。
2, UAS 行为规范
If a UAS receives an initial dialog initiation request with a
Supported header field that contains a "199" option-tag, it SHOULD
NOT send a 199 response on an early dialog associated with the
request before it sends a non-2xx final response.
UAS 只有在 发送过 1xx provisional response 后,才允许发送 199 response.
-- 这是当然的啊,要不怎么界定 dialog。
If the Supported header field of an initial dialog initiation request
does not contain a "199" option-tag, the UAS MUST NOT send a 199
response on any early dialog associated with the request.
UAS 只有在收到 Supported: 199 后,才允许发送 199 response.
-- 协议中写错了写成 UAC 了,已经有人勘误:Errata ID: 4886
When a UAS generates a 199 response, the response MUST contain a To
header field tag parameter [RFC3261], in order for other entities to
identify the early dialog that has been terminated. The UAS MUST
also insert a Reason header field [RFC3326] that contains a response
code describing the reason why the early dialog was terminated. The
UAS MUST NOT insert a "199" option-tag in the Supported, Require, or
Proxy-Require header field of the 199 response.
199 response 必需带 To header (and tag), 和一个 Reason header, 不能在 Supported, Require, Proxy-Require 等 header 中再插入 199 tag.
A 199 response SHOULD NOT contain a Session Description Protocol
(SDP) offer/answer message body, unless required by the rules in
RFC 3264 [RFC3264].
According to RFC 3264, if an INVITE request does not contain an SDP
offer, and the 199 response is the a first reliably sent response
associated with the request, the 199 response is required to contain
an SDP offer. In this case, the UAS SHOULD send the 199 response
unreliably, or send the 199 response reliably and include an SDP
offer with no "m=" lines in the response.
199 在通常情况下不应该携带 SDP offer/answer; 如果由于 INVITE has no SDP 等原因被要求携带,那么可以发送 unreliable 199 (wo/ SDPP), 或者发送 reliable 199 w/ SDP 但是 wo/ "m=" lines.
3, Proxy 行为规范
When a proxy receives a 199 response to an initial dialog initiation
request, it MUST process the response as any other non-100
provisional response. The proxy will forward the response upstream
towards the sender of the associated request. The proxy MAY release
resources it has reserved associated with the early dialog that is
terminated. If a proxy receives a 199 response out of dialog, it
MUST process it as other non-100 provisional responses received out
of dialog.
Proxy 收到 199 后,需要转发给上游比如 UAC.
When a forking proxy receives a non-2xx final response to an initial
dialog initiation request that it recognizes as terminating one or
more early dialogs associated with the request, it MUST generate and
send a 199 response upstream for each of the terminated early dialogs
that satisfy each of the following conditions:
对于 forking proxy, 如果收到的 1xx response 关联多个 early dialog, proxy 应该针对每个 dialog 给上游比如 UAC 发送 199.
Based on implementation policy, a forking proxy MAY wait before
sending the 199 response, e.g., if it expects to receive a 2xx final
response on another dialog shortly after it received the non-2xx
final response that triggered the 199 response.
Forking proxy 也允许等收到 2xx response 之后,再给 UAC 等发 199.
类似 UAS,199 response 必需带 To header (and tag), 和一个 Reason header, 不能在 Supported, Require, Proxy-Require 等 header 中再插入 199 tag.
If a forking proxy receives a reliably sent 199 response for a dialog
for which it has previously generated and sent a 199 response, it
MUST forward the 199 response. If a proxy receives an unreliably
sent 199 response for which it has previously generated and sent a
199 response, it MAY forward the response, or it MAY discard it.
Forking proxy 收到可靠传输的 199,必需转发;如果收到的是不可能传输的 199, 是否转发得看心情了。
When a forking proxy generates and sends a 199 response, the response
SHOULD NOT contain a Contact header field or a Record-Route header
field [RFC3261].
If the Require header field of an initial dialog initiation request
contains a "100rel" option-tag, a proxy MUST NOT generate and send
199 responses associated with that request. The reason is that a
proxy is not allowed to generate and send 199 responses reliably.
9.1. Example with a Forking Proxy that Generates 199
UAC P1 UAS_2 UAS_3 UAS_4
| | | | |
|-- INVITE -->| | | |
| |--- INVITE (2) ->| | |
| |--- INVITE (3) --------->| |
| |--- INVITE (4) ----------------->|
| |<-- 18x (2) -----| | |
|<- 18x (2) --| | | |
| |<-- 18x (3) -------------| |
|<- 18x (3) --| | | |
| |<-- 18x (4) ---------------------|
|<- 18x (4) --| | | |
| |<-- 4xx (2) -----| | |
| |--- ACK (2) ---->| | |
|<- 199 (2) --| | | |
| |<-- 4xx (3) -------------| |
| |--- ACK (3) ------------>| |
|<- 199 (3) --| | | |
| |<-- 200 (4) ---------------------|
|<- 200 (4) --| | | |
|-- ACK (4) ->| | | |
| |--- ACK (4) -------------------->|
| | | | |
9.2. Example with a Forking Proxy that Receives 200 OK
P1 由于由于没有收到过 4xx response,所以不会给 UAC 发 199.
UAC P1 UAS_2 UAS_3 UAS_4
| | | | |
|-- INVITE -->| | | |
| |--- INVITE (2) ->| | |
| |--- INVITE (3) --------->| |
| |--- INVITE (4) ----------------->|
| |<-- 18x (2) -----| | |
|<- 18x (2) --| | | |
| |<-- 18x (3) -------------| |
|<- 18x (3) --| | | |
| |<-- 18x (4) ---------------------|
|<- 18x (4) --| | | |
| |<-- 200 (4) ---------------------|
|<- 200 (4) --| | | |
|-- ACK (4) ->| | | |
| |--- ACK (4) -------------------->|
| | | | |
9.3. Example with Two Forking Proxies, of which One Generates 199
UAC P1 P2 UAS_2 UAS_3 UAS_4
| | | | | |
|-- INVITE -->| | | | |
| |-- INVITE (2) ------------------>| | |
| |-- INVITE ---->| | | |
| | |--- INVITE (3) --------->| |
| | |--- INVITE (4) ----------------->|
| | |<-- 18x (3) -------------| |parentheses
| |<- 18x (3) ----| | | |
|<- 18x (3) --| | | | |
| | |<-- 18x (4) ---------------------|
| |<- 18x (4) ----| | | |
|<- 18x (4) --| | | | |
| | |<-- 4xx (3) -------------| |
| | |--- ACK (3) ------------>| |
| | |<-- 4xx (4) ---------------------|
| | |--- ACK (4) -------------------->|
| |<- 4xx (3) ----| | | |
| |-- ACK (3) --->| | | |
|<- 199 (3) --| | | | |
|<- 199 (4) --| | | | |
| |<- 200 (2) ----------------------| | |
|<- 200 (2) --| | | | |
|-- ACK (2) ->| | | | |
| |-- ACK (2) --------------------->| | |
| | | | | |
标签:Terminated,SIP,199,UAS,request,dialog,Protocol,UAC,response 来源: https://www.cnblogs.com/redstone/p/16478970.html