SIP基本呼叫

我们首先来看下主要的呼叫流程。

INVITEsip:[email protected];user=phone SIP/2.0

From:"+861069690069"<sip:[email protected];user=phone>;tag=8741b8-ac1014d2-13c4-1c6-10e9bfd8-1c6

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

Call-ID: [email protected]

CSeq: 1 INVITE

Via: SIP/2.0/UDP172.16.20.210:5060;branch=z9hG4bK-1c6-6f0cc-66d0e581

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

Max-Forwards: 70

Supported: 100rel,replaces,timer

P-Preferred-Identity:"+861069690069"<sip:[email protected];user=phone>

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

Content-Type: application/SDP

Content-Length: 236

 

v=0

o=+861069690069 454 454 IN IP4172.16.20.210

s=-

c=IN IP4 172.16.20.210

t=0 0

m=audio 10008 RTP/AVP 8 0 18 4

a=rtpmap:8 PCMA/8000

a=rtpmap:0 PCMU/8000

a=rtpmap:18 G729/8000

a=rtpmap:4 G723/8000

a=ptime:20

a=ecan:fb on -

 

用户摘机发起一路呼叫,终端+861069690069向代理server发送INVITE请求

 

SIP/2.0 100 Trying

Via: SIP/2.0/UDP172.16.20.210:5060;branch=z9hG4bK-1c6-6f0cc-66d0e581;received=192.168.100.41

Call-ID: [email protected]

From: "+861069690069"<sip:[email protected];user=phone>;tag=8741b8-ac1014d2-13c4-1c6-10e9bfd8-1c6

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

CSeq: 1 INVITE

Content-Length: 0

 

代理server收到终端发送的INVITE请求,向终端+861069690069发送100 trying说明该请求已经收到,让终端停止INVITE重发定时器。

 

INVITEsip:[email protected]:5060 SIP/2.0

Via: SIP/2.0/UDP192.168.246.210:5060;branch=z9hG4bKw0hwph6xp20yo0gg2zhmwwpvmT25426

Call-ID: [email protected]

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

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

CSeq: 1 INVITE

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

Contact:<sip:192.168.246.210:5060>

Max-Forwards: 69

Supported: 100rel,replaces,timer

P-Asserted-Identity:<tel:+861069690069>

Privacy: none

P-Called-Party-ID:<sip:[email protected]>

Content-Length: 235

Content-Type: application/sdp

 

v=0

o=- 454 454 IN IP4 192.168.246.218

s=SBC call

c=IN IP4 192.168.246.218

t=0 0

m=audio 12962 RTP/AVP 8 0 18 4

a=rtpmap:8 PCMA/8000

a=rtpmap:0 PCMU/8000

a=rtpmap:18 G729/8000

a=rtpmap:4 G723/8000

a=ptime:20

a=ecan:fb on –

 

代理server通过对INVITE请求的验证通过后,检查via头域中是否包括自己的地址。若已包括自己的地址,说明已经发生回路,向终端+861069690069发送错误的应答;假设没有问题,代理server在请求消息的via头域插入自己的地址,并向INVITE消息的to头域所指的被叫终端转发INVITE请求。

 

SIP/2.0  100 Trying

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

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

Call-ID: [email protected]

CSeq: 1 INVITE

Via: SIP/2.0/UDP192.168.246.210:5060;branch=z9hG4bKw0hwph6xp20yo0gg2zhmwwpvmT25426

Supported: 100rel,replaces,timer

P-Preferred-Identity:"+861069690067"<sip:[email protected];user=phone>

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

Content-Length: 0

 

终端+861069690067收到代理server发送的INVITE请求,并向代理server发送100 trying说明该请求已经收到,让终端停止INVITE重发定时器。


SIP/2.0 180 Ringing

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

To:<sip:[email protected];user=phone>;tag=874368-ac1014d2-13c4-1c7-26f60a2f-1c7

Call-ID: [email protected]

CSeq: 1 INVITE

Via: SIP/2.0/UDP192.168.246.210:5060;branch=z9hG4bKw0hwph6xp20yo0gg2zhmwwpvmT25426

Supported: 100rel,replaces,timer

P-Preferred-Identity: "+861069690067"<sip:[email protected];user=phone>

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

Content-Length: 0

 

被叫终端对INVITE消息的合法性检查通过,指示代理server振铃,向代理server发送180 ring消息

 

SIP/2.0 180 Ringing

Via: SIP/2.0/UDP172.16.20.210:5060;branch=z9hG4bK-1c6-6f0cc-66d0e581;received=192.168.100.41

Call-ID:[email protected]

