SIP对应关系
注册命令(信令)
REGISTER registers the address listed in the To header field with a SIP server
由UA向注册服务器请求To字段中带的SIP地址
200 ok or other error code from server
第1对命令
SUBSCRIBE request current state and state updates from a remote node.
NOTIFY used to notify a SIP node that an event which has been requested by an earlier SUBSCRIBE method has occurred
第2对命令
INVITE indicates that the user or service is being invited to participate in a session
ACK confirms that the client has received a final response
client A client B
INVITE —–>
<—– 200 OK
ACK —–>
跟tcp的三次握手很相似的
另外与前面这对命令配合使用的命令还有
BYE indicates to the server that it wishes to release the call
CANCEL used to cancel a previous request sent by a client
其他命令
OPTIONS the server is being queried as to its capabilities
查询服务器的服务能力
INFO allows for the carrying of session related control information that is generated during a session
用来携带会话控制信息
MESSAGE allows the transfer of Instant Messages
用来发送即时消息
PRACK provide information on the progress of the request processing
查询请求处理进度
PUBLISH create, modify, and remove event state associated with an address-of-record
REFER requests that the recipient REFER to a resource provided in the request
UPDATE updates session information
—————————–
Key components of SIP network:
– SIP Phones (User-Agents)
– SIP Servers (registrar+proxy+redirect; usually combo)
– SIP PSTN gateways
– Applications servers (such as media servers)
SDP协议中关于媒体(Media 传输端口号的字段)
<port>:端口类型,该值的确定取决于对应的”c=”域中指定的网络和在第三个子项中定义的传输协议,UDP端口只能在1024-65535之间RTP端口可以是任意有效的范围,RTCP端口定义为大于对应RTP端口的奇数,当分级的多个媒体流编码通过单一的地址发送时,我们必须指定多个端口用于传输。 采用跟”c=”域中定义多个IP地址的格式一样,
m=<media> <port>/<number of ports> <transport> <fmt list>
example: m=video 49170/2 RTP/AVP 31
定义了两对的RTP/RTCP端口,49170 19171和49172 49173
/2指明视频和音频分流 by huzhibin
RTP端口号,RTCP端口号一般暗含,为RTP端口号+1
一个SIP信令例子,来自工作抓包:
REGISTER sip:bjmcc.com SIP/2.0
Via: SIP/2.0/UDP 192.168.11.2:5060;rport;branch=z9hG4bK1296028340
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2639413932
To: 13651229542<sip:13651229542@bjmcc.com>
Call-ID: 3623274500
CSeq: 1 REGISTER
Contact: <sip:13651229542@192.168.11.2:5060>
Authorization: Digest username=”sip:13651229542@bjmcc.com”,realm=”bjmcc.com”,uri=”sip:bjmcc.com”
Allow: INVITE,ACK,CANCEL,BYE,REGISTER,PRACK,PUBLISH,REFER,SUBSCRIBE,NOTIFY,MESSAGE
P-Preferred-Identity: 13651229542<sip:13651229542@bjmcc.com>
Require: pref
Max-Forwards: 70
User-Agent: XXX POC 2.0
Expires: 3600
Content-Length: 0
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK1296028340;received=182.0.0.9
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2639413932
To: 13651229542 <sip:13651229542@bjmcc.com>;tag=mUD7p0jt78BaF
Call-ID: 3623274500
CSeq: 1 REGISTER
Contact: <sip:13651229542@221.179.128.139:5060>;expires=3600
Date: Thu, 27 Oct 2011 12:52:35 GMT
Server: 1189641421 PoC-serv/OMA1.0 Nokia-proxy/sofia-proxy/1.9.32 (Nokia) nta/1.9.32
Supported: path, pref
Content-Length: 0
PUBLISH sip:13651229542@bjmcc.com SIP/2.0
Via: SIP/2.0/UDP 192.168.11.2:5060;rport;branch=z9hG4bK3074320496
From: 13651229542<sip:13651229542@bjmcc.com>;tag=936503320
To: <sip:13651229542@bjmcc.com>
Call-ID: 217453280
CSeq: 1 PUBLISH
Contact: <sip:13651229542@192.168.11.2:5060>
Content-Type: application/poc-settings+xml
P-Preferred-Identity: 13651229542<sip:13651229542@bjmcc.com>
Max-Forwards: 70
User-Agent: XXX POC 2.0
Expires: 3600
Event: poc-settings
Accept-Contact: *;+g.poc.talkburst;require;explicit
Supported: 100rel,eventlist,timer,multiple-refer
Content-Length: 602
<?xml version=”1.0″ encoding=”UTF-8″?>
<poc-settings xmlns=”urn:oma:params:xml:ns:poc:poc-settings” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”urn:oma:params:xml:ns:poc:poc-settings”>
<entity id=”sip:13651229542@bjmcc.com”>
<isb-settings>
<incoming-session-barring active=”false” />
</isb-settings>
<am-settings>
<answer-mode>automatic</answer-mode>
</am-settings>
<ipab-settings>
<incoming-personal-alert-barring active=”false” />
</ipab-settings>
<sss-settings>
<simultaneous-sessions-support active=”true” />
</sss-settings>
</entity>
</poc-settings>
SIP/2.0 200 OK
Server: 1189641421 PoC-serv/OMA1.0 Nokia_Server-test
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK3074320496;received=182.0.0.9
Record-Route: <sip:.r.rd251bba4c92bd978.1+2@221.179.128.139;lr>
To: <sip:13651229542@bjmcc.com>;tag=yr28aRYz
From: 13651229542<sip:13651229542@bjmcc.com>;tag=936503320
Call-ID: 217453280
CSeq: 1 PUBLISH
Expires: 3600
SIP-ETag: 46
Content-Length: 0
PUBLISH sip:13651229542@bjmcc.com SIP/2.0
Via: SIP/2.0/UDP 192.168.11.2:5060;rport;branch=z9hG4bK120788574
From: <sip:13651229542@bjmcc.com>;tag=198120338
To: 13651229542<sip:13651229542@bjmcc.com>
Call-ID: 3035654614
CSeq: 1 PUBLISH
Contact: <sip:13651229542@192.168.11.2:5060>
Content-Type: application/pidf+xml
P-Preferred-Identity: <sip:13651229542@bjmcc.com>
Max-Forwards: 70
User-Agent: XXX POC 2.0
Expires: 3600
Event: presence
Supported: 100rel,eventlist,timer,multiple-refer
Content-Length: 548
<?xml version=”1.0″ encoding=”UTF-8″ ?>
<presence xmlns=”urn:ietf:params:xml:ns:pidf” xmlns:op=”urn:oma:xml:prs:pidf:oma-pres” entity=”sip:13651229542@bjmcc.com”>
<tuple id=”13651229542″>
<status>
<basic>open</basic>
</status>
<op:registration-state>active</op:registration-state>
<op:barring-state>terminated</op:barring-state>
<op:service-description>
<op:service-id>org.openmobilealliance:PoC-session</op:service-id>
<op:version>1.0</op:version>
<op:description>POC</op:description>
</op:service-description>
</tuple>
</presence>
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK120788574;received=182.0.0.9
From: <sip:13651229542@bjmcc.com>;tag=198120338
To: 13651229542 <sip:13651229542@bjmcc.com>;tag=N46ZrU3X4H2va
Call-ID: 3035654614
CSeq: 1 PUBLISH
Date: Thu, 27 Oct 2011 12:52:37 GMT
Server: 1189641421 PoC-serv/OMA1.0 Nokia-proxy/sofia-proxy/1.9.32 (Nokia) nta/1.9.32
Content-Length: 0
SUBSCRIBE sip:13651229542.oma_allgroupcontacts@bjmcc.com SIP/2.0
Via: SIP/2.0/UDP 192.168.11.2:5060;rport;branch=z9hG4bK2262337016
From: <sip:13651229542@bjmcc.com>;tag=2880991092
To: <sip:13651229542.oma_allgroupcontacts@bjmcc.com>
Call-ID: 4106428832
CSeq: 1 SUBSCRIBE
Contact: <sip:13651229542@192.168.11.2:5060>
Accept: application/pidf+xml,application/rlmi+xml,multipart/related
P-Preferred-Identity: <sip:13651229542@bjmcc.com>
Max-Forwards: 70
User-Agent: XXX POC 2.0
Expires: 3600
Event: presence
Supported: eventlist
Content-Length: 0
SIP/2.0 403 Forbidden
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK2262337016;received=182.0.0.9
From: <sip:13651229542@bjmcc.com>;tag=2880991092
To: <sip:13651229542.oma_allgroupcontacts@bjmcc.com>;tag=pD0rtpm11trFp
Call-ID: 4106428832
CSeq: 1 SUBSCRIBE
Date: Thu, 27 Oct 2011 12:52:40 GMT
Server: 1189641421 PoC-serv/OMA1.0 Nokia-proxy/sofia-proxy/1.9.32 (Nokia) nta/1.9.32
Content-Length: 0
PUBLISH sip:13651229542@bjmcc.com SIP/2.0
Via: SIP/2.0/UDP 192.168.11.2:5060;rport;branch=z9hG4bK2214855368
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2869120680
To: <sip:13651229542@bjmcc.com>
Call-ID: 4082688008
CSeq: 2 PUBLISH
Contact: <sip:13651229542@192.168.11.2:5060>
Content-Type: application/poc-settings+xml
P-Preferred-Identity: 13651229542<sip:13651229542@bjmcc.com>
Max-Forwards: 70
User-Agent: XXX POC 2.0
Expires: 3600
Event: poc-settings
Accept-Contact: *;+g.poc.talkburst;require;explicit
Supported: 100rel,eventlist,timer,multiple-refer
Content-Length: 598
<?xml version=”1.0″ encoding=”UTF-8″?>
<poc-settings xmlns=”urn:oma:params:xml:ns:poc:poc-settings” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”urn:oma:params:xml:ns:poc:poc-settings”>
<entity id=”sip:13651229542@bjmcc.com”>
<isb-settings>
<incoming-session-barring active=”true” />
</isb-settings>
<am-settings>
<answer-mode>manual</answer-mode>
</am-settings>
<ipab-settings>
<incoming-personal-alert-barring active=”false” />
</ipab-settings>
<sss-settings>
<simultaneous-sessions-support active=”true” />
</sss-settings>
</entity>
</poc-settings>
SIP/2.0 200 OK
Server: 1189641421 PoC-serv/OMA1.0 Nokia_Server-test
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK2214855368;received=182.0.0.9
Record-Route: <sip:.r.rd251bba4c92bd97b.1+2@221.179.128.139;lr>
To: <sip:13651229542@bjmcc.com>;tag=8zP1CIqj
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2869120680
Call-ID: 4082688008
CSeq: 2 PUBLISH
Expires: 3600
SIP-ETag: 47
Content-Length: 0
INVITE sip:gp001&15010457516@bjmcc.com;session=chat SIP/2.0
Via: SIP/2.0/UDP 192.168.11.2:5060;rport;branch=z9hG4bK1835002226
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2774157390
To: <sip:gp001&15010457516@bjmcc.com;session=chat>
Call-ID: 3892761434
CSeq: 1 INVITE
Contact: <sip:13651229542@192.168.11.2:5060>;+g.poc.talkburst
Content-Type: application/sdp
Allow: INVITE,ACK,CANCEL,BYE,REGISTER,PRACK,PUBLISH,REFER,SUBSCRIBE,NOTIFY,MESSAGE
P-Preferred-Identity: 13651229542<sip:13651229542@bjmcc.com>
Session-Expires: 31104000
Supported: 100rel,eventlist,timer,multiple-refer
Max-Forwards: 70
User-Agent: XXX POC 2.0
Accept-Contact: *;+g.poc.talkburst;require;explicit
Content-Length: 269
v=0
o=mo-app 0 0 IN IP4 192.168.11.2
s=conversation
c=IN IP4 192.168.11.2
t=0 0
m=application 11609 UDP TBCP
a=fmtp:TBCP poc_lock=0
m=audio 11608 RTP/AVP 106
a=rtpmap:106 AMR/8000/1
a=fmtp:106 mode-set=0,1,2,3,4,5,6,7;octet-align=0
a=rtcp:11609
a=ptime:200
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK1835002226;received=182.0.0.9
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2774157390
To: <sip:gp001&15010457516@bjmcc.com;session=chat>
Call-ID: 3892761434
CSeq: 1 INVITE
Date: Thu, 27 Oct 2011 12:52:44 GMT
Server: 1189641421 PoC-serv/OMA1.0 Nokia-proxy/sofia-proxy/1.9.32 (Nokia) nta/1.9.32
Content-Length: 0
SIP/2.0 200 OK
Server: 1189641421 PoC-serv/OMA1.0 Nokia_Server-test
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK1835002226;received=182.0.0.9
Record-Route: <sip:192.168.1.175;lr>
Record-Route: <sip:.r.rd251bba4c92bd97c.1+2@221.179.128.139;lr>
To: <sip:gp001&15010457516@bjmcc.com;session=chat>;tag=gMjbGLb1
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2774157390
Call-ID: 3892761434
CSeq: 1 INVITE
Allow: INVITE, REGISTER, SUBSCRIBE, MESSAGE, BYE, ACK, CANCEL, REFER, PUBLISH
Contact: <sip:gp001&15010457516@bjmcc.com;session=chat>; +g.poc.talkburst=”TRUE”; isfocus
Session-Expires: 31104000;refresher=uac
P-Asserted-Identity: 13651229542 <sip:13651229542@bjmcc.com>
Allow-Events: refer,conference
Require: timer
Content-Type: application/sdp
Content-Length: 315
v=0
o=13651229542 123456 0 IN IP4 192.168.11.1
s=
c=IN IP4 192.168.11.1
t=0 0
m=audio 10132 RTP/AVP 106
a=rtpmap:106 AMR/8000
a=fmtp:106 mode-set=1; octet-align=0
a=maxptime:400
a=ptime:160
m=application 10133 udp TBCP
a=fmtp:TBCP queuing=0; tb_priority=1; timestamp=0; poc_sess_priority=0; poc_lock=0
SUBSCRIBE sip:gp001&15010457516@bjmcc.com;session=chat SIP/2.0
Via: SIP/2.0/UDP 192.168.11.2:5060;rport;branch=z9hG4bK231768174
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2373348874
To: <sip:gp001&15010457516@bjmcc.com;session=chat>
Call-ID: 3091144406
CSeq: 1 SUBSCRIBE
Contact: <sip:13651229542@192.168.11.2:5060>
Accept: application/conference-info+xml
P-Preferred-Identity: 13651229542<sip:13651229542@bjmcc.com>
Max-Forwards: 70
User-Agent: XXX POC 2.0
Expires: 3600
Event: conference
Accept-Contact: *;+g.poc.talkburst;require;explicit
Content-Length: 0
NOTIFY sip:13651229542@192.168.11.1:5060 SIP/2.0
Via: SIP/2.0/UDP 192.168.1.174;branch=z9hG4bKS3vt2Zp5ZFKQg
Record-Route: <sip:.r.rd251bba4c92bd97d.1+2@221.179.128.139;lr>
Via: SIP/2.0/UDP 192.168.1.175;branch=z9hG4bKjXPmHOtZEZ
Allow: INVITE, REGISTER, SUBSCRIBE, MESSAGE, BYE, ACK, CANCEL, REFER, PUBLISH
To: 13651229542<sip:13651229542@bjmcc.com>;tag=2373348874
From: <sip:gp001&15010457516@bjmcc.com;session=chat>;tag=So-NcYum
Contact: sip:gp001&15010457516@bjmcc.com
Call-ID: 3091144406
CSeq: 5512571 NOTIFY
User-Agent: PoC-serv/OMA1.0 Nokia_Server-test
Event: conference
Subscription-State: active; expires=3600
Content-Length: 436
Content-Type: application/conference-info+xml
Max-Forwards: 69
<?xml version=”1.0″ encoding=”UTF-8″?>
<conference-info
xmlns=”urn:ietf:params:xml:ns:conference-info”
state=”full” version=”0″ entity=”sip:gp001&15010457516@bjmcc.com”>
<users state=”full”>
<user entity=”sip:13651229542@bjmcc.com” state=”full”>
<display-text>13651229542</display-text>
<endpoint entity=”sip:13651229542@bjmcc.com”>
<status>connected</status>
</endpoint>
</user>
</users>
</conference-info>
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.1.174;branch=z9hG4bKS3vt2Zp5ZFKQg;received=192.168.11.1
Via: SIP/2.0/UDP 192.168.1.175;branch=z9hG4bKjXPmHOtZEZ
From: <sip:gp001&15010457516@bjmcc.com;session=chat>;tag=So-NcYum
To: 13651229542<sip:13651229542@bjmcc.com>;tag=2373348874
Call-ID: 3091144406
CSeq: 5512571 NOTIFY
Max-Forwards: 70
User-Agent: XXX POC 2.0
Content-Length: 0
SIP/2.0 200 OK
Server: 1189641421 PoC-serv/OMA1.0 Nokia_Server-test
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK1835002226;received=182.0.0.9
Record-Route: <sip:192.168.1.175;lr>
Record-Route: <sip:.r.rd251bba4c92bd97c.1+2@221.179.128.139;lr>
To: <sip:gp001&15010457516@bjmcc.com;session=chat>;tag=gMjbGLb1
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2774157390
Call-ID: 3892761434
CSeq: 1 INVITE
Allow: INVITE, REGISTER, SUBSCRIBE, MESSAGE, BYE, ACK, CANCEL, REFER, PUBLISH
Contact: <sip:gp001&15010457516@bjmcc.com;session=chat>; +g.poc.talkburst=”TRUE”; isfocus
Session-Expires: 31104000;refresher=uac
P-Asserted-Identity: 13651229542 <sip:13651229542@bjmcc.com>
Allow-Events: refer,conference
Require: timer
Content-Type: application/sdp
Content-Length: 315
v=0
o=13651229542 123456 0 IN IP4 192.168.11.1
s=
c=IN IP4 192.168.11.1
t=0 0
m=audio 10132 RTP/AVP 106
a=rtpmap:106 AMR/8000
a=fmtp:106 mode-set=1; octet-align=0
a=maxptime:400
a=ptime:160
m=application 10133 udp TBCP
a=fmtp:TBCP queuing=0; tb_priority=1; timestamp=0; poc_sess_priority=0; poc_lock=0
SUBSCRIBE sip:gp001&15010457516@bjmcc.com;session=chat SIP/2.0
Via: SIP/2.0/UDP 192.168.11.2:5060;rport;branch=z9hG4bK231768174
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2373348874
To: <sip:gp001&15010457516@bjmcc.com;session=chat>
Call-ID: 3091144406
CSeq: 1 SUBSCRIBE
Contact: <sip:13651229542@192.168.11.2:5060>
Accept: application/conference-info+xml
P-Preferred-Identity: 13651229542<sip:13651229542@bjmcc.com>
Max-Forwards: 70
User-Agent: XXX POC 2.0
Expires: 3600
Event: conference
Accept-Contact: *;+g.poc.talkburst;require;explicit
Content-Length: 0
SIP/2.0 200 OK
Server: 1189641421 PoC-serv/OMA1.0 Nokia_Server-test
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK231768174;received=182.0.0.9
Record-Route: <sip:192.168.1.175;lr>
Record-Route: <sip:.r.rd251bba4c92bd97d.1+2@221.179.128.139;lr>
To: <sip:gp001&15010457516@bjmcc.com;session=chat>;tag=So-NcYum
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2373348874
Call-ID: 3091144406
CSeq: 1 SUBSCRIBE
Contact: sip:gp001&15010457516@bjmcc.com
Expires: 3600
Content-Length: 0
SIP/2.0 200 OK
Server: 1189641421 PoC-serv/OMA1.0 Nokia_Server-test
Via: SIP/2.0/UDP 192.168.11.1:5060;rport=5060;branch=z9hG4bK1835002226;received=182.0.0.9
Record-Route: <sip:192.168.1.175;lr>
Record-Route: <sip:.r.rd251bba4c92bd97c.1+2@221.179.128.139;lr>
To: <sip:gp001&15010457516@bjmcc.com;session=chat>;tag=gMjbGLb1
From: 13651229542<sip:13651229542@bjmcc.com>;tag=2774157390
Call-ID: 3892761434
CSeq: 1 INVITE
Allow: INVITE, REGISTER, SUBSCRIBE, MESSAGE, BYE, ACK, CANCEL, REFER, PUBLISH
Contact: <sip:gp001&15010457516@bjmcc.com;session=chat>; +g.poc.talkburst=”TRUE”; isfocus
Session-Expires: 31104000;refresher=uac
P-Asserted-Identity: 13651229542 <sip:13651229542@bjmcc.com>
Allow-Events: refer,conference
Require: timer
Content-Type: application/sdp
Content-Length: 315
v=0
o=13651229542 123456 0 IN IP4 192.168.11.1
s=
c=IN IP4 192.168.11.1
t=0 0
m=audio 10132 RTP/AVP 106
a=rtpmap:106 AMR/8000
a=fmtp:106 mode-set=1; octet-align=0
a=maxptime:400
a=ptime:160
m=application 10133 udp TBCP
a=fmtp:TBCP queuing=0; tb_priority=1; timestamp=0; poc_sess_priority=0; poc_lock=0