SIP 學習筆記之一 流程

                                                                   SIP 學習筆記之一 流程

 
 
        下面是一個invite事務的主要步驟(省略了100trying和180ring,增加了200ok的ack,ack已經不屬於invite事物), u1 call u2, 主要記錄包的主要字段已經這些字段在轉發過程中的一些更改. 
 
UAC1 --         Proxy1 -----------      Proxy2-----          UAC2
[email protected]         a.com               b.com                   [email protected]
 
U1 call U2, 從invite到bye, 在整個流程中包的轉發的改變.如 resquest URI, via,contact, recorded-route, route, call-id,branch等的變化.
 
/************** U1 invite *****************/
Via: u1.a.com:prot;branch= z9hG4bK- xxxxxxxxx // via ,branch 表示了這個事務;
Contact : [email protected] // 爲被聯繫的地址;接收請求的地址;
Call-ID [email protected]        // 標識整個流程,從invite到bye中的各個事務;
From: [email protected]; tag=xxxx; //caller 發出時產生from tag; to 的tag 在callee回覆時產生. 如100trying
Cseq: 1 invite;               // 表示同一個流程中的事務的先後順序.以便服務器正確的改變該uac的狀態;
 
/************** P1 Forward invite to P2 *****************/
Request URI: [email protected]     // proxy找到b對應的域,並修改request uri;
Via: a.com:prot;branch= z9hG4bK- yyyyyyy  // via ,branch // 沒經過一個proxy轉發就增加via,裏面包括branch的值;
Via: u1.a.com:prot;branch= z9hG4bK- xxxxxxxxx // via ,branch
Recorded-route: a.com:port;lr
From: [email protected]; tag=xxxx;
Cseq: 1 invite;
 
/************** P2 Forward invite to U2*****************/
Request URI:[email protected]
Via:b.com:port;branch= z9hG4bK- zzzzzzz; branch
Via: a.com:prot;branch= z9hG4bK- yyyyyyy // via ,branch 
Via: u1.a.com:prot;branch= z9hG4bK- xxxxxxxxx // via ,branch
Recorded-route: b.com:port:lr
Recorded-route: a.com:port;lr
From: [email protected]; tag=xxxx;
Cseq: 1 invite;
 
/************** U2 100 Trying and 180 Ring reserved*****************/
/************** U2 send 200OK to p2*****************/
Request URI:[email protected]
Via:b.com:port;branch= z9hG4bK- zzzzzzz;  //回覆時的路由由via指定,只有是下一個請求時路由由route指定,所以在請求包中才指定route ;
Via: a.com:prot;branch= z9hG4bK- yyyyyyy // via ,branch 
Via: u1.a.com:prot;branch= z9hG4bK- xxxxxxxxx // via ,branch
Recorded-route: b.com:port:lr
Recorded-route: a.com:port;lr // recored-route 只有在這通會話結束時纔會被刪除.
Cseq:1 invite;
 
/************** P2 send 200OK to p1*****************/
Request URI:[email protected]
Via: a.com:prot;branch= z9hG4bK- yyyyyyy // via ,branch // 如何判斷loop? Proxy在比較本地ip是否在via中,如果在的話, 這比較branch是否相同,若相同則表示有環路,發送482,結束該會話,若不同這加上via,繼續轉發;
Via: u1.a.com:prot;branch= z9hG4bK- xxxxxxxxx // via ,branch
Recorded-route: b.com:port:lr
Recorded-route: a.com:port;lr //
Cseq:1 invite;
 
/************** P1send 200OK to u1 *****************/
Request URI:[email protected]
Via: u1.a.com:prot;branch= z9hG4bK- xxxxxxxxx // via ,branch
Recorded-route: b.com:port:lr //若在p1 在發送invite時,未添加recorded-route,這少了a.com這條,則當p1轉發200ok給u1時應該修改recorded-route的值,有b.comàa.com,給P1發送bye請求指定正確的路由;
Recorded-route: a.com:port;lr 
Cseq:1 invite;
 
/************** u1 send ack to p1 *****************/
Via: [email protected]; branch= z9hG4bK- xxxxxxxxx // branch 和第一個invite的相同
Recorded-route: b.com:port:lr
Recorded-route: a.com:port;lr //
Call-id
Cseq:1 ack;
 
