`
xumingyong
  • 浏览: 175802 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Capture file header format

 
阅读更多

截获包的文件头格式

 

(比如: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.

 

 

 

 

 

 

0
0
分享到:
评论

相关推荐

    capture file viewer for btsnoop_hci log-- part1/part5

    capture file viewer for bluetooth snoop_log.蓝牙协议栈hci log分析工具.共五个压缩包。

    capture file viewer for btsnoop_hci log-- part3/part5

    capture file viewer for bluetooth snoop_log.蓝牙协议栈hci log分析工具.共五个压缩包。压缩包三。

    capture file viewer for btsnoop_hci log-- part4/part5

    capture file viewer for bluetooth snoop_log.蓝牙协议栈hci log分析工具.共五个压缩包。压缩包4

    capture file viewer for btsnoop_hci log-- part5/part5

    capture file viewer for bluetooth snoop_log.蓝牙协议栈hci log分析工具.共五个压缩包。压缩包5.

    capture file viewer for btsnoop_hci log-- part2/part5

    capture file viewer for bluetooth snoop_log.蓝牙协议栈hci log分析工具.共五个压缩包。压缩包二。

    screen capture and file read

    screen capture and file read share it

    V4L2 多平面格式采集(Video Capture Multiplanar)

    在使用V4L2时,有的video设备 Capabilities为Video Capture Multiplanar。此时和Video Capture 格式设备采集所用的应用程序接口有些不同。

    capture monitor

    this program uses filter technology to capture file operation

    ethereal网络抓包工具

    Ethereal's native capture file format is libpcap format, which is also the format used by tcpdump and various other tools. So Ethereal can read capture files from: -libpcap/WinPcap, tcpdump and ...

    Android代码-ViewCapture

    save to file ViewCapture.with(v).asJPG().setOnSaveResultListener(this).save(); only get bitmap ViewCapture.with(v).getBitmap(); screenshots: License Licensed under the Apache License, Version 2.0 ...

    FSCapture.zip

    FSCapture,可支持截屏,录制视频,软件只有3M,使用方便,打开即用。

    FSCapture72.zip

    You can choose to send captures to editor, file, clipboard, printer, email, Word/PowerPoint document or upload them to your website. Editing tools include annotating (texts, arrowed lines, highlights...

    FastStone Screen Capture(FSCapture) 7

    FastStone Screen Capture(FSCapture)是一款很棒的图像浏览、编辑和抓屏工具,FastStone Capture支持包括BMP、JPEG、JPEG 2000、GIF、PNG、PCX、TIFF、WMF、ICO 和TGA在内的所有主流图片格式,其独有的光滑和毛刺...

    FastStone Capture_Capture_tool_

    FastStone Capture tool windows

    Video Capture Pro 2.5.2

    Video Capture Pro 2.5.2 unity推流工具

    vue中使用input[type=”file”]实现文件上传功能

    注意:input[type=file] 标签中的属性accept=application/msword,application/pdf 在pc上正常,但是在手机ios和android上这个文件格式限制会被忽略,所以需要在js中增加格式的判断,以及对应显示样式的设置.(我也是刚...

    DEV FSCapture90

    FastStone Capture(FSCapture)是经典好用的屏幕截图软件,还具有图像编辑和屏幕录制两大功能,可以捕捉全屏图像,或者活动窗口、窗口内的控件对象截图、支持手绘区域自由截图,或者滚动窗口等等,支持所有主流图片...

    FSCapture(动态截图)

    《FSCapture》是一款抓屏工具,体积小巧、功能强大,不但具有常规截图等功能,更有从扫描器获取图像,和将图像转换为 PDF文档等功能。 附带功能包括: 1、屏幕放大器; 2、屏幕取色器; 3、屏幕标尺; 4、将图像转换...

    FSCapture~FSCapture

    FSCapture 截图 录制视频的轻便级工具,希望大家用着喜欢。

    capture cis study capture cis study

    capture cis studycapture cis studycapture cis studycapture cis studycapture cis studycapture cis studycapture cis studycapture cis studycapture cis studycapture cis studycapture cis studycapture cis ...

Global site tag (gtag.js) - Google Analytics