2、注册信令
2.1基本注册
2.1.1 抓包过程
2.1.2 详细步骤
2.1.2.1、REGISTER
REGISTER sip:34020000002000000001@192.168.9.186:15060 SIP/2.0
Via: SIP/2.0/TCP 192.168.9.186:42860;rport;branch=z9hG4bK1557586049
From: <sip:30514805331320000140@192.168.9.186:5060>;tag=1292111901
To: <sip:30514805331320000140@192.168.9.186:5060>
Call-ID: 367786093
CSeq: 1 REGISTER
Contact: <sip:30514805331320000140@192.168.9.186:5060>
Max-Forwards: 70
User-Agent: DVR UAC
Expires: 3600
Content-Length: 0
2.1.2.2、401 Unauthorized
SIP/2.0 401 Unauthorized
Via: SIP/2.0/TCP 192.168.9.186:42860;rport=42860;received=192.168.9.186;branch=z9hG4bK1557586049
From: <sip:30514805331320000140@192.168.9.186:5060>;tag=1292111901
To: <sip:30514805331320000140@192.168.9.186:5060>;tag=354769008
CSeq: 1 REGISTER
Call-ID: 367786093
User-Agent: EasyGBS v200511
Content-Length: 0
Contact: <sip:34020000002000000001@192.168.9.161:15060>
WWW-Authenticate: Digest realm="3402000000",nonce="59074a1a5ae62cb13d81d919b69af0be"
2.1.2.3、重新REGISTER
REGISTER sip:34020000002000000001@192.168.9.186:15060 SIP/2.0
Via: SIP/2.0/TCP 192.168.9.186:42860;rport;branch=z9hG4bK2080745015
From: <sip:30514805331320000140@192.168.9.186:5060>;tag=1292111901
To: <sip:30514805331320000140@192.168.9.186:5060>
Call-ID: 367786093
CSeq: 2 REGISTER
Contact: <sip:30514805331320000140@192.168.9.186:5060>
Authorization: Digest username="30514805331320000140", realm="3402000000", nonce="59074a1a5ae62cb13d81d919b69af0be", uri="sip:34020000002000000001@192.168.9.186:15060", response="1cfb6de705b4c6fe0c135a6e7ebb7965", algorithm=MD5
Max-Forwards: 70
User-Agent: DVR UAC
Expires: 3600
Content-Length: 0
2.1.2.4、200 OK
SIP/2.0 200 OK
Via: SIP/2.0/TCP 192.168.9.186:42860;rport=42860;received=192.168.9.186;branch=z9hG4bK2080745015
From: <sip:30514805331320000140@192.168.9.186:5060>;tag=1292111901
To: <sip:30514805331320000140@192.168.9.186:5060>;tag=241770024
CSeq: 2 REGISTER
Call-ID: 367786093
User-Agent: Easy SIP Server
Content-Length: 0
Date: 2023-03-24T14:06:22.760
Expires: 3600
Contact: <sip:34020000002000000001@192.168.9.161:15060>
2.2基本数字证书双向认证注册
2.2.1、REGISTER
2.2.2、401 Unauthorized
2.2.3、重新REGISTER
2.2.4、200 OK
2.3、注销
2.3.1 、REGISTER
2.3.2 、401 Unauthorized
2.3.3 、重新REGISTER
2.3.4、200 OK
2.4、状态信息
2.4.1 心跳报
MESSAGE sip:34020000002000000001@192.168.9.161:15060 SIP/2.0
Via: SIP/2.0/TCP 192.168.9.186:42860;rport;branch=z9hG4bK999627714
From: <sip:30514805331320000140@192.168.9.186:5060>;tag=895079034
To: <sip:34020000002000000001@192.168.9.161:15060>
Call-ID: 1652649404
CSeq: 20 MESSAGE
Content-Type: Application/MANSCDP+xml
Max-Forwards: 70
User-Agent: DVR UAC
Content-Length: 160
<?xml version="1.0" encoding="UTF-8"?>
<Notify>
<CmdType>Keepalive</CmdType>
<SN>1</SN>
<DeviceID>30514805331320000140</DeviceID>
<Status>OK</Status>
</Notify>
SIP/2.0 200 OK
Via: SIP/2.0/TCP 192.168.9.186:42860;rport=42860;received=192.168.9.186;branch=z9hG4bK999627714
From: <sip:30514805331320000140@192.168.9.186:5060>;tag=895079034
To: <sip:34020000002000000001@192.168.9.161:15060>;tag=180771049
CSeq: 20 MESSAGE
Call-ID: 1652649404
User-Agent: Easy SIP Server
Content-Length: 0
2.5、实时点播
点击播放
流程4步 sip 服务器-> 设备客服端
INVITE sip:30514805331320000141@192.168.9.186:59354;transport=tcp SIP/2.0
Via: SIP/2.0/UDP 192.168.9.161:15060;rport=15060;branch=z9hG4bK863172447
From: <sip:34020000002000000001@3402000000>;tag=989172447
To: <sip:30514805331320000141@192.168.9.186:59354>
Call-ID: 211171919
CSeq: 356 INVITE
Max-Forwards: 70
User-Agent: Easy SIP Server
Content-Length: 222
Content-Type: application/sdp
Contact: <sip:34020000002000000001@192.168.9.161:15060>
Subject: 30514805331320000141:0148000141,34020000002000000001:0
v=0
o=34020000002000000001 0 0 IN IP4 192.168.9.161
s=Play
c=IN IP4 192.168.9.161
t=0 0
m=video 50100 RTP/AVP 96 98 97
a=recvonly
a=rtpmap:96 PS/90000
a=rtpmap:98 H264/90000
a=rtpmap:97 MPEG4/90000
y=0148000141
流程5步 设备客服端 -> sip 服务器
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.9.161:15060;rport=15060;branch=z9hG4bK863172447
From: <sip:34020000002000000001@3402000000>;tag=989172447
To: <sip:30514805331320000141@192.168.9.186:59354>
Call-ID: 211171919
CSeq: 356 INVITE
User-Agent: DVR UAC
Content-Length: 0
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.9.161:15060;rport=15060;branch=z9hG4bK863172447
From: <sip:34020000002000000001@3402000000>;tag=989172447
To: <sip:30514805331320000141@192.168.9.186:59354>;tag=382514535
Call-ID: 211171919
CSeq: 356 INVITE
Contact: <sip:30514805331320000141@192.168.9.186:59354>
Content-Type: application/sdp
User-Agent: DVR UAC
Content-Length: 265
v=0
o=30514805331320000140 719885386 719885386 IN IP4 192.168.9.186
s=Play
c=IN IP4 192.168.9.186
t=0 0
m=video 15000 RTP/AVP 96
a=setup:active
a=sendonly
a=rtpmap:96 PS/90000
a=username:30514805331320000140
a=password:12345678
a=filesize:0
y=0148000141
流程7步 sip 服务器 -> 设备客服端
ACK sip:30514805331320000141@192.168.9.186:59354;transport=tcp SIP/2.0
Via: SIP/2.0/UDP 192.168.9.161:15060;rport=15060;branch=z9hG4bK929172974
From: <sip:34020000002000000001@3402000000>;tag=989172447
To: <sip:30514805331320000141@192.168.9.186:59354>;tag=382514535
Call-ID: 211171919
CSeq: 356 ACK
Max-Forwards: 70
User-Agent: Easy SIP Server
Content-Length: 0
实时媒体流 RTP
流程19步 sip 服务器 -> 设备客服端
流程20步 设备客服端 -> sip 服务器
2.6 SDP 协议
v字段:协议版本
o字段:-
a字段:a=rtpmap: / [/] 中的,利用该属性携带编码器厂商名称。该属性表明该流为某厂商编码器编码且是不符合gb28181规定的媒体流,符合国标的媒体流不需要该属性。
例如:a=rtpmap:96 DAHUA/90000
a=rtpmap:96 HIKVISION/90000
a字段有下列格式:
a字段可携带倍数参数,用于文件下载时控制下载速度。格式: a=downloadspeed:下载倍数(整型)
a字段可携带文件大小参数,用于文件下载时的进度计算。格式: a=filesize:文件大小 (单位:Byte)
a字段可携带setup、connection作为TCP连接协商参数。 a=setup:TCP连接方式(表示本SDP发送者在建立RTP over TCP连接时是主动还是被动发起TCP连接,“active”为主动,“passive”为被动)
a字段可携带SVC参数,用于视频传输时的分辨率或者帧频控制。a=svcspace:空域编码方式 【取值整型。 0:不使用 1:1级增强 2:2级增强 3:3级增强 】 a = svctime:时域编码方式
s字段:表示请求媒体流的操作类型,“Play”标识为点播请求 “Playback”标识回播请求 “Download”表示文件下载 “Talk”表示语音对讲;
u字段:u行应填写视音频文件的URL。该URL的取值有两种:简捷方式和普通方式。简捷方式直接采用产生该历史媒体的媒体源(如某个摄像头)的设备ID以及相关参数,参数用“:”分隔;普通方式采样http://储存设备ID[/文件夹]*/文件名;
m字段:描述媒体的媒体类型、端口、传输层协议、负载类型等内容。媒体类型采样“video”标识视频或者视音频混合内容,采样“audio”标识传输音频内容;传输方式采用“RTP/AVP”标识传输层协议为 RTP over UDP,采用“TCP/RTP/AVP”标识传输层协议为RTP over TCP;
t字段:当回放或者下载时,t行值为开始时间,结束时间,采样“ ”分隔;
y字段:十进制整数字符串,标识SSRC值。其中第一位为历史或者实时媒体流的标识位,0为实时,1为历史;第2位到第6位取20位SIP监控域ID之中的4-8位作为域标识;第7-10位作为域内媒体流标识,是一个与当前域内产生的媒体流SSRC值后4位不充分的四位十进制整数;
f字段:f=v/编码格式/分辨率/帧率/码率类型/码率大小 a/编码格式/码率大小/采样率 其中v表示video a表示audio
2.7 设备目录查询
服务端 - > 客服端
MESSAGE sip:34020000001320000111@192.168.9.186:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP 192.168.9.161:15060;rport=15060;branch=z9hG4bK691041267
From: <sip:34020000002000000001@3402000000>;tag=45041267
To: <sip:34020000001320000111@3402000000>
Call-ID: 725041267
CSeq: 167 MESSAGE
Max-Forwards: 70
User-Agent: Easy SIP Server
Content-Length: 156
Content-Type: Application/MANSCDP+xml
<?xml version="1.0" encoding="UTF-8"?>
<Query>
<CmdType>Catalog</CmdType>
<SN>791041265</SN>
<DeviceID>34020000001320000111</DeviceID>
</Query>
客服端 - > 服务端
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.9.161:15060;rport=15060;branch=z9hG4bK691041267
From: <sip:34020000002000000001@3402000000>;tag=45041267
To: <sip:34020000001320000111@3402000000>;tag=54976721
Call-ID: 725041267
CSeq: 167 MESSAGE
User-Agent: DVR UAC
Content-Length: 0
客服端 - > 服务端
服务端 - > 客服端
SIP/2.0 200 OK
Via: SIP/2.0/UDP 192.168.9.186:5060;rport=5060;received=192.168.9.186;branch=z9hG4bK1596506343
From: <sip:34020000001320000111@192.168.9.186:5060>;tag=1063069655
To: <sip:34020000002000000001@192.168.9.161:15060>;tag=393041274
CSeq: 20 MESSAGE
Call-ID: 2086294613
User-Agent: Easy SIP Server
Content-Length: 0