/************** p1 send ack to p2 *****************/
Via: [email protected]; branch= z9hG4bK- xxxxxxxxx // branch 和第一個invite的相同
Via: a.com:prot;branch= z9hG4bK- yyyyyyy // via ,branch
Recorded-route: b.com:port:lr
Recorded-route: a.com:port;lr //
Call-id
Cseq:1 ack;
 
 
/************** p2 send ack to u2 *****************/
Via: [email protected]; branch= z9hG4bK- xxxxxxxxx // branch 和第一個invite的相同?
Via: a.com:prot;branch= z9hG4bK- yyyyyyy // via branch和之前的相同?
Via: b.com:prot;branch= z9hG4bK- zzzzzzz// via
Recorded-route: b.com:port:lr
Recorded-route: a.com:port;lr //
Call-id
Cseq:1 ack;
下面附上另一例子.
###########################################################################

 SIP Process

                               

/*************************************************************************/

/*                       Caller initiates a CALL                                                                                       */

/*************************************************************************/

 

(1)caller sends INVITE to proxy

 

INVITE sip:[email protected] SIP/2.0

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-d225e854f32d305d-1--d87543-;rport

Max-Forwards: 70

Contact: <sip:[email protected]:6054>

To: <sip:[email protected]>

From: "121"<sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 1 INVITE

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO

Content-Type: application/sdp

Supported: eventlist

User-Agent: eyeBeam release 3015c stamp 27107

Content-Length: 174

 

v=0

o=- 158622668 158622784 IN IP4 192.168.0.7

s=eyeBeam

c=IN IP4 192.168.0.7

t=0 0

m=audio 6056 RTP/AVP 18

a=alt:1 1 : 6E90EB78 DE47B706 192.168.0.7 6056

a=sendrecv

 

(2)Proxy sends Trying to caller

 

SIP/2.0 100 Trying

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-d225e854f32d305d-1--d87543-;rport=6054;received=116.227.0.44

From: "121"<sip:[email protected]>;tag=eb7eb665

To: <sip:[email protected]>

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 1 INVITE

Server: Brekeke SIP Server rev.239

Content-Length: 0

 

(3)Proxy sends 407 to caller

 

SIP/2.0 407 Proxy Authentication Required

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-d225e854f32d305d-1--d87543-;rport=6054;received=116.227.0.44

From: "121"<sip:[email protected]>;tag=eb7eb665

To: <sip:[email protected]>;tag=bf5a41354s

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 1 INVITE

Server: Brekeke SIP Server rev.239

Proxy-Authenticate: Digest realm="sharepoint",nonce="8e33a2d7020a3fd855c91b66dd1794200cff2fcb",algorithm=MD5

Content-Length: 0

 

(4)Caller sends ACK to proxy

 

ACK sip:[email protected] SIP/2.0

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-d225e854f32d305d-1--d87543-;rport

To: <sip:[email protected]>;tag=bf5a41354s

From: "121"<sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 1 ACK

Content-Length: 0

 

(5)Caller sends INVITE with authorization to Proxy

 

INVITE sip:[email protected] SIP/2.0

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-1360d1470e65407a-1--d87543-;rport

Max-Forwards: 70

Contact: <sip:[email protected]:6054>

To: <sip:[email protected]>

From: "121"<sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 INVITE

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO

Content-Type: application/sdp

Proxy-Authorization: Digest username="121",realm="sharepoint",nonce="8e33a2d7020a3fd855c91b66dd1794200cff2fcb",uri="sip:[email protected]",response="181e124b006b03d1ac51d2d54bf9edd0",algorithm=MD5

Supported: eventlist

User-Agent: eyeBeam release 3015c stamp 27107

Content-Length: 174

 

v=0

o=- 158622668 158622784 IN IP4 192.168.0.7

s=eyeBeam

c=IN IP4 192.168.0.7

t=0 0

m=audio 6056 RTP/AVP 18

a=alt:1 1 : 6E90EB78 DE47B706 192.168.0.7 6056

a=sendrecv

 

(6)Proxy sends INVITE to callee

 

INVITE sip:[email protected]:5060;user=phone SIP/2.0

Via: SIP/2.0/UDP 192.168.0.121:5060;rport;branch=z9hG4bK0d40ceebef1-c38f89c2-2b40ce84

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-1360d1470e65407a-1--d87543-;rport=6054;received=116.227.0.44

Max-Forwards: 69

Contact: <sip:[email protected]:5060>

