利用 wireshark 完成的的一次抓取 RTSP 视频流播放。
Transmission Control Protocol, Src Port: 4431, Dst Port: 8554, Seq: 1, Ack: 1, Len: 130
Real Time Streaming Protocol
Request: OPTIONS rtsp://192.168.1.109:8554/live0.264 RTSP/1.0\r\n
CSeq: 2\r\n
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)\r\n
\r\n
Transmission Control Protocol, Src Port: 8554, Dst Port: 4431, Seq: 1, Ack: 131, Len: 146
Real Time Streaming Protocol
Response: RTSP/1.0 200 OK\r\n
CSeq: 2\r\n
Server: LIBEASYRTSPD-JV/1/1.6\r\n
Public: OPTIONS, DESCRIBE, SETUP, PLAY, PAUSE, TEARDOWN, GET_PARAMETER, SET_PARAMETER\r\n
\r\n
对于RTSP而言,采用的是第三种:摘要认证。
当客户端发送给服务端 DESCRIBE 报文时,若采取用户认证,则会返回带有 WWW-Authenticate
字段的响应报文,在 WWW-Authenticate
字段中,会携带:realm
和 nonce
字段,以便产生 response
字段,供后续进行验证。
当客户端收到服务端带有的 WWW-Authenticate
的报文时,会根据下列方法产生 response
字段,以便在请求报文的 Authorization
中携带,完成用户鉴权。
对于 response
的产生,同 GB28181 鉴权生成 response
方法一样,但只有 MD5 加密方式,具体方法如下:
response= md5(md5(username:realm:password):nonce:md5(public_method:url) );
后服务端收到Authorization
和 Accept: application/sdp\r\n
请求报文,会在响应报文中携带 SDP 相关信息,以便完成相关编码方式的选择。
后续的请求报文,都将携带 Authorization
字段。
Transmission Control Protocol, Src Port: 4431, Dst Port: 8554, Seq: 131, Ack: 147, Len: 156
Real Time Streaming Protocol
Request: DESCRIBE rtsp://192.168.1.109:8554/live0.264 RTSP/1.0\r\n
CSeq: 3\r\n
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)\r\n
Accept: application/sdp\r\n
\r\n
Transmission Control Protocol, Src Port: 8554, Dst Port: 4431, Seq: 147, Ack: 287, Len: 182
Real Time Streaming Protocol
Response: RTSP/1.0 401 Unauthorized\r\n
CSeq: 3\r\n
Date: Tue, May 16 2017 05:49:24 GMT\r\n
WWW-Authenticate: Digest realm="LIBEASYRTSPD-JV", nonce="41b3fc540e909d63b1c8ff0444f1ed76", stale="FALSE"\r\n
\r\n
Transmission Control Protocol, Src Port: 4431, Dst Port: 8554, Seq: 287, Ack: 329, Len: 351
Real Time Streaming Protocol
Request: DESCRIBE rtsp://192.168.1.109:8554/live0.264 RTSP/1.0\r\n
CSeq: 4\r\n
Authorization: Digest username="admin", realm="LIBEASYRTSPD-JV", nonce="41b3fc540e909d63b1c8ff0444f1ed76", uri="rtsp://192.168.1.109:8554/live0.264", response="288c401e9abb17dd3ae10b044a72e9ee"\r\n
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)\r\n
Accept: application/sdp\r\n
\r\n
Transmission Control Protocol, Src Port: 8554, Dst Port: 4431, Seq: 329, Ack: 638, Len: 513
Real Time Streaming Protocol
Response: RTSP/1.0 200 OK\r\n
CSeq: 4\r\n
Date: Tue, May 16 2017 05:49:24 GMT\r\n
Content-Base: rtsp://192.168.1.109:8554/live0.264/\r\n
Content-type: application/sdp
Content-length: 318
x-Accept-Dynamic-Rate: 1\r\n
\r\n
Session Description Protocol
Session Description Protocol Version (v): 0
Owner/Creator, Session Id (o): - 1398474260 1 IN IP4 192.168.1.109
Session Name (s): Session Streamed by LIBEASYRTSPD-JV
Session Information (i): live0.264
Time Description, active time (t): 0 0
Session Attribute (a): tool:LIBEASYRTSPD-JV v1/1.6
Media Description, name and address (m): video 0 RTP/AVP 96
Connection Information (c): IN IP4 192.168.1.109
Bandwidth Information (b): AS:2
Media Attribute (a): rtpmap:96 H265/90000
Media Attribute (a): control:track1
Media Description, name and address (m): audio 0 RTP/AVP 8
Connection Information (c): IN IP4 0.0.0.0
Bandwidth Information (b): AS:64
Media Attribute (a): rtpmap:8 PCMA/8000
Media Attribute (a): control:track2
在 SETUP 阶段,根据视频流和音频流的两个是否存在,如果两个同时存在,则会进行两次 SETUP 阶段,否则只有一次,同时会建立一个 Session
,在后续都会存在。
Transmission Control Protocol, Src Port: 4431, Dst Port: 8554, Seq: 638, Ack: 842, Len: 383
Real Time Streaming Protocol
Request: SETUP rtsp://192.168.1.109:8554/live0.264/track1 RTSP/1.0\r\n
CSeq: 5\r\n
Authorization: Digest username="admin", realm="LIBEASYRTSPD-JV", nonce="41b3fc540e909d63b1c8ff0444f1ed76", uri="rtsp://192.168.1.109:8554/live0.264/", response="d62bc1d2763c903b9dbdff7c01ee72b8"\r\n
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)\r\n
Transport: RTP/AVP;unicast;client_port=58822-58823
\r\n
Transmission Control Protocol, Src Port: 8554, Dst Port: 4431, Seq: 842, Ack: 1021, Len: 248
Real Time Streaming Protocol
Response: RTSP/1.0 200 OK\r\n
CSeq: 5\r\n
Date: Thu, Oct 19 2023 13:49:32 GMT\r\n
Session: 3C66DB38;timeout=60
Transport: RTP/AVP;unicast;destination=192.168.1.104;source=192.168.1.109;client_port=58822-58823;server_port=40215-40216;mode=PLAY;
x-Dynamic-Rate: 1\r\n
\r\n
Transmission Control Protocol, Src Port: 4431, Dst Port: 8554, Seq: 1021, Ack: 1090, Len: 402
Real Time Streaming Protocol
Request: SETUP rtsp://192.168.1.109:8554/live0.264/track2 RTSP/1.0\r\n
CSeq: 6\r\n
Authorization: Digest username="admin", realm="LIBEASYRTSPD-JV", nonce="41b3fc540e909d63b1c8ff0444f1ed76", uri="rtsp://192.168.1.109:8554/live0.264/", response="d62bc1d2763c903b9dbdff7c01ee72b8"\r\n
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)\r\n
Transport: RTP/AVP;unicast;client_port=58824-58825
Session: 3C66DB38
\r\n
Transmission Control Protocol, Src Port: 8554, Dst Port: 4431, Seq: 1090, Ack: 1423, Len: 248
Real Time Streaming Protocol
Response: RTSP/1.0 200 OK\r\n
CSeq: 6\r\n
Date: Thu, Oct 19 2023 13:49:32 GMT\r\n
Session: 3C66DB38;timeout=60
Transport: RTP/AVP;unicast;destination=192.168.1.104;source=192.168.1.109;client_port=58824-58825;server_port=40087-40088;mode=PLAY;
x-Dynamic-Rate: 1\r\n
\r\n
Transmission Control Protocol, Src Port: 4431, Dst Port: 8554, Seq: 1423, Ack: 1338, Len: 362
Real Time Streaming Protocol
Request: PLAY rtsp://192.168.1.109:8554/live0.264/ RTSP/1.0\r\n
CSeq: 7\r\n
Authorization: Digest username="admin", realm="LIBEASYRTSPD-JV", nonce="41b3fc540e909d63b1c8ff0444f1ed76", uri="rtsp://192.168.1.109:8554/live0.264/", response="135714bdbe4d768af5d1a2c40cc3a118"\r\n
User-Agent: LibVLC/3.0.18 (LIVE555 Streaming Media v2016.11.28)\r\n
Session: 3C66DB38
Range: npt=0.000-\r\n
\r\n
Transmission Control Protocol, Src Port: 8554, Dst Port: 4431, Seq: 1338, Ack: 1785, Len: 265
Real Time Streaming Protocol
Response: RTSP/1.0 200 OK\r\n
CSeq: 7\r\n
Date: Tue, May 16 2017 05:49:24 GMT\r\n
Session: 3C66DB38
Range: npt=0.000-\r\n
RTP-Info: url=rtsp://192.168.1.109:8554/live0.264/track1;seq=51013;rtptime=936573910,url=rtsp://192.168.1.109:8554/live0.264/track2;seq=50139;rtptime=1617512174\r\n
\r\n
因篇幅问题不能全部显示,请点此查看更多更全内容