HTTP Streaming protocol 分析笔记
Windows Media service
提供mms://
和http://
协议进行音视频流播放。由于微软没有公开以上协议的技术细节,很难对流进行下载保存。http
相对简单,以下对其进行抓包分析。
mms/http/rstp
协议文档可参考
http://sdp.ppona.com
HTTP
交互过程:
GET /xfm2003/video/morrissey_-_first_of_the_gang_to_die_hi.wmv HTTP/1.0
Accept: */*
User-Agent: NSPlayer/9.0.0.3250
Host: 195.173.73.27
X-Accept-Authentication: Negotiate, NTLM, Digest, Basic
Pragma: no-cache,rate=1.000,stream-time=0,stream-offset=4294967295:4294967295, packet-num=4294967295,max-duration=0
Pragma: xPlayStrm=1
Pragma: xClientGUID={3300AD50-2C39-46c0-AE0A-EF4916E929D5}
Pragma: stream-switch-count=3
Pragma: stream-switch-entry=ffff:1:0 ffff:2:2 ffff:3:0
Accept-Language: en-gb, *;q=0.1
HTTP/1.0 200 OK
Content-Type: application/octet-stream
Server: Cougar 4.1.0.3857
Via: netcache1-new (NetCache NetApp/5.6.2R1D17)
Cache-Control: no-cache
Pragma: no-cache
Pragma: client-id=5382809
Pragma: features="seekable,stridable"
<HTTP BODY>
..
<HTTP BODY>
包格式:
Command(2 bytes)
|
Length(2 bytes)
|
Data (length bytes)
|
...
|
...
|
...
|
Data
Seq(4)
|
ID(1)
|
Flag(1)
|
Length(2)
|
Asf Data(length – 8)
|
保存:把所有的Asf Data写入本地文件中,接收完后,最后回写ASF_File_Properties_Object 几个重要的字段(File Size/File Size/Creation Date/Data Packets Count/Play Duration/Send Duration/Preroll/Flags),即为.asf文件了
00000000 48 54 54 50 2f 31 2e 30 20 32 30 30 20 4f 4b 0d HTTP/1.0 200 OK.
...
000000E0 6b 61 62 6c 65 2c 73 74 72 69 64 61 62 6c 65 22 kable,st ridable"
000000F0 0d 0a 0d 0a
000000F4
24 48 44 0b
00 00 00 00 00 04 44 0b
30 26 b2 75
$H
D..... ..D.0&.u
00000104 8e 66 cf 11 a6 d9 00 aa 00 62 ce 6c 8f 0d 00 00 .f...... .b.l....
00000114 00 00 00 00 09 00 00 00 01 02
a1 dc ab 8c 47 a9
........ ......G.
00000124 cf 11 8e e4 00 c0 0c 20 53 65 68 00 00 00 00 00 ....... Seh.....
...
<Type Header Structure>: 24 48 44 0b
Command: 24 48
2448 “$H” Header packet follows
2444 “$D” Data (media) packet follows
A444 “?D” Data (sometimes used instead of $D)
2445 “$E” End of stream
2443 “$C” Changing media – reload new media, new ASF header follows
244D “$M” Meta data follows (used for custom scripts)
2450 “$P” Packet pair data follows
Length: 44 0b = 0b44 , Next header addr = 000000F4 + 0B44 + 4 = 00000C3C
<Type Object>: 00 00 00 00 00 04 44 0b
Seq: 00 00 00 00
Id: 00 (00=live 01=pre-recorded)
Flag: 04 (00 = middle of packet, 04 = first packet
08 = last packet 0C = only one packe)
<ASF header>: 30 26 b2 ..
Asf header size = 8f 0d 00 00 00 00 00 00 = 0d8f = 2271
ASF_File_Properties_Object
=
8CABDCA1-A947-11CF-8EE4-00C00C205365
= a1 dc ab 8c 47 a9 cf 11 8e e4 00 c0 0c 20 53 65
<asf header ...>
Next addr = 00000C3C + 028D + 4 = 00000ECD
00000C3C 24 48 8d 02 01 00 00 00 00 08 8d 02 00 69 00 61 $H...... .....i.a
00000C4C 00 20 00 56 00 69 00 64 00 65 00 6f 00 20 00 39 . .V.i.d .e.o. .9
...
00000E8C 84 00 00 02 00 2d a2 00 00 03 00 2d 8a 03 00 36 .....-.. ...-...6
00000E9C 26 b2 75 8e 66 cf 11 a6 d9 00 aa 00 62 ce 6c 0a &.u.f... ....b.l.
00000EAC f8 8f 00 00 00 00 00 8c 59 e9 68 6e 33 1d 47 8f ........ Y.hn3.G.
00000EBC 2f 57 6e 11 e0 37 c5 c3 0c 00 00 00 00 00 00 01 /Wn..7.. ........
00000ECC 01 .
上面
36 26 ...
为
<Data object>
开始
<ASF data packet> Next addr = 00000ECD + 0b4f + 4 = 00001A20
Live, seq = 05e7, first frame, packet size= 0b4f – 8 = 0b47 = 2887
00000ECD 24 44 4f 0b e7 05 00 00 00 04 4f 0b 82 00 00 09 $DO..... ..O.....
00000EDD 5d 00 0d c8 01 00 0a 00 82 03 43 be 02 00 00 0a ]....... ..C.....
00000EED ea 03 00 00 80 d3 01 00 28 00 2c 01 07 d0 91 d0 ........ (.,.....
<ASF data packet> Next addr = 00001A20 + 0b4f + 4 = 00002573
Live, seq = 05e8
00001A19 04 62 86 dd 4c 94 48 24 44 4f 0b e8 .b..L.H$ DO..
00001A25 05 00 00 00 00 4f 0b 82 00 00 09 5d 00 18 c8 01 .....O.. ...]....
00001A35 00 5e 00 84 82 a9 ea 09 00 00 08 8e 0a 00 00 d0 .^...... ........
00001A45 d3 01 00 a4 00 b4 c5 18 44 00 04 1f 2c 86 08 ac ........ D...,...
..
<ASF data packet> Next addr = 00002573 + 0b4f + 4 = 000030C6
Live, seq = 05e9
00002561 16 fc 1c fc 85 00 63 4c e2 09 02 48 a2 08 07 b5 ......cL ...H....
00002571 66 d4 24 44 4f 0b e9 05 00 00 00 00 f.$DO... ....
0000257D 4f 0b 82 00 00 09 5d 00 76 c8 01 00 6c 00 84 03 O.....]. v...l...
0000258D 46 83 02 00 00 0a 25 04 00 00 f8 d3 01 00 28 00 F.....%. ......(.
ASF Format
Header Object
|
File Properties Object
|
Stream Properties Object 1
|
…
|
Stream Properties Object N
|
<Other header objects>
|
Data Object
|
Data Packet 1
|
…
|
Data Packet M
|
<Other top-level objects>
|
Index Object 1
|
…
|
Index Object K
|
Simple Index Object 1
|
…
|
Simple Index Object L
|
The Header Object is represented using the following structure.
ASF_Header_Object
|
75B22630-668E-11CF-A6D9-00AA0062CE6C
|
Field name
|
Field type
|
Size (bytes)
|
Object ID
|
GUID
|
16
|
Object Size
|
QWORD
|
8
|
Number of Header Objects
|
DWORD
|
4
|
Reserved1
|
BYTE
|
1
|
Reserved2
|
BYTE
|
1
|
The File Properties Object is represented using the following structure.
ASF_File_Properties_Object
|
8CABDCA1-A947-11CF-8EE4-00C00C205365
|
Field name
|
Field type
|
Size (bits)
| |
Object ID
|
GUID
|
128
| |
Object Size
|
QWORD
|
64
| |
File ID
|
GUID
|
128
| |
File Size
|
QWORD
|
64
| |
Creation Date
|
QWORD
|
64
| |
Data Packets Count
|
QWORD
|
64
| |
Play Duration
|
QWORD
|
64
| |
Send Duration
|
QWORD
|
64
| |
Preroll
|
QWORD
|
64
| |
Flags
|
DWORD
|
32
| |
|
Broadcast Flag
|
|
1 (LSB)
|
|
Seekable Flag
|
|
1
|
|
Reserved
|
|
30
|
Minimum Data Packet Size
|
DWORD
|
32
| |
Maximum Data Packet Size
|
DWORD
|
32
| |
Maximum Bitrate
|
DWORD
|
32
|
|
The Data Object is represented using the following structure.
Field name
|
Field type
|
Size (bytes)
|
Object ID
|
GUID
|
16
|
Object Size
|
QWORD
|
8
|
File ID
|
GUID
|
16
|
Total Data Packets
|
QWORD
|
8
|
Reserved
|
WORD
|
2
|
Data Packets
|
See section 5.2
|
varies
|
|