wltrace.pcap module

Pcap file parser.

class wltrace.pcap.PcapCapture(path, *args, **kwargs)[source]

Bases: wltrace.common.WlTrace

Represent a Pcap packet trace.

Currently only support two link types.

LINKTYPES = [105, 127]
classmethod save(path, pkts)[source]
exception wltrace.pcap.PcapException[source]

Bases: exceptions.Exception

class wltrace.pcap.PcapHeader(fh, *args, **kwargs)[source]

Bases: wltrace.common.GenericHeader

Pcap file header.

The format is documented here: https://wiki.wireshark.org/Development/LibpcapFileFormat

Note that the file header does not contain the total number of packets in the file.

Parameters:fh (file object) – the packet trace file.
FIELDS = ['magic_number', 'version_major', 'version_minor', 'thiszone', 'sigfigs', 'snaplen', 'network']
classmethod to_binary(endian='@', snaplen=65535, network=127)[source]
class wltrace.pcap.PcapPacketHeader(fh, header, *args, **kwargs)[source]

Bases: wltrace.common.GenericHeader

Per packet header in Pcap format.

FIELDS = ['ts_sec', 'ts_usec', 'incl_len', 'orig_len']
classmethod encapsulate(pkt, endian='@')[source]