Built-in Engines#

PCAP Support#

This module contains the implementation for PCAP file extraction support, as is used by pcapkit.foundation.extraction.Extractor.

class pcapkit.foundation.engines.pcap.PCAP(extractor)#

Bases: Engine[Frame]

PCAP file extraction support.

Parameters:

extractor (Extractor) – Extractor instance.

run()#

Start extraction.

This method is the entry point for PCAP file extraction. It will start the extraction process by parsing the PCAP global header and then halt the extraction process until the self.extractor._read_frame method is called.

The method will parse the PCAP global header and save the parsed result as self.extractor._gbhdr. Information such as PCAP version, data link layer protocol type, nanosecond flag and byteorder will also be save the current Extractor instance.

If TCP flow tracing is enabled, the nanosecond flag and byteorder will be used for the output PCAP file of the traced TCP flows.

For output, the method will dump the parsed PCAP global header under the name of Global Header.

Return type:

None

read_frame()#

Read frames.

This method performs following operations:

  • extract frames and each layer of packets;

  • make Info object out of frame properties;

  • write to output file with corresponding dumper;

  • reassemble IP and/or TCP datagram;

  • trace TCP flows if any;

  • record frame Info object to frame storage.

Return type:

Frame

Returns:

Parsed frame instance.