MichelinMessi 2020-05-16
最近在做SIP相关,整理下文档
1.client向server发送注册请求 REGISTER sip:114.116.224.107 SIP/2.0 Via: SIP/2.0/UDP 10.93.244.6:5060;rport;branch=z9hG4bKPjYqs3EqEoCHrmDM5TdFDI8zYraI3mhzFM Max-Forwards: 70 From: <sip:114.116.224.107>;tag=CB.XiNZfHrSBvnAuqwHiZRt8DxvMi0T3 To: <sip:114.116.224.107> Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49088 REGISTER Contact: <sip:10.93.244.6:5060;ob> Expires: 300 Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Content-Length: 0 2.server返回401, 并带上密钥 SIP/2.0 401 Unauthorized Via: SIP/2.0/UDP 10.93.244.6:5060;rport=5060;branch=z9hG4bKPjYqs3EqEoCHrmDM5TdFDI8zYraI3mhzFM From: <sip:114.116.224.107>;tag=CB.XiNZfHrSBvnAuqwHiZRt8DxvMi0T3 To: <sip:114.116.224.107>;tag=rBKvaNN2cSj4e Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49088 REGISTER User-Agent: FreeSWITCH-mod_sofia/1.10.2-release+git~20191231T140119Z~f7bdd3845a~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE Supported: timer, path, replaces WWW-Authenticate: Digest realm="114.116.224.107", nonce="c8ba50d5-eab6-4a1f-9aa7-9f8c88f96c90", algorithm=MD5, qop="auth" Content-Length: 0 3.server收到401和密钥,通过密钥加密注册密码,然后返回给server REGISTER sip:114.116.224.107 SIP/2.0 Via: SIP/2.0/UDP 10.93.244.6:5060;rport;branch=z9hG4bKPjycbsvrhaCRSwvM1BReQaULqjhPZj4u6J Max-Forwards: 70 From: <sip:114.116.224.107>;tag=CB.XiNZfHrSBvnAuqwHiZRt8DxvMi0T3 To: <sip:114.116.224.107> Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49089 REGISTER Contact: <sip:10.93.244.6:5060;ob> Expires: 300 Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Authorization: Digest username="1005", realm="114.116.224.107", nonce="c8ba50d5-eab6-4a1f-9aa7-9f8c88f96c90", uri="sip:114.116.224.107", response="948801fddf1be64200dc700367d832ef", algorithm=MD5, cnonce="jpgf75GhmNhZoxjqHZfthlhqfD4PGasJ", qop=auth, nc=00000001 //验证信息 Content-Length: 0 4.server返回200 验证成功 SIP/2.0 200 OK Via: SIP/2.0/UDP 10.93.244.6:5060;rport=5060;branch=z9hG4bKPjycbsvrhaCRSwvM1BReQaULqjhPZj4u6J From: <sip:114.116.224.107>;tag=CB.XiNZfHrSBvnAuqwHiZRt8DxvMi0T3 To: <sip:114.116.224.107>;tag=SmcNcg65918pa Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49089 REGISTER Contact: <sip:10.93.244.6:5060;ob>;expires=300 Date: Sun, 30 Mar 2020 03:22:15 GMT User-Agent: FreeSWITCH-mod_sofia/1.10.2-release+git~20191231T140119Z~f7bdd3845a~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE Supported: timer, path, replaces Content-Length: 0
1.client向server发送注销请求,REGISTER,Expires被设置为0 REGISTER sip:114.116.224.107 SIP/2.0 Via: SIP/2.0/UDP 10.93.244.6:5060;rport;branch=z9hG4bKPjCqeYwimKf9L52BQCayGkV9sGGrsXFLkW Max-Forwards: 70 From: <sip:114.116.224.107>;tag=DYA25izzkD4rNjstBnvJPfAv487vsRP7 To: <sip:114.116.224.107> Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49090 REGISTER Contact: <sip:10.93.244.6:5060;ob> Expires: 0 Content-Length: 0 2.server带回验证key SIP/2.0 401 Unauthorized Via: SIP/2.0/UDP 10.93.244.6:5060;rport=5060;branch=z9hG4bKPjCqeYwimKf9L52BQCayGkV9sGGrsXFLkW From: <sip:114.116.224.107>;tag=DYA25izzkD4rNjstBnvJPfAv487vsRP7 To: <sip:114.116.224.107>;tag=y1aHNQtQUermm Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49090 REGISTER User-Agent: FreeSWITCH-mod_sofia/1.10.2-release+git~20191231T140119Z~f7bdd3845a~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE Supported: timer, path, replaces WWW-Authenticate: Digest realm="114.116.224.107", nonce="6710e4ba-e19f-403e-a3d7-65e628211b81", algorithm=MD5, qop="auth" Content-Length: 0 3.client加密认证信息再次发送REGISTER REGISTER sip:114.116.224.107 SIP/2.0 Via: SIP/2.0/UDP 10.93.244.6:5060;rport;branch=z9hG4bKPjX6W-c9Wzo.3-shnAIByzLiET6o2R1-hb Max-Forwards: 70 From: <sip:114.116.224.107>;tag=DYA25izzkD4rNjstBnvJPfAv487vsRP7 To: <sip:114.116.224.107> Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49091 REGISTER Contact: <sip:10.93.244.6:5060;ob> Expires: 0 Authorization: Digest username="1005", realm="114.116.224.107", nonce="6710e4ba-e19f-403e-a3d7-65e628211b81", uri="sip:114.116.224.107", response="4bffa0240ce67296e5401c13e4235939", algorithm=MD5, cnonce="jpgf75GhmNhZoxjqHZfthlhqfD4PGasJ", qop=auth, nc=00000001 Content-Length: 0 4.验证成功,注销完成 SIP/2.0 200 OK Via: SIP/2.0/UDP 10.93.244.6:5060;rport=5060;branch=z9hG4bKPjX6W-c9Wzo.3-shnAIByzLiET6o2R1-hb From: <sip:114.116.224.107>;tag=DYA25izzkD4rNjstBnvJPfAv487vsRP7 To: <sip:114.116.224.107>;tag=Za49pjBUrQe7F Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49091 REGISTER Date: Sun, 30 Mar 2020 03:22:35 GMT User-Agent: FreeSWITCH-mod_sofia/1.10.2-release+git~20191231T140119Z~f7bdd3845a~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE Supported: timer, path, replaces Content-Length: 0
REGISTER sip:114.116.224.107 SIP/2.0 Via: SIP/2.0/UDP 10.93.244.6:5060;rport;branch=z9hG4bKPjYqs3EqEoCHrmDM5TdFDI8zYraI3mhzFM Max-Forwards: 70 From: <sip:114.116.224.107>;tag=CB.XiNZfHrSBvnAuqwHiZRt8DxvMi0T3 To: <sip:114.116.224.107> Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49088 REGISTER Contact: <sip:10.93.244.6:5060;ob> Expires: 300 Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Content-Length: 0
REGISTER sip:114.116.224.107 SIP/2.0 Via: SIP/2.0/UDP 10.93.244.6:5060;rport;branch=z9hG4bKPjX6W-c9Wzo.3-shnAIByzLiET6o2R1-hb Max-Forwards: 70 From: <sip:114.116.224.107>;tag=DYA25izzkD4rNjstBnvJPfAv487vsRP7 To: <sip:114.116.224.107> Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49091 REGISTER Contact: <sip:10.93.244.6:5060;ob> Expires: 0 Authorization: Digest username="1005", realm="114.116.224.107", nonce="6710e4ba-e19f-403e-a3d7-65e628211b81", uri="sip:114.116.224.107", response="4bffa0240ce67296e5401c13e4235939", algorithm=MD5, cnonce="jpgf75GhmNhZoxjqHZfthlhqfD4PGasJ", qop=auth, nc=00000001 Content-Length: 0
INVITE sip:114.116.224.107:5060 SIP/2.0 Via: SIP/2.0/UDP 10.93.244.6:5060;rport;branch=z9hG4bKPj7mkDH292jmm1y6Y2Jkws.gWRKW40d8Kp Max-Forwards: 70 From: sip:114.116.224.107;tag=mBuoO4GR7-AC-XUHv0cgzvX16MuG4Kng To: sip:114.116.224.107 Contact: <sip:10.93.244.6:5060;ob> Call-ID: IqTLNL8Gfdx09DOa8VUFb9XCMncifRav CSeq: 13594 INVITE Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Supported: replaces, 100rel, timer, norefersub Session-Expires: 1800 Min-SE: 90 Proxy-Authorization: Digest username="1005", realm="114.116.224.107", nonce="f1e24226-ce30-4829-9614-a766901286bb", uri="sip::5060", response="4d7707bcc2decb57d9a11cce6b08529d", algorithm=MD5, cnonce="4vUxSXgyvi49AycztD.GDdu171ISBQlF", qop=auth, nc=00000001 Content-Type: application/sdp Content-Length: 741 v=0 o=- 3794527338 3794527338 IN IP4 10.93.244.6 s=pjmedia b=AS:117 t=0 0 a=X-nat:0 m=audio 4000 RTP/AVP 96 97 98 99 3 0 8 9 100 120 121 122 123 c=IN IP4 10.93.244.6 b=TIAS:96000 a=rtcp:4001 IN IP4 10.93.244.6 a=sendrecv a=rtpmap:96 speex/16000 a=rtpmap:97 speex/8000 a=rtpmap:98 speex/32000 a=rtpmap:99 iLBC/8000 a=fmtp:99 mode=30 a=rtpmap:3 GSM/8000 a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:9 G722/8000 a=rtpmap:100 opus/48000/2 a=fmtp:100 useinbandfec=1 a=rtpmap:120 telephone-event/16000 a=fmtp:120 0-16 a=rtpmap:121 telephone-event/8000 a=fmtp:121 0-16 a=rtpmap:122 telephone-event/32000 a=fmtp:122 0-16 a=rtpmap:123 telephone-event/48000 a=fmtp:123 0-16 a=ssrc:731817971 cname:5cc7c43d3f24b061
SIP/2.0 401 Unauthorized Via: SIP/2.0/UDP 10.93.244.6:5060;rport=5060;branch=z9hG4bKPjYqs3EqEoCHrmDM5TdFDI8zYraI3mhzFM From: <sip:114.116.224.107>;tag=CB.XiNZfHrSBvnAuqwHiZRt8DxvMi0T3 To: <sip:114.116.224.107>;tag=rBKvaNN2cSj4e Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49088 REGISTER User-Agent: FreeSWITCH-mod_sofia/1.10.2-release+git~20191231T140119Z~f7bdd3845a~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE Supported: timer, path, replaces WWW-Authenticate: Digest realm="114.116.224.107", nonce="c8ba50d5-eab6-4a1f-9aa7-9f8c88f96c90", algorithm=MD5, qop="auth" Content-Length: 0
SIP/2.0 407 Proxy Authentication Required Via: SIP/2.0/UDP 10.93.244.6:5060;rport=5060;branch=z9hG4bKPjeLCrGcm6YPo9ntRNCkJJXWY6wMdZBWTe From: <sip:114.116.224.107>;tag=mBuoO4GR7-AC-XUHv0cgzvX16MuG4Kng To: <sip:114.116.224.107>;tag=U6y6F67c4KNvH Call-ID: IqTLNL8Gfdx09DOa8VUFb9XCMncifRav CSeq: 13593 INVITE User-Agent: FreeSWITCH-mod_sofia/1.10.2-release+git~20191231T140119Z~f7bdd3845a~64bit Accept: application/sdp Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE Supported: timer, path, replaces Allow-Events: talk, hold, conference, presence, as-feature-event, dialog, line-seize, call-info, sla, include-session-description, presence.winfo, message-summary, refer Proxy-Authenticate: Digest realm="114.116.224.107", nonce="f1e24226-ce30-4829-9614-a766901286bb", algorithm=MD5, qop="auth" Content-Length: 0
ACK sip:114.116.224.107:5060 SIP/2.0 Via: SIP/2.0/UDP 10.93.244.6:5060;rport;branch=z9hG4bKPjeLCrGcm6YPo9ntRNCkJJXWY6wMdZBWTe Max-Forwards: 70 From: sip:114.116.224.107;tag=mBuoO4GR7-AC-XUHv0cgzvX16MuG4Kng To: sip:114.116.224.107;tag=U6y6F67c4KNvH Call-ID: IqTLNL8Gfdx09DOa8VUFb9XCMncifRav CSeq: 13593 ACK Content-Length: 0
SIP/2.0 200 OK Via: SIP/2.0/UDP 10.93.244.6:5060;rport=5060;branch=z9hG4bKPjX6W-c9Wzo.3-shnAIByzLiET6o2R1-hb From: <sip:114.116.224.107>;tag=DYA25izzkD4rNjstBnvJPfAv487vsRP7 To: <sip:114.116.224.107>;tag=Za49pjBUrQe7F Call-ID: jRZZL9t5obumvLrRrpgTvs8NlbY9Ts2O CSeq: 49091 REGISTER Date: Sun, 30 Mar 2020 03:22:35 GMT User-Agent: FreeSWITCH-mod_sofia/1.10.2-release+git~20191231T140119Z~f7bdd3845a~64bit Allow: INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, INFO, UPDATE, REGISTER, REFER, NOTIFY, PUBLISH, SUBSCRIBE Supported: timer, path, replaces Content-Length: 0
BYE sip:114.116.224.107:5060;transport=udp SIP/2.0 Via: SIP/2.0/UDP 10.93.244.6:5060;rport;branch=z9hG4bKPjEb-cfykgn.pipVqIPwpR9e0Vte4VW96I Max-Forwards: 70 From: sip:114.116.224.107;tag=mBuoO4GR7-AC-XUHv0cgzvX16MuG4Kng To: sip:114.116.224.107;tag=vFrZH1rg1vBFD Call-ID: IqTLNL8Gfdx09DOa8VUFb9XCMncifRav CSeq: 13595 BYE Content-Length: 0