To: <sip:[email protected]>

From: "121"<sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 INVITE

Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO

Proxy-Authorization: Digest username="121",realm="sharepoint",nonce="8e33a2d7020a3fd855c91b66dd1794200cff2fcb",uri="sip:[email protected]",response="181e124b006b03d1ac51d2d54bf9edd0",algorithm=MD5

Supported: eventlist

User-Agent: eyeBeam release 3015c stamp 27107

P-Behind-NAT: Yes

Record-Route: <sip:192.168.0.121:5060;lr>

Content-Type: application/sdp

Content-Length: 131

 

v=0

o=- 158622668 158622784 IN IP4 192.168.0.121

s=eyeBeam

c=IN IP4 192.168.0.121

t=0 0

m=audio 10156 RTP/AVP 18

a=sendrecv

 

(7)Callee sends Trying to proxy

 

SIP/2.0 100 Trying

Via: SIP/2.0/UDP 192.168.0.121:5060;rport=5060;branch=z9hG4bK0d40ceebef1-c38f89c2-2b40ce84

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-1360d1470e65407a-1--d87543-;rport=6054;received=116.227.0.44

To: <sip:[email protected]>

From: "121" <sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 INVITE

Content-Length: 0

 

(8)Callee sends Ringing to proxy

 

SIP/2.0 180 Ringing

Via: SIP/2.0/UDP 192.168.0.121:5060;rport=5060;branch=z9hG4bK0d40ceebef1-c38f89c2-2b40ce84

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-1360d1470e65407a-1--d87543-;rport=6054;received=116.227.0.44

Contact: <sip:[email protected]:5060;user=phone>

Record-Route: <sip:192.168.0.121:5060;lr>

To: <sip:[email protected]>;tag=995280513

From: "121" <sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 INVITE

Content-Length: 0

 

(9)Proxy sends Trying to caller

 

SIP/2.0 100 Trying

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-1360d1470e65407a-1--d87543-;rport=6054;received=116.227.0.44

From: "121"<sip:[email protected]>;tag=eb7eb665

To: <sip:[email protected]>

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 INVITE

Server: Brekeke SIP Server rev.239

Content-Length: 0

 

(10)Proxy sends Ringing to caller

 

SIP/2.0 180 Ringing

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-1360d1470e65407a-1--d87543-;rport=6054;received=116.227.0.44

Contact: <sip:[email protected]:5060;user=phone>

Record-Route: <sip:116.228.5.146:5060;lr>

To: <sip:[email protected]>;tag=995280513

From: "121" <sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 INVITE

Content-Length: 0

 

/*************************************************************************/

/*               Ringing,waiting callee "off hook"                                                                               */

/*************************************************************************/

 

(11)Callee sends OK to proxy

 

SIP/2.0 200 OK

Via: SIP/2.0/UDP 192.168.0.121:5060;rport=5060;branch=z9hG4bK0d40ceebef1-c38f89c2-2b40ce84

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-1360d1470e65407a-1--d87543-;rport=6054;received=116.227.0.44

Contact: <sip:[email protected]:5060;user=phone>

Record-Route: <sip:192.168.0.121:5060;lr>

To: <sip:[email protected]>;tag=995280513

From: "121" <sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 INVITE

Content-Type: application/sdp

Content-Length:   170

 

v=0

o=- 1707914491 1707914491 IN IP4 192.168.0.58

s=-

c=IN IP4 192.168.0.58

t=0 0

m=audio 40000 RTP/AVP 18

a=rtpmap:18 G729/8000

a=fmtp:18 annexb=no

a=ptime:20

 

(12)Proxy sends OK to caller

 

SIP/2.0 200 OK

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-1360d1470e65407a-1--d87543-;rport=6054;received=116.227.0.44

Contact: <sip:[email protected]:5060;user=phone>

Record-Route: <sip:116.228.5.146:5060;lr>

To: <sip:[email protected]>;tag=995280513

From: "121" <sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 INVITE

Content-Type: application/sdp

Content-Length: 171

 

v=0

o=- 1707914491 1707914491 IN IP4 116.228.5.146

s=-

c=IN IP4 116.228.5.146

t=0 0

m=audio 10158 RTP/AVP 18

a=rtpmap:18 G729/8000

a=fmtp:18 annexb=no

a=ptime:20

 

(13)Caller sends ACK to proxy

 

