pcap module

PCAP Processing Helper Functions

pcap.count_packets_in_pcap(in_filename: str) int[source]

Count the total number of packets from a given PCAP(NG) file.

pcap.eth_from_sll(sll_bytes: bytes) bytes[source]

Convert an SLL (“cooked”) PCAP packet into an Ethernet one

pcap.get_reader(file: BinaryIO) dpkt.pcap.Reader | dpkt.pcapng.Reader[source]

Create a reader for a PCAP(NG) file

pcap.get_writer(file: BinaryIO, packet_size: int = 9000) dpkt.pcap.Writer | dpkt.pcapng.Writer[source]

Create a writer for a PCAP(NG) file

Parameters:
  • file – file object to write to

  • packet_size – packet size (Bytes)

pcap.packet_size_from_pcap(in_filename: str) int[source]

Get the packet size from a given PCAP(NG) file. Note: only inspects the first packet!

Parameters:

in_filename (str) – path to file

Returns:

packet size (Bytes)