Capture-Format Constants

pcapkit.corekit.const.capture holds the values the PCAP and PCAP-NG file formats fix and that code beyond their own file-header protocols reads: the capture engines, the dumpers and the toolkit. Each is the one home of its value (#1739), and none is configurable.

Added in version 1.7.0: Moved here from pcapkit.protocols.misc.pcap.header.schema, pcapkit.protocols.misc.pcap.frame.schema and pcapkit.protocols.misc.pcapng.schema (#2883).

PCAP

pcapkit.corekit.const.capture.MAGIC_NUMBER: Dict[bytes, tuple[Literal['big', 'little'], bool]]

PCAP magic numbers, as the octets open the file, mapped to the byte order ('big' or 'little') and the timestamp resolution (True for nanoseconds, False for microseconds) each one declares.

pcapkit.corekit.const.capture.RESOLUTION: Dict[bool, int]

Units per second of a PCAP record’s ts_usec field, keyed by the nanosecond flag its file’s magic number declares (MAGIC_NUMBER): microseconds, or nanoseconds.

pcapkit.corekit.const.capture.RESOLUTION_PLACES: Dict[bool, int]

Decimal places of a ts_usec fraction at each resolution of RESOLUTION, keyed the same way – six for microseconds, nine for nanoseconds – and derived from it, so that an epoch rounded to its file’s resolution follows the one home.

pcapkit.corekit.const.capture.RECORD_HEADER_LEN = 16

Length of a PCAP record header, which precedes each record’s packet data.

PCAP-NG

pcapkit.corekit.const.capture.BYTE_ORDER_MAGIC = 439041101

Byte-Order Magic of a PCAP-NG Section Header Block, read in the byte order of the section that wrote it.

pcapkit.corekit.const.capture.GENERIC_BLOCK_MINIMUM = 12

The octets every PCAP-NG block’s fixed fields span – Block Type and both copies of Block Total Length – and so the shortest Block Total Length of any block, and the whole of it for a block not in BLOCK_MINIMUM.

pcapkit.corekit.const.capture.BLOCK_MINIMUM: Dict[int, int]

PCAP-NG block types mapped to the octets their fixed fields span, Block Type and both copies of Block Total Length included; any other block spans GENERIC_BLOCK_MINIMUM.

pcapkit.corekit.const.capture.DEFAULT_RESOLUTION = 1000000

Units per second of a timestamp on a PCAP-NG interface that carries no if_tsresol option: microseconds, the default the format gives that option.