相对于看RTSP协议,直接抓包分析会对该协议有一个简单的认知。本文在Windows下使用Wireshark抓包,live555服务器使用前些日子搞的工程。
一、RTSP包
1、OPTION
CSeq: 2\r\n
User-Agent: LibVLC/2.1.3 (LIVE555 Streaming Media v2014.01.21)\r\n
\r\n
CSeq: 2\r\n
Date: Sun, Jan 03 2016 11:57:35 GMT\r\n
Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, GET_PARAMETER, SET_PARAMETER\r\n
\r\n
2、DESCRIBE
CSeq: 3\r\n
User-Agent: LibVLC/2.1.3 (LIVE555 Streaming Media v2014.01.21)\r\n
Accept: application/sdp\r\n
\r\n
CSeq: 3\r\n
Date: Sun, Jan 03 2016 11:57:35 GMT\r\n
Content-Base: rtsp://192.168.18.18:8554/h264ESVideo/\r\n
Content-type: application/sdp
Content-length: 515
\r\n
3、SETUP
SETUP命令用于确定转输机制,建立RTSP会话。客户端发的包如下:
Request: SETUP rtsp://192.168.18.18:8554/h264ESVideo/track1 RTSP/1.0\r\n
CSeq: 4\r\n
User-Agent: LibVLC/2.1.3 (LIVE555 Streaming Media v2014.01.21)\r\n
Transport: RTP/AVP/TCP;unicast;client_port=64328-64329
\r\n
服务器回应:
Response: RTSP/1.0 200 OK\r\n
CSeq: 4\r\n
Date: Sun, Jan 03 2016 11:57:35 GMT\r\n
Transport: RTP/AVP/TCP;unicast;destination=192.168.18.1;source=192.168.18.18;client_port=64328-64329;server_port=6970-6971
Session: 735B75BD;timeout=65
\r\n
Transport的值表示传输协议,如为“Transport: RTP/AVP/TCP”表示RTP使用TCP来传输。如果是 “RTP/AVP/UDP”则表示使用UDP传输。后面接着的值表示单播(unicast)、多播(multicast)。以及端口号范围。回应包除了上述内容,还有IP地址。
4、PLAY
Request: PLAY rtsp://192.168.18.18:8554/h264ESVideo/ RTSP/1.0\r\n
CSeq: 5\r\n
User-Agent: LibVLC/2.1.3 (LIVE555 Streaming Media v2014.01.21)\r\n
Session: 735B75BD
Range: npt=0.000-\r\n
\r\n
服务器回应:
Response: RTSP/1.0 200 OK\r\n
CSeq: 5\r\n
Date: Sun, Jan 03 2016 11:57:35 GMT\r\n
Range: npt=0.000-\r\n
Session: 735B75BD
RTP-Info: url=rtsp://192.168.18.18:8554/h264ESVideo/track1;seq=33054;rtptime=859736117\r\n
\r\n
5、GET_PARAMETER
获取参数命令,客户端发包:
Request: GET_PARAMETER rtsp://192.168.18.18:8554/h264ESVideo/ RTSP/1.0\r\n
CSeq: 6\r\n
User-Agent: LibVLC/2.1.3 (LIVE555 Streaming Media v2014.01.21)\r\n
Session: 735B75BD
\r\n
服务器回应:
Response: RTSP/1.0 200 OK\r\n
CSeq: 6\r\n
Date: Sun, Jan 03 2016 11:57:35 GMT\r\n
Session: 735B75BD
Content-length: 10
\r\n
6、TEARDOWN
CSeq: 7\r\n
User-Agent: LibVLC/2.1.3 (LIVE555 Streaming Media v2014.01.21)\r\n
Session: 735B75BD
\r\n
服务器回应:
Response: RTSP/1.0 200 OK\r\n
CSeq: 7\r\n
Date: Sun, Jan 03 2016 11:57:38 GMT\r\n
\r\n
二、RTP包
三、RTCP包
Goodbyte包
李迟 2016.1.3 晚