打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
PCAP文件格式分析(做抓包软件之必备)
PCAP文件格式分析(做抓包软件之必备)
一、基本格式:
文件头 数据包头 数据报 数据包头 数据报......
二、文件头结构体:
sturct pcap_file_header
{
DWORD              magic;
      WORD                 version_major;
      WORD                 version_minor;
DWORD              thiszone;
DWORD              sigfigs;
DWORD              snaplen;
DWORD              linktype;
}
 
说明:
 
1、标识位:32位的,这个标识位的值是16进制的 0xa1b2c3d4。
a 32-bit        magic number ,The magic number has the value hex a1b2c3d4.
2、主版本号:16位, 默认值为0x2。
a 16-bit          major version number,The major version number should have the value 2.
3、副版本号:16位,默认值为0x04。
a 16-bit          minor version number,The minor version number should have the value 4.
4、区域时间:32位,实际上该值并未使用,因此可以将该位设置为0。
a 32-bit          time zone offset field that actually not used, so you can (and probably should) just make it 0;
5、精确时间戳:32位,实际上该值并未使用,因此可以将该值设置为0。
a 32-bit          time stamp accuracy field tha not actually used,so you can (and probably should) just make it 0;
6、数据包最大长度:32位,该值设置所抓获的数据包的最大长度,如果所有数据包都要抓获,将该值设置为65535; 例如:想获取数据包的前64字节,可将该值设置为64。
a 32-bit          snapshot length" field;The snapshot length field should be the maximum number of bytes perpacket that will be captured. If the entire packet is captured, make it 65535; if you only capture, for example, the first 64 bytes of the packet, make it 64.
7、链路层类型:32位, 数据包的链路层包头决定了链路层的类型。
a 32-bit link layer type field.The link-layer type depends on the type of link-layer header that the
packets in the capture file have:
 
以下是数据值与链路层类型的对应表
0            BSD       loopback devices, except for later OpenBSD
1            Ethernet, and Linux loopback devices   以太网类型,大多数的数据包为这种类型。
6            802.5 Token Ring
7            ARCnet
8            SLIP
9            PPP
10          FDDI
100        LLC/SNAP-encapsulated ATM
101        raw IP, with no link
102        BSD/OS SLIP
103        BSD/OS PPP
104        Cisco HDLC
105        802.11
108        later OpenBSD loopback devices (with the AF_value in network byte order)
113               special Linux cooked capture
114               LocalTalk
 
 
 
 
三、数据包头结构体:
struct pcap_pkthdr
{
struct timeval         ts;
      DWORD              caplen;
      DWORD              len;
}
 
struct timeval
{
DWORD       GMTtime;
DWORD       microTime
}
说明:
 
1、时间戳,包括:
秒计时:32位,一个UNIX格式的精确到秒时间值,用来记录数据包抓获的时间,记录方式是记录从格林尼治时间的1970年1月1日 00:00:00 到抓包时经过的秒数;
毫秒计时:32位, 抓取数据包时的毫秒值。
a time stamp, consisting of:
a UNIX-format time-in-seconds when the packet was captured, i.e. the number of seconds since January 1,1970, 00:00:00 GMT (that GMT, *NOT* local time!);  
the number of microseconds since that second when the packet was captured;
 
2、数据包长度:32位 ,标识所抓获的数据包保存在pcap文件中的实际长度,以字节为单位。
a 32-bit value giving the number of bytes of packet data that were captured;
 
3、数据包实际长度: 所抓获的数据包的真实长度,如果文件中保存不是完整的数据包,那么这个值可能要比前面的数据包长度的值大。
a 32-bit value giving the actual length of the packet, in bytes (which may be greater than the previous number, if you are not saving the entire packet).
 
发表于 @ 2008年01月01日 21:12:00 | 评论( 2 ) | 编辑| 举报| 收藏
旧一篇:Packed.Win32.NSAnti.a(svchoxt)分析报告 | 新一篇:延迟加载Dll的实现原理
相关文章
Table of Delphi data types and C++ typeswindows data typesMFC 数据类型ethereal文件格式libpcap如何知道可执行文件是32-bit还是64-bitMAKELONG用法MultiMedia eXtensionstcpdump抓包命令swh326 发表于2009年7月27日 星期一 15:18:36  IP:举报删除
时间戳后面那个是毫秒么~?? 我看另一篇文章写的microseconds呢anzijin 发表于2009年7月27日 星期一 18:05:07  IP:举报删除
是微秒,这里写错了,非常感谢你的指正。
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/anzijin/archive/2008/01/01/2008333.aspx
本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
libpcap函数库 [TurboLinux知识库]
IP包流量分析(一)(python+pypcap+dkpt)
回调函数packet_handler()
Pcap_loop函数
JPCAP:使用Java来sniffer网络数据包
【原创】抓包分析之 “TCP Previous segment not captured”
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服