- before SIP protocol , what is a protocol
以qq为例, qq的client如何在various tcp data find out qq data , 就是用qq的应用层协议识别
协议包括头部信息, 数据长度 , flow control , error control 等
一个最简单的协议例子是:
1: 单向传播, 没有flow control 和 error control
2: 假设 receiver 可以无时延的收到所有data
3: 在数据链接层 , receiver可以去掉头部信息并上传给 net 层
4: sender side , data link 层 接受data from net 层
- 那么, 什么是sip 协议? sip协议由以下几个RFC文档构成
https://www.ietf.org/rfc/rfc3261.txt
https://tools.ietf.org/html/rfc3262
Reliability of Provisional Responses in the Session Initiation Protocol (SIP)
说明:
1 2 3 4 |
SIP defines two types of responses, provisional and final. Final responses convey the result of the request processing, and are sent reliably. Provisional responses provide information on the progress of the request processing, but are not sent reliably |
sip 定义了2中response , final response 和 provisional response ,
provisional 是临时的 , 以1开头, 比如 100 trying, 180 ringing , 一个invite 可能会有多个 provisional response , provisonal response 不是 reliable 因为没有ACK 机制, 但是,对于有的 provisional response ,又必须确保其正确传达到 client , 所以, PRACK (Provisional Response Acknowledgement) method 被用到
对于 prack 的详细解释, 见 https://www.dialogic.com/webhelp/BorderNet2020/1.0.0/WebHelp/sip_prack.htm
https://www.avaya.com/blogs/archives/2015/12/understanding-sip-prack-for-avaya-aura.html
https://www.vocal.com/sip-2/prack/
final (2xx-6xx) ,一个invite 只能有1个 final response
详细见 : https://andrewjprokop.wordpress.com/2014/06/18/understanding-sip-responses/
对于 pjsip 来说, pjsip_ua lib 实现的是rfc 3262 所描述的功能
RFC 3665 : 具体讲一个 sip callflow 的例子 SIP与SIP通话 https://tools.ietf.org/html/rfc3665
bob and alice are all sip agent
bob send register request to sip server
1 2 3 4 5 6 7 8 9 10 11 |
Bob SIP Server | | | REGISTER F1 | |------------------------------>| | 401 Unauthorized F2 | |<------------------------------| | REGISTER F3 | |------------------------------>| | 200 OK F4 | |<------------------------------| | | |
1 2 |
This flow shows the use of HTTP Digest for authentication using TLS transport. |
上图是 TLS 协议传输 register 的示例 , 在实际中, 手机zoiper一般不用 TLS
TLS 端口是 5061 , 非 TLS 是 5060
当 zoiper 用户停用账户时 , 也会发一个 register request , 但是 :
message header —-> contact —> contact parameter : expires =0
—
在通话过程中, 也就是 session already establish , 还会发现有 invite request 出现
this is called “re-invite” , see article https://tools.ietf.org/html/rfc6141
RFC 3666 : SIP 与 PSTN callflow https://tools.ietf.org/html/rfc3666
-
- RFC 5939 : 详细解释 session description protocol (SDP)
https://tools.ietf.org/html/rfc5939
- 关键字
call center 呼叫中心
asterisk
freeSwitch
kamailio
opensips
Kamailio : 开源的sip proxy server
NAT traversal : 内网穿透
PBX : private branch exchange 私有交换机 , asterisk 就是 soft PBX , SIP SERVER 指的也是 PBX
NAP : network access point