请问用Wireshark捕获保存的*.cap文件的格式是什么?

来源:百度知道 编辑:UC知道 时间:2024/05/30 05:03:27
*.cap文件有24字节的文件头,每个数据包有16字节的数据包头
请问文件头和数据包头每个字节表示什么含义?

组成pcap格式文件,首先按照这个结构写入一个24字节包头:
typedef struct pcap_hdr_s {
guint32 magic_number; /* magic number */
guint16 version_major; /* major version number */
guint16 version_minor; /* minor version number */
gint32 thiszone; /* GMT to local correction */
guint32 sigfigs; /* accuracy of timestamps */
guint32 snaplen; /* max length of captured packets, in octets */
guint32 network; /* data link type */
} pcap_hdr_t;
然后是16字节的包描述(注意后面的说明):
typedef struct pcaprec_hdr_s {
guint32 ts_sec; /* timestamp seconds */ 抓包的时间,可以填0
guint32 ts_usec; /* timestamp microseconds */ 毫秒数,直接以0填充
guint32 incl_len; /* number of octets of packet saved in file */ 文件中的包长,就是(Etherne+udp+snmp)的总长度了
guint32 orig_l