Module pcap_parser::pcapng

source ·
Expand description

PCAPNG file format

See https://github.com/pcapng/pcapng for details.

There are several ways of parsing a PCAPNG file. The first method is to use parse_pcapng. This method requires to load the entire file to memory, and thus may not be good for large files.

The second method is to create a PcapNGCapture object, which implements the Capture trait to provide generic methods. However, this method also reads the entire file.

The third (and prefered) method is to use a PcapNGReader object.

The last method is to manually read the blocks using parse_sectionheaderblock, parse_block_le and/or parse_block_be.

§File format and parsing

A capture file is organized in blocks. Blocks are organized in sections, each section starting with a Section Header Block (SHB), and followed by blocks (interface description, statistics, packets, etc.). A file is usually composed of one section, but can contain multiple sections. When a SHB is encountered, this means a new section starts (and all information about previous section has to be flushed, like interfaces).

§Endianness

The endianness of a block is indicated by the Section Header Block that started the section containing this block. Since a file can contain several sections, a single file can contain both endianness variants.

Structs§

Enums§

  • A block from a PcapNG file

Constants§

Functions§