ACK sip:[email protected]:5060;user=phone SIP/2.0

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-5e41766c37714d75-1--d87543-;rport

Max-Forwards: 70

Route: <sip:116.228.5.146:5060;lr>

Contact: <sip:[email protected]:6054>

To: <sip:[email protected]>;tag=995280513

From: "121"<sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 ACK

Proxy-Authorization: Digest username="121",realm="sharepoint",nonce="8e33a2d7020a3fd855c91b66dd1794200cff2fcb",uri="sip:[email protected]",response="181e124b006b03d1ac51d2d54bf9edd0",algorithm=MD5

User-Agent: eyeBeam release 3015c stamp 27107

Content-Length: 0

 

(14)Proxy sends ACK to callee

 

ACK sip:[email protected]:5060;user=phone SIP/2.0

Via: SIP/2.0/UDP 192.168.0.121:5060;rport;branch=z9hG4bKfc7a71cbef1-c38f89c2-2b40ce84

Via: SIP/2.0/UDP 192.168.0.7:6054;branch=z9hG4bK-d87543-5e41766c37714d75-1--d87543-;rport=6054;received=116.227.0.44

Max-Forwards: 69

Contact: <sip:[email protected]:5060>

To: <sip:[email protected]>;tag=995280513

From: "121"<sip:[email protected]>;tag=eb7eb665

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 2 ACK

Proxy-Authorization: Digest username="121",realm="sharepoint",nonce="8e33a2d7020a3fd855c91b66dd1794200cff2fcb",uri="sip:[email protected]",response="181e124b006b03d1ac51d2d54bf9edd0",algorithm=MD5

User-Agent: eyeBeam release 3015c stamp 27107

P-Behind-NAT: Yes

Record-Route: <sip:192.168.0.121:5060;lr>

Content-Length: 0

 

/*************************************************************************/

/*                      Callee "on hook"                                                                                    */

/*************************************************************************/

 

(15)Callee sends BYE to proxy

 

BYE sip:[email protected]:5060 SIP/2.0

Via: SIP/2.0/UDP 192.168.0.58:5060;branch=z9hG4bK-1042040550

Route: <sip:192.168.0.121:5060;lr>

To: "121" <sip:[email protected]>;tag=eb7eb665

From: <sip:[email protected]>;tag=995280513

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 3 BYE

Max-Forwards: 70

User-Agent: Dlink-1.00.370

Content-Length: 0

 

(16)Proxy sends BYE to caller

 

BYE sip:[email protected]:6054 SIP/2.0

Via: SIP/2.0/UDP 116.228.5.146:5060;rport;branch=z9hG4bK4ac58eebef3-84116836-de76c3f7

Via: SIP/2.0/UDP 192.168.0.58:5060;branch=z9hG4bK-1042040550

To: "121" <sip:[email protected]>;tag=eb7eb665

From: <sip:[email protected]>;tag=995280513

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 3 BYE

Max-Forwards: 69

User-Agent: Dlink-1.00.370

Record-Route: <sip:116.228.5.146:5060;lr>

Content-Length: 0

 

(17)Caller sends OK to proxy

 

SIP/2.0 200 OK

Via: SIP/2.0/UDP 116.228.5.146:5060;rport=5060;branch=z9hG4bK4ac58eebef3-84116836-de76c3f7

Via: SIP/2.0/UDP 192.168.0.58:5060;branch=z9hG4bK-1042040550

Record-Route: <sip:116.228.5.146:5060;lr>

Contact: <sip:[email protected]:6054>

To: "121"<sip:[email protected]>;tag=eb7eb665

From: <sip:[email protected]>;tag=995280513

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 3 BYE

User-Agent: eyeBeam release 3015c stamp 27107

Content-Length: 0

 

(18)Prxoy sends OK to callee

 

SIP/2.0 200 OK

Via: SIP/2.0/UDP 192.168.0.58:5060;branch=z9hG4bK-1042040550

Record-Route: <sip:192.168.0.121:5060;lr>

Contact: <sip:[email protected]:5060>

To: "121"<sip:[email protected]>;tag=eb7eb665

From: <sip:[email protected]>;tag=995280513

Call-ID: 1b693f6e6b37ef70@dG9tYXRvLTNlMTY2Zjgw

CSeq: 3 BYE

User-Agent: eyeBeam release 3015c stamp 27107

Content-Length: 0

 

 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章