1.1.1. Route/Record-Route
? Record-Route can be used:
– ensures Firewall proxy stays in path
? A Firewall proxy adds Record-Route header
– Clients and Servers copy Record-Route and put in Route header for all messages
Request routing
例 Only Proxy 3 remains in route
1. UA1 is instructed to INVITE “sip:UA2@proxy1”
2. The message should be sent to Proxy 1
3. The message should be sent to Proxy 2
4. The message should be sent to Proxy 3
5. The message should be sent to UA2.
6. UA2 sends a “200 OK”, which should be sent back to UA1, through all three proxies.
7. UA1 sends an ACK to Proxy 3.
8. Proxy 3 sends the ACK to UA2.
9. UA2 sends a BYE to proxy 3.
10. Proxy 3 sends the BYE to UA1.
11. UA1 sends a 200 OK through proxy 3 to UA2.
1.1.1. Expires
The RFC is referring to a REGISTER request that includes an expires parameter on the Contact and one is a separate header field like this:
Contact: <sip:foo@example.com>;expires=1000
Contact: <sip:bar@example.com>
Expires: 2000
for the above, the foo contact should expire after 1000 seconds, and the bar contact after 2000 seconds.
The test used the Contact header:
Contact: <sip:contact13@regtest.pingtel.com;Expires=1800>;EXPIRES=2970
which means something else entirely. The ';expires=1800' inside the angle brackets is a part of the URI, not a field parameter of the Contact field. The ';expires=2970' outside is the field parameter, so it is correct to use it as
the expiration time of the contact.The inner one is used by the proxy to control forking timeouts when this Contact is used, and has nothing to do with the registration expiration.
Broad Band
1.2. 基本過程
1.2.1. 主要過程
SIP IP電話系統定義了註冊/登出、呼叫、重新導向、能力查詢四種工作過程。
Basic Call Signalling & Routing
The process for establishing communication with SIP usually occurs in six steps:
? Step 1 Registering, initiating and locating the user
? Step 2 Determine the media to use (using SDP)
? Step 3 Determine willingness of called party to communicate
? Step 4 Call setup
? Step 5 Call modification or handling (optional)
? Step 6 Call termination
Addressing: SIP gives a globally reachable address and callees ‘bind’ to this address using the
REGISTER method. Addresses are in a URL format such as sip:user@host. It must include the
host, and may include the user name, port number & other parameters (e.g. transport). For
example sip:bob@office.com or sip:voicemail@siteA.com?subject=returnmycall
Registration: Each time a UA is enabled it creates an address mapping in the ‘Location Service’
explicitly by sending a REGISTER request to the ‘Registrar’. The Registrar reads & writes
mappings to location service based on the contents of REGISTER requests.
Proxy & Redirection: The Proxy server acts as a rendezvous point at which all callees are
globally reachable. It performs the routeing function i.e. to which hop (UA / Proxy / Redirect) the
request is relayed to. The request may be forked whereby several destinations may be tried
sequentially or in parallel. A Proxy server can be ‘stateful’ when it keeps state during a transaction
and discards information about the transaction when it is complete. The Redirection server differs
in that it only returns a mapped address back to the UA (i.e. instructs the UA to initiate a request
elsewhere). Unlike a Proxy server it does not initiate its own SIP request. Unlike a UAS it does
not accept or terminate calls.
SIP IP電話系統中的呼叫是通過INVITE邀請請求、成功響應和ACK確認請求的三向交握來實現的。即當主叫使用者代理程式要發起呼叫時,它構造一個INVITE訊息,並發送給被叫。被叫收到邀請後決定接受該呼叫,就回送一個成功響應(狀態代碼為200)。主叫方收到成功響應後,向對方發送ACK請求。被叫收到ACK請求後,呼叫成功建立。
呼叫的終止通過BYE請求訊息來實現。當參與呼叫的任一方要結束通話時,它就構造一個BYE請求訊息,並發送給對方。對方收到BYE請求後,釋放與此呼叫相關的資源,回送一個成功響應,表示呼叫已經終止。
當主被叫雙方已建立呼叫,如果任一方想要修改當前的通訊參數(通訊類型、編碼等),可以通過發送一個對話內的INVITE請求訊息(稱為re-INVITE)來實現。
Proxy 伺服器類似於HTTP的proxy和SMTP的MTA(Message Transfer Agent ),有點像中繼器,它本身並不對使用者請求進行響應,只是轉寄使用者請求的中繼器,然後將自身地址加入該訊息的路徑頭部分,以保證將響應按原路返回並防止環路的發生。
SIP協議支援三種來電者式:
l 由使用者代理程式服務機(UAC)向使用者代理程式伺服器(UAS)直接呼叫
l 由Proxy 伺服器代表UAC向被叫發起呼叫
l 由UAC在重新導向伺服器的輔助下進行重新導向呼叫
(1)SIP使用者代理程式向SIPProxy 伺服器發送呼叫,建立請求(INVITE)。
(2)SIPProxy 伺服器向重新導向伺服器發送呼叫建立請求。
(3)重新導向伺服器返回重新導向訊息。
(4)SIPProxy 伺服器向重新導向伺服器指定的SIPProxy 伺服器發送呼叫,建立請求。
(5)被請求的SIPProxy 伺服器使用非SIP協議,例如網域名稱查詢或者LDAP到定位服務器查詢被叫位置。
(6)定位服務器返回被叫位置(被叫SIPProxy 伺服器)。
(7)被請求的SIPProxy 伺服器向被叫SIPProxy 伺服器發送呼叫,建立請求。
(8)被叫SIPProxy 伺服器向SIP使用者代理程式(被叫)發送呼叫,建立請求(被叫響鈴或顯示)。
(9)被叫使用者代理程式向被叫SIP使用者代理程式伺服器發送同意或拒絕。
(10)被叫使用者代理程式伺服器向主叫Proxy 伺服器所請求的Proxy 伺服器發送同意或拒絕。
(11)主叫Proxy 伺服器所請求的Proxy 伺服器向主叫Proxy 伺服器發同意或拒絕。
(12)主叫Proxy 伺服器向主叫SIP使用者代理程式指示被叫是否同意呼叫請求。
呼叫建立後,雙方根據協商得到的媒體和壓縮演算法等資訊相互連信。呼叫拆除過程類似於建立過程。
1.1.1. 註冊/登出
The REGISTER function is used in a SIP system primarily to associate a temporary contact address with an address-of-record. This contact is generally in the form of a URI, such as Contact: <sip:alice@pc33.atlanta.com> and is generally
dynamic and associated with the IP address or hostname of the SIP UA.
SIP為使用者定義了註冊和登出過程,其目的是可以動態建立使用者的邏輯地址和其當前聯絡地址之間的對應關係,以方實現呼叫路由和對使用者移動性的支援。邏輯地址和聯絡地址的分離也方便了使用者,它不論在何處、使用何種裝置,都可以通過唯一的邏輯地址進行通訊。
註冊/登出過程是通過REGISTER訊息和200成功響應來實現的。在註冊/登出時,使用者將其邏輯地址和當前聯絡地址通過REGISTER訊息發送給其註冊伺服器,註冊伺服器對該請求訊息進行處理,並以200成功響應訊息通知使用者註冊/登出成功。
註冊伺服器是接受REGISTER請求的伺服器,其目的是根據使用者在請求中規定的聯絡資訊更新位置資料庫。
SIP通過E-mail形式的地址來標明使用者地址。每一使用者通過一等級化的URL來標識,它通過諸如使用者電話號碼或主機名稱等元素來構造(例如:SIP:user@company.com)。因為它與E-mail地址的相似性,SIP URLs容易與使用者的E-mail地址關聯。
第三方註冊:此時From域與To域中的地址將會不同,如果使用者A代理使用者B進行註冊,那麼From域中將會填寫使用者A的帳號;To域中將會填寫使用者B的帳號。
註冊更新:逾時前重新發起的Register訊息中Call-ID參數不變,Cseq參數則會增加。
User’s address bob@office.com is bound to user’s current location 197.63.48.169.
註冊請求
註冊響應
1.1.1. 直接呼叫
由使用者代理程式服務機(UAC)向使用者代理程式伺服器(UAS)直接呼叫。
例1
例2
Alice Bob
| |
| INVITE F1 |
|----------------------->|
| 180 Ringing F2 |
|<-----------------------|
| |
| 200 OK F3 |
|<-----------------------|
| ACK F4 |
|----------------------->|
| Both Way RTP Media |
|<======================>|
| |
| BYE F5 |
|<-----------------------|
| 200 OK F6 |
|----------------------->|
| |
F1 INVITE Alice -> Bob
INVITE sip:bob@biloxi.example.com SIP/2.0
Via: SIP/2.0/TCP client.atlanta.example.com:5060;branch=z9hG4bK74bf9
Max-Forwards: 70
From: Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl
To: Bob <sip:bob@biloxi.example.com>
Call-ID: 3848276298220188511@atlanta.example.com
CSeq: 1 INVITE
Contact: <sip:alice@client.atlanta.example.com;transport=tcp>
Content-Type: application/sdp
Content-Length: 151
v=0
o=alice 2890844526 2890844526 IN IP4 client.atlanta.example.com s=-
c=IN IP4 192.0.2.101
t=0 0
m=audio 49172 RTP/AVP 0
a=rtpmap:0 PCMU/8000
F2 180 Ringing Bob -> Alice
SIP/2.0 180 Ringing
Via: SIP/2.0/TCP client.atlanta.example.com:5060;branch=z9hG4bK74bf9;received=192.0.2.101
From: Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl
To: Bob <sip:bob@biloxi.example.com>;tag=8321234356
Call-ID: 3848276298220188511@atlanta.example.com
CSeq: 1 INVITE
Contact: <sip:bob@client.biloxi.example.com;transport=tcp>
Content-Length: 0
F3 200 OK Bob -> Alice
SIP/2.0 200 OK
Via: SIP/2.0/TCP client.atlanta.example.com:5060;branch=z9hG4bK74bf9;received=192.0.2.101
From: Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl
To: Bob <sip:bob@biloxi.example.com>;tag=8321234356
Call-ID: 3848276298220188511@atlanta.example.com
CSeq: 1 INVITE
Contact: <sip:bob@client.biloxi.example.com;transport=tcp>
Content-Type: application/sdp
Content-Length: 147
v=0
o=bob 2890844527 2890844527 IN IP4 client.biloxi.example.com s=-
c=IN IP4 192.0.2.201
t=0 0
m=audio 3456 RTP/AVP 0
……
F4 ACK Alice -> Bob
ACK sip:bob@client.biloxi.example.com SIP/2.0
Via: SIP/2.0/TCP client.atlanta.example.com:5060;branch=z9hG4bK74bd5
Max-Forwards: 70
From: Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl
To: Bob <sip:bob@biloxi.example.com>;tag=8321234356
Call-ID: 3848276298220188511@atlanta.example.com
CSeq: 1 ACK
Content-Length: 0
/* RTP streams are established between Alice and Bob */
/* Bob Hangs Up with Alice. Note that the CSeq is NOT 2, since
Alice and Bob maintain their own independent CSeq counts.
(The INVITE was request 1 generated by Alice, and the BYE is
request 1 generated by Bob) */
F5 BYE Bob -> Alice
BYE sip:alice@client.atlanta.example.com SIP/2.0
Via: SIP/2.0/TCP client.biloxi.example.com:5060;branch=z9hG4bKnashds7
Max-Forwards: 70
From: Bob <sip:bob@biloxi.example.com>;tag=8321234356
To: Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl
Call-ID: 3848276298220188511@atlanta.example.com
CSeq: 1 BYE
Content-Length: 0
F6 200 OK Alice -> Bob
SIP/2.0 200 OK
Via: SIP/2.0/TCP client.biloxi.example.com:5060;branch=z9hG4bKnashds7 ;received=192.0.2.201
From: Bob <sip:bob@biloxi.example.com>;tag=8321234356
To: Alice <sip:alice@atlanta.example.com>;tag=9fxced76sl
Call-ID: 3848276298220188511@atlanta.example.com
CSeq: 1 BYE
Content-Length: 0