1.SDP (rfc 4566)
1)用於交換參數
2)內容分三部分Session description, Time description and Media description (m-line)
3)SDP用於描述會話的媒體屬性,一般放在SIP協議的消息體中攜帶,基於文本的編碼方式
format:
Session description
v= (protocol version)
o= (originator and session identifier)
s= (session name)
i=* (session information)
u=* (URI of description)
e=* (email address)
p=* (phone number)
c=* (connection information -- not required if included in
all media)
b=* (zero or more bandwidth information lines)
One or more time descriptions ("t=" and "r=" lines; see below)
z=* (time zone adjustments)
k=* (encryption key)
a=* (zero or more session attribute lines)
Zero or more media descriptions
Time description
t= (time the session is active)
r=* (zero or more repeat times)
Media description, if present
m= (media name and transport address)
i=* (media title)
c=* (connection information -- optional if included at
session level)
b=* (zero or more bandwidth information lines)
k=* (encryption key)
a=* (zero or more media attribute lines)
2. SIP
1) request/respones的應用層文本協議
SIP和XMPP都是應用層的協議,主要用來在互聯網上發送語音和即時通訊IM。
RFC3261定義了SIP,RFC3920定義了XMPP。XMPP來自即時通訊系統,而SIP相似語音和視頻通訊。
XMPP增長了Jingle擴展協議來支持面向鏈接的業務,如語音和視頻;而SIP增長了SIMPLE協議來支持即時通訊業務。
SIP協議是一個Client/Sever協議,所以SIP消息分兩種:請求消息和響應消息。
請求消息是SIP客戶端爲了激活特定操做而發給服務器端的消息。
2). Request:
經常使用的SIP請求消息以下:
INVITE:表示主叫用戶發起會話請求,邀請其餘用戶加入一個會話。也能夠用在呼叫創建後用於更新會話(此時該INVITE又稱爲Re-invite)。
ACK:客戶端向服務器端證明它已經收到了對INVITE請求的最終響應。
BYE:表示終止一個已經創建的呼叫。
CANCEL:表示在收到對請求的最終響應以前取消該請求,對於已完成的請求則無影響。
REGISTER:表示客戶端向SIP服務器端註冊列在To字段中的地址信息。
OPTIONS:表示查詢被叫的相關信息和功能。
----------------------------------------------------------------------------
Example:
INVITE sip:bob@biloxi.com SIP/2.0
Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bK776asdhds
Max-Forwards: 70
To: Bob <sip:bob@biloxi.com>
From: Alice <sip:alice@atlanta.com>;tag=1928301774
Call-ID: a84b4c76e66710@pc33.atlanta.com
CSeq: 314159 INVITE
Contact: <sip:alice@pc33.atlanta.com>
Content-Type: application/sdp
Content-Length: 142
----------------------------------------------------------------------------
3). Respones:
100試呼叫(Trying)
180振鈴(Ringing)
181呼叫正在前轉(Call is Being Forwarded)
200成功響應(OK)
302臨時遷移(Moved Temporarily)
400錯誤請求(Bad Request)
401未受權(Unauthorized)
403禁止(Forbidden)
404用戶不存在(Not Found)
408請求超時(Request Timeout)
480暫時無人接聽(Temporarily Unavailable)
486線路忙(Busy Here)
504服務器超時(Server Time-out)
600全忙(Busy Everywhere)
----------------------------------------------------------------------------
Example:
SIP/2.0 200 OK
Via: SIP/2.0/UDP server10.biloxi.com
;branch=z9hG4bKnashds8;received=192.0.2.3
Via: SIP/2.0/UDP bigbox3.site3.atlanta.com
;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2
Via: SIP/2.0/UDP pc33.atlanta.com
;branch=z9hG4bK776asdhds ;received=192.0.2.1
To: Bob <sip:bob@biloxi.com>;tag=a6c85cf
From: Alice <sip:alice@atlanta.com>;tag=1928301774
Call-ID: a84b4c76e66710@pc33.atlanta.com
CSeq: 314159 INVITE
Contact: <sip:bob@192.0.2.4>
Content-Type: application/sdp
Content-Length: 131
----------------------------------------------------------------------------