截获包的文件头格式
(比如:wireshark, ethereal, tcpdump -w filename)
Many capture file formats have such a header.
The header of libpcap-format files (as used by tcpdump, Ethereal,
Analyzer, and a number of other programs) contains:
-- a 32-bit "magic number";
-- a 16-bit major version number;
-- a 16-bit minor version number;
-- an unused 32-bit time zone offset field;
-- an unused 32-bit time stamp accuracy field;
-- a 32-bit field giving the maximum length of the saved data in
packets;
-- a 32-bit field giving the link-layer type of the packets in the
capture.
All numbers are in the same byte order, which is typically the byte
order of the machine that wrote the capture file.
The magic number:
has the value hex A1B2C3D4. On a big-endian machine,
such as a SPARC machine, the four bytes of that number are A1, B2, C3,
and D4, in order. On a little-endian mchine, such as a PC, the four
bytes of that number are D4, C3, B2, and A1, in order.
That number serves two purposes:
1) it indicates that the file is a libpcap-format file;
2) it indicates the byte order of the numbers in the file header
and the header written in front of the packet data.
If, when a program or library routine reads the file header, the number
is hex A1B2C3D4, the other numbers in the header are in the byte order
of the machine reading the file, and do not need to be byte-swapped.
If, however, it's D4C3B2A2, they're in the opposite byte order of the
machine reading the file, so the program or library routine needs to
byte-swap them.
The current major and minor version numbers
for libpcap-format files are
2 and 4, respectively.
The two unused fields are set to 0 by libpcap (as used by tcpdump and
many other programs) and the internal library Ethereal uses to write
capture files. I don't know whether they were ever used.
The maximum length of the saved data in packets is the "snapshot length
"
specified when the capture was done, e.g. with "-s" for tcpdump or
Tethereal, and "-s" or the appropriate dialog box option for Ethereal,
causing no more than that many bytes of packet data to be saved to the
file.
The link-layer type
is a number specifying the type of link-layer
headers in the capture, e.g. Ethernet, FDDI, Token Ring, etc..
Following that header are a sequence of records, one per packet. Each
record consists of a per-packet header followed by the raw packet data.
The per-packet header contains:
a time stamp
, consisting of 2 32-bit numbers, giving the time
the packet arrived, in seconds since January 1, 1970, 00:00:00
GMT in the first number, and microseconds since the second in
question in the second number;
a 32-bit number
giving the number of bytes of data for that
packet that are in the file;
a 32-bit number
givin the number of bytes of data that were in
the packet - this could be larger than the previous number.
So the data before the first MAC address, in an Ethernet capture,
consists of *two separate* pieces:
1) the per-file header;
2) the per-packet header.
There is only one per-file header, at the beginning of the file. There
is one per-packet header before *each* packet's data.
Note that libpcap includes routines to read and write these files, so
one rarely needs to know the details of this - if you want to write a
program to read or write those files, you should try to use the libpcap
routines to read them ("pcap_open_offline()", "pcap_loop()",
"pcap_close()") or to write them ("pcap_dump_open()", "pcap_dump()",
"pcap_dump_close()") if you can.
实例一:
Per file Header: D4 A3 B2 A1 02 00 04 00 00 00 00 00 00 00 00 00 60 00 00 00 01 00 00 00
|magic |version |time zone |time stamp |packet len. |linklayer type
Per pkt Header: A9 7D ED 49 9E A5 0E 00 60 00 00 00 D6 02 00 00 00 18 82 83 1B 7D ...
|time stamp |number. |number. |dst MAC Addr.
分享到:
相关推荐
regardless of bus type Fits on a diskette for easy transportability and quick downloads Drag and drop captured data to other products in html format<br> Save captured data to a text file...
"My File Format", NULL, NULL, my_file_open, my_file_read, my_file_write, my_file_close, NULL, /* no private data needed */ NULL, /* no private data needed */ NULL, /* no private data needed ...
V4L2_FIELD_NONE,//default format, can be changed by s_fmt sizeof(struct vfe_buffer), dev,NULL); ret = sysfs_create_group(&dev->pdev->dev.kobj, &vfe_attribute_group); #ifdef CONFIG_ES dev->...
V4L2_FIELD_NONE,//default format, can be changed by s_fmt sizeof(struct vfe_buffer), dev,NULL); ret = sysfs_create_group(&dev->pdev->dev.kobj, &vfe_attribute_group); #ifdef CONFIG_ES dev->...
WAV是一种流行的无损音频格式,由RIFF(Resource Interchange File Format)结构组成,包含文件头和数据块。你需要在程序中写入这些结构,然后将采集到的音频数据写入数据块。以下是一个简单的WAV文件头结构: ```c...
Data Format Section 5.19. Summary Exercises Chapter 6. I/O Multiplexing: The select and poll Functions Section 6.1. Introduction Section 6.2. I/O Models Section 6.3. select Function ...
- **Main Source File & Main Header File**: 分别指定主源文件和主头文件的名称,默认分别为`MAIN.C`和`MAIN.H`。 - **Compiler Settings**: 选择编译器类型。英飞凌DAVE支持Keil和Tasking两种编译器,分别适用于8...
<EncoderProfile quality="1080p" fileFormat="mp4" duration="30"> bitRate="9000000" width="1920" height="1080" frameRate="24" /> bitRate="128000" sampleRate="44100" channels="1" ...
[2960379] Fix build with -Wformat -Werror=format-security by Per Oyvind Karlsen [2938273] allow instrumentation to change execute by Konrad Grochowski [2926072] Indirection operators in expressions...