【文章內容簡介】
From: UserA sip:UAA@。tag=589304To: UserB sip:UAB@CallID: 8204589102@CSeq: 1 INVITEContentLength: 0,User Agent B發(fā)送臨時消息(響鈴)給User Agent A,這樣它就不會超時和放棄。SIP/180 RingingFrom: UserA sip:UAA@。tag=589304To: UserB sip:UAB@。tag=314159CallID: 8204589102@CSeq: 1 INVITEContent Length: 0,User B決定接受呼叫。此時,User Agent B發(fā)送一個OK響應給User Agent A。在響應的payload中,還有另一條SDP消息。它包含一組兩個用戶代理都支持的介質編碼。此時,雙方正式處于呼叫中。使用200類型的響應可以接受所有類型的SIP請求。SIP/200 OKFrom: UserA sip:UAA@。tag=589304To: UserB sip:UAB@。tag=314159CallID: 8204589102@CSeq: 1 INVITEContact: sip:UserB@ContentType: application/sdpContentLength: 140v=0o=UserB 2890844527 2890844527 IN IP4 s=Session SDPc=IN IP4 t=3034423619 0m=audio 3456 RTP/AVP 0a=rtpmap:0 PCMU/80005. User Agent A最后使用一條ACK消息進行確認。對于這種請求類型來說,沒有重試和響應消息,即使消息丟失。ACK只在INVITE消息中使用。ACKsip:UAB@ SIP/Via: SIP/:5060Route: sip:UserB@From: UserA sip:UAA@。tag=589304To: UserB sip:UAB@。tag=314159CallID: 8204589102@CSeq: 1 ACKContentLength: 06..兩個用戶代理現在使用最后一條SDP消息中選定的方法進行連接。RTP使用PCMU/8000編碼對在端口49170 amp。 3456上雙向傳輸的音頻數據進行打包。,其中一個用戶掛斷。此時,這個用戶的用戶代理發(fā)送一個新的請求BYE。這條消息可以由任一方發(fā)送。BYEsip:UAB@ SIP/Via: SIP/:5060To: UserB sip:UAB@。tag=314159From: UserA sip:UAA@。tag=589304CallID: 8204589102@CSeq: 1 BYEContentLength: 0,然后使用一條OK消息作為應答。呼叫連接至此斷開。SIP/200 OKTo: UserB sip:UAB@。tag=314159From: UserA sip:UAA@。tag=589304CallID: 8204589102@CSeq: 1 BYEContentLength: 0 SIP應用拓撲圖23 SIP應用拓撲SIP網絡的組成包括:-User Agent;-SIP Proxy ;-SIP Redirect; -SIP Registrar ;-SIP Location ;User Agent – 用戶代理 一個發(fā)起和終止會話的實體,包含兩個功能實體:?User Agent Clients (UAC) – 發(fā)起呼叫的功能實體. ?User Agent Server (UAS) – 接收呼叫的功能實體.SIP Proxy – 代理服務器?為其它的客戶機代理,進行SIP消息的轉接和轉發(fā)的功能。消息機制與UAC和UAS相似。 ?對收到的請求消息進行翻譯和處理后,傳遞給其他的服務器。SIP Redirect – 重定向服務器?接受SIP請求消息,進行地址映射,將映射后的地址(零個或多個)返回給客戶機 ?與代理服務器proxy server不同的是, redirect server不會發(fā)起自己的呼叫。 ?與user agent server不同的是, redirect server不接受或主動終止呼叫。 SIP Registrar 注冊服務器?接受REGISTER 請求的服務器。?可以支持鑒權的功能。?在典型應用中,可與代理服務器proxy sever或重定向redirect server一起提供用戶定位服務。SIP Location – 位置服務器?為SIP 重定向Redirect Server或 代理proxy server 提供被叫用戶可能的位置信息。 SIP呼叫流程l 基本呼叫流程圖24 基本呼叫流程圖具體流程說明如下:? INVITE is a Request and contains Tesla’s media information? 180 Ringing is an Informational response and is not required? 200 OK is a final Response and contains Marconi’s media information? ACK pletes threewayhandshake.? BYE tears down sessionl 代理呼叫流程圖25 代理呼叫流程圖具體流程說明如下:? INVITE is sent to Proxy instead of to Heisenberg directly.? Proxy looks up address of Heisenberg and forwards INVITE to that IP Address. ? Responses to INVITE route back through the Proxy: 180 Ringing and 200 OK ? 200 OK contains a Contact header which allows the ACK and all future requests to go directly bypassing Proxy.l 重定向呼叫圖26 重定向呼叫流程圖具體流程說明如下:? INVITE is sent to Redirect Server? Server looks up address of Heisenberg and returns that address in a Contact header in a 302 Moved Temporarily response ? The ACK pletes the transaction with the Server Schroedinger then resends the INVITE directly to Heisenbergl 注冊流程圖27 注冊流程圖具體流程說明如下:? Heisenberg sends a REGISTER request to a Registrar Server. The request contains Contact headers listing the URLs for which Heisenberg wishes to receive ining SIP calls? Registrar Accepts registration and replies with 200 OK and echoes current Contact listl SIP到PSTN呼叫圖28 SIP到PSTN呼叫流程圖具體流程說明如下:? RequestURI in the INVITE contains a Telephone Number which is sent to PSTN Gateway.? The Gateway maps the INVITE to a SS7 ISUP IAM (Initial Address Message)? 183 Session Progress establishes early media session so caller hears Ring Tone.? Two way Speech path is established after ANM (Answer Message) and 200 OKl PSTN到SIP呼叫圖29 PSTN到SIP呼叫流程圖具體流程說明如下:? ISDN telephone call is routed to a PSTN/SIP Gateway? The Gateway maps the ISDN Setup message to a SIP INVITE message to a Proxy? Proxy consults Database and maps telephone number to SIP URL of the SIP Phone and proxies the INVITE? The 180 Ringing response is mapped to a ISDN Alerting message no ring tone is generatedl Proxy并行查找呼叫流程圖210 Proxy并行查找呼叫流程圖具體流程說明如下:? Single INVITE request returns three Contact headers from Redirect Server.? Babbage tries each location in parallel? Each INVITE has same To, From, and CallID, but a unique branch tag which identifies each leg.? First two INVITEs fail, but third is successful and session is established.? Forking Proxy Servers also can perform this function.l SIP可靠性呼叫流程圖211 SIP可靠性呼叫流程圖具體流程說明如下:? Unreliable UDP transport is assumed? OPTIONS message is lost between Proxy and UAS.? Stateful Proxy realizes message loss and retransmits message after timer T1 expires? 200 OK response is lost between Proxy and UAC.? UAC retransmits OPTIONS after timer T2 expires? Proxy realizes response loss and retransmits 200 OK response SDPSession Description Protocol(SDP)會話描述協(xié)議。最為一種會話參數屬性的描述協(xié)議,獨立于一般的傳輸協(xié)議,如包括會話通知協(xié)議 (SAP) 、會話初始協(xié)議(SIP)、實時流協(xié)議 (RTSP)、 MIME 擴展協(xié)議的電子郵件以及超文本傳輸協(xié)議 (HTTP)。作為一種會話描述規(guī)范,其和其它傳輸協(xié)議共同完成網絡會話協(xié)商。SDP協(xié)議結構,SDP 信息是文本信息,采用 UTF8 編 碼中的 ISO 10646 字符集。 SDP 會話描述如下: ( 標注 * 符號的表示可選字段 ) : v= (協(xié)議版本) o= (所有者/創(chuàng)建者和會話標識符) s= (會話名稱) i=* (會話信息) u=* (URI 描述) e=* (Email 地址) p=* (電話號碼) c=* (連接信息 ― 如果包含在所有媒體中,則不需要該字段) b=* (帶寬信息) 一個或更多時間描述(如下所示): z=* (時間區(qū)域調整) k=* (加密密鑰) a=* (0 個或多個會話屬性行) 0個或多個媒體描述(如下所示) 時間描述 t= (會話活動時間) r=* (0或多次重復次數) 媒體描述 m= (媒體名稱和傳輸地址) i=* (媒體標題) c=* (連接信息 — 如果包含在會話層則該字段可選) b=* (帶寬信息) k=* (加密密鑰) a=* (0 個或多個會話屬性行)SDP描述由許多文本行組成,文本行的格式為類型=值,類型是一個字母,值是結構化的文本串,其格式依類型而定。第三章 P2P技術 P2P概述P2P網絡是一種具有較高擴展性的分布式系統(tǒng)結構,其對等概念是指網絡中的物理節(jié)點在邏輯上具有相同的地位,而并非處理能力和信息負擔上完全的對等。P2P系統(tǒng)最大的特點就是用戶之間直接共享資源,其核心技術就是分布式對象的定位機制,這也是提高網絡可擴展性、解決網絡帶寬被吞噬的關鍵所在。迄今為止,P2P網絡已經歷了三代不同網絡模型,各種模型各有優(yōu)缺點,有的還存在著本身難以克服的缺陷,因此在目前P2P技術還遠未成熟的階段,各種網絡結構依然能夠共存,甚至呈現相互借鑒的形式。P2P打破了傳統(tǒng)的Client/Server(C/S)模