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.… |
| Allow | Allow header字段列出生成消息的UA支持的一组方法。 | Allow: INVITE, ACK, OPTIONS, CANCEL, BYE |
| Authentication-Info | Authentication Info header字段提供与HTTP摘要的相互身份验证。UAS可以在2xx响应中包含此头字段,该响应使用基于授权头字段的摘要成功验证了请求。 | Authentication-Info: nextnonce="47364c23432d2e131a5fb210812c" |
| Authorization | 授权标头字段包含UA的身份验证凭据。 | Authorization: Digest username="Alice", realm="atlanta.com", nonce="84a4cc6f3082121f32b42a2187831a9e", response="7587245234b3434cc3412213e5f113a5432" |
| Call-ID | Call ID header字段唯一标识特定邀请或特定客户端的所有注册。一次多媒体会议可能会产生多个具有不同呼叫ID的呼叫,例如,如果用户多次邀请单个用户参加同一(长期)会议。调用ID区分大小写,只需逐字节进行比较。 | Call-ID: f81d4fae-7dec-11d0-a765-00a0c91e6bf6@biloxi.com |
| Call-Info | Call Info header字段提供有关调用者或被调用者的附加信息。URI的用途由“purpose”参数描述。“icon”参数指定适合作为呼叫者或被呼叫者的图标表示的图像。“info”参数通常描述调用者或被调用者。 | Call-Info: wwww.example.com/alice/photo… ;purpose=icon, www.example.com/alice/ ;purpose=info |
| Contact | 联系人标头字段值提供一个URI,其含义取决于它所处的请求或响应类型。 | |
| Content-Disposition | Content Disposition header字段描述UAC或UAS如何解释消息正文或多部分消息的消息正文部分。此SIP头字段扩展MIME内容类型。 | Content-Disposition: session |
| Content-Encoding | 内容编码头字段的紧凑形式是e。 | Content-Encoding: gzip e: tar |
| Content-Language | Content-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 |
| Date | Date: Sat, 13 Nov 2010 23:29:00 GMT | |
| Error-Info | SIP/2.0 404 The number you have dialed is not in service Error-Info: <sip:not-in-service-recording@atlanta.com> | |
| Expires | Expires: 5 | |
| From | From标头字段指示请求的发起人。这可能与对话框的启动器不同。被调用者发送给调用者的请求使用发件人标头字段中被调用者的地址。 | From: "A. G. Bell" <sip:agb@bell-telephone.com> ;tag=a48s From: sip:+12125551212@server.phone2net.com;tag=887s f: Anonymous <sip:c8oqz84zk7z@privacy.org>;tag=hyh8 |
| In-Reply-To | In Reply To header字段枚举此调用引用或返回的调用ID。这些调用ID可能已被客户端缓存,然后包含在返回调用的此标头字段中。这允许自动呼叫分配系统将回话路由到第一个呼叫的发起人。这还允许被叫方筛选呼叫,以便只接受他们发起的呼叫的返回呼叫。此字段不能替代请求身份验证。 | In-Reply-To: 70710@saturn.bell-tel.com, 17320@saturn.bell-tel.com |
| Max-Forwards | Max Forwards header字段必须与任何SIP方法一起使用,以限制可以将请求转发到下一个下游服务器的代理或网关的数量。当客户端试图跟踪一个似乎失败或在中间链中循环的请求链时,这也很有用。 | Max-Forwards: 6 |
| Min-Expires | Min Expires标头字段表示该服务器管理的软状态元素支持的最小刷新间隔。这包括由登记员存储的联系人标题字段。标头字段包含从0到(2^32)-1的十进制整数秒数。 | Min-Expires: 60 |
| MIME-Version | MIME-Version: 1.0 | |
| Organization | Organization header字段表示发出请求或响应的SIP元素所属的组织的名称。 | Organization: Boxes by Bob |
| Priority | Priority 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-Authorization | Proxy Authorization header字段允许客户端向需要身份验证的代理标识其自身(或其用户)。代理授权字段值由凭据组成,其中包含所请求资源的代理和/或领域的用户代理的身份验证信息。 | Proxy-Authorization: Digest username="Alice", realm="atlanta.com", nonce="c60f3082ee1212b402a21831ae", response="245f23415f11432b3434341c022" |
| Proxy-Require | Proxy Require标头字段用于指示代理必须支持的代理敏感功能。 | Proxy-Require: foo |
| Require | UAC使用Require header字段告诉UAS UAC希望UAS支持的选项,以便处理请求。尽管是可选的标题字段,但如果存在Require,则不能忽略它。 | Require: 100rel |
| Retry-After | Retry After header字段可与500(服务器内部错误)或503(服务不可用)响应一起使用,以指示服务预计对请求客户端不可用的时间,并与404(未找到)、413(请求实体太大)、480(暂时不可用)、486(此处忙)、600(忙)或603一起使用。(拒绝)响应,指示被叫方预计何时再次可用。此字段的值是响应时间后的正整数秒数(十进制)。 | Retry-After: 18000;duration=3600 Retry-After: 120 (I'm in a meeting) |
| Route | Route header字段用于通过列出的代理集强制路由请求 | Route: <sip:bigbox3.site3.atlanta.com;lr>;,
<sip:server10.biloxi.com;lr>;
|
| Server | Server: HomeServer v2 | |
| Subject | Subject header字段提供一个摘要或指示调用的性质,允许在不解析会话描述的情况下进行调用筛选。会话描述不必使用与邀请相同的Subject指示。 | Subject: Need more boxes s: Tech Support |
| Supported | Supported header字段枚举UAC或UAS支持的所有扩展。 | Supported: 100rel |
| Timestamp | Timestamp: 54 | |
| To | “收件人标头”字段指定请求的逻辑收件人。 | To: The Operator <sip:operator@cs.columbia.edu>;tag=287447 |
| Unsupported | Unsupported header字段列出了UAS不支持的功能。 | Unsupported: foo |
| User-Agent | 用户代理标头字段包含有关发起请求的UAC的信息。 | User-Agent: Softphone Beta1.5 |
| Via | Via 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 |
| Warning | Warning: 307 isi.edu "Session parameter 'foo' not understood" Warning: 301 isi.edu "Incompatible network address type 'E.164'" | |
| WWW-Authenticate | WWW Authenticate标头字段值包含身份验证质询。 | WWW-Authenticate: Digest realm="atlanta.com", domain="sip:boxesbybob.com", qop="auth", nonce="f84f1cec41e6cbe5aea9c8e88d359", opaque="", stale=FALSE, algorithm=MD5 |
SIP Response Code
1xx = 通知性应答
| 2xx = 成功应答
| 3xx = 转接应答
|
4xx = 呼叫失败
| 5xx = 服务器失败
| 6xx = 全局失败
|
SIP Finite State Machine
-
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 -
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| | | +-----------+