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)来实现。
代理服务器类似于HTTP的proxy和SMTP的MTA(Message Transfer Agent ),有点像中继器,它本身并不对用户请求进行响应,只是转发用户请求的中继器,然后将自身地址加入该消息的路径头部分,以保证将响应按原路返回并防止环路的发生。
SIP协议支持三种呼叫方式:
l 由用户代理服务机(UAC)向用户代理服务器(UAS)直接呼叫
l 由代理服务器代表UAC向被叫发起呼叫
l 由UAC在重定向服务器的辅助下进行重定向呼叫
(1)SIP用户代理向SIP代理服务器发送呼叫,建立请求(INVITE)。
(2)SIP代理服务器向重定向服务器发送呼叫建立请求。
(3)重定向服务器返回重定向消息。
(4)SIP代理服务器向重定向服务器指定的SIP代理服务器发送呼叫,建立请求。
(5)被请求的SIP代理服务器使用非SIP协议,例如域名查询或者LDAP到定位服务器查询被叫位置。
(6)定位服务器返回被叫位置(被叫SIP代理服务器)。
(7)被请求的SIP代理服务器向被叫SIP代理服务器发送呼叫,建立请求。
(8)被叫SIP代理服务器向SIP用户代理(被叫)发送呼叫,建立请求(被叫振铃或显示)。
(9)被叫用户代理向被叫SIP用户代理服务器发送同意或拒绝。
(10)被叫用户代理服务器向主叫代理服务器所请求的代理服务器发送同意或拒绝。
(11)主叫代理服务器所请求的代理服务器向主叫代理服务器发同意或拒绝。
(12)主叫代理服务器向主叫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)直接呼叫。
例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