From:"+861069690069"<sip:[email protected];user=phone>;tag=8741b8-ac1014d2-13c4-1c6-10e9bfd8-1c6

To:<sip:[email protected];user=phone>;tag=sbc0509wwxwpz1q

CSeq: 1 INVITE

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

Contact:<sip:192.168.246.210:5060>

P-Asserted-Identity:<sip:[email protected]>,<tel:+861069690067>

Content-Length: 0

 

代理server收到180 ring消息,指示主叫方听回铃音

 

SIP/2.0 200 OK

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

To:<sip:[email protected];user=phone>;tag=874368-ac1014d2-13c4-1c7-26f60a2f-1c7

Call-ID:[email protected]

CSeq: 1 INVITE

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

Via: SIP/2.0/UDP192.168.246.210:5060;branch=z9hG4bKw0hwph6xp20yo0gg2zhmwwpvmT25426

Supported: 100rel,replaces,timer

P-Preferred-Identity:"+861069690067"<sip:[email protected];user=phone>

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

Content-Type: application/SDP

Content-Length: 248

 

v=0

o=+861069690067 456 456 IN IP4172.16.20.210

s=-

c=IN IP4 172.16.20.210

t=0 0

m=audio 10012 RTP/AVP 8 0 18 4

a=rtpmap:8 PCMA/8000

a=rtpmap:0 PCMU/8000

a=rtpmap:18 G729/8000

a=rtpmap:4 G723/8000

a=ptime:20

a=ecan:fb on -

a=sendrecv

 

被叫方摘机,向代理server发送200OK消息,表示已经摘机能够開始通话了

 

SIP/2.0 200 OK

Via: SIP/2.0/UDP172.16.20.210:5060;branch=z9hG4bK-1c6-6f0cc-66d0e581;received=192.168.100.41

Call-ID: [email protected]

From:"+861069690069"<sip:[email protected];user=phone>;tag=8741b8-ac1014d2-13c4-1c6-10e9bfd8-1c6

To:<sip:[email protected];user=phone>;tag=sbc0509wwxwpz1q

CSeq: 1 INVITE

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

Contact:<sip:192.168.246.210:5060>

Supported: 100rel,replaces,timer

P-Asserted-Identity:<sip:[email protected]>,<tel:+861069690067>

Content-Length: 247

Content-Type: application/sdp

 

v=0

o=- 456 456 IN IP4 192.168.246.218

s=SBC call

c=IN IP4 192.168.246.218

t=0 0

m=audio 12964 RTP/AVP 8 0 18 4

a=rtpmap:8 PCMA/8000

a=rtpmap:0 PCMU/8000

a=rtpmap:18 G729/8000

a=rtpmap:4 G723/8000

a=ptime:20

a=ecan:fb on -

a=sendrecv

 

代理server收到200 OK消息后改动状态机,而且发送200OK消息到主叫,告诉主叫,被叫已经接通

 

ACK sip:192.168.246.210:5060SIP/2.0

From:"+861069690069"<sip:[email protected];user=phone>;tag=8741b8-ac1014d2-13c4-1c6-10e9bfd8-1c6

To:<sip:[email protected];user=phone>;tag=sbc0509wwxwpz1q

Call-ID:[email protected]

CSeq: 1 ACK

Via: SIP/2.0/UDP172.16.20.210:5060;branch=z9hG4bK-1c8-6f6ac-7e19e755

Max-Forwards: 70

P-Preferred-Identity:"+861069690069"<sip:[email protected];user=phone>

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

Content-Length: 0

 

代理server收到ACK后,向被叫方发送200 OK相应的ACK消息,表示200 OK消息已经收到,而且主叫和被叫能够进行通话

 

ACKsip:[email protected]:5060 SIP/2.0

Via: SIP/2.0/UDP192.168.246.210:5060;branch=z9hG4bKw0wp6h1p6ovh1lzr1lgr1rpzmT25427

Call-ID:[email protected]

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

To:<sip:[email protected];user=phone>;tag=874368-ac1014d2-13c4-1c7-26f60a2f-1c7

CSeq: 1 ACK

Max-Forwards: 69

Content-Length: 0

 

被叫发送收到ACK消息后,通话建立成功

 

语音通讯建立成功,開始进行正常的语音通话……

 

BYE sip:192.168.246.210:5060SIP/2.0

From:<sip:[email protected];user=phone>;tag=874368-ac1014d2-13c4-1c7-26f60a2f-1c7

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

Call-ID: [email protected]

CSeq: 1 BYE

Via: SIP/2.0/UDP172.16.20.210:5060;branch=z9hG4bK-1d1-719f3-76b3cbbd

