RFC3261摘要-SIP协议头,响应号,状态机

214 阅读11分钟

Sip is Session Initiation Protocol, much of SIP's message and header field syntax is identical to HTTP/1.1

SIP Header

Header

Definition

Example

Accept如果不存在Accept header字段,服务器应该采用默认值application/sdp。Accept: application/sdp;level=1, application/x-private, text/html
Accept-Encoding允许接受编码头字段为空。它相当于接受编码:identity,也就是说,只允许使用identity编码,即不允许使用编码。这与HTTP定义略有不同,HTTP定义指出,当不存在时,可以使用任何编码,但首选标识编码。Accept-Encoding: gzip
Accept-Language
Alert-Info当出现在INVITE请求中时,Alert Info header字段指定UAS的备选铃声。当出现在180(振铃)响应中时,Alert Info header(警报信息标题)字段指定UAC的备选回铃音。典型的用法是代理插入此头字段以提供独特的环特征。Alert-Info: www.example.com/sounds/moo.…
AllowAllow header字段列出生成消息的UA支持的一组方法。Allow: INVITE, ACK, OPTIONS, CANCEL, BYE
Authentication-InfoAuthentication Info header字段提供与HTTP摘要的相互身份验证。UAS可以在2xx响应中包含此头字段,该响应使用基于授权头字段的摘要成功验证了请求。Authentication-Info: nextnonce="47364c23432d2e131a5fb210812c"
Authorization授权标头字段包含UA的身份验证凭据。Authorization: Digest username="Alice", realm="atlanta.com",  nonce="84a4cc6f3082121f32b42a2187831a9e", response="7587245234b3434cc3412213e5f113a5432"
Call-IDCall ID header字段唯一标识特定邀请或特定客户端的所有注册。一次多媒体会议可能会产生多个具有不同呼叫ID的呼叫,例如,如果用户多次邀请单个用户参加同一(长期)会议。调用ID区分大小写,只需逐字节进行比较。Call-ID: f81d4fae-7dec-11d0-a765-00a0c91e6bf6@biloxi.com
Call-InfoCall Info header字段提供有关调用者或被调用者的附加信息。URI的用途由“purpose”参数描述。“icon”参数指定适合作为呼叫者或被呼叫者的图标表示的图像。“info”参数通常描述调用者或被调用者。Call-Info: wwww.example.com/alice/photo… ;purpose=icon, www.example.com/alice/ ;purpose=info
Contact联系人标头字段值提供一个URI,其含义取决于它所处的请求或响应类型。
Content-DispositionContent Disposition header字段描述UAC或UAS如何解释消息正文或多部分消息的消息正文部分。此SIP头字段扩展MIME内容类型Content-Disposition: session
Content-Encoding内容编码头字段的紧凑形式是e。Content-Encoding: gzip e: tar
Content-LanguageContent-Language: fr
Content-Length紧凑形式是l。Content-Length: 349 l: 173
Content-Type紧凑形式是c。Content-Type: application/sdp c: text/html; charset=ISO-8859-4
CSeq请求中的CSeq头字段包含单个十进制序列号和请求方法。序列号必须可以表示为32位无符号整数。CSeq的方法部分区分大小写。CSeq头字段用于在对话框中对事务进行排序,提供唯一标识事务的方法,并区分新请求和请求重新传输。如果序列号和请求方法相同,则认为两个CSeq头字段相等。CSeq: 4711 INVITE
DateDate: Sat, 13 Nov 2010 23:29:00 GMT
Error-InfoSIP/2.0 404 The number you have dialed is not in service Error-Info: <sip:not-in-service-recording@atlanta.com>
ExpiresExpires: 5
FromFrom标头字段指示请求的发起人。这可能与对话框的启动器不同。被调用者发送给调用者的请求使用发件人标头字段中被调用者的地址。
From: "A. G. Bell" &lt;sip:agb@bell-telephone.com&gt; ;tag=a48s
From: sip:+12125551212@server.phone2net.com;tag=887s
f: Anonymous &lt;sip:c8oqz84zk7z@privacy.org&gt;;tag=hyh8
In-Reply-ToIn Reply To header字段枚举此调用引用或返回的调用ID。这些调用ID可能已被客户端缓存,然后包含在返回调用的此标头字段中。这允许自动呼叫分配系统将回话路由到第一个呼叫的发起人。这还允许被叫方筛选呼叫,以便只接受他们发起的呼叫的返回呼叫。此字段不能替代请求身份验证。In-Reply-To: 70710@saturn.bell-tel.com, 17320@saturn.bell-tel.com
Max-ForwardsMax Forwards header字段必须与任何SIP方法一起使用,以限制可以将请求转发到下一个下游服务器的代理或网关的数量。当客户端试图跟踪一个似乎失败或在中间链中循环的请求链时,这也很有用。Max-Forwards: 6
Min-ExpiresMin Expires标头字段表示该服务器管理的软状态元素支持的最小刷新间隔。这包括由登记员存储的联系人标题字段。标头字段包含从0到(2^32)-1的十进制整数秒数。Min-Expires: 60
MIME-VersionMIME-Version: 1.0
OrganizationOrganization header字段表示发出请求或响应的SIP元素所属的组织的名称。Organization: Boxes by Bob
PriorityPriority header字段表示客户端感知到的请求的紧急程度。优先级标头字段描述SIP请求对接收人员或其代理应具有的优先级。例如,它可能被考虑到有关呼叫路由和接受的决策中。对于这些决定,不包含优先级标头字段的消息应被视为指定了“正常”优先级。优先级报头字段不影响通信资源的使用,例如路由器中的分组转发优先级或对PSTN网关中电路的访问。标题字段可以有值“非紧急”、“正常”、“紧急”和“紧急”,但其他值可以在别处定义。建议仅当生命、肢体或财产处于迫在眉睫的危险时,才使用“紧急情况”的值。否则,没有为此标题字段定义语义。Subject: A tornado is heading our way! Priority: emergency
Subject: Weekend plans Priority: non-urgent
Proxy-Authenticate代理身份验证标头字段值包含身份验证质询。Proxy-Authenticate: Digest realm="atlanta.com",
domain="sip:ss1.carrier.com", qop="auth",
nonce="f84f1cec41e6cbe5aea9c8e88d359",
opaque="", stale=FALSE, algorithm=MD5
Proxy-AuthorizationProxy Authorization header字段允许客户端向需要身份验证的代理标识其自身(或其用户)。代理授权字段值由凭据组成,其中包含所请求资源的代理和/或领域的用户代理的身份验证信息。Proxy-Authorization: Digest username="Alice", realm="atlanta.com",
nonce="c60f3082ee1212b402a21831ae",
response="245f23415f11432b3434341c022"
Proxy-Require Proxy Require标头字段用于指示代理必须支持的代理敏感功能。Proxy-Require: foo
RequireUAC使用Require header字段告诉UAS UAC希望UAS支持的选项,以便处理请求。尽管是可选的标题字段,但如果存在Require,则不能忽略它。Require: 100rel
Retry-AfterRetry After header字段可与500(服务器内部错误)或503(服务不可用)响应一起使用,以指示服务预计对请求客户端不可用的时间,并与404(未找到)、413(请求实体太大)、480(暂时不可用)、486(此处忙)、600(忙)或603一起使用。(拒绝)响应,指示被叫方预计何时再次可用。此字段的值是响应时间后的正整数秒数(十进制)。
Retry-After: 18000;duration=3600
Retry-After: 120 (I'm in a meeting)
RouteRoute header字段用于通过列出的代理集强制路由请求
Route: <sip:bigbox3.site3.atlanta.com;lr>;,
         <sip:server10.biloxi.com;lr>;
ServerServer: HomeServer v2
SubjectSubject header字段提供一个摘要指示调用的性质,允许在不解析会话描述的情况下进行调用筛选。会话描述不必使用与邀请相同的Subject指示Subject: Need more boxes s: Tech Support
SupportedSupported header字段枚举UAC或UAS支持的所有扩展。Supported: 100rel
TimestampTimestamp: 54
To“收件人标头”字段指定请求的逻辑收件人。

To: The Operator <sip:operator@cs.columbia.edu>;tag=287447

UnsupportedUnsupported header字段列出了UAS不支持的功能。Unsupported: foo
User-Agent用户代理标头字段包含有关发起请求的UAC的信息。User-Agent: Softphone Beta1.5
ViaVia header字段指示到目前为止请求所采用的路径,并指示路由响应中应遵循的路径。Via标头字段值中的分支ID参数用作事务标识符,并由代理用于检测循环。Via header字段值包含用于发送消息的传输协议、客户端的主机名或网络地址,以及它希望接收响应的端口号。Via头字段值还可以包含诸如“maddr”、“ttl”、“received”和“branch”等参数,定义的传输协议有“UDP”、“TCP”、“TLS”和“SCTP”。“TLS”指TCP上的TLS。当向SIPS URI发送请求时,协议仍指示“SIP”,传输协议为TLS。

Via: SIP/2.0/UDP erlang.bell-telephone.com:5060; branch=z9hG4bK87asdks7

Via: SIP/2.0/UDP 192.0.2.1:5060 ;received=192.0.2.207; branch=z9hG4bK77asjd

Via: SIP / 2.0 / UDP first.example.com: 4000;ttl=16; maddr=224.2.0.1 ;branch=z9hG4bKa7c6a8dlze.1

WarningWarning: 307 isi.edu "Session parameter 'foo' not understood" Warning: 301 isi.edu "Incompatible network address type 'E.164'"
WWW-AuthenticateWWW Authenticate标头字段值包含身份验证质询。WWW-Authenticate: Digest realm="atlanta.com",
domain="sip:boxesbybob.com", qop="auth",
nonce="f84f1cec41e6cbe5aea9c8e88d359",
opaque="", stale=FALSE, algorithm=MD5

SIP Response Code

1xx = 通知性应答

  • 100 正在尝试
  • 180 正在拨打
  • 181 正被转接
  • 182 正在排队
  • 183 通话进展

2xx = 成功应答

  • 200 OK
  • 202 被接受:用于转介

3xx = 转接应答

  • 300 多项选择
  • 301 被永久迁移
  • 302 被暂时迁移
  • 305 使用代理服务器
  • 380 替代服务

4xx = 呼叫失败

  • 400 呼叫不当
  • 401 未经授权:只供注册机构使用,代理服务器应使用代理服务器授权407
  • 402 要求付费(预订为将来使用)
  • 403 被禁止的
  • 404 未发现:未发现用户
  • 405 不允许的方法
  • 406 不可接受
  • 407 需要代理服务器授权
  • 408 呼叫超时:在预定时间内无法找到用户
  • 410 已消失:用户曾经存在,但已从此处消失
  • 413 呼叫实体过大
  • 414 呼叫URI过长
  • 415 不支持的媒体类型
  • 416 不支持的URI方案
  • 420 不当扩展:使用了不当SIP协议扩展,服务器无法理解该扩展
  • 421 需要扩展
  • 423 时间间隔过短
  • 480 暂时不可使用
  • 481 通话/事务不存在
  • 482 检测到循环
  • 483 跳数过多
  • 484 地址不全
  • 485 模糊不清
  • 486 此处太忙
  • 487 呼叫被终止
  • 488 此处不可接受
  • 491 呼叫待批
  • 493 无法解读:无法解读 S/MIME文体部分

5xx = 服务器失败

  • 500 服务器内部错误
  • 501 无法实施:SIP呼叫方法在此处无法实施
  • 502 不当网关
  • 503 服务不可使用
  • 504 服务器超时
  • 505 不支持该版本:服务器不支持SIP协议的这个版本
  • 513 消息过长

6xx = 全局失败

  • 600 各处均忙
  • 603 拒绝
  • 604 无处存在
  • 606 不可使用 

SIP Finite State Machine

  1. Overview of client Transaction
    Figure 1: INVITE client transaction 
    
                                   |INVITE from TU
                 Timer A fires     |INVITE sent
                 Reset A,          V                      Timer B fires
                 INVITE sent +-----------+                or Transport Err.
                   +---------|           |---------------+inform TU
                   |         |  Calling  |               |
                   +-------->|           |-------------->|
                             +-----------+ 2xx           |
                                |  |       2xx to TU     |
                                |  |1xx                  |
        300-699 +---------------+  |1xx to TU            |
       ACK sent |                  |                     |
    resp. to TU |  1xx             V                     |
                |  1xx to TU  -----------+               |
                |  +---------|           |               |
                |  |         |Proceeding |-------------->|
                |  +-------->|           | 2xx           |
                |            +-----------+ 2xx to TU     |
                |       300-699    |                     |
                |       ACK sent,  |                     |
                |       resp. to TU|                     |
                |                  |                     |      NOTE:
                |  300-699         V                     |
                |  ACK sent  +-----------+Transport Err. |  transitions
                |  +---------|           |Inform TU      |  labeled with
                |  |         | Completed |-------------->|  the event
                |  +-------->|           |               |  over the action
                |            +-----------+               |  to take
                |              ^   |                     |
                |              |   | Timer D fires       |
                +--------------+   | -                   |
                                   |                     |
                                   V                     |
                             +-----------+               |
                             |           |               |
                             | Terminated|<--------------+
                             |           |
                             +-----------+
    
    Figure 2: non-INVITE client transaction 
    
                                       |Request from TU
                                       |send request
                   Timer E             V
                   send request  +-----------+
                       +---------|           |-------------------+
                       |         |  Trying   |  Timer F          |
                       +-------->|           |  or Transport Err.|
                                 +-----------+  inform TU        |
                    200-699         |  |                         |
                    resp. to TU     |  |1xx                      |
                    +---------------+  |resp. to TU              |
                    |                  |                         |
                    |   Timer E        V       Timer F           |
                    |   send req +-----------+ or Transport Err. |
                    |  +---------|           | inform TU         |
                    |  |         |Proceeding |------------------>|
                    |  +-------->|           |-----+             |
                    |            +-----------+     |1xx          |
                    |              |      ^        |resp to TU   |
                    | 200-699      |      +--------+             |
                    | resp. to TU  |                             |
                    |              |                             |
                    |              V                             |
                    |            +-----------+                   |
                    |            |           |                   |
                    |            | Completed |                   |
                    |            |           |                   |
                    |            +-----------+                   |
                    |              ^   |                         |
                    |              |   | Timer K                 |
                    +--------------+   | -                       |
                                       |                         |
                                       V                         |
                 NOTE:           +-----------+                   |
                                 |           |                   |
             transitions         | Terminated|<------------------+
             labeled with        |           |
             the event           +-----------+
             over the action
             to take
    
  2. Overview of server Transaction
    Figure 3: non-INVITE server transaction 
    
                                   |INVITE
                                   |pass INV to TU
                INVITE             V send 100 if TU won't in 200ms
                send response+-----------+
                    +--------|           |--------+101-199 from TU
                    |        | Proceeding|        |send response
                    +------->|           |<-------+
                             |           |          Transport Err.
                             |           |          Inform TU
                             |           |--------------->+
                             +-----------+                |
                300-699 from TU |     |2xx from TU        |
                send response   |     |send response      |
                                |     +------------------>+
                                |                         |
                INVITE          V          Timer G fires  |
                send response+-----------+ send response  |
                    +--------|           |--------+       |
                    |        | Completed |        |       |
                    +------->|           |<-------+       |
                             +-----------+                |
                                |     |                   |
                            ACK |     |                   |
                            -   |     +------------------>+
                                |        Timer H fires    |
                                V        or Transport Err.|
                             +-----------+  Inform TU     |
                             |           |                |
                             | Confirmed |                |
                             |           |                |
                             +-----------+                |
                                   |                      |
                                   |Timer I fires         |
                                   |-                     |
                                   |                      |
                                   V                      |
                             +-----------+                |
                             |           |                |
                             | Terminated|<---------------+
                             |           |
                             +-----------+
    
    Figure 4: non-INVITE server transaction 
    
                                      |Request received
                                      |pass to TU
                                      V
                                +-----------+
                                |           |
                                | Trying    |-------------+
                                |           |             |
                                +-----------+             |200-699 from TU
                                      |                   |send response
                                      |1xx from TU        |
                                      |send response      |
                                      |                   |
                   Request            V      1xx from TU  |
                   send response+-----------+send response|
                       +--------|           |--------+    |
                       |        | Proceeding|        |    |
                       +------->|           |<-------+    |
                +<--------------|           |             |
                |Trnsprt Err    +-----------+             |
                |Inform TU            |                   |
                |                     |                   |
                |                     |200-699 from TU    |
                |                     |send response      |
                |  Request            V                   |
                |  send response+-----------+             |
                |      +--------|           |             |
                |      |        | Completed |<------------+
                |      +------->|           |
                +<--------------|           |
                |Trnsprt Err    +-----------+
                |Inform TU            |
                |                     |Timer J fires
                |                     |-
                |                     |
                |                     V
                |               +-----------+
                |               |           |
                +-------------->| Terminated|
                                |           |
                                +-----------+