logo资料库

pcapng格式解析中文版.docx

第1页 / 共38页
第2页 / 共38页
第3页 / 共38页
第4页 / 共38页
第5页 / 共38页
第6页 / 共38页
第7页 / 共38页
第8页 / 共38页
资料共38页,剩余部分请下载后查看
PCAP下一代转储文件格式
PCAP-DumpFileFormat
Status of this Memo
Copyright Notice
Abstract
Updates
1.  目标
2.  文件结构(General File Structure)
2.1.  块结构(General Block Structure)
2.2.  块类型(Block Types)
2.3.  逻辑块层次结构(Logical Block Hierarchy)
2.4.  物理文件的布局(Physical File Layout)
2.5.  选项(Options)
2.6.  数据格式(Data format)
3.  块定义(Block Definition)
3.1.  节头块(Section Header Block)
3.2.  接口描述块(Interface Description Block)
3.3. 增强分组块(Enhanced Packet Block)
3.4.  简单分组块(Simple Packet Block)
3.5.  分组块(Packet Block)
3.6.  名称解析块(Name Resolution Block)
3.7.  接口统计块(Interface Statistics Block)
4. 实验块(Experimental Blocks)
4.1. 替代性分组块(Alternative Packet Blocks)
4.2. 压缩块(Compression Block)
4.3. 加密块(Encryption Block)
4.4. 固定长度块(Fixed Length Block)
4.5. 目录块(Directory Block)
4.6. 流量统计和监控块(Traffic Statistics and Monitoring Bl
4.7.事件/安全块(Event/Security Block)
5.  推荐的扩展名: .pcapng
6. 怎样增加供应商/域特定扩展
7.  结论
Appendix A.  Packet Block Flags Word
Appendix B.  Standardized Block Type Codes
Appendix C.  Standardized Link Type Codes
Appendix D.  Link Layer Headers
Authors' Addresses
Full Copyright Statement
Intellectual Property
Acknowledgment
附录:pcap文件格式说明
文件格式
ile Header
Record (Packet) Header
Packet Data
Network Working Group Internet-Draft Expires: September 2, 2004 L. Degioanni CACE Technologies F. Risso Politecnico di Torino G. Varenni CACE Technologies March 2004 TOC PCAP 下一代转储文件格式 PCAP-DumpFileFormat Status of this Memo This document is an Internet-Draft and is in full conformance with all provisions of Section 10 of RFC 2026. Internet-Drafts are working documents of the Internet Engineering Task Force (IETF), its areas, and its working groups. Note that other groups may also distribute working documents as Internet-Drafts. Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as “work in progress.” The list of current Internet-Drafts can be accessed at http://www.ietf.org/ietf/1id-abstracts.txt. The list of Internet-Draft Shadow Directories can be accessed at http://www.ietf.org/shadow.html. This Internet-Draft will expire on September 2, 2004. Copyright Notice
Copyright © The Internet Society (2004). All Rights Reserved. Abstract This document describes a format to dump captured packets on a file. This format is extensible and it is currently proposed for implementation in the libpcap/WinPcap packet capture library. Updates            [27 Jul 2009] Guy Harris: added some missing reserved block types in Appendix B. [27 Jul 2009] Guy Harris: fixed a typo in Appendix B. The range of standardized blocks are in the range 0x00000000-0x7FFFFFFF. [ 8 Feb 2008] Gianluca Varenni: better documentation for the format of the timestamps. Renamed the if_tsaccur option into if_tsresol. [22 Oct 2007] Gianluca Varenni: added a note related to 64-bit alignment. Specified that the option length field is the length without padding. typos here and there. Added some option examples. [17 Oct 2007] Ulf Lamping: Major review: "Interface ID" in "ISB" now 32 bits. isb_starttime/isb_endtime depends on if_tsaccur. Lot's of other editing ... [ 8 Oct 2007] Ulf Lamping: Fixed several typos. Grouped the block types into mandatory, optional, experimental, obsolete. [14 Sep 2006] Gianluca Varenni: Added the block type code for Arinc 429 in AFDX Encapsulation Information Block [23 May 2006] Gianluca Varenni: Added the block type code for IRIG Timestamp Block [23 Apr 2006] Gianluca Varenni: Cleaned up Appendix C a bit: we should use the LINKTYPE_xxx values from libpcap, not the DLT_xxx ones. Fixed the introduction to the appendix and added some comments. [21 Mar 2006] Gianluca Varenni: Added a preliminary version of Appendix C, detailing the Standardized Link Types. [21 Mar 2006] Gianluca Varenni: Added a preliminary version of Appendix B, detailing the Standardized Block Type codes.
     [21 Mar 2006] Gianluca Varenni: Added the Enhanced Packet Block in section 2.2. Fixed a typo in the list: it's Interface Statistics Block, and not Capture Statistics Block. [21 Mar 2006] Gianluca Varenni: Fixed some minor typos in the document. [21 Mar 2006] Gianluca Varenni: Fixed an error in Packet Block: option pack_hash should have code 3. [21 Mar 2006] Gianluca Varenni: Added the definition of the Enhanced Packet Block. [12 Mar 2006] Gianluca Varenni: Added option if_tsoffset in the Interface Description Block. 目录 PCAP 下一代转储文件格式....................................................................................................1 PCAP-DumpFileFormat........................................................................................................1 Status of this Memo......................................................................................................1 Copyright Notice............................................................................................................1 Abstract............................................................................................................................2 Updates............................................................................................................................2 1. 目标............................................................................................................................. 5 2. 文件结构(General File Structure)....................................................................5 2.1. 块结构(General Block Structure)................................................................ 5 2.2. 块类型(Block Types)...................................................................................... 6 2.3. 逻辑块层次结构(Logical Block Hierarchy)................................................ 7 2.4. 物理文件的布局(Physical File Layout)....................................................... 7 2.5. 选项(Options)...................................................................................................9 2.6. 数据格式(Data format)..................................................................................10 3. 块定义(Block Definition).................................................................................11 3.1. 节头块(Section Header Block)...................................................................11 3.2. 接口描述块(Interface Description Block)................................................ 12 3.3. 增强分组块(Enhanced Packet Block).........................................................15 3.4. 简单分组块(Simple Packet Block).............................................................17
3.5. 分组块(Packet Block)...................................................................................18 3.6. 名称解析块(Name Resolution Block)....................................................... 20 3.7. 接口统计块(Interface Statistics Block).................................................... 22 4. 实验块(Experimental Blocks)..........................................................................23 4.1. 替代性分组块(Alternative Packet Blocks).................................................23 4.2. 压缩块(Compression Block)........................................................................ 24 4.3. 加密块(Encryption Block).............................................................................24 4.4. 固定长度块(Fixed Length Block).................................................................25 4.5. 目录块(Directory Block)................................................................................ 26 4.6. 流量统计和监控块(Traffic Statistics and Monitoring Blocks)...............26 4.7.事件/安全块(Event/Security Block).............................................................. 26 5. 推荐的扩展名: .pcapng......................................................................................... 27 6. 怎样增加供应商/域特定扩展.................................................................................... 27 7. 结论........................................................................................................................... 27 Appendix A. Packet Block Flags Word................................................................28 Appendix B. Standardized Block Type Codes.................................................. 28 Appendix C. Standardized Link Type Codes..................................................... 29 Appendix D. Link Layer Headers.......................................................................... 33 Authors' Addresses....................................................................................................34 Full Copyright Statement.......................................................................................... 34 Intellectual Property................................................................................................... 35 Acknowledgment.........................................................................................................35
1. 目标 交换分组痕迹的问题变得越来越关键。不幸的是,现在这个问题仍然没 有标准的解决方案。其中最能够被接受的分组交换格式之一是在 libpcap 中 定义的,这是相当古老的,并且从可扩展性的角度来看不适合某些特定的应 用程序。 该文件提出了转储数据包踪迹(packet traces)的新格式,它追求一 下几个目标:  可扩展性:除了一些常见的功能,第三方应该能够在文件中嵌入丰富 的信息,无法理解这些信息的工具可以之间忽略它。  可移植性:一个捕捉跟踪必须包含读取时所需要的所有信息,而不依 赖于捕获数据时的网络、硬件和操作系统。  合并/附加数据:应该可以在给定文件的末尾添加数据,并将得到的文 件仍然必须是可读的。 2. 文件结构(General File Structure) 2.1. 块结构(General Block Structure) 一个 pcapng 格式的文件有各种块(block)组成,块的结构描述如下: 1 2 3 0 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ /* variable length, aligned to 32 bits */ Block Total Length(块长度) Block Total Length(块长度) Block Type(块类型) Block Body (块内容) Figure 1: 块结构描述 每个字段的含义如下:
 块类型: 32 bits,该字段标识当前块的类型,不同类型的块有 不同的类型值。  块长度:32 bits,当前块的总长度,单位为 byte,不包含块体 的块的总长度为 12 byte。  块体: 块的内容,长度不固定,但需要 4 字节对齐。  块长度:32 bits,当前块的总长度,单位为 byte,与块体前面 的块长度重复。 2.2. 块类型(Block Types) 目前标准化的块类型代码在附录 B 中被指定,他们已被分为以下四类: 强制性块(MANDATORY blocks)必须在每个文件中出现至少一 次:  节头块():它定义了捕获文件的最重要的特征。  接口描述块(Interface Description Block ) :它定义了用于捕获流 量的接口的最重要的特征。 可选块(OPTIONAL blocks)可以出现在文件中:  增强分组块():它包含一个捕获数据包,或它的一部分,代表 了原有的分组块(Packet Block)的演进。  简单分组块 ( Simple Packet Block) :它包含一个捕获数据包,或 它的一部分,以及很少的关于数据包描述信息。  名称解析块( Name Resolution Block ):它定义由存在于数据包转 储和规范名称的对应数字地址的映射。  接口统计块( Interface Statistics Block ):它定义了如何存储一些统 计数据(例如分组丢弃,等等),它对于了解数据包捕获的条件 是有用的。 已过时块(OBSOLETE blocks)不应该出现在新写入的文件(但在 这里留下供参考):  分组块(Packet Block) :它包含单个捕获分组,或它的一部分。 它应该被视为过时的,有增强分组块而取得。 实验块(EXPERIMENTAL blocks)被认为是有意义的,但作者认 为他们应该被定义以前更深入的讨论:  Alternative Packet Blocks 替代性包块  Compression Block 压缩块  Encryption Block 加密块  Fixed Length Block 固定长度块
 Directory Block 目录块  Traffic Statistics and Monitoring Blocks 流量统计和监控模 块  Event/Security Blocks 事件/安全模块 2.3. 逻辑块层次结构(Logical Block Hierarchy) 下图用树状结构的形式展示了当前所定义的块的层次结构: Section Header | +- Interface Description | +- Simple Packet | +- Enhanced Packet | +- Interface Statistics | +- Name Resolution Figure 2: 一个 pcapng 文件的逻辑块层次 2.4. 物理文件的布局(Physical File Layout) 一个 pcapng 格式的文件必须具有节头块(Section Header Block) 开始。 在一个 dump 文件中可以存在多于一个节头块,每一个节头块的作 用范围从紧随其后的数据开始,直至下一个节头块(或文件结束)。 因为版本号的不同,应用程序可能无法读取一节(Section)的内容,必 须跳过这一节,直到下一节头块。 需要注意的是,为了适当地跳过块,直 到下一节,所有的块必须以类型和长度字段开始。这是一个必须在块格式的 未来版本进行维护的强制性要求。 图 3 展示出了一个典型的文件结构中,整个文件只包含一个节头块。 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SHB v1.0 | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Data Figure 3: 一个典型的文件结构
图 4 显示了包含三个节头块的文件,通常是文件拼接的结果。只能理解 文件格式的 1.0 版本的应用程序可以跳过中间部分,并继续处理第三个节头 块之后的数据包。 1st Section --|-- 2nd Section --| |-- | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SHB v1.0 | Data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SHB V1.0 | Data | SHB V1.1 | Data --|-- 3rd Section Figure 4: 包含 3 个节头块的文件. Figure 5 显示了一个堪比“经典 libpcap 格式的”pcapng 文件结构,它包含 一个节头块(SHB),一个单一的接口描述块(IDB)和几个增强分组块(EPB)。 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SHB | IDB | EPB | EPB | | EPB | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ Figure 5: 一个经典的 pcapng 文件结构 ... Figure 6 shows a complex example file. In addition to the minimum file above, it contains packets captured from three interfaces, and also includes some Name Resolution Blocks (NRB) and an Interface Statistics Block (ISB). Figure 6 是一个复杂的示例文件。除了上述的最小化的文件,它包含了 来自三个接口捕获的数据包,并且还包括一些名称解析模块(NRB)和接口 统计块(ISB)。 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SHB | IDB | IDB | IDB | EPB | EPB | NRB | | EPB | ISB | NRB | EPB | EPB | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ... Figure 6: 一个复杂的 pcapng 文件结构 最后一个例子应该很明显,该块结构使得相比于传统的 libpcap 格式的 文件格式非常灵活。
分享到:
收藏