Max-Forwards: 70

Supported: 100rel,replaces,timer

P-Preferred-Identity:"+861069690067"<sip:[email protected];user=phone>

Content-Length: 0

 

主叫方挂机,向代理server发送BYE消息

 

SIP/2.0 200 OK

Via: SIP/2.0/UDP172.16.20.210:5060;branch=z9hG4bK-1d1-719f3-76b3cbbd;received=192.168.100.41

Call-ID:[email protected]

From: <sip:[email protected];user=phone>;tag=874368-ac1014d2-13c4-1c7-26f60a2f-1c7

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

CSeq: 1 BYE

Content-Length: 0

 

代理server收到,BYE消息后,确认挂机后,向主叫方发送200OK,表示主叫方已经成功挂机,而且向被叫方发送BYE消息,通知其挂机

 

BYEsip:[email protected]:5060 SIP/2.0

Via: SIP/2.0/UDP 192.168.246.210:5060;branch=z9hG4bKlvog2lhovvv0w6pmllymrhl16T15221

Call-ID: [email protected]

From:<sip:[email protected];user=phone>;tag=sbc0509wwxwpz1q

To:"+861069690069"<sip:[email protected];user=phone>;tag=8741b8-ac1014d2-13c4-1c6-10e9bfd8-1c6

CSeq: 1 BYE

Max-Forwards: 69

Reason: Q.850;cause=16

Content-Length: 0

 

代理server向被叫发送关机消息BYE,告诉被叫主叫已经挂机

 

SIP/2.0 200 OK

From:<sip:[email protected];user=phone>;tag=sbc0509wwxwpz1q

To: "+861069690069"<sip:[email protected];user=phone>;tag=8741b8-ac1014d2-13c4-1c6-10e9bfd8-1c6

Call-ID: [email protected]

CSeq: 1 BYE

Via: SIP/2.0/UDP192.168.246.210:5060;branch=z9hG4bKlvog2lhovvv0w6pmllymrhl16T15221

Supported: 100rel,replaces,timer

P-Preferred-Identity:"+861069690069"<sip:[email protected];user=phone>

Content-Length: 0

 

被叫方收到BYE消息后,确认挂机,而且回复200OK,表示挂机操作已经成功完毕

SIP基本呼叫

呼叫消息的流程图

 

依据上述的呼叫信息,对其进行具体的解说。

1)  主叫方“+861069690069”发起语音呼叫,主叫方地址:172.16.20.210,向代理server(192.168.246.210:)发送INVITE请求,须要和被叫方“69690067”建立呼叫。

2)  代理server收到主叫方,发送的INVITE请求后,回复100 Trying100 Trying表示代理server已经收到了INVITE请求,不须要UAC,即主叫方启用INVITE重发定时间,再次发送INVITE消息。

3)  代理server对收到的INVITE消息进行合法性检查,检查通过后,在注冊server上查找被叫,是否存在这种注冊被叫号码,假设被叫不存在向主叫方发送404消息结束本次呼叫请求,否则,想被叫注冊的地址发送呼叫请求INVITE消息。

4)  被叫方收到INVITE请求消息后,回复100 Trying。并对INVITE消息的合法性检測。

5)  被叫方对INVITE消息的合法性检測通过后,開始振铃,而且向代理server发送180,表示被叫方開始振铃,主叫方听回铃音或彩铃。

6)  代理server收到180后,改动代理server的状态机状态,改动为振铃状态,而且发送振铃消息给主叫方,主叫方听回铃音。

7)  被叫方摘机,向代理server发送200OK消息,表示被叫方已经摘机。

8)  代理server收到200OK消息后改动状态机,而且发送200OK消息到主叫,告诉主叫,被叫已经接通。

9)  主叫收到200OK后,打开媒体通道,建立通话,而且向代理server发送ACK消息,表示已经收到200OK消息。

10)代理server收到ACK后,向被叫方发送200OK相应的ACK消息,表示200OK消息已经收到,而且主叫和被叫能够进行通话。

11) 被叫发送收到ACK消息后,通话建立成功。

12)通过以上11个步骤,通话最终建立成功。

13)主叫方挂机,向代理server发送BYE消息。

14)代理server收到,BYE消息后,确认挂机后,向主叫方发送200OK,表示主叫方已经成功挂机,而且向被叫方发送BYE消息,通知其挂机。

15) 被叫方收到BYE消息后,确认挂机,而且回复200OK,表示挂机操作已经成功完毕。

16) 经过以上步骤,通话到此结束。

 

你可能感兴趣的:(IP)