NOTIFY sip:pafnuty@lecturehall21.academy.ru SIP/2.0
Via SIP/2.0/TCP dist.probablilty.org:5060;branch=z9hG4bK4321 Max-Forwards: 70
To: P. L. Chebychev
Allow: ACK, INVITE, CANCEL, BYE, NOTIFY, SUBSCRIBE, MESSAGE Allow-Events: dialog
Contact:
Content-Type: application/cpim-pidf+xml Content-Length: 244
Chebychev 发送 200 OK 响应 NOTIFY SIP/2.0 200 OK
Via SIP/2.0/TCP dist.probablilty.org:5060 ;branch=z9hG4bK4321;received=24.32.1.3
To: P. L. Chebychev
之后,当 Poisson 登陆后,再次发送 NOTIFY 消息
NOTIFY sip:pafnuty@lecturehall21.academy.ru SIP/2.0
Via SIP/2.0/TCP dist.probablilty.org:5060;branch=z9hG4bK334241 Max-Forwards: 70
To: P. L. Chebychev
Allow: ACK, INVITE, CANCEL, BYE, NOTIFY, SUBSCRIBE, MESSAGE Allow-Events: presence
Contact:
Content-Type: application/cpim-pidf+xml Content-Length: 325
Chebychev 发 200 OK 确认 SIP/2.0 200 OK
Via SIP/2.0/TCP dist.probablilty.org:5060 ;branch=z9hG4bK334241;received=24.32.1.3
To: P. L. Chebychev
现在 Chebychev 已经知道 Possion 在线了,开始发送及时消息。 MESSAGE sip:s.possion@dist.probability.org SIP/2.0
Via SIP/2.0/TCP lecturehall21.academy.ru:5060;branch=z9hG4bK3gtr2 Max-Forwards: 70
To: M. Poisson
From: P. L. Chebychev
Allow: ACK, INVITE, CANCEL, BYE, NOTIFY, SUBSCRIBE, MESSAGE Content-Type: text/plain Content-Length: 9
Hi There!
注意到这里,MESSAGE 是独立与会话的,它不属于任何会话。每个消息都含有一个新的 Call-ID 和 From tag。200 OK 用来确认收到该信息。 SIP/2.0 200 OK Via SIP/2.0/TCP
lecturehall21.academy.ru:5060;branch=z9hG4bK3gtr2;received=19.34.3.1 To: M. Poisson
MESSAGE sip:chebychev@academy.ru SIP/2.0
Via SIP/2.0/TCP dist.probablilty.org:5060;branch=z9hG4bK4526245 Max-Forwards: 70
To: P. L. Chebychev
From: M. Poisson
Allow: ACK, INVITE, CANCEL, BYE, NOTIFY, SUBSCRIBE, MESSAGE Content-Type: text/plain Content-Length: 30
Well, hello there to you, too! 收到消息后,发 200 OK SIP/2.0 200 OK Via SIP/2.0/TCP
dist.probablilty.org:5060;branch=z9hG4bK4526245;received=24.32.1.3 To: P. L. Chebychev
SIP 编程开发介绍
我们的系统是建立在 Trillium TAPA 架构之上的,有关 TAPA 架构请参阅相关文档,这里就不具体介绍了。今天我们的任务是学习如何建立 SIP 网络构架,也就是如何编程开发。
SIP 协议是独立于下层协议的传输机制。它可以通过 TCP 传,也可以通过 UDP 传。它自己本身提供了一套可靠方案,而使用 UDP 允许将 SIP 消息做为广播形式发送。 SIP 网络主要由两个组件组成:
? ?
用户代理 (User Agent - UA) 网络服务 (Network Server - NS)
下面是一段关于两组件的英文说明,比较容易读懂。 User Agent
A SIP user agent is an entity capable of initiating and terminating calls. It consists of a SIP protocol client ( the User Agent Client - UAC ), and a SIP protocol server ( the User Agent Server - UAS ). The UAC initiates and sends SIP requests to a SIP server. The UAS returns responses to SIP requests received on behalf of a physical user. It may accept, redirect, or refuse a call. NetWork Server
A network server is forwarding entity in the network. A Network server can be a proxy, redirect, or a registrar server, or a combination of these.
A proxy server receives a request, determines which possible server(s) to send it to, and then forwards or services the request. It acts as an intermediate routing entity that receives requests and forwards them after suitable modifications. Other functions of the proxy may include call supplementary services, policy enforcement and record keeping, authentication and authorization, and firewall or NAT traversal support.
A redirect server receives a request, resolves the received address into one or more new addresses, and returns these addresses to the client. It does not initiate SIP requests or accept calls.
A registrar server records and maintains a database of SIP addresses associated with SIP endpoints and provides an address translation service to redirect and proxy servers. It is typically co-located with either a proxy or a redirect server. However, a stand-alone registrar implementation is also possible.