Winpcap 的PCap 文件格式 解析
SourceCode: WinPcap Ver 4.02
Tools: WireShark Ver 1.3.0-SVN-29835
Pcap为 WireShark, Ethereal等 网络协议分析器 支持的常用格式之一。
如下将阐述PCAP的文件格式。
struct pcap_file_header {
bpf_u_int32 magic; /* 0xa1b2c3d4 */
u_short version_major; /* magjor Version 2 */
u_short version_minor; /* magjor Version 4 */
bpf_int32 thiszone; /* gmt to local correction */
bpf_u_int32 sigfigs; /* accuracy of timestamps */
bpf_u_int32 snaplen; /* max length saved portion of each pkt */
bpf_u_int32 linktype; /* data link type (LINKTYPE_*) */
};
表一
linktype
Value
LINKTYPE_NULL
0
LINKTYPE_ETHERNET
1
/* also for 100Mb and up */
LINKTYPE_EXP_ETHERNET
2
/* 3Mb experimental Ethernet */
LINKTYPE_AX25
3
LINKTYPE_PRONET
4
LINKTYPE_CHAOS
5
LINKTYPE_TOKEN_RING
6
/* DLT_IEEE802 is used for Token Ring */
LINKTYPE_ARCNET
7
LINKTYPE_SLIP
8
LINKTYPE_PPP
9
LINKTYPE_FDDI
10
struct timeval {
long tv_sec; /* seconds 含义同 time_t 对象的值 */
long tv_usec; /* and microseconds */
};
struct pcap_pkthdr {
struct timeval ts; /* time stamp */
bpf_u_int32 caplen; /* length of portion present */
bpf_u_int32 len; /* length this packet (off wire) */
};
pcap文件格式 结构
rel="File-List" href="file:///C:\DOCUME~1\shigx\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml">
文件头
格式如结构体pcap_file_header
数据包头1
格式如pcap_pkthdr
数据包
数据包
数据包头n-1
格式如pcap_pkthdr
数据包
数据包
数据包头n
格式如pcap_pkthdr
数据包
数据包
rel="File-List" href="file:///C:\DOCUME~1\shigx\LOCALS~1\Temp\msohtml1\01\clip_filelist.xml">