PyPCAPKit - Stream PCAP File Extractor

The PyPCAPKit project is an open source Python program focus on PCAP parsing and analysis, which works as a stream PCAP file extractor. With support of DictDumper, it shall support multiple output report formats.

Important

The whole project supports Python 3.6 or later.

Module Documentation

pcapkit is an independent open source library, using only DictDumper as its formatted output dumper.

Unlike popular PCAP file extractors, such as Scapy, DPKT, PyShark, and etc, pcapkit uses streaming strategy to read input files. That is to read frame by frame, decrease occupation on memory, as well as enhance efficiency in some way.

User Interface

pcapkit.interface defines several user-oriented interfaces, variables, and etc. These interfaces are designed to help and simplify the usage of pcapkit.

Core User Interface

pcapkit.interface.core defines core user-oriented interfaces, variables, and etc., which wraps around the foundation classes from pcapkit.foundation.

PCAP Extration
pcapkit.interface.core.extract(fin=None, fout=None, format=None, auto=True, extension=True, store=True, files=False, nofile=False, verbose=False, engine=None, layer=None, protocol=None, ip=False, ipv4=False, ipv6=False, tcp=False, strict=True, trace=False, trace_fout=None, trace_format=None, trace_byteorder='little', trace_nanosecond=False)[source]

Extract a PCAP file.

Parameters
  • fin (Optional[str]) – file name to be read; if file not exist, raise FileNotFound

  • fout (Optional[str]) – file name to be written

  • format (Optional[Formats]) – file format of output

  • auto (bool) – if automatically run till EOF

  • extension (bool) – if check and append extensions to output file

  • store (bool) – if store extracted packet info

  • files (bool) – if split each frame into different files

  • nofile (bool) – if no output file is to be dumped

  • verbose (bool | VerboseHandler) – a bool value or a function takes the Extract instance and current parsed frame (depends on engine selected) as parameters to print verbose output information

  • engine (Optional[Engines]) – extraction engine to be used

  • layer (Optional[Layers | Type[Protocol]]) – extract til which layer

  • protocol (Optional[Protocols]) – extract til which protocol

  • ip (bool) – if record data for IPv4 & IPv6 reassembly

  • ipv4 (bool) – if perform IPv4 reassembly

  • ipv6 (bool) – if perform IPv6 reassembly

  • tcp (bool) – if perform TCP reassembly

  • strict (bool) – if set strict flag for reassembly

  • trace (bool) – if trace TCP traffic flows

  • trace_fout (Optional[str]) – path name for flow tracer if necessary

  • trace_format (Optional[Formats]) – output file format of flow tracer

  • trace_byteorder (Literal["big", "little"]) – output file byte order

  • trace_nanosecond (bool) – output nanosecond-resolution file flag

Returns

An Extractor object.

Return type

Extractor

Payload Reassembly
pcapkit.interface.core.reassemble(protocol, strict=False)[source]

Reassemble fragmented datagrams.

Parameters
  • protocol (str | Type[Protocol]) – protocol to be reassembled

  • strict (bool) – if return all datagrams (including those not implemented) when submit

Returns

A Reassembly object of corresponding protocol.

Raises

FormatError – If protocol is NOT any of IPv4, IPv6 or TCP.

Return type

Reassembly

TCP Flow Tracing
pcapkit.interface.core.trace(fout, format, byteorder='little', nanosecond=False)[source]

Trace TCP flows.

Parameters
  • fout (Optional[str]) – output path

  • format (Optional[str]) – output format

  • byteorder (Literal[‘little’, ‘big’]) – output file byte order

  • nanosecond (bool) – output nanosecond-resolution file flag

Return type

TraceFlow

Returns

A TraceFlow object.

Output File Formats
pcapkit.interface.core.TREE = 'tree'
pcapkit.interface.core.JSON = 'json'
pcapkit.interface.core.PLIST = 'plist'
pcapkit.interface.core.PCAP = 'pcap'
Layer Thresholds
pcapkit.interface.core.RAW = 'none'
pcapkit.interface.core.INET = 'internet'
pcapkit.interface.core.TRANS = 'transport'
pcapkit.interface.core.APP = 'application'
Extration Engines
pcapkit.interface.core.DPKT = 'dpkt'
pcapkit.interface.core.Scapy = 'scapy'
pcapkit.interface.core.PCAPKit = 'default'
pcapkit.interface.core.PyShark = 'pyshark'

Auxiliary Interface

pcapkit.interface.misc contains miscellaneous user interface functions, classes, etc., which are generally provided per user’s requests.

pcapkit.interface.misc.follow_tcp_stream(fin=None, verbose=False, extension=True, engine=None, fout=None, format=None, byteorder='little', nanosecond=False)[source]

Follow TCP streams.

Parameters
  • fin (Optional[str]) – file name to be read; if file not exist, raise FileNotFound

  • extension (bool) – if check and append extensions to output file

  • verbose (bool) – if print verbose output information

  • engine (Optional[Engines]) – extraction engine to be used

  • fout (Optional[str]) – path name for flow tracer if necessary

  • format (Optional[Formats]) – output file format of flow tracer

  • byteorder (ByteOrder) – output file byte order

  • nanosecond (bool) – output nanosecond-resolution file flag

Returns

List of extracted TCP streams.

Return type

tuple[Stream, …]

Data Structures
class pcapkit.interface.misc.Stream(filename, packets, conversations)[source]

Bases: Info

Data model for TCP streams.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

filename: Optional[str]

Output filename.

packets: tuple[Frame, ...]

Packet list.

conversations: tuple[bytes | tuple[bytes, ...], ...]

TCP conversation.

Library Foundation

pcapkit.foundation is a collection of foundations for pcapkit, including PCAP file extraction tool Extrator, TCP flow tracer TraceFlow, registry management APIs for pcapkit, and TCP/IP reassembly implementations.

Extractor for PCAP Files

pcapkit.foundation.extraction contains Extractor only, which synthesises file I/O and protocol analysis, coordinates information exchange in all network layers, extracts parametres from a PCAP file.

Todo

Implement engine support for pypcap & pycapfile.

class pcapkit.foundation.extraction.Extractor(fin=None, fout=None, format=None, auto=True, extension=True, store=True, files=False, nofile=False, verbose=False, engine=None, layer=None, protocol=None, ip=False, ipv4=False, ipv6=False, tcp=False, strict=True, trace=False, trace_fout=None, trace_format=None, trace_byteorder='little', trace_nanosecond=False)[source]

Bases: object

Extractor for PCAP files.

Notes

For supported engines, please refer to run().

Parameters
  • fin (Optional[str]) – file name to be read; if file not exist, raise FileNotFound

  • fout (Optional[str]) – file name to be written

  • format (Optional[Formats]) – file format of output

  • auto (bool) – if automatically run till EOF

  • extension (bool) – if check and append extensions to output file

  • store (bool) – if store extracted packet info

  • files (bool) – if split each frame into different files

  • nofile (bool) – if no output file is to be dumped

  • verbose (bool | VerboseHandler) – a bool value or a function takes the Extractor instance and current parsed frame (depends on engine selected) as parameters to print verbose output information

  • engine (Optional[Engines]) – extraction engine to be used

  • layer (Optional[Layers]) – extract til which layer

  • protocol (Optional[Protocols]) – extract til which protocol

  • ip (bool) – if record data for IPv4 & IPv6 reassembly

  • ipv4 (bool) – if perform IPv4 reassembly

  • ipv6 (bool) – if perform IPv6 reassembly

  • tcp (bool) – if perform TCP reassembly

  • strict (bool) – if set strict flag for reassembly

  • trace (bool) – if trace TCP traffic flows

  • trace_fout (Optional[str]) – path name for flow tracer if necessary

  • trace_format (Optional[Formats]) – output file format of flow tracer

  • trace_byteorder (Literal["big", "little"]) – output file byte order

  • trace_nanosecond (bool) – output nanosecond-resolution file flag

__init__(fin=None, fout=None, format=None, auto=True, extension=True, store=True, files=False, nofile=False, verbose=False, engine=None, layer=None, protocol=None, ip=False, ipv4=False, ipv6=False, tcp=False, strict=True, trace=False, trace_fout=None, trace_format=None, trace_byteorder='little', trace_nanosecond=False)[source]

Initialise PCAP Reader.

Parameters
  • fin (Optional[str]) – file name to be read; if file not exist, raise FileNotFound

  • fout (Optional[str]) – file name to be written

  • format (Optional[Formats]) – file format of output

  • auto (bool) – if automatically run till EOF

  • extension (bool) – if check and append extensions to output file

  • store (bool) – if store extracted packet info

  • files (bool) – if split each frame into different files

  • nofile (bool) – if no output file is to be dumped

  • verbose (bool | VerboseHandler) – a bool value or a function takes the Extractor instance and current parsed frame (depends on engine selected) as parameters to print verbose output information

  • engine (Optional[Engines]) – extraction engine to be used

  • layer (Optional[Layers]) – extract til which layer

  • protocol (Optional[Protocols]) – extract til which protocol

  • ip (bool) – if record data for IPv4 & IPv6 reassembly

  • ipv4 (bool) – if perform IPv4 reassembly

  • ipv6 (bool) – if perform IPv6 reassembly

  • tcp (bool) – if perform TCP reassembly

  • strict (bool) – if set strict flag for reassembly

  • trace (bool) – if trace TCP traffic flows

  • trace_fout (Optional[str]) – path name for flow tracer if necessary

  • trace_format (Optional[Formats]) – output file format of flow tracer

  • trace_byteorder (Literal["big", "little"]) – output file byte order

  • trace_nanosecond (bool) – output nanosecond-resolution file flag

Warns

FormatWarning – Warns under following circumstances:

  • If using PCAP output for TCP flow tracing while the extraction engine is PyShark.

  • If output file format is not supported.

Return type

None

__iter__()[source]

Iterate and parse PCAP frame.

Raises

IterableError – If self._flag_a is True, as such operation is not applicable.

Return type

Extractor

__next__()[source]

Iterate and parse next PCAP frame.

It will call _read_frame() to parse next PCAP frame internally, until the EOF reached; then it calls _cleanup() for the aftermath.

Return type

Frame | ScapyPacket | DPKTPacket

__call__()[source]

Works as a simple wrapper for the iteration protocol.

Raises

IterableError – If self._flag_a is True, as iteration is not applicable.

Return type

Frame | ScapyPacket | DPKTPacket

property info: VersionInfo

Version of input PCAP file.

Raises

UnsupportedCall – If self._exeng is 'scapy' or 'pyshark', as such engines does not reserve such information.

Return type

VersionInfo

property length: int

Frame number (of current extracted frame or all).

Return type

int

property format: Formats

Format of output file.

Raises

UnsupportedCall – If self._flag_q is set as True, as output is disabled by initialisation parameter.

Return type

Formats

property input: str

Name of input PCAP file.

Return type

str

property output: str

Name of output file.

Raises

UnsupportedCall – If self._flag_q is set as True, as output is disabled by initialisation parameter.

Return type

str

property header: Header

Global header.

Return type

Header

property frame: tuple[Frame, ...]

Extracted frames.

Raises

UnsupportedCall – If self._flag_d is True, as storing frame data is disabled.

property reassembly: ReassemblyData

Frame record for reassembly.

Return type

ReassemblyData

property trace: tuple[Index, ...]

Index table for traced flow.

Raises

UnsupportedCall – If self._flag_t is True, as TCP flow tracing is disabled.

Return type

tuple[Index, …]

property engine: Engines

PCAP extraction engine.

Return type

Engines

run()[source]

Start extraction.

We uses import_test() to check if a certain engine is available or not. For supported engines, each engine has different driver method:

Warns

EngineWarning – If the extraction engine is not available. This is either due to dependency not installed, or supplied engine unknown.

Return type

None

record_header()[source]

Read global header.

The method will parse the PCAP global header and save the parsed result as self._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

record_frames()[source]

Read packet frames.

The method calls _read_frame() to parse each frame from the input PCAP file; and calls _cleanup() upon complision.

Notes

Under non-auto mode, i.e. self._flag_a is False, the method performs no action.

Return type

None

classmethod register(format, module, class_, ext)[source]

Register a new dumper class.

Notes

The full qualified class name of the new dumper class should be as {module}.{class_}.

Parameters
  • format (str) – format name

  • module (str) – module name

  • class_ (str) – class name

  • ext (str) – file extension

Return type

None

classmethod make_name(fin='in.pcap', fout='out', fmt='tree', extension=True, *, files=False, nofile=False)[source]

Generate input and output filenames.

The method will perform following processing:

  1. sanitise fin as the input PCAP filename; in.pcap as default value and append .pcap extension if needed and extension is True; as well as test if the file exists;

  2. if nofile is True, skips following processing;

  3. if fmt provided, then it presumes corresponding output file extension;

  4. if fout not provided, it presumes the output file name based on the presumptive file extension; the stem of the output file name is set as out; should the file extension is not available, then it raises FormatError;

  5. if fout provided, it presumes corresponding output format if needed; should the presumption cannot be made, then it raises FormatError;

  6. it will also append corresponding file extension to the output file name if needed and extension is True.

Parameters
  • fin (str) – Input filename.

  • fout (str) – Output filename.

  • fmt (Formats) – Output file format.

  • extension (bool) – If append .pcap file extension to the input filename if fin does not have such file extension; if check and append extensions to output file.

  • files (bool) – If split each frame into different files.

  • nofile (bool) – If no output file is to be dumped.

Returns

  1. input filename

  2. output filename / directory name

  3. output format

  4. output file extension (without .)

  5. if split each frame into different files

Return type

Generated input and output filenames

Raises
  • FileNotFound – If input file does not exists.

  • FormatError – If output format not provided and cannot be presumpted.

_read_frame()[source]

Headquarters for frame reader.

This method is a dispatcher for parsing frames.

Return type

Frame | ScapyPacket | DPKTPacket

Returns

The parsed frame instance.

_cleanup()[source]

Cleanup after extraction & analysis.

The method clears the self._expkg and self._extmp attributes, sets self._flag_e as True and closes the input file.

Return type

None

_default_read_frame()[source]

Read frames with default engine.

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.

_run_scapy(scapy_all)[source]

Call scapy.all.sniff() to extract PCAP files.

This method assigns self._expkg as scapy.all and self._extmp as an iterator from scapy.all.sniff().

Parameters

scapy_all (module) – The scapy.all module.

Warns

AttributeWarning – If self._exlyr and/or self._exptl is provided as the Scapy engine currently does not support such operations.

Return type

None

_scapy_read_frame()[source]

Read frames with Scapy engine.

Return type

ScapyPacket

Returns

Parsed frame instance.

See also

Please refer to _default_read_frame() for more operational information.

_run_dpkt(dpkt)[source]

Call dpkt.pcap.Reader to extract PCAP files.

This method assigns self._expkg as dpkt and self._extmp as an iterator from dpkt.pcap.Reader.

Parameters

dpkt (module) – The dpkt module.

Warns

AttributeWarning – If self._exlyr and/or self._exptl is provided as the DPKT engine currently does not support such operations.

Return type

None

_dpkt_read_frame()[source]

Read frames with DPKT engine.

Returns

Parsed frame instance.

Return type

dpkt.dpkt.Packet

See also

Please refer to _default_read_frame() for more operational information.

_run_pyshark(pyshark)[source]

Call pyshark.FileCapture to extract PCAP files.

This method assigns self._expkg as pyshark and self._extmp as an iterator from pyshark.FileCapture.

Parameters

pyshark (types.ModuleType) – The pyshark module.

Warns

AttributeWarning – Warns under following circumstances:

  • if self._exlyr and/or self._exptl is provided as the PyShark engine currently does not support such operations.

  • if reassembly is enabled, as the PyShark engine currently does not support such operation.

Return type

None

_pyshark_read_frame()[source]

Read frames with PyShark engine.

Return type

PySharkPacket

Returns

Parsed frame instance.

See also

Please refer to _default_read_frame() for more operational information.

_flag_a: bool

Auto extract flag.

_flag_d: bool

Store data flag.

_flag_e: bool

EOF flag.

_flag_q: bool

No output file.

_flag_t: bool

Trace flag.

_exptl: Protocols

Extract til protocol.

_exlyr: Layers

Extract til layer.

_exeng: Engines

Extract using engine.

_expkg: Any

Extract module instance.

_extmp: Any

Extract iterator instance.

_gbhdr: Header

Global header.

__output__: DefaultDict[str, tuple[str, str, str | None]]

Format dumper mapping for writing output files. The values should be a tuple representing the module name, class name and file extension.

Type

DefaultDict[str, tuple[str, str, str | None]]

Data Structures
class pcapkit.foundation.extraction.ReassemblyData(ipv4, ipv6, tcp)[source]

Bases: Info

Data storage for reassembly.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ipv4: Optional[tuple[IP_Datagram, ...]]

IPv4 reassembled data.

ipv6: Optional[tuple[IP_Datagram, ...]]

IPv6 reassembled data.

tcp: Optional[tuple[TCP_Datagram, ...]]

TCP reassembled data.

Trace TCP Flows

pcapkit.foundation.traceflow is the interface to trace TCP flows from a series of packets and connections.

Note

This was implemented as the demand of my mate @gousaiyang

class pcapkit.foundation.traceflow.TraceFlow(fout, format, byteorder='little', nanosecond=False)[source]

Bases: object

Trace TCP flows.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

TraceFlow

__init__(fout, format, byteorder='little', nanosecond=False)[source]

Initialise instance.

Parameters
  • fout (Optional[str]) – output path

  • format (Optional[str]) – output format

  • byteorder (Literal[‘little’, ‘big’]) – output file byte order

  • nanosecond (bool) – output nanosecond-resolution file flag

Return type

None

__call__(packet)[source]

Dump frame to output files.

Parameters

packet (Packet) – a flow packet (trace.packet)

Return type

None

property index: tuple[Index, ...]

Index table for traced flow.

dump(packet)[source]

Dump frame to output files.

Parameters

packet (Dict[str, Any]) – a flow packet (trace.packet)

Return type

None

trace(packet: Packet, *, output: Literal[True] = False) Dumper[source]
trace(packet: Packet, *, output: Literal[False] = False) str

Trace packets.

Parameters
  • packet – a flow packet (trace.packet)

  • output – flag if has formatted dumper

Returns

If output is True, returns the initiated Dumper object, which will dump data to the output file named after the flow label; otherwise, returns the flow label itself.

Notes

The flow label is formatted as following:

f'{packet.src}_{packet.srcport}-{packet.dst}_{info.dstport}-{packet.timestamp}'
submit()[source]

Submit traced TCP flows.

Returns

Traced TCP flow (trace.index).

Return type

tuple[Index, …]

classmethod register(format, module, class_, ext)[source]

Register a new dumper class.

Notes

The full qualified class name of the new dumper class should be as {module}.{class_}.

Parameters
  • format (str) – format name

  • module (str) – module name

  • class_ (str) – class name

  • ext (str) – file extension

Return type

None

classmethod make_fout(fout='./tmp', fmt='pcap')[source]

Make root path for output.

Parameters
  • fout (str) – root path for output

  • fmt (str) – output format

Returns

Dumper of specified format and file extension of output file.

Warns
  • FormatWarning – If fmt is not supported.

  • FileWarning – If fout exists and fmt is None.

Raises

FileExists – If fout exists and fmt is NOT None.

Return type

tuple[Type[Dumper], str | None]

__output__: DefaultDict[str, tuple[str, str, str | None]]

Format dumper mapping for writing output files. The values should be a tuple representing the module name, class name and file extension.

Type

DefaultDict[str, tuple[str, str, str | None]]

_buffer: dict[BufferID, Buffer]

Buffer field (trace.buffer).

Type

dict[BufferID, Buffer]

Terminology
trace.packet

Data structure for TCP flow tracing (TraceFlow.dump) is as following:

tract_dict = dict(
    protocol=data_link,                     # data link type from global header
    index=frame.info.number,                # frame number
    frame=frame.info,                       # extracted frame info
    syn=tcp.flags.syn,                      # TCP synchronise (SYN) flag
    fin=tcp.flags.fin,                      # TCP finish (FIN) flag
    src=ip.src,                             # source IP
    dst=ip.dst,                             # destination IP
    srcport=tcp.srcport,                    # TCP source port
    dstport=tcp.dstport,                    # TCP destination port
    timestamp=frame.info.time_epoch,        # frame timestamp
)
trace.buffer

Data structure for internal buffering when performing flow tracing algorithms (TraceFlow._buffer) is as following:

(dict) buffer --> memory buffer for reassembly
 |--> (tuple) BUFID : (dict)
 |       |--> ip.src      |
 |       |--> tcp.srcport |
 |       |--> ip.dst      |
 |       |--> tcp.dstport |
 |                        |--> 'fpout' : (dictdumper.dumper.Dumper) output dumper object
 |                        |--> 'index': (list) list of frame index
 |                        |              |--> (int) frame index
 |                        |--> 'label': (str) flow label generated from ``BUFID``
 |--> (tuple) BUFID ...
trace.index

Data structure for TCP flow tracing (element from TraceFlow.index tuple) is as following:

(tuple) index
 |--> (Info) data
 |     |--> 'fpout' : (Optional[str]) output filename if exists
 |     |--> 'index': (tuple) tuple of frame index
 |     |              |--> (int) frame index
 |     |--> 'label': (str) flow label generated from ``BUFID``
 |--> (Info) data ...
Data Structures
pcapkit.foundation.traceflow.BufferID: tuple[IPAddress, int, IPAddress, int]

Buffer ID is a tuple of source IP, source port, destination IP, and destination port.

class pcapkit.foundation.traceflow.Packet(protocol, index, frame, syn, fin, src, dst, srcport, dstport, timestamp)[source]

Bases: Info, Generic[IPAddress]

Data structure for TCP flow tracing.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

protocol: RegType_LinkType

Data link type from global header.

index: int

Frame number.

frame: DataType_Frame | dict[str, Any]

Extracted frame info.

syn: bool

TCP synchronise (SYN) flag.

fin: bool

TCP finish (FIN) flag.

src: IPAddress

Source IP.

dst: IPAddress

Destination IP.

srcport: int

TCP source port.

dstport: int

TCP destination port.

timestamp: float

Frame timestamp.

class pcapkit.foundation.traceflow.Buffer(fpout, index, label)[source]

Bases: Info

Data structure for TCP flow tracing.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

fpout: Dumper

Output dumper object.

index: list[int]

List of frame index.

label: str

Flow label generated from BUFID.

class pcapkit.foundation.traceflow.Index(fpout, index, label)[source]

Bases: Info

Data structure for TCP flow tracing.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

fpout: Optional[str]

Output filename if exists.

index: tuple[int, ...]

Tuple of frame index.

label: str

Flow label generated from BUFID.

Fragmented Packets Reassembly

pcapkit.reassembly bases on algorithms described in RFC 791 and RFC 815, implements datagram reassembly of IP and TCP packets.

Base Class

pcapkit.foundation.reassembly.reassembly contains Reassembly only, which is an abstract base class for all reassembly classes, bases on algorithms described in RFC 791 and RFC 815, implements datagram reassembly of IP and TCP packets.

class pcapkit.foundation.reassembly.reassembly.Reassembly(*, strict=True)[source]

Bases: Generic[PT, DT, IT, BT]

Base class for reassembly procedure.

Parameters
  • strict (bool) – if return all datagrams (including those not implemented) when submit

  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Reassembly[PT, DT, IT, BT]

__init__(*, strict=True)[source]

Initialise packet reassembly.

Parameters

strict (bool) – if return all datagrams (including those not implemented) when submit

Return type

None

__call__(packet)[source]

Call packet reassembly.

Parameters

packet (TypeVar(PT, bound= Info)) – packet dict to be reassembled (detailed format described in corresponding protocol)

Return type

None

abstract property name: str

Protocol name of current reassembly object.

Return type

str

property count: int

Total number of reassembled packets.

Return type

int

property datagram: tuple[DT, ...]

Reassembled datagram.

abstract property protocol: Type[Protocol]

Protocol of current reassembly object.

Return type

Type[Protocol]

abstract reassembly(info)[source]

Reassembly procedure.

Parameters

info (TypeVar(PT, bound= Info)) – info dict of packets to be reassembled

Return type

None

abstract submit(buf, **kwargs)[source]

Submit reassembled payload.

Parameters
  • buf (BT) – buffer dict of reassembled packets

  • **kwargs (Any) – arbitrary keyword arguments

Return type

list[DT]

fetch()[source]

Fetch datagram.

Returns

Tuple of reassembled datagrams.

Return type

tuple[DT, …]

Fetch reassembled datagrams from _dtgram and returns a tuple of such datagrams.

If no cache found, the method will call submit() to forcedly obtain newly reassembled payload. Otherwise, the already calculated _dtgram will be returned.

index(pkt_num)[source]

Return datagram index.

Parameters

pkt_num (int) – index of packet

Return type

Optional[int]

Returns

Reassembled datagram index which was from No. pkt_num packet; if not found, returns None.

run(packets)[source]

Run automatically.

Parameters

packets (list[PT]) – list of packet dicts to be reassembled

Return type

None

_buffer: dict[IT, BT]

Dict buffer field.

Type

dict[IT, BT]

_dtgram: list[DT]

List reassembled datagram.

Type

list[DT]

IP Datagram Reassembly

The following algorithm implement is based on IP reassembly procedure introduced in RFC 791, using RCVBT (fragment receivedbit table). Though another algorithm is explained in RFC 815, replacing RCVBT, however, this implement still used the elder one.

Algorithm

See also

The algorithm is described in RFC 791.

FO

Fragment Offset

IHL

Internet Header Length

MF

More Fragments Flag

TTL

Time To Live

NFB

Number of Fragment Blocks

TL

Total Length

TDL

Total Data Length

BUFID

Buffer Identifier

RCVBT

Fragment Received Bit Table

TLB

Timer Lower Bound

DO {
   BUFID <- source|destination|protocol|identification;

   IF (FO = 0 AND MF = 0) {
      IF (buffer with BUFID is allocated) {
         flush all reassembly for this BUFID;
         Submit datagram to next step;
         DONE.
      }
   }

   IF (no buffer with BUFID is allocated) {
      allocate reassembly resources with BUFID;
      TIMER <- TLB;
      TDL <- 0;
      put data from fragment into data buffer with BUFID
         [from octet FO*8 to octet (TL-(IHL*4))+FO*8];
      set RCVBT bits [from FO to FO+((TL-(IHL*4)+7)/8)];
   }

   IF (MF = 0) {
      TDL <- TL-(IHL*4)+(FO*8)
   }

   IF (FO = 0) {
      put header in header buffer
   }

   IF (TDL # 0 AND all RCVBT bits [from 0 to (TDL+7)/8] are set) {
      TL <- TDL+(IHL*4)
      Submit datagram to next step;
      free all reassembly resources for this BUFID;
      DONE.
   }

   TIMER <- MAX(TIMER,TTL);

} give up until (next fragment or timer expires);

timer expires: {
   flush all reassembly with this BUFID;
   DONE.
}
Base Class

pcapkit.foundation.reassembly.ip contains IP_Reassembly only, which reconstructs fragmented IP packets back to origin.

class pcapkit.foundation.reassembly.ip.IP_Reassembly(*, strict=True)[source]

Bases: Reassembly[Packet[AT], Datagram[AT], Tuple[AT, AT, int, TransType], Buffer[AT]], Generic[AT]

Reassembly for IP payload.

Important

This class is not intended to be instantiated directly, but rather used as a base class for the protocol-aware reassembly classes.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Reassembly[PT, DT, IT, BT]

reassembly(info)[source]

Reassembly procedure.

Parameters

info (Packet[TypeVar(AT, IPv4Address, IPv6Address)]) – info dict of packets to be reassembled

Return type

None

submit(buf, *, bufid, checked=False)[source]

Submit reassembled payload.

Parameters
  • buf (Buffer[AT]) – buffer dict of reassembled packets

  • bufid (tuple[AT, AT, int, TransType]) – buffer identifier

  • checked (bool) – buffer consistency checked flag

Returns

Reassembled packets.

Return type

list[Datagram[AT]]

Data Structures
class pcapkit.foundation.reassembly.ip.Packet(*args, **kwargs)[source]

Bases: Info, Generic[AT]

Data model for ipv4.packet / ipv6.packet.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

bufid: tuple[AT, AT, int, TransType]

Buffer ID.

num: int

Original packet range number.

fo: int

Fragment offset.

ihl: int

Internet header length.

mf: bool

More fragments flag.

tl: int

Total length, header included.

header: bytes

Raw bytes type header.

payload: bytearray

Raw bytearray type payload.

class pcapkit.foundation.reassembly.ip.DatagramID(*args, **kwargs)[source]

Bases: Info, Generic[AT]

Data model for ipv4.datagram / ipv6.datagram original packet identifier.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

src: AT

Source address.

dst: AT

Destination address.

id: int

IP protocol identifier.

proto: TransType

Payload protocol type.

class pcapkit.foundation.reassembly.ip.Datagram(*args, **kwargs)[source]

Bases: Info, Generic[AT]

Data model for ipv4.datagram / ipv6.datagram.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

completed: bool

Completed flag.

id: DatagramID[AT]

Original packet identifier.

index: tuple[int, ...]

Packet numbers.

header: bytes

Initial IP header.

payload: bytes | tuple[bytes, ...]

Reassembled IP payload.

packet: Optional[Protocol]

Parsed IP payload.

class pcapkit.foundation.reassembly.ip.Buffer(*args, **kwargs)[source]

Bases: Info, Generic[AT]

Data model for ipv4.buffer / ipv6.buffer.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

TDL: int

Total data length.

RCVBT: bytearray

Fragment received bit table.

index: list[int]

List of reassembled packets.

header: bytes

Header buffer.

datagram: bytearray

Data buffer, holes set to b'\x00'.

IPv4 Datagram Reassembly

pcapkit.foundation.reassembly.ipv4 contains IPv4_Reassembly only, which reconstructs fragmented IPv4 packets back to origin. Please refer to Base Class for more information.

class pcapkit.foundation.reassembly.ipv4.IPv4_Reassembly(*, strict=True)[source]

Bases: IP_Reassembly[IPv4Address]

Reassembly for IPv4 payload.

Example

>>> from pcapkit.reassembly import IPv4_Reassembly
# Initialise instance:
>>> ipv4_reassembly = IPv4_Reassembly()
# Call reassembly:
>>> ipv4_reassembly(packet_dict)
# Fetch result:
>>> result = ipv4_reassembly.datagram
Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Reassembly[PT, DT, IT, BT]

property name: Literal['Internet Protocol version 4']

Protocol of current packet.

Return type

Literal[‘Internet Protocol version 4’]

property protocol: Type[IPv4]

Protocol of current reassembly object.

Return type

Type[IPv4]

Terminology
ipv4.packet

Data structure for IPv4 datagram reassembly (IPv4_Reassembly.reassembly) is as following:

packet_dict = dict(
  bufid = tuple(
      ipv4.src,                   # source IP address
      ipv4.dst,                   # destination IP address
      ipv4.id,                    # identification
      ipv4.proto,                 # payload protocol type
  ),
  num = frame.number,             # original packet range number
  fo = ipv4.frag_offset,          # fragment offset
  ihl = ipv4.hdr_len,             # internet header length
  mf = ipv4.flags.mf,             # more fragment flag
  tl = ipv4.len,                  # total length, header includes
  header = ipv4.header,           # raw bytes type header
  payload = ipv4.payload,         # raw bytearray type payload
)
ipv4.datagram

Data structure for reassembled IPv4 datagram (element from IPv4_Reassembly.datagram tuple) is as following:

(tuple) datagram
 |--> (Info) data
 |     |--> 'completed' : (bool) True --> implemented
 |     |--> 'id' : (Info) original packet identifier
 |     |            |--> 'src' --> (IPv4Address) ipv4.src
 |     |            |--> 'dst' --> (IPv4Address) ipv4.dst
 |     |            |--> 'id' --> (int) ipv4.id
 |     |            |--> 'proto' --> (EtherType) ipv4.proto
 |     |--> 'index' : (tuple) packet numbers
 |     |               |--> (int) original packet range number
 |     |--> 'header' : (bytes) IPv4 header
 |     |--> 'payload' : (bytes) reassembled IPv4 payload
 |     |--> 'packet' : (Protocol) parsed reassembled payload
 |--> (Info) data
 |     |--> 'completed' : (bool) False --> not implemented
 |     |--> 'id' : (Info) original packet identifier
 |     |            |--> 'src' --> (IPv4Address) ipv4.src
 |     |            |--> 'dst' --> (IPv4Address) ipv4.dst
 |     |            |--> 'id' --> (int) ipv4.id
 |     |            |--> 'proto' --> (EtherType) ipv4.proto
 |     |--> 'index' : (tuple) packet numbers
 |     |               |--> (int) original packet range number
 |     |--> 'header' : (bytes) IPv4 header
 |     |--> 'payload' : (tuple) partially reassembled IPv4 payload
 |     |                 |--> (bytes) IPv4 payload fragment
 |     |                 |--> ...
 |     |--> 'packet' : (None)
 |--> (Info) data ...
ipv4.buffer

Data structure for internal buffering when performing reassembly algorithms (IPv4_Reassembly._buffer) is as following:

(dict) buffer --> memory buffer for reassembly
 |--> (tuple) BUFID : (dict)
 |     |--> ipv4.src       |
 |     |--> ipv4.dst       |
 |     |--> ipv4.id        |
 |     |--> ipv4.proto     |
 |                         |--> 'TDL' : (int) total data length
 |                         |--> 'RCVBT' : (bytearray) fragment received bit table
 |                         |               |--> (bytes) b'\\x00' -> not received
 |                         |               |--> (bytes) b'\\x01' -> received
 |                         |               |--> (bytes) ...
 |                         |--> 'index' : (list) list of reassembled packets
 |                         |               |--> (int) packet range number
 |                         |--> 'header' : (bytes) header buffer
 |                         |--> 'datagram' : (bytearray) data buffer, holes set to b'\\x00'
 |--> (tuple) BUFID ...
IPv6 Datagram Reassembly

pcapkit.foundation.reassembly.ipv6 contains IPv6_Reassembly only, which reconstructs fragmented IPv6 packets back to origin. Please refer to Base Class for more information.

class pcapkit.foundation.reassembly.ipv6.IPv6_Reassembly(*, strict=True)[source]

Bases: IP_Reassembly[IPv6Address]

Reassembly for IPv6 payload.

Example

>>> from pcapkit.reassembly import IPv6_Reassembly
# Initialise instance:
>>> ipv6_reassembly = IPv6_Reassembly()
# Call reassembly:
>>> ipv6_reassembly(packet_dict)
# Fetch result:
>>> result = ipv6_reassembly.datagram
Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Reassembly[PT, DT, IT, BT]

property name: Literal['Internet Protocol version 6']

Protocol of current packet.

Return type

Literal[‘Internet Protocol version 6’]

property protocol: Type[IPv6]

Protocol of current reassembly object.

Return type

Type[IPv6]

Terminology
ipv6.packet

Data structure for IPv6 datagram reassembly (IPv6_Reassembly.reassembly) is as following:

packet_dict = dict(
  bufid = tuple(
      ipv6.src,                   # source IP address
      ipv6.dst,                   # destination IP address
      ipv6.label,                 # label
      ipv6_frag.next,             # next header field in IPv6 Fragment Header
  ),
  num = frame.number,             # original packet range number
  fo = ipv6_frag.offset,          # fragment offset
  ihl = ipv6.hdr_len,             # header length, only headers before IPv6-Frag
  mf = ipv6_frag.mf,              # more fragment flag
  tl = ipv6.len,                  # total length, header includes
  header = ipv6.header,           # raw bytes type header before IPv6-Frag
  payload = ipv6.payload,         # raw bytearray type payload after IPv6-Frag
)
ipv6.datagram

Data structure for reassembled IPv6 datagram (element from IPv6_Reassembly.datagram tuple) is as following:

(tuple) datagram
 |--> (Info) data
 |     |--> 'completed' : (bool) True --> implemented
 |     |--> 'id' : (Info) original packet identifier
 |     |            |--> 'src' --> (IPv6Address) ipv6.src
 |     |            |--> 'dst' --> (IPv6Address) ipv6.dst
 |     |            |--> 'id' --> (int) ipv6.label
 |     |            |--> 'proto' --> (EtherType) ipv6_frag.next
 |     |--> 'index' : (tuple) packet numbers
 |     |               |--> (int) original packet range number
 |     |--> 'payload' : (bytes) reassembled IPv4 packet
 |     |--> 'packet' : (Protocol) parsed reassembled payload
 |--> (Info) data
 |     |--> 'completed' : (bool) False --> not implemented
 |     |--> 'id' : (Info) original packet identifier
 |     |            |--> 'src' --> (IPv6Address) ipv6.src
 |     |            |--> 'dst' --> (IPv6Address) ipv6.dst
 |     |            |--> 'id' --> (int) ipv6.id
 |     |            |--> 'proto' --> (EtherType) ipv6_frag.next
 |     |--> 'index' : (tuple) packet numbers
 |     |               |--> (int) original packet range number
 |     |--> 'header' : (bytes) IPv4 header
 |     |--> 'payload' : (tuple) partially reassembled IPv4 payload
 |     |                 |--> (bytes) IPv4 payload fragment
 |     |                 |--> ...
 |     |--> 'packet' : (None)
 |--> (Info) data ...
ipv6.buffer

Data structure for internal buffering when performing reassembly algorithms (IPv6_Reassembly._buffer) is as following:

(dict) buffer --> memory buffer for reassembly
 |--> (tuple) BUFID : (dict)
 |     |--> ipv6.src       |
 |     |--> ipc6.dst       |
 |     |--> ipv6.label     |
 |     |--> ipv6_frag.next |
 |                         |--> 'TDL' : (int) total data length
 |                         |--> RCVBT : (bytearray) fragment received bit table
 |                         |             |--> (bytes) b'\\x00' -> not received
 |                         |             |--> (bytes) b'\\x01' -> received
 |                         |             |--> (bytes) ...
 |                         |--> 'index' : (list) list of reassembled packets
 |                         |               |--> (int) packet range number
 |                         |--> 'header' : (bytes) header buffer
 |                         |--> 'datagram' : (bytearray) data buffer, holes set to b'\\x00'
 |--> (tuple) BUFID ...
TCP Datagram Reassembly

pcapkit.foundation.reassembly.tcp contains TCP_Reassembly only, which reconstructs fragmented TCP packets back to origin. The algorithm for TCP reassembly is described as below.

Algorithm

See also

This algorithm is an adaptation of the algorithm described in RFC 815.

DSN

Data Sequence Number

ACK

TCP Acknowledgement

SYN

TCP Synchronisation Flag

FIN

TCP Finish Flag

RST

TCP Reset Connection Flag

BUFID

Buffer Identifier

HDL

Hole Discriptor List

ISN

Initial Sequence Number

src

source IP

dst

destination IP

srcport

source TCP port

dstport

destination TCP port

DO {
   BUFID <- src|dst|srcport|dstport|ACK;
   IF (SYN is true) {
      IF (buffer with BUFID is allocated) {
         flush all reassembly for this BUFID;
         submit datagram to next step;
      }
   }

   IF (no buffer with BUFID is allocated) {
      allocate reassembly resources with BUFID;
      ISN <- DSN;
      put data from fragment into data buffer with BUFID
         [from octet fragment.first to octet fragment.last];
      update HDL;
   }

   IF (FIN is true or RST is true) {
      submit datagram to next step;
      free all reassembly resources for this BUFID;
      BREAK.
   }
} give up until (next fragment);

update HDL: {
   DO {
      select the next hole descriptor from HDL;

      IF (fragment.first >= hole.first) CONTINUE.
      IF (fragment.last <= hole.first) CONTINUE.

      delete the current entry from HDL;

      IF (fragment.first >= hole.first) {
         create new entry "new_hole" in HDL;
         new_hole.first <- hole.first;
         new_hole.last <- fragment.first - 1;
         BREAK.
      }

      IF (fragment.last <= hole.last) {
         create new entry "new_hole" in HDL;
         new_hole.first <- fragment.last + 1;
         new_hole.last <- hole.last;
         BREAK.
      }
   } give up until (no entry from HDL)
}

The following algorithm implement is based on IP Datagram Reassembly Algorithm introduced in RFC 815. It described an algorithm dealing with RCVBT (fragment received bit table) appeared in RFC 791. And here is the process:

  1. Select the next hole descriptor from the hole descriptor list. If there are no more entries, go to step eight.

  2. If fragment.first is greater than hole.last, go to step one.

  3. If fragment.last is less than hole.first, go to step one.

  4. Delete the current entry from the hole descriptor list.

  5. If fragment.first is greater than hole.first, then create a new hole descriptor new_hole with new_hole.first equal to hole.first, and new_hole.last equal to fragment.first minus one (-1).

  6. If fragment.last is less than hole.last and fragment.more_fragments is true, then create a new hole descriptor new_hole, with new_hole.first equal to fragment.last plus one (+1) and new_hole.last equal to hole.last.

  7. Go to step one.

  8. If the hole descriptor list is now empty, the datagram is now complete. Pass it on to the higher level protocol processor for further handling. Otherwise, return.

Implementation

pcapkit.foundation.reassembly.tcp contains Reassembly only, which reconstructs fragmented TCP packets back to origin.

class pcapkit.foundation.reassembly.tcp.TCP_Reassembly(*, strict=True)[source]

Bases: Reassembly[Packet, Datagram, Tuple[IPAddress, int, IPAddress, int], Buffer]

Reassembly for TCP payload.

Example

>>> from pcapkit.reassembly import TCP_Reassembly
# Initialise instance:
>>> tcp_reassembly = TCP_Reassembly()
# Call reassembly:
>>> tcp_reassembly(packet_dict)
# Fetch result:
>>> result = tcp_reassembly.datagram
Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Reassembly[PT, DT, IT, BT]

property name: Literal['Transmission Control Protocol']

Protocol of current packet.

Return type

Literal[‘Transmission Control Protocol’]

property protocol: Type[TCP]

Protocol of current reassembly object.

Return type

Type[TCP]

reassembly(info)[source]

Reassembly procedure.

Parameters

info (Packet) – info dict of packets to be reassembled

Return type

None

submit(buf, *, bufid)[source]

Submit reassembled payload.

Parameters
  • buf (Buffer) – buffer dict of reassembled packets

  • bufid (BufferID) – buffer identifier

Returns

Reassembled packets.

Return type

list[Datagram]

Terminology
tcp.packet

Data structure for TCP datagram reassembly (TCP_Reassembly.reassembly) is as following:

packet_dict = Info(
  bufid = tuple(
      ip.src,                     # source IP address
      tcp.srcport,                # source port
      ip.dst,                     # destination IP address
      tcp.dstport,                # destination port
  ),
  dsn = tcp.seq,                  # data sequence number
  ack = tcp.ack,                  # acknowledgement number
  num = frame.number,             # original packet range number
  syn = tcp.flags.syn,            # synchronise flag
  fin = tcp.flags.fin,            # finish flag
  rst = tcp.flags.rst,            # reset connection flag
  len = tcp.raw_len,              # payload length, header excludes
  first = tcp.seq,                # this sequence number
  last = tcp.seq + tcp.raw_len,   # next (wanted) sequence number
  header = tcp.packet.header,     # raw bytes type header
  payload = tcp.raw,              # raw bytearray type payload
)
tcp.datagram

Data structure for reassembled TCP datagram (element from TCP_Reassembly.datagram tuple) is as following:

(tuple) datagram
 |--> (Info) data
 |     |--> 'completed' : (bool) True --> implemented
 |     |--> 'id' : (Info) original packet identifier
 |     |            |--> 'src' --> (tuple)
 |     |            |               |--> (IPv4Address) ip.src
 |     |            |               |--> (int) tcp.srcport
 |     |            |--> 'dst' --> (tuple)
 |     |            |               |--> (IPv4Address) ip.dst
 |     |            |               |--> (int) tcp.dstport
 |     |            |--> 'ack' --> (int) original packet ACK number
 |     |--> 'index' : (tuple) packet numbers
 |     |               |--> (int) original packet range number
 |     |               |--> ...
 |     |--> 'header' : (bytes) initial TCP header
 |     |--> 'payload' : (bytes) reassembled payload
 |     |--> 'packet' : (Protocol) parsed reassembled payload
 |--> (Info) data
 |     |--> 'completed' : (bool) False --> not implemented
 |     |--> 'id' : (Info) original packet identifier
 |     |            |--> 'src' --> (tuple)
 |     |            |               |--> (IPv4Address) ip.src
 |     |            |               |--> (int) tcp.srcport
 |     |            |--> 'dst' --> (tuple)
 |     |            |               |--> (IPv4Address) ip.dst
 |     |            |               |--> (int) tcp.dstport
 |     |            |--> 'ack' --> (int) original packet ACK number
 |     |--> 'index' : (tuple) packet numbers
 |     |               |--> (int) original packet range number
 |     |               |--> ...
 |     |--> 'header' : (bytes) initial TCP header
 |     |--> 'payload' : (tuple) partially reassembled payload
 |     |                 |--> (bytes) payload fragment
 |     |                 |--> ...
 |     |--> 'packet' : (None) not implemented
 |--> (Info) data ...
tcp.buffer

Data structure for internal buffering when performing reassembly algorithms (TCP_Reassembly._buffer) is as following:

(dict) buffer --> memory buffer for reassembly
 |--> (tuple) BUFID : (dict)
 |       |--> ip.src      |
 |       |--> ip.dst      |
 |       |--> tcp.srcport |
 |       |--> tcp.dstport |
 |                        |--> 'hdl' : (list) hole descriptor list
 |                        |             |--> (Info) hole --> hole descriptor
 |                        |                   |--> "first" --> (int) start of hole
 |                        |                   |--> "last" --> (int) stop of hole
 |                        |--> 'hdr' : (bytes) initial TCP header
 |                        |--> 'ack' : (dict) ACK list
 |                                      |--> (int) ACK : (dict)
 |                                      |                 |--> 'ind' : (list) list of reassembled packets
 |                                      |                 |             |--> (int) packet range number
 |                                      |                 |--> 'isn' : (int) ISN of payload buffer
 |                                      |                 |--> 'len' : (int) length of payload buffer
 |                                      |                 |--> 'raw' : (bytearray) reassembled payload,
 |                                      |                                          holes set to b'\x00'
 |                                      |--> (int) ACK ...
 |                                      |--> ...
 |--> (tuple) BUFID ...
Data Structures
class pcapkit.foundation.reassembly.tcp.Packet(bufid, dsn, ack, num, syn, fin, rst, len, first, last, header, payload)[source]

Bases: Info

Data model for tcp.packet.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

bufid: Tuple[IPAddress, int, IPAddress, int]

Buffer ID.

dsn: int

Data sequence number.

ack: int

Acknowledgment number.

num: int

Original packet range number.

syn: bool

Synchronise flag.

fin: bool

Finish flag.

rst: bool

Reset connection flag.

len: int

Payload length, header excluded.

first: int

This sequence number.

last: int

Next (wanted) sequence number.

header: bytes

Raw bytes type header.

payload: bytearray

Raw bytearray type payload.

class pcapkit.foundation.reassembly.tcp.DatagramID(src, dst, ack)[source]

Bases: Info, Generic[IPAddress]

Data model for tcp.datagram original packet identifier.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

src: tuple[IPAddress, int]

Source address.

dst: tuple[IPAddress, int]

Destination address.

ack: int

Original packet ACK number.

class pcapkit.foundation.reassembly.tcp.Datagram(completed, id, index, header, payload, packet)[source]

Bases: Info, Generic[IPAddress]

Data model for tcp.datagram.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

completed: bool

Completed flag.

id: DatagramID[IPAddress]

Original packet identifier.

index: tuple[int, ...]

Packet numbers.

header: bytes

Initial TCP header.

payload: bytes | tuple[bytes, ...]

Reassembled payload (application layer data).

packet: Optional[Protocol]

Parsed reassembled payload.

class pcapkit.foundation.reassembly.tcp.HoleDiscriptor(fisrt, last)[source]

Bases: Info

Data model for tcp.buffer hole descriptor.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

first: int

Start of hole.

last: int

Stop of hole.

class pcapkit.foundation.reassembly.tcp.Fragment(ind, isn, len, raw)[source]

Bases: Info

Data model for tcp.buffer ACK list fragment item.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ind: list[int]

List of reassembled packets.

isn: int

ISN of payload buffer.

len: int

Length of payload buffer.

raw: bytearray

Reassembled payload holes set to b’x00’.

class pcapkit.foundation.reassembly.tcp.Buffer(hdl, hdr, ack)[source]

Bases: Info

Data model for tcp.buffer.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

hdl: list[HoleDiscriptor]

Hole descriptor list.

hdr: bytes

Initial TCP header.

ack: dict[int, Fragment]

ACK list.

Registry Management

This module (pcapkit.foundation.registry) provides the registry management for pcapkit, as the module contains various registry points.

Auxiliary Methods
pcapkit.foundation.registry.register_output(format, module, class_, ext)[source]

registered a new dumper class.

Notes

The full qualified class name of the new dumper class should be as {module}.{class_}.

The function will register the given dumper class to the pcapkit.foundation.traceflow.TraceFlow.__output__ and pcapkit.foundation.extraction.Extractor.__output__ registry.

Parameters
  • format (str) – format name

  • module (str) – module name

  • class_ (str) – class name

  • ext (str) – file extension

Return type

None

pcapkit.foundation.registry.register_linktype(code, module, class_)[source]

Register a new protocol class.

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

The function will register the given protocol class to the pcapkit.protocols.misc.pcap.frame.Frame.__proto__ registry.

Parameters
Return type

None

pcapkit.foundation.registry.register_port(proto, code, module, class_)[source]

Register a new protocol class.

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

The function will register the given protocol class to the pcapkit.protocols.transport.tcp.TCP.__proto__ and/or pcapkit.protocols.transport.udp.UDP.__proto__ registry.

Parameters
  • proto (Literal["tcp", "udp"]) – protocol name (must be tcp or udp)

  • code (int) – port number

  • module (str) – module name

  • class_ (str) – class name

Return type

None

Dumper Registries
pcapkit.foundation.registry.register_extractor(format, module, class_, ext)[source]

registered a new dumper class.

Notes

The full qualified class name of the new dumper class should be as {module}.{class_}.

The function will register the given dumper class to the pcapkit.foundation.extraction.Extractor.__output__ registry.

Parameters
  • format (str) – format name

  • module (str) – module name

  • class_ (str) – class name

  • ext (str) – file extension

Return type

None

pcapkit.foundation.registry.register_traceflow(format, module, class_, ext)[source]

registered a new dumper class.

Notes

The full qualified class name of the new dumper class should be as {module}.{class_}.

The function will register the given dumper class to the pcapkit.foundation.traceflow.TraceFlow.__output__ registry.

Parameters
  • format (str) – format name

  • module (str) – module name

  • class_ (str) – class name

  • ext (str) – file extension

Return type

None

Protocol Registries
pcapkit.foundation.registry.register_protocol(protocol)[source]

registered protocol class.

The protocol class must be a subclass of Protocol, and will be registered to the pcapkit.protocols.__proto__ registry.

Parameters

protocol (Type[Protocol]) – Protocol class.

Return type

None

pcapkit.foundation.registry.register_pcap(code, module, class_)[source]

Register a new protocol class.

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

The function will register the given protocol class to the pcapkit.protocols.misc.pcap.frame.Frame.__proto__ registry.

Parameters
Return type

None

Internet Layer Registries
pcapkit.foundation.registry.register_transtype(code, module, class_)[source]

Register a new protocol class.

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

The function will register the given protocol class to the pcapkit.protocols.internet.internet.Internet.__proto__ registry.

Parameters
Return type

None

pcapkit.foundation.registry.register_hopopt(code, meth)[source]

Register an option parser.

The function will register the given option parser to the pcapkit.protocols.internet.hopopt.HOPOPT.__option__ registry.

Parameters
  • code (IPv6_Option) – HOPOPT option code as in Option.

  • meth (str | HOPOPT_OptionParser) – Method name or callable to parse the option.

Return type

None

pcapkit.foundation.registry.register_ipv6_opts(code, meth)[source]

Register an option parser.

The function will register the given option parser to the pcapkit.protocols.internet.ipv6_opts.IPv6_Opts.__option__ registry.

Parameters
  • code (IPv6_Option) – IPv6-Opts option code as in Option.

  • meth (str | IPv6_Opts_OptionParser) – Method name or callable to parse the option.

Return type

None

pcapkit.foundation.registry.register_ipv6_route(code, meth)[source]

Register an routing data parser.

The function will register the given routing data parser to the pcapkit.protocols.internet.ipv6_route.IPv6_Route.__routing__ registry.

Parameters
  • code (IPv6_Routing) – IPv6-Route data type code as in Routing.

  • meth (str | IPv6_Route_TypeParser) – Method name or callable to parse the data.

Return type

None

Transport Layer Registries
pcapkit.foundation.registry.register_tcp_port(code, module, class_)[source]

Register a new protocol class.

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

The function will register the given protocol class to the pcapkit.protocols.transport.tcp.TCP.__proto__ registry.

Parameters
  • code (int) – port number

  • module (str) – module name

  • class_ (str) – class name

Return type

None

pcapkit.foundation.registry.register_tcp(code, meth)[source]

Register an option parser.

The function will register the given option parser to the pcapkit.protocols.transport.tcp.TCP.__option__ registry.

Parameters
  • code (TCP_Option) – TCP option code as in Option.

  • meth (str | TCP_OptionParser) – Method name or callable to parse the option.

Return type

None

pcapkit.foundation.registry.register_mptcp(code, meth)[source]

Register an MPTCP option parser.

The function will register the given option parser to the pcapkit.protocols.transport.tcp.TCP.__mp_option__ registry.

Parameters
  • code (TCP_MPTCPOption) – Multipath TCP option code as in MPTCPOption.

  • meth (str | TCP_MPOptionParser) – Method name or callable to parse the option.

Return type

None

pcapkit.foundation.registry.register_udp_port(code, module, class_)[source]

Register a new protocol class.

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

The function will register the given protocol class to the pcapkit.protocols.transport.udp.UDP.__proto__ registry.

Parameters
  • code (int) – port number

  • module (str) – module name

  • class_ (str) – class name

Return type

None

Application Layer Registries
pcapkit.foundation.registry.register_http(code, meth)[source]

registered a frame parser.

The function will register the given frame parser to the pcapkit.protocols.application.httpv2.HTTPv2.__frame__ registry.

Parameters
  • code (HTTP_Frame) – HTTP/2 frame type code as in Frame.

  • meth (str | HTTP_FrameParser) – Method name or callable to parse the frame.

Return type

None

Protocol Family

pcapkit.protocols is collection of all protocol families, with detailed implementation and methods.

Root Protocol

pcapkit.protocols.protocol contains Protocol only, which is an abstract base class for all protocol family, with pre-defined utility arguments and methods of specified protocols.

class pcapkit.protocols.protocol.Protocol(file=None, length=None, **kwargs)[source]

Bases: Generic[PT]

Abstract base class for all protocol family.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__init__(file: BinaryIO, length: Optional[int] = None, **kwargs: Any) None[source]
__init__(**kwargs: Any) None

Initialisation.

Parameters
__post_init__(file: BinaryIO, length: Optional[int] = None, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction arguments, please refer to self.make.

Return type

None

__repr__()[source]

Returns representation of parsed protocol data.

Example

>>> protocol
<Frame alias='...' frame=(..., packet=b'...', sethernet=..., protocols='Ethernet:IPv6:Raw')>
Return type

str

__str__()[source]

Returns formatted hex representation of source data stream.

Example

>>> protocol
Frame(..., packet=b"...", sethernet=..., protocols='Ethernet:IPv6:Raw')
>>> print(protocol)
00 00 00 00 00 00 00 a6 87 f9 27 93 16 ee fe 80 00 00 00     ..........'........
00 00 00 1c cd 7c 77 ba c7 46 b7 87 00 0e aa 00 00 00 00     .....|w..F.........
fe 80 00 00 00 00 00 00 1c cd 7c 77 ba c7 46 b7 01 01 a4     ..........|w..F....
5e 60 d9 6b 97                                               ^`.k.
Return type

str

__iter__()[source]

Iterate through self._data.

Return type

BinaryIO

__getitem__(key)[source]

Subscription (getitem) support.

  • If key is a Protocol object, the method will fetch its indexes (id()).

  • Later, search the packet’s chain of protocols with the calculated key.

  • If no matches, then raises ProtocolNotFound.

Parameters

key (str | Protocol | Type[Protocol]) – Indexing key.

Returns

The sub-packet from the current packet of indexed protocol.

Raises

ProtocolNotFound – If key is not in the current packet.

Return type

Protocol

See also

The method calls self.expand_comp to handle the key and expand it for robust searching.

__contains__(name)[source]

Returns if certain protocol is in the instance.

Parameters

name (str | Protocol | Type[Protocol]) – Name to search

Return type

bool

See also

The method calls self.expand_comp to handle the name and expand it for robust searching.

abstract classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

StdlibEnum | AenumEnum

__hash__()[source]

Return the hash value for self._data.

Return type

int

abstract property name: str

Name of current protocol.

Return type

str

property alias: str

Acronym of current protocol.

Return type

str

property info_name: str

Key name of the info dict.

Return type

str

property info: PT

Info dict of current instance.

Return type

TypeVar(PT, bound= Info)

property data: bytes

Binary packet data of current instance.

Return type

bytes

abstract property length: int

Header length of current protocol.

Return type

int

property payload: Protocol

Payload of current instance.

Return type

Protocol

property protocol: Optional[str]

Name of next layer protocol (if any).

Return type

Optional[str]

property protochain: ProtoChain

Protocol chain of current instance.

Return type

ProtoChain

property packet: Packet

DataType_Packet data of the protocol.

classmethod id()[source]

Index ID of the protocol.

By default, it returns the name of the protocol. In certain cases, the method may return multiple values.

Return type

tuple[str, …]

abstract read(length=None, **kwargs)[source]

Read (parse) packet data.

Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

TypeVar(PT, bound= Info)

Returns

Parsed packet data.

abstract make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

static decode(byte, *, encoding=None, errors='strict')[source]

Decode bytes into str.

Should decoding failed using encoding, the method will try again decoding the bytes as 'unicode_escape' with 'replace' for error handling.

See also

The method is a wrapping function for bytes.decode().

Parameters
  • byte (bytes) – Source bytestring.

  • encoding (Optional[str]) – The encoding with which to decode the bytes. If not provided, pcapkit will first try detecting its encoding using chardet. The fallback encoding would is UTF-8.

  • errors (Literal[‘strict’, ‘ignore’, ‘replace’]) – The error handling scheme to use for the handling of decoding errors. The default is 'strict' meaning that decoding errors raise a UnicodeDecodeError. Other possible values are 'ignore' and 'replace' as well as any other name registered with codecs.register_error() that can handle UnicodeDecodeError.

Return type

str

Return type

str

Parameters
static unquote(url, *, encoding='utf-8', errors='replace')[source]

Unquote URLs into readable format.

Should decoding failed , the method will try again replacing '%' with '\x' then decoding the url as 'unicode_escape' with 'replace' for error handling.

See also

This method is a wrapper function for urllib.parse.unquote().

Parameters
  • url (str) – URL string.

  • encoding (str) – The encoding with which to decode the bytes.

  • errors (Literal[‘strict’, ‘ignore’, ‘replace’]) – The error handling scheme to use for the handling of decoding errors. The default is 'strict' meaning that decoding errors raise a UnicodeDecodeError. Other possible values are 'ignore' and 'replace' as well as any other name registered with codecs.register_error() that can handle UnicodeDecodeError.

Return type

str

static expand_comp(value)[source]

Expand protocol class to protocol name.

The method is used to expand protocol class to protocol name, in the following manner:

  1. If value is a protocol instance, the method will return the protocol class, and the protocol names in upper case obtained from Protocol.id.

  2. If value is a protocol class, the method will return the protocol class itself, and the protocols names in upper case obtained from Protocol.id.

  3. If value is str, the method will attempt to search for the existing registered protocol class from pcapkit.protocols.__proto__ and follow step 2; otherwise, return the value itself.

Parameters

value (str | Protocol | Type[Protocol]) – Protocol class or name.

Return type

tuple

classmethod analyze(proto, payload, **kwargs)[source]

Analyse packet payload.

Parameters
  • proto (int) – Protocol registry number.

  • payload (bytes) – Packet payload.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol

Returns

Parsed payload as a Protocol instance.

_read_protos(size)[source]

Read next layer protocol type.

  • If succeed, returns the enum of next layer protocol.

  • If fail, returns None.

Parameters

size (int) – buffer size

Return type

Optional[StdlibEnum | AenumEnum]

_read_fileng(*args, **kwargs)[source]

Read file buffer (self._file).

This method wraps the file.read call.

Parameters
  • *args (Any) – arbitrary positional arguments

  • **kwargs (Any) – arbitrary keyword arguments

Returns

Data read from file buffer.

Return type

bytes

_read_unpack(size=1, *, signed=False, lilendian=False, quiet=False)[source]

Read bytes and unpack for integers.

Parameters
  • size (int) – buffer size

  • signed (bool) – signed flag

  • lilendian (bool) – little-endian flag

  • quiet (bool) – quiet (no exception) flag

Return type

int

Returns

Unpacked data upon success

Raises

StructError – If unpack (struct.pack()) failed, and struct.error raised.

_read_binary(size=1)[source]

Read bytes and convert into binaries.

Parameters

size (int) – buffer size

Return type

str

Returns

Binary bits (0/1).

_read_packet(length: Optional[int] = None, *, header: None = None) bytes[source]
_read_packet(*, header: int, payload: Optional[int] = None, discard: Literal[True]) bytes
_read_packet(*, header: int, payload: Optional[int] = None, discard: Literal[False] = False) DataType_Packet

Read raw packet data.

Parameters
  • length – length of the packet

  • header – length of the packet header

  • payload – length of the packet payload

  • discard – flag if discard header data

  • If header omits, returns the whole packet data in bytes.

  • If discard is set as True, returns the packet body (in bytes) only.

  • Otherwise, returns the header and payload data as DataType_Packet object.

classmethod _make_pack(integer, *, size=1, signed=False, lilendian=False)[source]

Pack integers to bytes.

Parameters
  • integer (int) – integer to be packed

  • size (int) – buffer size

  • signed (bool) – signed flag

  • lilendian (bool) – little-endian flag

Return type

bytes

Returns

Packed data upon success.

Raises

StructError – If failed to pack the integer.

classmethod _make_index(name: int | StdlibEnum | AenumEnum, *, pack: Literal[False] = False) int[source]
classmethod _make_index(name: int | StdlibEnum | AenumEnum, *, pack: Literal[True], size: int = 4, signed: bool = False, lilendian: bool = False) bytes
classmethod _make_index(name: str, default: Optional[int] = None, *, namespace: Type[StdlibEnum] | Type[AenumEnum], pack: Literal[False] = False) int
classmethod _make_index(name: str, default: Optional[int] = None, *, namespace: Type[StdlibEnum] | Type[AenumEnum], pack: Literal[True], size: int = 4, signed: bool = False, lilendian: bool = False) bytes
classmethod _make_index(name: str, default: Optional[int] = None, *, namespace: dict[int, str], reversed: Literal[False] = False, pack: Literal[False] = False) int
classmethod _make_index(name: str, default: Optional[int] = None, *, namespace: dict[int, str], reversed: Literal[False] = False, pack: Literal[True], size: int = 4, signed: bool = False, lilendian: bool = False) bytes
classmethod _make_index(name: str, default: Optional[int] = None, *, namespace: dict[str, int], reversed: Literal[True], pack: Literal[False] = False) int
classmethod _make_index(name: str, default: Optional[int] = None, *, namespace: dict[str, int], reversed: Literal[True], pack: Literal[True], size: int = 4, signed: bool = False, lilendian: bool = False) bytes

Return first index of name from a dict or enumeration.

Parameters
  • name – item to be indexed

  • default – default value

  • namespace – namespace for item

  • reversed – if namespace is str -> int pairs

  • pack – if need struct.pack() to pack the result

  • size – buffer size

  • signed – signed flag

  • lilendian – little-endian flag

Returns

Index of name from a dict or enumeration. If pack is True, returns bytes; otherwise, returns int.

Raises

ProtocolNotImplemented – If name is NOT in namespace and default is None.

_decode_next_layer(dict_, proto, length=None)[source]

Decode next layer protocol.

Parameters
  • dict_ (TypeVar(PT, bound= Info)) – info buffer

  • proto (int) – next layer protocol index

  • length (Optional[int]) – valid (non-padding) length

Return type

TypeVar(PT, bound= Info)

Returns

Current protocol with next layer extracted.

_import_next_layer(proto, length=None)[source]

Import next layer extractor.

Parameters
  • proto (int) – next layer protocol index

  • length (Optional[int]) – valid (non-padding) length

Return type

Protocol

Returns

Instance of next layer.

__layer__: Optional[Literal['Link', 'Internet', 'Transport', 'Application']]
__proto__: DefaultDict[int, tuple[str, str]]

& self._import_next_layer. The values should be a tuple representing the module name and class name.

_info: PT

Parsed packet data.

_data: bytes

Raw packet data.

_file: BinaryIO

Source packet stream.

_next: Protocol
_seekset: int

File pointer.

Type

int

_exlayer: Optional[str]

Parse packet until such layer.

Type

str

_exproto: Optional[str | Protocol | Type[Protocol]]

Parse packet until such protocol.

Type

str

_sigterm

If terminate parsing next layer of protocol.

Type

bool

Data Structures
class pcapkit.protocols.data.protocol.Packet(header, payload)[source]

Bases: Info

Header and payload data.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

header: bytes

packet header

payload: bytes

packet payload

Auxiliary Protocols

pcapkit.protocols.misc contains the auxiliary protocol implementations. Such includes the Raw class for not-supported protocols, the NoPayload class for indication of empty payload, and PCAP header classes.

PCAP File Headers

pcapkit.protocols.misc.pcap contains header descriptions for PCAP files, including global header (Header) and frame header (Frame).

Global Header

pcapkit.protocols.misc.pcap.header contains Header only, which implements extractor for global headers * of PCAP, whose structure is described as below:

typedef struct pcap_hdr_s {
    guint32 magic_number;   /* magic number */
    guint16 version_major;  /* major version number */
    guint16 version_minor;  /* minor version number */
    gint32  thiszone;       /* GMT to local correction */
    guint32 sigfigs;        /* accuracy of timestamps */
    guint32 snaplen;        /* max length of captured packets, in octets */
    guint32 network;        /* data link type */
} pcap_hdr_t;

class pcapkit.protocols.misc.pcap.header.Header(file=None, length=None, **kwargs)[source]

Bases: Protocol[Header]

PCAP file global header extractor.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises

UnsupportedCall – This protocol has no registry entry.

Return type

NoReturn

property name: Literal['Global Header']

Name of corresponding protocol.

Return type

Literal[‘Global Header’]

property length: Literal[24]

Header length of corresponding protocol.

Return type

Literal[24]

property version: VersionInfo

Version infomation of input PCAP file.

Return type

VersionInfo

property payload: NoReturn

Payload of current instance.

Raises

UnsupportedCall – This protocol doesn’t support payload.

Return type

NoReturn

property protocol: LinkType

Data link type.

Return type

LinkType

property protochain: NoReturn

Protocol chain of current instance.

Raises

UnsupportedCall – This protocol doesn’t support protochain.

Return type

NoReturn

property byteorder: Literal['big', 'little']

Header byte order.

Return type

Literal[‘big’, ‘little’]

property nanosecond: bool

Nanosecond-resolution flag.

Return type

bool

read(length=None, **kwargs)[source]

Read global header of PCAP file.

Notes

PCAP file has four different valid magic numbers.

  • d4 c3 b2 a1 – Little-endian microsecond-timestamp PCAP file.

  • a1 b2 c3 d4 – Big-endian microsecond-timestamp PCAP file.

  • 4d 3c b2 a1 – Little-endian nanosecond-timestamp PCAP file.

  • a1 b2 3c 4d – Big-endian nano-timestamp PCAP file.

Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Header

Returns

Parsed packet data.

Raises

FileError – If the magic number is invalid.

make(*, byteorder='little', lilendian=None, bigendian=None, nanosecond=False, version=(2, 4), version_major=None, version_minor=None, thiszone=0, sigfigs=0, snaplen=262144, network=LinkType.NULL, network_default=None, network_namespace=None, network_reversed=False, **kwargs)[source]

Make (construct) packet data.

Parameters
  • byteorder (Literal["big", "little"]) – header byte order

  • lilendian (Optional[bool]) – little-endian flag

  • bigendian (Optional[bool]) – big-endian flag

  • nanosecond (bool) – nanosecond-resolution file flag

  • version (tuple[int, int] | VersionInfo) – version information

  • version_major (Optional[int]) – major version number

  • version_minor (Optional[int]) – minor version number

  • thiszone (int) – GMT to local correction

  • sigfigs (int) – accuracy of timestamps

  • snaplen (int) – max length of captured packets, in octets

  • network (RegType_LinkType | StdlibEnum | AenumEnum | str | int) – data link type

  • network_default (Optional[int]) – default value for unknown data link type

  • network_namespace (Optional[dict[str, int] | dict[int, str] | Type[StdlibEnum] | Type[AenumEnum]]) – data link type namespace

  • network_reversed (bool) – if namespace is str -> int pairs

  • **kwargs (Any) – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

Data Structures
class pcapkit.protocols.data.misc.pcap.header.Header(magic_number, version_major, version_minor, thiszone, sigfigs, snaplen, network)[source]

Bases: Info

Global header of PCAP file.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

magic_number: MagicNumber

Magic number.

version: VersionInfo

Version number.

thiszone: int

GMT to local correction.

sigfigs: int

Accuracy of timestamps.

snaplen: int

Max length of captured packets, in octets.

network: LinkType

Data link type.

class pcapkit.protocols.data.misc.pcap.header.MagicNumber(data, byteorder, nanosecond)[source]

Bases: Info

Magic number of PCAP file.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Magic number sequence.

byteorder: Literal['big', 'little']

Byte order.

nanosecond: bool

Nanosecond-timestamp resolution flag.


*

https://wiki.wireshark.org/Development/LibpcapFileFormat#Global_Header

Frame Header

pcapkit.protocols.misc.pcap.frame contains Frame only, which implements extractor for frame headers * of PCAP, whose structure is described as below:

typedef struct pcaprec_hdr_s {
    guint32 ts_sec;     /* timestamp seconds */
    guint32 ts_usec;    /* timestamp microseconds */
    guint32 incl_len;   /* number of octets of packet saved in file */
    guint32 orig_len;   /* actual length of packet */
} pcaprec_hdr_t;

class pcapkit.protocols.misc.pcap.frame.Frame(file=None, length=None, **kwargs)[source]

Bases: Protocol[Frame]

Per packet frame header extractor.

This class currently supports parsing of the following protocols, which are registered in the self.__proto__ attribute:

Index

Protocol

pcapkit.const.reg.linktype.LinkType.ETHERNET

pcapkit.protocols.link.ethernet.Ethernet

pcapkit.const.reg.linktype.LinkType.IPV4

pcapkit.protocols.internet.ipv4.IPv4

pcapkit.const.reg.linktype.LinkType.IPV6

pcapkit.protocols.internet.ipv6.IPv6

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, *, num: int, header: DataType_Header, **kwargs: Any) None[source]
__post_init__(*, num: int, header: DataType_Header, **kwargs: Any) None

Initialisation.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • num (int) – Frame index number.

  • header (Header) – Global header of the PCAP file.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

__index__()[source]

Index of the frame.

Parameters

self (Optional[Frame]) – Frame object or None.

Return type

int

Returns

If the object is initiated, i.e. self._fnum exists, returns the frame index number of itself; else raises UnsupportedCall.

Raises

UnsupportedCall – This protocol has no registry entry.

property name: str

Name of corresponding protocol.

Return type

str

property length: Literal[16]

Header length of corresponding protocol.

Return type

Literal[16]

property header: Header

Global header of the PCAP file.

Return type

Header

classmethod register(code, module, class_)[source]

Register a new protocol class.

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

Parameters
Return type

None

index(name)[source]

Call ProtoChain.index.

Parameters

name (str | Protocol | Type[Protocol]) – name to be searched

Returns

First index of name.

Raises

IndexNotFound – if name is not present

Return type

int

read(length=None, *, _read=True, **kwargs)[source]

Read each block after global header.

Parameters
  • length (Optional[int]) – Length of packet data.

  • _read (bool) – If the class is called in a parsing scenario.

  • **kwargs (Any) – Arbitrary keyword arguments.

Returns

Parsed packet data.

Return type

DataType_Frame

Raises

EOFError – If self._file reaches EOF.

make(*, timestamp=None, ts_sec=None, ts_usec=None, incl_len=None, orig_len=None, packet, nanosecond=False, **kwargs)[source]

Make frame packet data.

Parameters
  • timestamp (Optional[float | Decimal]) – UNIX-Epoch timestamp

  • ts_sec (Optional[int]) – timestamp seconds

  • ts_usec (Optional[int]) – timestamp microseconds

  • incl_len (Optional[int]) – number of octets of packet saved in file

  • orig_len (Optional[int]) – actual length of packet

  • packet (bytes) – raw packet data

  • nanosecond (bool) – nanosecond-resolution file flag

  • **kwargs (Any) – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

_decode_next_layer(dict_, proto=None, length=None)[source]

Decode next layer protocol.

Parameters
  • dict_ (Frame) – info buffer

  • proto (Optional[int]) – next layer protocol index

  • length (Optional[int]) – valid (non-padding) length

Returns

current protocol with packet extracted

Return type

dict

__proto__: DefaultDict[int, tuple[str, str]]

Protocol index mapping for decoding next layer, c.f. self._decode_next_layer & self._import_next_layer. The values should be a tuple representing the module name and class name.

Type

DefaultDict[int, tuple[str, str]]

Data Structures
class pcapkit.protocols.data.misc.pcap.frame.Frame(frame_info, time, number, time_epoch, time_delta, len, cap_len)[source]

Bases: Info

Frame header of PCAP file.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

frame_info: FrameInfo

Metadata information.

time: datetime

Timestamp instance.

number: int

Frame index.

time_epoch: Decimal

UNIX timestamp.

len: int

Number of octets of packet saved in file.

cap_len: int

Actual length of packet.

protocols: str

Protocol chain.

class pcapkit.protocols.data.misc.pcap.frame.FrameInfo(ts_sec, ts_usec, incl_len, orig_len)[source]

Bases: Info

Frame metadata information.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ts_sec: int

Timestamp seconds.

ts_usec: int

Timestamp microseconds.

incl_len: int

Number of octets of packet saved in file.

orig_len: int

Actual length of packet.


*

https://wiki.wireshark.org/Development/LibpcapFileFormat#Record_.28Packet.29_Header

Raw Packet Data

pcapkit.protocols.misc.raw contains Raw only, which implements extractor for unknown protocol, and constructs a Protocol like object.

class pcapkit.protocols.misc.raw.Raw(file=None, length=None, **kwargs)[source]

Bases: Protocol[Raw]

This class implements universal unknown protocol.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Would pcapkit encounter malformed packets, the original parsing error instance will be provided as in error.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • error (Optional[Exception]) – Parsing errors if any (for parsing).

  • alias (Optional[int]) – Original enumeration of the unknown protocol.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises

UnsupportedCall – This protocol has no registry entry.

Return type

NoReturn

property name: Literal['Unknown']

Name of current protocol.

Return type

Literal[‘Unknown’]

property length: Literal[0]

Header length of current protocol.

Return type

Literal[0]

property protocol: NoReturn

Name of next layer protocol.

Raises

UnsupportedCall – This protocol doesn’t support protocol.

Return type

NoReturn

read(length=None, *, error=None, alias=None, **kwargs)[source]

Read raw packet data.

Parameters
  • length (Optional[int]) – Length of packet data.

  • error (Optional[Exception]) – Parsing errors if any.

  • alias (Optional[int]) – Original enumeration of the unknown protocol.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Raw

Returns

The parsed packet data.

make(**kwargs)[source]

Make raw packet data.

Parameters
  • packet (bytes) – Raw packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

bytes

Returns

Constructed packet data.

Data Structures
class pcapkit.protocols.data.misc.raw.Raw(protocol, packet, error)[source]

Bases: Info

Raw packet is an unknown protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

protocol: Optional[int]

Original enumeration of this protocol.

packet: bytes

packet data

error: Optional[Exception]

error instance when parsing packet data

No-Payload Packet

pcapkit.protocols.null contains NoPayload only, which implements a Protocol like object whose payload is recursively NoPayload itself.

class pcapkit.protocols.misc.null.NoPayload(file=None, length=None, **kwargs)[source]

Bases: Protocol[NoPayload]

This class implements no-payload protocol.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises

UnsupportedCall – This protocol has no registry entry.

Return type

NoReturn

property name: Literal['Null']

Name of current protocol.

Return type

Literal[‘Null’]

property length: Literal[0]

Header length of current protocol.

Return type

Literal[0]

property protocol: NoReturn

Name of next layer protocol.

Raises

UnsupportedCall – This protocol doesn’t support protocol.

Return type

NoReturn

read(length=None, **kwargs)[source]

Read (parse) packet data.

Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

NoPayload

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

bytes

Returns

Constructed packet data.

Data Structures
class pcapkit.protocols.data.misc.null.NoPayload[source]

Bases: Info

No-payload packet is an empty packet.

Parameters
  • args (VT) –

  • kwargs (VT) –

Return type

Info

Internet Layer Protocols

pcapkit.protocols.internet is collection of all protocols in internet layer, with detailed implementation and methods.

Base Protocol

pcapkit.protocols.internet.internet contains Internet, which is a base class for internet layer protocols, eg. AH, IPsec, IPv4, IPv6, IPX, and etc.

class pcapkit.protocols.internet.internet.Internet(file=None, length=None, **kwargs)[source]

Bases: Protocol[PT], Generic[PT]

Abstract base class for internet layer protocol family.

This class currently supports parsing of the following protocols, which are registered in the self.__proto__ attribute:

Index

Protocol

HOPOPT

pcapkit.protocols.internet.hopopt.HOPOPT

IPv4

pcapkit.protocols.internet.ipv4.IPv4

TCP

pcapkit.protocols.transport.tcp.TCP

UDP

pcapkit.protocols.transport.udp.UDP

IPv6

pcapkit.protocols.internet.ipv6.IPv6

IPv6_Route

pcapkit.protocols.internet.ipv6_route.IPv6_Route

IPv6_Frag

pcapkit.protocols.internet.ipv6_frag.IPv6_Frag

AH

pcapkit.protocols.internet.ah.AH

IPv6_NoNxt

pcapkit.protocols.misc.raw.Raw

IPv6_Opts

pcapkit.protocols.internet.ipv6_opts.IPv6_Opts

IPX_in_IP

pcapkit.protocols.internet.ipx.IPX

Mobility_Header

pcapkit.protocols.internet.mh.MH

HIP

pcapkit.protocols.internet.hip.HIP

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

property layer: Literal['Internet']

Protocol layer.

Return type

Literal[‘Internet’]

classmethod register(code, module, class_)[source]

Register a new protocol class.

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

Parameters
Return type

None

_read_protos(size)[source]

Read next layer protocol type.

Parameters

size (int) – buffer size

Return type

TransType

Returns

Next layer’s protocol enumeration.

_decode_next_layer(dict_, proto=None, length=None, *, version=4, ipv6_exthdr=None)[source]

Decode next layer extractor.

Parameters
  • dict_ (TypeVar(PT, bound= Info)) – info buffer

  • proto (Optional[int]) – next layer protocol index

  • length (Optional[int]) – valid (non-padding) length

  • version (Literal[4, 6]) – IP version

  • ipv6_exthdr (Optional[ProtoChain]) – protocol chain of IPv6 extension headers

Return type

TypeVar(PT, bound= Info)

Returns

Current protocol with next layer extracted.

_import_next_layer(proto, length=None, *, version=4, extension=False)[source]

Import next layer extractor.

Parameters
  • proto (int) – next layer protocol index

  • length (Optional[int]) – valid (non-padding) length

  • version (Literal[4, 6]) – IP protocol version

  • extension (bool) – if is extension header

Return type

Protocol

Returns

Instance of next layer.

__layer__: Optional[Literal['Link', 'Internet', 'Transport', 'Application']] = 'Internet'

Layer of protocol.

__proto__: DefaultDict[int, tuple[str, str]]

Protocol index mapping for decoding next layer, c.f. self._decode_next_layer & self._import_next_layer.

Type

DefaultDict[int, Tuple[str, str]]

IP - Internet Protocol

pcapkit.protocols.internet.ip contains IP only, which is a base class for Internet Protocol (IP) protocol family *, eg. IPv4, IPv6, and IPsec.

class pcapkit.protocols.internet.ip.IP(file=None, length=None, **kwargs)[source]

Bases: Internet[PT], Generic[PT]

This class implements all protocols in IP family.

  • Internet Protocol version 4 (IPv4) [RFC 791]

  • Internet Protocol version 6 (IPv6) [RFC 2460]

  • Authentication Header (pcapkit.~protocols.internet.ah.AH) [RFC 4302]

  • Encapsulating Security Payload (ESP) [RFC 4303]

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

classmethod id()[source]

Index ID of the protocol.

Returns

Index ID of the protocol.

Return type

tuple[Literal[“IPv4”], Literal[“IPv6”]]


*

https://en.wikipedia.org/wiki/Internet_Protocol

IPv4 - Internet Protocol version 4

pcapkit.protocols.internet.ipv4 contains IPv4 only, which implements extractor for Internet Protocol version 4 (IPv4) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

ip.version

Version (4)

0

4

ip.hdr_len

Internal Header Length (IHL)

1

8

ip.dsfield.dscp

Differentiated Services Code Point (DSCP)

1

14

ip.dsfield.ecn

Explicit Congestion Notification (ECN)

2

16

ip.len

Total Length

4

32

ip.id

Identification

6

48

Reserved Bit (must be \x00)

6

49

ip.flags.df

Don’t Fragment (DF)

6

50

ip.flags.mf

More Fragments (MF)

6

51

ip.frag_offset

Fragment Offset

8

64

ip.ttl

Time To Live (TTL)

9

72

ip.proto

Protocol (Transport Layer)

10

80

ip.checksum

Header Checksum

12

96

ip.src

Source IP Address

16

128

ip.dst

Destination IP Address

20

160

ip.options

IP Options (if IHL > 5)


class pcapkit.protocols.internet.ipv4.IPv4(file=None, length=None, **kwargs)[source]

Bases: IP[IPv4]

This class implements Internet Protocol version 4.

This class currently supports parsing of the following IPv4 options, which are directly mapped to the pcapkit.const.ipv4.option_number.OptionNumber enumeration:

Option Code

Option Parser

EOOL

_read_opt_eool()

NOP

_read_opt_nop()

SEC

_read_opt_sec()

LSR

_read_opt_lsr()

TS

_read_opt_ts()

ESEC

_read_opt_esec()

RR

_read_opt_rr()

SID

_read_opt_sid()

SSR

_read_opt_ssr()

MTUP

_read_opt_mtup()

MTUR

_read_opt_mtur()

TR

_read_opt_tr()

RTRALT

_read_opt_rtralt()

QS

_read_opt_qs()

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Internet Protocol version 4']

Name of corresponding protocol.

Return type

Literal[“Internet Protocol version 4”]

property length: int

Header length of corresponding protocol.

Return type

int

property protocol: TransType

Name of next layer protocol.

Return type

TransType

property src: IPv4Address

Source IP address.

Return type

IPv4Address

property dst: IPv4Address

Destination IP address.

Return type

IPv4Address

read(length=None, **kwargs)[source]

Read Internet Protocol version 4 (IPv4).

Structure of IPv4 header [RFC 791]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |Type of Service|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |Flags|      Fragment Offset    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |         Header Checksum       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source Address                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination Address                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

IPv4

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

classmethod id()[source]

Index ID of the protocol.

Return type

tuple[Literal[“IPv4”]]

Returns

Index ID of the protocol.

_read_ipv4_addr()[source]

Read IP address.

Return type

IPv4Address

Returns

Parsed IP address.

_read_ipv4_opt_type(code)[source]

Read option type field.

Parameters

code (int) – option kind value

Return type

OptionType

Returns

Extracted IPv4 option type, as an object of the option flag (copied flag), option class, and option number.

_read_ipv4_options(length)[source]

Read IPv4 option list.

Parameters

length (int) – length of options

Return type

Option

Returns

Extracted IPv4 options.

Raises

ProtocolError – If the threshold is NOT matching.

_read_opt_unassigned(kind, *, options)[source]

Read IPv4 unassigned options.

Structure of IPv4 unassigned options [RFC 791]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     type      |    length     |         option data ...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_UnassignedOption

Returns

Parsed option data.

Raises

ProtocolError – If size is LESS THAN 3.

_read_opt_eool(kind, *, options)[source]

Read IPv4 End of Option List (EOOL) option.

Structure of IPv4 End of Option List (EOOL) option [RFC 719]:

+--------+
|00000000|
+--------+
  Type=0
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_EOOLOption

Returns

Parsed option data.

_read_opt_nop(kind, *, options)[source]

Read IPv4 No Operation (NOP) option.

Structure of IPv4 No Operation (NOP) option [RFC 719]:

+--------+
|00000001|
+--------+
  Type=1
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_NOPOption

Returns

Parsed option data.

_read_opt_sec(kind, *, options)[source]

Read IPv4 Security (SEC) option.

Structure of IPv4 Security (SEC) option [RFC 1108]:

+------------+------------+------------+-------------//----------+
|  10000010  |  XXXXXXXX  |  SSSSSSSS  |  AAAAAAA[1]    AAAAAAA0 |
|            |            |            |         [0]             |
+------------+------------+------------+-------------//----------+
  TYPE = 130     LENGTH   CLASSIFICATION         PROTECTION
                               LEVEL              AUTHORITY
                                                    FLAGS
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_SECOption

Returns

Parsed option data.

Raises

ProtocolError – If size is LESS THAN 3.

_read_opt_lsr(kind, *, options)[source]

Read IPv4 Loose Source Route (LSR) option.

Structure of IPv4 Loose Source Route (LSR) option [RFC 791]:

+--------+--------+--------+---------//--------+
|10000011| length | pointer|     route data    |
+--------+--------+--------+---------//--------+
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_LSROption

Returns

Parsed option data.

Raises

ProtocolError – If option is malformed.

_read_opt_ts(kind, *, options)[source]

Read IPv4 Time Stamp (TS) option.

Structure of IPv4 Time Stamp (TS) option [RFC 791]:

+--------+--------+--------+--------+
|01000100| length | pointer|oflw|flg|
+--------+--------+--------+--------+
|         internet address          |
+--------+--------+--------+--------+
|             timestamp             |
+--------+--------+--------+--------+
|                 .                 |
                  .
                  .
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_TSOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

_read_opt_esec(kind, *, options)[source]

Read IPv4 Extended Security (ESEC) option.

Structure of IPv4 Extended Security (ESEC) option [RFC 1108]:

+------------+------------+------------+-------//-------+
|  10000101  |  000LLLLL  |  AAAAAAAA  |  add sec info  |
+------------+------------+------------+-------//-------+
 TYPE = 133      LENGTH     ADDITIONAL      ADDITIONAL
                           SECURITY INFO     SECURITY
                            FORMAT CODE        INFO
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_ESECOption

Returns

Parsed option data.

Raises

ProtocolError – If size is LESS THAN 3.

_read_opt_rr(kind, *, options)[source]

Read IPv4 Record Route (RR) option.

Structure of IPv4 Record Route (RR) option [RFC 791]:

+--------+--------+--------+---------//--------+
|00000111| length | pointer|     route data    |
+--------+--------+--------+---------//--------+
  Type=7
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_RROption

Returns

Parsed option data.

Raises

ProtocolError – If option is malformed.

_read_opt_sid(kind, *, options)[source]

Read IPv4 Stream ID (SID) option.

Structure of IPv4 Stream ID (SID) option [RFC 791][RFC 6814]:

+--------+--------+--------+--------+
|10001000|00000010|    Stream ID    |
+--------+--------+--------+--------+
 Type=136 Length=4
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_SIDOption

Returns

Parsed option data.

Raises

ProtocolError – If size is NOT 4.

_read_opt_ssr(kind, *, options)[source]

Read IPv4 Strict Source Route (SSR) option.

Structure of IPv4 Strict Source Route (SSR) option [RFC 791]:

+--------+--------+--------+---------//--------+
|10001001| length | pointer|     route data    |
+--------+--------+--------+---------//--------+
 Type=137
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_SSROption

Returns

Parsed option data.

Raises

ProtocolError – If option is malformed.

_read_opt_mtup(kind, *, options)[source]

Read IPv4 MTU Probe (MTUP) option.

Structure of IPv4 MTU Probe (MTUP) option [RFC 1063][RFC 1191]:

+--------+--------+--------+--------+
|00001011|00000100|   2 octet value |
+--------+--------+--------+--------+
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_MTUPOption

Returns

Parsed option data.

Raises

ProtocolError – If size is NOT 4.

_read_opt_mtur(kind, *, options)[source]

Read IPv4 MTU Reply (MTUR) option.

Structure of IPv4 MTU Reply (MTUR) option [RFC 1063][RFC 1191]:

+--------+--------+--------+--------+
|00001100|00000100|   2 octet value |
+--------+--------+--------+--------+
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_MTUROption

Returns

Parsed option data.

Raises

ProtocolError – If size is NOT 4.

_read_opt_tr(kind, *, options)[source]

Read IPv4 Traceroute (TR) option.

Structure of IPv4 Traceroute (TR) option [RFC 1393][RFC 6814]:

 0               8              16              24
+-+-+-+-+-+-+-+-+---------------+---------------+---------------+
|F| C |  Number |    Length     |          ID Number            |
+-+-+-+-+-+-+-+-+---------------+---------------+---------------+
|      Outbound Hop Count       |       Return Hop Count        |
+---------------+---------------+---------------+---------------+
|                     Originator IP Address                     |
+---------------+---------------+---------------+---------------+
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_TROption

Returns

Parsed option data.

Raises

ProtocolError – If size is NOT 12.

_read_opt_rtralt(kind, *, options)[source]

Read IPv4 Router Alert (RTRALT) option.

Structure of IPv4 Router Alert (RTRALT) option [RFC 2113]:

+--------+--------+--------+--------+
|10010100|00000100|  2 octet value  |
+--------+--------+--------+--------+
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_RTRALTOption

Returns

Parsed option data.

Raises

ProtocolError – If size is NOT 4.

_read_opt_qs(kind, *, options)[source]

Read IPv4 Quick Start (QS) option.

Structure of IPv4 Quick Start (QS) option [RFC 4782]:

  • A Quick-Start Request

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |   Option      |  Length=8     | Func. | Rate  |   QS TTL      |
    |               |               | 0000  |Request|               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                        QS Nonce                           | R |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
  • Report of Approved Rate

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |   Option      |  Length=8     | Func. | Rate  |   Not Used    |
    |               |               | 1000  | Report|               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                        QS Nonce                           | R |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
Parameters
  • kind (RegType_OptionNumber) – option type code

  • options (Option) – extracted IPv4 options

Return type

DataType_QSOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

Data Structures
class pcapkit.protocols.data.internet.ipv4.IPv4(version, hdr_len, tos, len, id, flags, offset, ttl, protocol, checksum, src, dst)[source]

Bases: Info

Data model for IPv4 packet.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

version: Literal[4]

Version.

hdr_len: int

Internet header length.

tos: ToSField

Type of services.

len: int

Total length.

id: int

Identification.

flags: Flags

Flags.

offset: int

Fragment offset.

ttl: timedelta

Time to live.

protocol: TransType

Protocol.

checksum: bytes

Header checksum.

src: IPv4Address

Source address.

dst: IPv4Address

Destination address.

options: OrderedMultiDict[OptionNumber, Option]
class pcapkit.protocols.data.internet.ipv4.ToSField(pre, del, thr, rel, ecn)[source]

Bases: Info

Data model for IPv4 ToS fields.

Important

Due to the preserved keyword conflict, please use from_dict() to create an instance of this data model.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

ToSField

pre: ToSPrecedence

Precedence.

del: ToSDelay

Delay.

Note

This field is conflict with del keyword. To access this field, directly use getattr() instead.

thr: ToSThroughput

Throughput.

rel: ToSReliability

Reliability.

ecn: ToSECN

Explicit congestion notification (ECN).

class pcapkit.protocols.data.internet.ipv4.Flags(df, mf)[source]

Bases: Info

Data model for IPv4 Flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

df: bool

Don’t fragment.

mf: bool

More fragments.

class pcapkit.protocols.data.internet.ipv4.Option(code, length, type)[source]

Bases: Info

Data model for IPv4 options.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

code: OptionNumber

Option code.

length: int

Option length.

type: OptionType

Option type.

class pcapkit.protocols.data.internet.ipv4.OptionType(change, class, number)[source]

Bases: Info

Data model for IPv4 option type data.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

OptionType

change: bool

Change flag.

class: OptionClass

Option class.

Note

This field is conflict with class keyword. To access this field, directly use getattr() instead.

number: int

Number.

class pcapkit.protocols.data.internet.ipv4.UnassignedOption(code, length, type, data)[source]

Bases: Option

Data model for IPv4 unassigned option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Option data.

class pcapkit.protocols.data.internet.ipv4.EOOLOption(code, length, type)[source]

Bases: Option

Data model for IPv4 End of Option List (EOOL) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.internet.ipv4.NOPOption(code, length, type)[source]

Bases: Option

Data model for IPv4 No Operation (NOP) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.internet.ipv4.SECOption(code, length, type, level, flags)[source]

Bases: Option

Data model for IPv4 Security (SEC) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

level: ClassificationLevel

Classification level.

flags: Optional[OrderedMultiDict[ProtectionAuthority, bool]]

Protection authority flags.

class pcapkit.protocols.data.internet.ipv4.LSROption(code, length, type, pointer, route)[source]

Bases: Option

Data model for IPv4 Loose Source Route (LSR) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

pointer: int

Pointer.

route: Optional[tuple[IPv4Address, ...]]

Route.

class pcapkit.protocols.data.internet.ipv4.TSOption(code, length, type, pointer, overflow, flag, timestamp)[source]

Bases: Option

Data model for IPv4 Time Stamp (TS) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

pointer: int

Pointer.

overflow: int

Overflow.

flag: TSFlag

Flag.

timestamp: Optional[bytes | tuple[dt_type, ...] | OrderedMultiDict[IPv4Address, dt_type]]

Timestamp data.

class pcapkit.protocols.data.internet.ipv4.ESECOption(code, length, type, level, flags)[source]

Bases: Option

Data model for IPv4 Extended Security (ESEC) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

level: ClassificationLevel

Classification level.

flags: Optional[OrderedMultiDict[ProtectionAuthority, bool]]

Protection authority flags.

class pcapkit.protocols.data.internet.ipv4.RROption(code, length, type, pointer, route)[source]

Bases: Option

Data model for IPv4 Record Route (RR) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

pointer: int

Pointer.

route: Optional[tuple[IPv4Address, ...]]

Route.

class pcapkit.protocols.data.internet.ipv4.SIDOption(code, length, type, sid)[source]

Bases: Option

Data model for IPv4 Stream ID (SID) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

sid: int

Stream ID.

class pcapkit.protocols.data.internet.ipv4.SSROption(code, length, type, pointer, route)[source]

Bases: Option

Data model for IPv4 Strict Source Route (SSR) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

pointer: int

Pointer.

route: Optional[tuple[IPv4Address, ...]]

Route.

class pcapkit.protocols.data.internet.ipv4.MTUPOption(code, length, type, mtu)[source]

Bases: Option

Data model for IPv4 MTU Probe (MTUP) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

mtu: int

MTU.

class pcapkit.protocols.data.internet.ipv4.MTUROption(code, length, type, mtu)[source]

Bases: Option

Data model for IPv4 MTU Reply (MTUR) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

mtu: int

MTU.

class pcapkit.protocols.data.internet.ipv4.TROption(code, length, type, id, outbound, return, originator)[source]

Bases: Option

Data model for IPv4 Traceroute (TR) option.

Important

Due to the preserved keyword conflict, please use from_dict() to create an instance of this data model.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

TROption

id: int

ID number.

outbound: int

Outbound hop count.

return: int

Return hop count.

Note

This field is conflict with return keyword. To access this field, directly use getattr() instead.

originator: IPv4Address
class pcapkit.protocols.data.internet.ipv4.RTRALTOption(code, length, type, alert)[source]

Bases: Option

Data model for IPv4 Router Alert (RTRALT) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

alert: RouterAlert

Router alert.

class pcapkit.protocols.data.internet.ipv4.QSOption(code, length, type, func, rate, ttl, nounce)[source]

Bases: Option

Data model for IPv4 Quick Start (QS) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

func: QSFunction

QS function.

rate: int

Rate request/report.

ttl: Optional[timedelta]

TTL.

nounce: int

Nounce.


*

https://en.wikipedia.org/wiki/IPv4

IPv6 - Internet Protocol version 6

pcapkit.protocols.internet.ipv6 contains IPv6 only, which implements extractor for Internet Protocol version 6 (IPv6) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

ip.version

Version (6)

0

4

ip.class

Traffic Class

1

12

ip.label

Flow Label

4

32

ip.payload

Payload Length (header excludes)

6

48

ip.next

Next Header

7

56

ip.limit

Hop Limit

8

64

ip.src

Source Address

24

192

ip.dst

Destination Address


class pcapkit.protocols.internet.ipv6.IPv6(file=None, length=None, **kwargs)[source]

Bases: IP[IPv6]

This class implements Internet Protocol version 6.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Internet Protocol version 6']

Name of corresponding protocol.

Return type

Literal[‘Internet Protocol version 6’]

property length: Literal[40]

Header length of corresponding protocol.

Return type

Literal[40]

property protocol: TransType

Name of next layer protocol.

Return type

TransType

property src: IPv6Address

Source IP address.

Return type

IPv6Address

property dst: IPv6Address

Destination IP address.

Return type

IPv6Address

property extension_headers: OrderedMultiDict[ExtensionHeader, Protocol]

IPv6 extension header records.

Return type

OrderedMultiDict[ExtensionHeader, Protocol]

read(length=None, **kwargs)[source]

Read Internet Protocol version 6 (IPv6).

Structure of IPv6 header [RFC 2460]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| Traffic Class |           Flow Label                  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Payload Length        |  Next Header  |   Hop Limit   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                         Source Address                        +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                      Destination Address                      +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

IPv6

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

classmethod id()[source]

Index ID of the protocol.

Returns

Index ID of the protocol.

Return type

tuple[Literal[“IPv6”]]

_read_ip_hextet()[source]

Read first four hextets of IPv6.

Returns

Parsed hextets data, including version number, traffic class and flow label.

Return type

tuple[int, int, int]

_read_ip_addr()[source]

Read IP address.

Return type

IPv6Address

Returns

Parsed IP address.

_decode_next_layer(ipv6, proto=None, length=None)[source]

Decode next layer extractor.

Parameters
  • ipv6 (IPv6) – info buffer

  • proto (Optional[int]) – next layer protocol name

  • length (Optional[int]) – valid (not padding) length

Return type

IPv6

Returns

Current protocol with next layer extracted.

Data Structures
class pcapkit.protocols.data.internet.ipv6.IPv6(version, class, label, payload, next, limit, src, dst)[source]

Bases: Info

Data model for Internet Protocol version 6.

Important

Due to the preserved keyword conflict, please use from_dict() to create an instance of this data model.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

IPv6

version: Literal[6]

Version.

class: int

Traffic class.

Note

This field is conflict with class keyword. To access this field, directly use getattr() instead.

label: int

Flow label.

payload: int

Payload length.

next: TransType

Next header.

limit: int

Hop limit.

src: IPv6Address

Source address.

dst: IPv6Address

Destination address.

fragment: Packet

Fragmented packet header & payload (from IPv6-Frag header).

protocol: TransType

Highest header protocol type (extension header excluded).

hdr_len: int

Header length (including extension headers).

raw_len: int

Raw payload length (excluding extension headers).


*

https://en.wikipedia.org/wiki/IPv6_packet

IPv6-Frag - Fragment Header for IPv6

pcapkit.protocols.internet.ipv6_frag contains IPv6_Frag only, which implements extractor for Fragment Header for IPv6 (IPv6-Frag) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

frag.next

Next Header

1

8

Reserved

2

16

frag.offset

Fragment Offset

3

29

Reserved

3

31

frag.mf

More Flag

4

32

frag.id

Identification


class pcapkit.protocols.internet.ipv6_frag.IPv6_Frag(file=None, length=None, **kwargs)[source]

Bases: Internet[IPv6_Frag]

This class implements Fragment Header for IPv6.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, *, extension: bool = False, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
Keyword Arguments
  • extension – If the protocol is used as an IPv6 extension header.

  • **kwargs – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Fragment Header for IPv6']

Name of current protocol.

Return type

Literal[‘Fragment Header for IPv6’]

property alias: Literal['IPv6-Frag']

Acronym of corresponding protocol.

Return type

Literal[‘IPv6-Frag’]

property length: Literal[8]

Header length of current protocol.

Return type

Literal[8]

property payload: Protocol | NoReturn

Payload of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protocol: Optional[str] | NoReturn

Name of next layer protocol (if any).

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protochain: ProtoChain | NoReturn

Protocol chain of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

read(length=None, *, extension=False, **kwargs)[source]

Read Fragment Header for IPv6.

Structure of IPv6-Frag header [RFC 8200]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |   Reserved    |      Fragment Offset    |Res|M|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Identification                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the packet is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

IPv6_Frag

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

Data Structures
class pcapkit.protocols.data.internet.ipv6_frag.IPv6_Frag(next, offset, mf, id)[source]

Bases: Info

Data model for IPv6 fragment header.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

next: TransType

Next header.

offset: int

Fragment offset.

mf: bool

More flag.

id: int

Identification.


*

https://en.wikipedia.org/wiki/IPv6_packet#Fragment

IPv6-Opts - Destination Options for IPv6

pcapkit.protocols.internet.ipv6_opts contains IPv6_Opts only, which implements extractor for Destination Options for IPv6 (IPv6-Opts) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

opt.next

Next Header

1

8

opt.length

Header Extensive Length

2

16

opt.options

Options


class pcapkit.protocols.internet.ipv6_opts.IPv6_Opts(file=None, length=None, **kwargs)[source]

Bases: Internet[IPv6_Opts]

This class implements Destination Options for IPv6.

This class currently supports parsing of the following IPv6 Hop-by-Hop options, which are registered in the self.__option__ attribute:

Option Code

Option Parser

Pad1

_read_opt_pad()

PadN

_read_opt_pad()

Tunnel_Encapsulation_Limit

_read_opt_tun()

Router_Alert

_read_opt_ra()

CALIPSO

_read_opt_calipso()

SMF_DPD

_read_opt_smf_dpd()

PDM

_read_opt_pdm()

Quick_Start

_read_opt_qs()

RPL_Option_0x63

_read_opt_rpl()

MPL_Option

_read_opt_mpl()

ILNP_Nonce

_read_opt_ilnp()

Line_Identification_Option

_read_opt_lio()

Jumbo_Payload

_read_opt_jumbo()

Home_Address

_read_opt_home()

IP_DFF

_read_opt_ip_dff()

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, *, extension: bool = False, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Destination Options for IPv6']

Name of current protocol.

Return type

Literal[“Destination Options for IPv6”]

property length: int

Header length of current protocol.

Return type

int

property payload: Protocol | NoReturn

Payload of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

Return type

pcapkit.protocols.protocol.Protocol

property protocol: Optional[str] | NoReturn

Name of next layer protocol (if any).

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protochain: ProtoChain | NoReturn

Protocol chain of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

Return type

ProtoChain | NoReturn

read(length=None, *, extension=False, **kwargs)[source]

Read Destination Options for IPv6.

Structure of IPv6-Opts header [RFC 8200]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
|                                                               |
.                                                               .
.                            Options                            .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the packet is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

IPv6_Opts

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

classmethod register_option(code, meth)[source]

Register an option parser.

Parameters
  • code (RegType_Option) – IPv6-Opts option code.

  • meth (str | OptionParser) – Method name or callable to parse the option.

Return type

None

_read_opt_type(kind)[source]

Read option type field.

Parameters

kind (int) – option kind value

Returns

Extracted IPv6-Opts option type field information (unknown option action and change flag), c.f. [RFC 8200#section-4.2].

Return type

tuple[int, bool]

_read_ipv6_opts(length)[source]

Read IPv6-Opts options.

Positional arguments:

length: length of options

Return type

Option

Returns

Extracted IPv6-Opts options

Raises

ProtocolError – If the threshold is NOT matching.

Parameters

length (int) –

_read_opt_none(code, acts, cflg, *, options)[source]

Read IPv6-Opts unassigned options.

Structure of IPv6-Opts unassigned options [RFC 8200]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
|  Option Type  |  Opt Data Len |  Option Data
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_UnassignedOption

Returns

Parsed option data.

_read_opt_pad(code, acts, cflg, *, options)[source]

Read IPv6-Opts padding options.

Structure of IPv6-Opts padding options [RFC 8200]:

  • Pad1 option:

    +-+-+-+-+-+-+-+-+
    |       0       |
    +-+-+-+-+-+-+-+-+
    
  • PadN option:

    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
    |       1       |  Opt Data Len |  Option Data
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
    
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Returns

parsed option data

Return type

Union[DataType_Opt_Pad1, DataType_Opt_PadN]

Raises

ProtocolError – If code is NOT 0 or 1.

_read_opt_tun(code, acts, cflg, *, options)[source]

Read IPv6-Opts Tunnel Encapsulation Limit option.

Structure of IPv6-Opts Tunnel Encapsulation Limit option [RFC 2473]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |Hdr Ext Len = 0| Opt Type = 4  |Opt Data Len=1 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Tun Encap Lim |PadN Opt Type=1|Opt Data Len=1 |       0       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_TunnelEncapsulationLimitOption

Returns

Parsed option data.

Raises

ProtocolError – If ipv6_opts.tun.length is NOT 1.

_read_opt_ra(code, acts, cflg, *, options)[source]

Read IPv6-Opts Router Alert option.

Structure of IPv6-Opts Router Alert option [RFC 2711]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0 0 0|0 0 1 0 1|0 0 0 0 0 0 1 0|        Value (2 octets)       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_RouterAlertOption

Returns

Parsed option data.

Raises

ProtocolError – If ipv6_opts.tun.length is NOT 2.

_read_opt_calipso(code, acts, cflg, *, options)[source]

Read IPv6-Opts Common Architecture Label IPv6 Security Option (CALIPSO) option.

Structure of IPv6-Opts CALIPSO option [RFC 5570]:

------------------------------------------------------------
| Next Header | Hdr Ext Len   | Option Type | Option Length|
+-------------+---------------+-------------+--------------+
|             CALIPSO Domain of Interpretation             |
+-------------+---------------+-------------+--------------+
| Cmpt Length |  Sens Level   |     Checksum (CRC-16)      |
+-------------+---------------+-------------+--------------+
|      Compartment Bitmap (Optional; variable length)      |
+-------------+---------------+-------------+--------------+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_CALIPSOOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

_read_opt_smf_dpd(code, acts, cflg, *, options)[source]

Read IPv6-Opts Simplified Multicast Forwarding Duplicate Packet Detection (SMF_DPD) option.

Structure of IPv6-Opts SMF_DPD option [RFC 6621]:

  • IPv6 SMF_DPD option header in I-DPD (Identification-Based DPD) mode

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                   ...              |0|0|0|  01000  | Opt. Data Len |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |0|TidTy| TidLen|             TaggerID (optional) ...           |
    +-+-+-+-+-+-+-+-+               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                               |            Identifier  ...
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
  • IPv6 SMF_DPD option header in H-DPD (Hash-Based) mode

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                   ...              |0|0|0| OptType | Opt. Data Len |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |1|    Hash Assist Value (HAV) ...
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_SMFIdentificationBasedDPDOption | DataType_SMFHashBasedDPDOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

_read_opt_pdm(code, acts, cflg, *, options)[source]

Read IPv6-Opts Performance and Diagnostic Metrics (PDM) option.

Structure of IPv6-Opts PDM option [RFC 8250]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Option Type  | Option Length |    ScaleDTLR  |     ScaleDTLS |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   PSN This Packet             |  PSN Last Received            |
|-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Delta Time Last Received    |  Delta Time Last Sent         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_PDMOption

Returns

Parsed option data.

Raises

ProtocolError – If ipv6_opts.pdm.length is NOT 10.

_read_opt_qs(code, acts, cflg, *, options)[source]

Read IPv6-Opts Quick Start option.

Structure of IPv6-Opts Quick-Start option [RFC 4782]:

  • A Quick-Start Request:

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |   Option      |  Length=6     | Func. | Rate  |   QS TTL      |
    |               |               | 0000  |Request|               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                        QS Nonce                           | R |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
  • Report of Approved Rate:

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |   Option      |  Length=6     | Func. | Rate  |   Not Used    |
    |               |               | 1000  | Report|               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                        QS Nonce                           | R |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_QuickStartOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

_read_opt_rpl(code, acts, cflg, *, options)[source]

Read IPv6-Opts Routing Protocol for Low-Power and Lossy Networks (RPL) option.

Structure of IPv6-Opts RPL option [RFC 6553]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  |  Opt Data Len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|O|R|F|0|0|0|0|0| RPLInstanceID |          SenderRank           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         (sub-TLVs)                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_RPLOption

Returns

Parsed option data.

Raises

ProtocolError – If ipv6_opts.rpl.length is NOT 4.

_read_opt_mpl(code, acts, cflg, *, options)[source]

Read IPv6-Opts Multicast Protocol for Low-Power and Lossy Networks (MPL) option.

Structure of IPv6-Opts MPL option [RFC 7731]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  |  Opt Data Len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| S |M|V|  rsv  |   sequence    |      seed-id (optional)       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_MPLOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

_read_opt_ilnp(code, acts, cflg, *, options)[source]

Read IPv6-Opts Identifier-Locator Network Protocol (ILNP) Nonce option.

Structure of IPv6-Opts ILNP Nonce option [RFC 6744]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header   | Hdr Ext Len   |  Option Type  | Option Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                         Nonce Value                           /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_ILNPOption

Returns

Parsed option data.

_read_opt_lio(code, acts, cflg, *, options)[source]

Read IPv6-Opts Line-Identification option.

Structure of IPv6-Opts Line-Identification option [RFC 6788]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  | Option Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LineIDLen     |     Line ID...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_LineIdentificationOption

Returns

Parsed option data.

_read_opt_jumbo(code, acts, cflg, *, options)[source]

Read IPv6-Opts Jumbo Payload option.

Structure of IPv6-Opts Jumbo Payload option [RFC 2675]:

                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  |  Opt Data Len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Jumbo Payload Length                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_JumboPayloadOption

Returns

Parsed option data.

Raises

ProtocolError – If ipv6_opts.jumbo.length is NOT 4.

_read_opt_home(code, acts, cflg, *, options)[source]

Read IPv6-Opts Home Address option.

Structure of IPv6-Opts Home Address option [RFC 6275]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  | Option Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                          Home Address                         +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_HomeAddressOption

Returns

Parsed option data.

Raises

ProtocolError – If ipv6_opts.jumbo.length is NOT 16.

_read_opt_ip_dff(code, acts, cflg, *, options)[source]

Read IPv6-Opts Depth-First Forwarding (IP_DFF) option.

Structure of IPv6-Opts IP_DFF option [RFC 6971]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |  OptTypeDFF   | OptDataLenDFF |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|VER|D|R|0|0|0|0|        Sequence Number        |      Pad1     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted IPv6-Opts options

Return type

DataType_IPDFFOption

Returns

Parsed option data.

Raises

ProtocolError – If ipv6_opts.ip_dff.length is NOT 2.

Data Structures
class pcapkit.protocols.data.internet.ipv6_opts.IPv6_Opts(next, length, options)[source]

Bases: Info

Data model for IPv6-Opts protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

next: TransType

Next header.

length: int

Header extension length.

options: OrderedMultiDict[RegType_Option, Option]

IPv6-Opts options.

class pcapkit.protocols.data.internet.ipv6_opts.Option(type, action, change, length)[source]

Bases: Info

Data model for IPv6-Opts option data.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: RegType_Option

Option type.

action: int

Unknown option cation.

change: bool

Change flag.

length: int

Content length.

class pcapkit.protocols.data.internet.ipv6_opts.UnassignedOption(type, action, change, length, data)[source]

Bases: Option

Data model for IPv6-Opts unassigned option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Option data.

class pcapkit.protocols.data.internet.ipv6_opts.PadOption(type, action, change, length)[source]

Bases: Option

Data model for IPv6-Opts padding options.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.internet.ipv6_opts.TunnelEncapsulationLimitOption(type, action, change, length, limit)[source]

Bases: Option

Data model for IPv6-Opts tunnel encapsulation limit option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

limit: int

Tunnel encapsulation limit.

class pcapkit.protocols.data.internet.ipv6_opts.RouterAlertOption(type, action, change, length, value)[source]

Bases: Option

Data model for IPv6-Opts router alter option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

value: RouterAlert

Router alter value.

class pcapkit.protocols.data.internet.ipv6_opts.CALIPSOOption(type, action, change, length, domain, cmpt_len, level, checksum)[source]

Bases: Option

Data model for IPv6-Opts Common Architecture Label IPv6 Security Option (CALIPSO) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

domain: int

CALIPSO domain of interpretation.

cmpt_len: int

Compartment length.

level: int

Sensitivity level.

checksum: bytes

Checksum.

cmpt_bitmap: tuple[int, ...]

Compartment bitmap.

class pcapkit.protocols.data.internet.ipv6_opts.SMFDPDOption(type, action, change, length, dpd_type, tid_type)[source]

Bases: Option

Data model for IPv6-Opts Simplified Multicast Forwarding Duplicate Packet Detection (SMF_DPD) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

dpd_type: SMFDPDMode

DPD type.

tid_type: TaggerID

TaggerID type.

class pcapkit.protocols.data.internet.ipv6_opts.SMFIdentificationBasedDPDOption(type, action, change, length, pdm_type, tid_type, tid_len, tid, id)[source]

Bases: Option

Data model for IPv6-Opts I-DPD (Identification-Based DPD) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

tid_len: int

TaggerID length.

tid: Optional[int | IPv4Address | IPv6Address]

TaggerID.

id: int

Identifier.

class pcapkit.protocols.data.internet.ipv6_opts.SMFHashBasedDPDOption(type, action, change, length, pdm_type, tid_type, hav)[source]

Bases: Option

Data model for IPv6-Opts H-DPD (Hash-Based DPD) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

hav: bytes

Hash assist value.

class pcapkit.protocols.data.internet.ipv6_opts.PDMOption(type, action, change, length, scaledtlr, scaledtls, psntp, psnlr, deltatlr, deltatls)[source]

Bases: Option

Data model for IPv6-Opts Performance Diagnostic Metrics (PDM) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

scaledtlr: timedelta

Scale delta time last received.

scaledtls: timedelta

Scale delta time last sent.

psntp: int

Packet sequence number this packet.

psnlr: int

Packet sequence number last received.

deltatlr: timedelta

Delta time last received.

deltatls: timedelta

Delta time last sent.

class pcapkit.protocols.data.internet.ipv6_opts.QuickStartOption(type, action, change, length, func, rate, ttl, nounce)[source]

Bases: Option

Data model for IPv6-Opts Quick Start option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

func: QSFunction

QS function.

rate: int

Rate request/report.

ttl: Optional[timedelta]

TTL.

nounce: int

Nounce.

class pcapkit.protocols.data.internet.ipv6_opts.RPLOption(type, action, change, length, flags, id, rank)[source]

Bases: Option

Data model for IPv6-Opts Routing Protocol for Low-Power and Lossy Networks (RPL) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: RPLFlags

Flags.

id: int

RPL instance ID.

rank: int

Sender rank.

class pcapkit.protocols.data.internet.ipv6_opts.RPLFlags(down, rank_err, fwd_err)[source]

Bases: Info

Data model for IPv6-Opts RPL option flags fields.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

down: bool

Down flag.

rank_err: bool

Rank error flag.

fwd_err: bool

Forwarding error flag.

class pcapkit.protocols.data.internet.ipv6_opts.MPLOption(type, action, change, length, seed_type, flags, seq, seed_id)[source]

Bases: Option

Data model for IPv6-Opts Multicast Protocol for Low-Power and Lossy Networks (MPL) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

seed_type: SeedID

Seed length.

flags: MPLFlags

Flags.

seq: int

Sequence number.

seed_id: Optional[int]

Seed ID.

class pcapkit.protocols.data.internet.ipv6_opts.MPLFlags(max, verification)[source]

Bases: Info

Data model for IPv6-Opts MPL option flags fields.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

max: bool

Max flag.

verification: bool

Verification flag.

class pcapkit.protocols.data.internet.ipv6_opts.ILNPOption(type, action, change, length, nounce)[source]

Bases: Option

Data model for IPv6-Opts Identifier-Locator Network Protocol (ILNP) Nonce option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

nounce: bytes

Nonce value.

class pcapkit.protocols.data.internet.ipv6_opts.LineIdentificationOption(type, action, change, length, line_id_len, line_id)[source]

Bases: Option

Data model for IPv6-Opts Line-Identification option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

line_id_len: int

Line ID length.

line_id: int

Line ID.

class pcapkit.protocols.data.internet.ipv6_opts.JumboPayloadOption(type, action, change, length, payload_len)[source]

Bases: Option

Data model for Jumbo Payload option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

payload_len: int

Jumbo payload length.

class pcapkit.protocols.data.internet.ipv6_opts.HomeAddressOption(type, action, change, length, address)[source]

Bases: Option

Data model for IPv6-Opts Home Address option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

address: IPv6Address

Home address.

class pcapkit.protocols.data.internet.ipv6_opts.IPDFFOption(type, action, change, length, version, flags, seq)[source]

Bases: Option

Data model for IPv6-Opts Depth-First Forwarding (IP_DFF) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

version: int

Version.

flags: DFFFlags

Flags.

seq: int

Sequence number.

class pcapkit.protocols.data.internet.ipv6_opts.DFFFlags(dup, ret)[source]

Bases: Info

Data model for IPv6-Opts IP_DFF option flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

dup: bool

Duplicate flag.

ret: bool

Return flag.


*

https://en.wikipedia.org/wiki/IPv6_packet#Hop-by-hop_options_and_destination_options

IPv6-Route - Routing Header for IPv6

pcapkit.protocols.internet.ipv6_route contains IPv6_Route only, which implements extractor for Routing Header for IPv6 (IPv6-Route) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

route.next

Next Header

1

8

route.length

Header Extensive Length

2

16

route.type

Routing Type

3

24

route.seg_left

Segments Left

4

32

route.data

Type-Specific Data


class pcapkit.protocols.internet.ipv6_route.IPv6_Route(file=None, length=None, **kwargs)[source]

Bases: Internet[IPv6_Route]

This class implements Routing Header for IPv6.

This class currently supports parsing of the following Routing Header for IPv6 routing data types, which are registered in the self.__routing__ attribute:

Routing Code

Data Parser

Source_Route

_read_data_type_src()

Type_2_Routing_Header

_read_data_type_2()

RPL_Source_Route_Header

_read_data_type_rpl()

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, *, extension: bool = False, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
Keyword Arguments
  • extension – If the protocol is used as an IPv6 extension header.

  • **kwargs – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Routing Header for IPv6']

Name of current protocol.

Return type

Literal[‘Routing Header for IPv6’]

property alias: Literal['IPv6-Route']

Acronym of corresponding protocol.

Return type

Literal[‘IPv6-Route’]

property length: int

Header length of current protocol.

Return type

int

property payload: Protocol | NoReturn

Payload of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

Return type

pcapkit.protocols.protocol.Protocol

property protocol: Optional[str] | NoReturn

Name of next layer protocol (if any).

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protochain: ProtoChain | NoReturn

Protocol chain of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

read(length=None, *, extension=False, **kwargs)[source]

Read Routing Header for IPv6.

Structure of IPv6-Route header [RFC 8200][RFC 5095]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |  Routing Type | Segments Left |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                       type-specific data                      .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the packet is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

IPv6_Route

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

classmethod register_routing(code, meth)[source]

Register an routing data parser.

Parameters
  • code (RegType_Routing) – IPv6-Route data type code.

  • meth (str | TypeParser) – Method name or callable to parse the data.

Return type

None

_read_data_type_none(length)[source]

Read IPv6-Route unknown type data.

Structure of IPv6-Route unknown type data [RFC 8200][RFC 5095]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |  Routing Type | Segments Left |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                       type-specific data                      .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters

length (int) – route data length

Return type

UnknownType

Returns

Parsed route data.

_read_data_type_src(length)[source]

Read IPv6-Route Source Route data.

Structure of IPv6-Route Source Route data [RFC 5095]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  | Routing Type=0| Segments Left |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Reserved                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                           Address[1]                          +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                           Address[2]                          +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
.                               .                               .
.                               .                               .
.                               .                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                           Address[n]                          +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters

length (int) – route data length

Return type

SourceRoute

Returns

Parsed route data.

_read_data_type_2(length)[source]

Read IPv6-Route Type 2 data.

Structure of IPv6-Route Type 2 data [RFC 6275]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  | Hdr Ext Len=2 | Routing Type=2|Segments Left=1|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Reserved                           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                         Home Address                          +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters

length (int) – route data length

Return type

Type2

Returns

Parsed route data.

Raises

ProtocolError – If length is NOT 20.

_read_data_type_rpl(length)[source]

Read IPv6-Route RPL Source data.

Structure of IPv6-Route RPL Source data [RFC 6554]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  | Routing Type  | Segments Left |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| CmprI | CmprE |  Pad  |               Reserved                |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
.                                                               .
.                        Addresses[1..n]                        .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters

length (int) – route data length

Return type

RPL

Returns

Parsed route data.

Raises

ProtocolError – If length is NOT 20.

Data Structures
class pcapkit.protocols.data.internet.ipv6_route.IPv6_Route(next, length, type, seg_left)[source]

Bases: Info

Data model for IPv6-Route protocol.

See also

The type-specific routing data is stored directly in the top-level IPv6_Route object. Please refer to the RoutingType subclasses for the details.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

next: TransType

Next header.

length: int

Header extension length.

type: Routing

Routing type.

seg_left: int

Segments left.

class pcapkit.protocols.data.internet.ipv6_route.RoutingType[source]

Bases: Info

Data model for Routing Type.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.internet.ipv6_route.UnknownType(data)[source]

Bases: RoutingType

Data model for IPv6-Route unknown type.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Data.

class pcapkit.protocols.data.internet.ipv6_route.SourceRoute(ip)[source]

Bases: RoutingType

Data model for IPv6-Route Source Route data type.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ip: tuple[IPv6Address, ...]

Source addresses.

class pcapkit.protocols.data.internet.ipv6_route.Type2(ip)[source]

Bases: RoutingType

Data model for IPv6-Route Type 2 data type.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ip: IPv6Address

Address.

class pcapkit.protocols.data.internet.ipv6_route.RPL(cmpr_i, cmpr_e, pad, ip)[source]

Bases: RoutingType

Data model for RPL Source data type.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

cmpr_i: int

CmprI.

cmpr_e: int

CmprE.

pad: int

Pad.

ip: tuple[IPv6Address, ...]

IPv6 addresses.


*

https://en.wikipedia.org/wiki/IPv6_packet#Routing

HOPOPT - IPv6 Hop-by-Hop Options

pcapkit.protocols.internet.hopopt contains HOPOPT only, which implements extractor for IPv6 Hop-by-Hop Options header (HOPOPT) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

hopopt.next

Next Header

1

8

hopopt.length

Header Extensive Length

2

16

hopopt.options

Options


class pcapkit.protocols.internet.hopopt.HOPOPT(file=None, length=None, **kwargs)[source]

Bases: Internet[HOPOPT]

This class implements IPv6 Hop-by-Hop Options.

This class currently supports parsing of the following IPv6 Hop-by-Hop options, which are registered in the self.__option__ attribute:

Option Code

Option Parser

Pad1

_read_opt_pad()

PadN

_read_opt_pad()

Tunnel_Encapsulation_Limit

_read_opt_tun()

Router_Alert

_read_opt_ra()

CALIPSO

_read_opt_calipso()

SMF_DPD

_read_opt_smf_dpd()

PDM

_read_opt_pdm()

Quick_Start

_read_opt_qs()

RPL_Option_0x63

_read_opt_rpl()

MPL_Option

_read_opt_mpl()

ILNP_Nonce

_read_opt_ilnp()

Line_Identification_Option

_read_opt_lio()

Jumbo_Payload

_read_opt_jumbo()

Home_Address

_read_opt_home()

IP_DFF

_read_opt_ip_dff()

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, *, extension: bool = False, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['IPv6 Hop-by-Hop Options']

Name of current protocol.

Return type

Literal[“IPv6 Hop-by-Hop Options”]

property length: int

Header length of current protocol.

Return type

int

property payload: Protocol | NoReturn

Payload of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

Return type

pcapkit.protocols.protocol.Protocol

property protocol: Optional[str] | NoReturn

Name of next layer protocol (if any).

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protochain: ProtoChain | NoReturn

Protocol chain of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

Return type

ProtoChain | NoReturn

read(length=None, *, extension=False, **kwargs)[source]

Read IPv6 Hop-by-Hop Options.

Structure of HOPOPT header [RFC 8200]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               +
|                                                               |
.                                                               .
.                            Options                            .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the packet is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

HOPOPT

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

classmethod register_option(code, meth)[source]

Register an option parser.

Parameters
  • code (RegType_Option) – HOPOPT option code.

  • meth (str | OptionParser) – Method name or callable to parse the option.

Return type

None

_read_opt_type(kind)[source]

Read option type field.

Parameters

kind (int) – option kind value

Returns

Extracted HOPOPT option type field information (unknown option action and change flag), c.f. [RFC 8200#section-4.2].

Return type

tuple[int, bool]

_read_hopopt_options(length)[source]

Read HOPOPT options.

Positional arguments:

length: length of options

Return type

Option

Returns

Extracted HOPOPT options

Raises

ProtocolError – If the threshold is NOT matching.

Parameters

length (int) –

_read_opt_none(code, acts, cflg, *, options)[source]

Read HOPOPT unassigned options.

Structure of HOPOPT unassigned options [RFC 8200]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
|  Option Type  |  Opt Data Len |  Option Data
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_UnassignedOption

Returns

Parsed option data.

_read_opt_pad(code, acts, cflg, *, options)[source]

Read HOPOPT padding options.

Structure of HOPOPT padding options [RFC 8200]:

  • Pad1 option:

    +-+-+-+-+-+-+-+-+
    |       0       |
    +-+-+-+-+-+-+-+-+
    
  • PadN option:

    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
    |       1       |  Opt Data Len |  Option Data
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- - - - - - - - -
    
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_PadOption

Returns

Parsed option data.

Raises

ProtocolError – If code is NOT 0 or 1.

_read_opt_tun(code, acts, cflg, *, options)[source]

Read HOPOPT Tunnel Encapsulation Limit option.

Structure of HOPOPT Tunnel Encapsulation Limit option [RFC 2473]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |Hdr Ext Len = 0| Opt Type = 4  |Opt Data Len=1 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Tun Encap Lim |PadN Opt Type=1|Opt Data Len=1 |       0       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_TunnelEncapsulationLimitOption

Returns

Parsed option data.

Raises

ProtocolError – If hopopt.tun.length is NOT 1.

_read_opt_ra(code, acts, cflg, *, options)[source]

Read HOPOPT Router Alert option.

Structure of HOPOPT Router Alert option [RFC 2711]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|0 0 0|0 0 1 0 1|0 0 0 0 0 0 1 0|        Value (2 octets)       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_RouterAlertOption

Returns

Parsed option data.

Raises

ProtocolError – If hopopt.tun.length is NOT 2.

_read_opt_calipso(code, acts, cflg, *, options)[source]

Read HOPOPT Common Architecture Label IPv6 Security Option (CALIPSO) option.

Structure of HOPOPT CALIPSO option [RFC 5570]:

------------------------------------------------------------
| Next Header | Hdr Ext Len   | Option Type | Option Length|
+-------------+---------------+-------------+--------------+
|             CALIPSO Domain of Interpretation             |
+-------------+---------------+-------------+--------------+
| Cmpt Length |  Sens Level   |     Checksum (CRC-16)      |
+-------------+---------------+-------------+--------------+
|      Compartment Bitmap (Optional; variable length)      |
+-------------+---------------+-------------+--------------+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_CALIPSOOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

_read_opt_smf_dpd(code, acts, cflg, *, options)[source]

Read HOPOPT Simplified Multicast Forwarding Duplicate Packet Detection (SMF_DPD) option.

Structure of HOPOPT SMF_DPD option [RFC 6621]:

  • IPv6 SMF_DPD option header in I-DPD (Identification-Based DPD) mode

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                   ...              |0|0|0|  01000  | Opt. Data Len |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |0|TidTy| TidLen|             TaggerID (optional) ...           |
    +-+-+-+-+-+-+-+-+               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                               |            Identifier  ...
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
  • IPv6 SMF_DPD option header in H-DPD (Hash-Based) mode

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                   ...              |0|0|0| OptType | Opt. Data Len |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |1|    Hash Assist Value (HAV) ...
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_SMFIdentificationBasedDPDOption | DataType_SMFHashBasedDPDOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

_read_opt_pdm(code, acts, cflg, *, options)[source]

Read HOPOPT Performance and Diagnostic Metrics (PDM) option.

Structure of HOPOPT PDM option [RFC 8250]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Option Type  | Option Length |    ScaleDTLR  |     ScaleDTLS |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   PSN This Packet             |  PSN Last Received            |
|-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Delta Time Last Received    |  Delta Time Last Sent         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_PDMOption

Returns

Parsed option data.

Raises

ProtocolError – If hopopt.pdm.length is NOT 10.

_read_opt_qs(code, acts, cflg, *, options)[source]

Read HOPOPT Quick Start option.

Structure of HOPOPT Quick-Start option [RFC 4782]:

  • A Quick-Start Request:

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |   Option      |  Length=6     | Func. | Rate  |   QS TTL      |
    |               |               | 0000  |Request|               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                        QS Nonce                           | R |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
  • Report of Approved Rate:

     0                   1                   2                   3
     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |   Option      |  Length=6     | Func. | Rate  |   Not Used    |
    |               |               | 1000  | Report|               |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    |                        QS Nonce                           | R |
    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
    
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_QuickStartOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

_read_opt_rpl(code, acts, cflg, *, options)[source]

Read HOPOPT Routing Protocol for Low-Power and Lossy Networks (RPL) option.

Structure of HOPOPT RPL option [RFC 6553]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  |  Opt Data Len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|O|R|F|0|0|0|0|0| RPLInstanceID |          SenderRank           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         (sub-TLVs)                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_RPLOption

Returns

Parsed option data.

Raises

ProtocolError – If hopopt.rpl.length is NOT 4.

_read_opt_mpl(code, acts, cflg, *, options)[source]

Read HOPOPT Multicast Protocol for Low-Power and Lossy Networks (MPL) option.

Structure of HOPOPT MPL option [RFC 7731]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  |  Opt Data Len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| S |M|V|  rsv  |   sequence    |      seed-id (optional)       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_MPLOption

Returns

Parsed option data.

Raises

ProtocolError – If the option is malformed.

_read_opt_ilnp(code, acts, cflg, *, options)[source]

Read HOPOPT Identifier-Locator Network Protocol (ILNP) Nonce option.

Structure of HOPOPT ILNP Nonce option [RFC 6744]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header   | Hdr Ext Len   |  Option Type  | Option Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                         Nonce Value                           /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_ILNPOption

Returns

Parsed option data.

_read_opt_lio(code, acts, cflg, *, options)[source]

Read HOPOPT Line-Identification option.

Structure of HOPOPT Line-Identification option [RFC 6788]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  | Option Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| LineIDLen     |     Line ID...
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_LineIdentificationOption

Returns

Parsed option data.

_read_opt_jumbo(code, acts, cflg, *, options)[source]

Read HOPOPT Jumbo Payload option.

Structure of HOPOPT Jumbo Payload option [RFC 2675]:

                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  |  Opt Data Len |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Jumbo Payload Length                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_JumboPayloadOption

Returns

Parsed option data.

Raises

ProtocolError – If hopopt.jumbo.length is NOT 4.

_read_opt_home(code, acts, cflg, *, options)[source]

Read HOPOPT Home Address option.

Structure of HOPOPT Home Address option [RFC 6275]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |  Option Type  | Option Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                                                               +
|                                                               |
+                          Home Address                         +
|                                                               |
+                                                               +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_HomeAddressOption

Returns

Parsed option data.

Raises

ProtocolError – If hopopt.jumbo.length is NOT 16.

_read_opt_ip_dff(code, acts, cflg, *, options)[source]

Read HOPOPT Depth-First Forwarding (IP_DFF) option.

Structure of HOPOPT IP_DFF option [RFC 6971]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |  Hdr Ext Len  |  OptTypeDFF   | OptDataLenDFF |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|VER|D|R|0|0|0|0|        Sequence Number        |      Pad1     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (RegType_Option) – option type value

  • acts (int) – unknown option action value

  • cflg (bool) – change flag value

  • options (Option) – extracted HOPOPT options

Return type

DataType_IPDFFOption

Returns

Parsed option data.

Raises

ProtocolError – If hopopt.ip_dff.length is NOT 2.

__option__: DefaultDict[int, str | OptionParser]

Option code to method mapping, c.f. _read_hopopt_options(). Method names are expected to be referred to the class by _read_opt_${name}, and if such name not found, the value should then be a method that can parse the option by itself.

Type

DefaultDict[RegType_Option, str | OptionParser]

Data Structures
class pcapkit.protocols.data.internet.hopopt.HOPOPT(next, length, options)[source]

Bases: Info

Data model for HOPOPT protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

next: TransType

Next header.

length: int

Header extension length.

options: OrderedMultiDict[RegType_Option, Option]

HOPOPT options.

class pcapkit.protocols.data.internet.hopopt.Option(type, action, change, length)[source]

Bases: Info

Data model for HOPOPT option data.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: RegType_Option

Option type.

action: int

Unknown option cation.

change: bool

Change flag.

length: int

Content length.

class pcapkit.protocols.data.internet.hopopt.UnassignedOption(type, action, change, length, data)[source]

Bases: Option

Data model for HOPOPT unassigned option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Option data.

class pcapkit.protocols.data.internet.hopopt.PadOption(type, action, change, length)[source]

Bases: Option

Data model for HOPOPT padding options.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.internet.hopopt.TunnelEncapsulationLimitOption(type, action, change, length, limit)[source]

Bases: Option

Data model for HOPOPT tunnel encapsulation limit option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

limit: int

Tunnel encapsulation limit.

class pcapkit.protocols.data.internet.hopopt.RouterAlertOption(type, action, change, length, value)[source]

Bases: Option

Data model for HOPOPT router alter option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

value: RouterAlert

Router alter value.

class pcapkit.protocols.data.internet.hopopt.CALIPSOOption(type, action, change, length, domain, cmpt_len, level, checksum)[source]

Bases: Option

Data model for HOPOPT Common Architecture Label IPv6 Security Option (CALIPSO) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

domain: int

CALIPSO domain of interpretation.

cmpt_len: int

Compartment length.

level: int

Sensitivity level.

checksum: bytes

Checksum.

cmpt_bitmap: tuple[int, ...]

Compartment bitmap.

class pcapkit.protocols.data.internet.hopopt.SMFDPDOption(type, action, change, length, dpd_type, tid_type)[source]

Bases: Option

Data model for HOPOPT Simplified Multicast Forwarding Duplicate Packet Detection (SMF_DPD) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

dpd_type: SMFDPDMode

DPD type.

tid_type: TaggerID

TaggerID type.

class pcapkit.protocols.data.internet.hopopt.SMFIdentificationBasedDPDOption(type, action, change, length, pdm_type, tid_type, tid_len, tid, id)[source]

Bases: SMFDPDOption

Data model for HOPOPT I-DPD (Identification-Based DPD) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

tid_len: int

TaggerID length.

tid: Optional[int | IPv4Address | IPv6Address]

TaggerID.

id: int

Identifier.

class pcapkit.protocols.data.internet.hopopt.SMFHashBasedDPDOption(type, action, change, length, pdm_type, tid_type, hav)[source]

Bases: SMFDPDOption

Data model for HOPOPT H-DPD (Hash-Based DPD) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

hav: bytes

Hash assist value.

class pcapkit.protocols.data.internet.hopopt.PDMOption(type, action, change, length, scaledtlr, scaledtls, psntp, psnlr, deltatlr, deltatls)[source]

Bases: Option

Data model for HOPOPT Performance Diagnostic Metrics (PDM) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

scaledtlr: timedelta

Scale delta time last received.

scaledtls: timedelta

Scale delta time last sent.

psntp: int

Packet sequence number this packet.

psnlr: int

Packet sequence number last received.

deltatlr: timedelta

Delta time last received.

deltatls: timedelta

Delta time last sent.

class pcapkit.protocols.data.internet.hopopt.QuickStartOption(type, action, change, length, func, rate, ttl, nounce)[source]

Bases: Option

Data model for HOPOPT Quick Start option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

func: QSFunction

QS function.

rate: int

Rate request/report.

ttl: Optional[timedelta]

TTL.

nounce: int

Nounce.

class pcapkit.protocols.data.internet.hopopt.RPLOption(type, action, change, length, flags, id, rank)[source]

Bases: Option

Data model for HOPOPT Routing Protocol for Low-Power and Lossy Networks (RPL) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: RPLFlags

Flags.

id: int

RPL instance ID.

rank: int

Sender rank.

class pcapkit.protocols.data.internet.hopopt.RPLFlags(down, rank_err, fwd_err)[source]

Bases: Info

Data model for HOPOPT RPL option flags fields.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

down: bool

Down flag.

rank_err: bool

Rank error flag.

fwd_err: bool

Forwarding error flag.

class pcapkit.protocols.data.internet.hopopt.MPLOption(type, action, change, length, seed_type, flags, seq, seed_id)[source]

Bases: Option

Data model for HOPOPT Multicast Protocol for Low-Power and Lossy Networks (MPL) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

seed_type: SeedID

Seed length.

flags: MPLFlags

Flags.

seq: int

Sequence number.

seed_id: Optional[int]

Seed ID.

class pcapkit.protocols.data.internet.hopopt.MPLFlags(max, verification)[source]

Bases: Info

Data model for HOPOPT MPL option flags fields.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

max: bool

Max flag.

verification: bool

Verification flag.

class pcapkit.protocols.data.internet.hopopt.ILNPOption(type, action, change, length, nounce)[source]

Bases: Option

Data model for HOPOPT Identifier-Locator Network Protocol (ILNP) Nonce option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

nounce: bytes

Nonce value.

class pcapkit.protocols.data.internet.hopopt.LineIdentificationOption(type, action, change, length, line_id_len, line_id)[source]

Bases: Option

Data model for HOPOPT Line-Identification option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

line_id_len: int

Line ID length.

line_id: int

Line ID.

class pcapkit.protocols.data.internet.hopopt.JumboPayloadOption(type, action, change, length, payload_len)[source]

Bases: Option

Data model for Jumbo Payload option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

payload_len: int

Jumbo payload length.

class pcapkit.protocols.data.internet.hopopt.HomeAddressOption(type, action, change, length, address)[source]

Bases: Option

Data model for HOPOPT Home Address option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

address: IPv6Address

Home address.

class pcapkit.protocols.data.internet.hopopt.IPDFFOption(type, action, change, length, version, flags, seq)[source]

Bases: Option

Data model for HOPOPT Depth-First Forwarding (IP_DFF) option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

version: int

Version.

flags: DFFFlags

Flags.

seq: int

Sequence number.

class pcapkit.protocols.data.internet.hopopt.DFFFlags(dup, ret)[source]

Bases: Info

Data model for HOPOPT IP_DFF option flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

dup: bool

Duplicate flag.

ret: bool

Return flag.


*

https://en.wikipedia.org/wiki/IPv6_packet#Hop-by-hop_options_and_destination_options

IPsec - Internet Protocol Security

pcapkit.protocols.internet.ipsec contains IPsec only, which is a base class for Internet Protocol Security (IPsec) protocol family *, eg. AH and ESP .

class pcapkit.protocols.internet.ipsec.IPsec(file=None, length=None, **kwargs)[source]

Bases: Internet[PT], Generic[PT]

Abstract base class for IPsec protocol family.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

classmethod id()[source]

Index ID of the protocol.

Returns

Index ID of the protocol.

Return type

tuple[Literal[“AH”], Literal[“ESP”]]


*

https://en.wikipedia.org/wiki/IPsec

ESP class is currently NOT implemented.

AH - Authentication Header

pcapkit.protocols.internet.ah contains AH only, which implements extractor for Authentication Header (AH) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

ah.next

Next Header

1

8

ah.length

Payload Length

2

16

Reserved (must be zero)

4

32

sah.spi

Security Parameters Index (SPI)

8

64

sah.seq

Sequence Number Field

12

96

sah.icv

Integrity Check Value (ICV)


class pcapkit.protocols.internet.ah.AH(file=None, length=None, **kwargs)[source]

Bases: IPsec[AH]

This class implements Authentication Header.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, *, version: Literal[4, 6] = 4, extension: bool = False, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • version (Literal[4, 6]) – IP protocol version.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Authentication Header']

Name of corresponding protocol.

Return type

Literal[‘Authentication Header’]

property length: int

Header length of current protocol.

Return type

int

property payload: Protocol | NoReturn

Payload of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protocol: Optional[str] | NoReturn

Name of next layer protocol (if any).

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protochain: ProtoChain | NoReturn

Protocol chain of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

read(length=None, *, version=4, extension=False, **kwargs)[source]

Read Authentication Header.

Structure of AH header [RFC 4302]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header   |  Payload Len  |          RESERVED             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Security Parameters Index (SPI)               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Sequence Number Field                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
+                Integrity Check Value-ICV (variable)           |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • version (Literal[4, 6]) – IP protocol version.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

AH

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

classmethod id()[source]

Index ID of the protocol.

Returns

Index ID of the protocol.

Return type

tuple[Literal[“AH”]]

Data Structures
class pcapkit.protocols.data.internet.ah.AH(next, length, spi, seq, icv)[source]

Bases: Info

Data model for AH protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

next: TransType

Next header.

length: int

Payload length.

spi: int

Security parameters index.

seq: int

Sequence number field.

icv: bytes

Integrity check value.


*

https://en.wikipedia.org/wiki/IPsec

HIP - Host Identity Protocol

pcapkit.protocols.internet.hip contains HIP only, which implements extractor for Host Identity Protocol (HIP) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

hip.next

Next Header

1

8

hip.length

Header Length

2

16

Reserved (\x00)

2

17

hip.type

Packet Type

3

24

hip.version

Version

3

28

Reserved

3

31

Reserved (\x01)

4

32

hip.chksum

Checksum

6

48

hip.control

Controls

8

64

hip.shit

Sender’s Host Identity Tag

24

192

hip.rhit

Receiver’s Host Identity Tag

40

320

hip.parameters

HIP Parameters


class pcapkit.protocols.internet.hip.HIP(file=None, length=None, **kwargs)[source]

Bases: Internet[HIP]

This class implements Host Identity Protocol.

This class currently supports parsing of the following HIP parameters, which are directly mapped to the pcapkit.const.hip.parameter.Parameter enumeration:

Parameter Code

Parameter Parser

ESP_INFO

_read_param_esp_info()

R1_COUNTER

_read_param_r1_counter()

LOCATOR_SET

_read_param_locator_set()

PUZZLE

_read_param_puzzle()

SOLUTION

_read_param_solution()

SEQ

_read_param_seq()

ACK

_read_param_ack()

DH_GROUP_LIST

_read_param_dh_group_list()

DIFFIE_HELLMAN

_read_param_diffie_hellman()

HIP_TRANSFORM

_read_param_hip_transform()

HIP_CIPHER

_read_param_hip_cipher()

NAT_TRAVERSAL_MODE

_read_param_nat_traversal_mode()

TRANSACTION_PACING

_read_param_transaction_pacing()

ENCRYPTED

_read_param_encrypted()

HOST_ID

_read_param_host_id()

HIT_SUITE_LIST

_read_param_hit_suite_list()

CERT

_read_param_cert()

NOTIFICATION

_read_param_notification()

ECHO_REQUEST_SIGNED

_read_param_echo_request_signed()

REG_INFO

_read_param_reg_info()

REG_REQUEST

_read_param_reg_request()

REG_RESPONSE

_read_param_reg_response()

REG_FAILED

_read_param_reg_failed()

REG_FROM

_read_param_reg_from()

ECHO_RESPONSE_SIGNEED

_read_param_echo_response_signed()

TRANSPORT_FORMAT_LIST

_read_param_transport_format_list()

ESP_TRANSFORM

_read_param_esp_transform()

SEQ_DATA

_read_param_seq_data()

ACK_DATA

_read_param_ack_data()

PAYLOAD_MIC

_read_param_payload_mic()

TRANSACTION_ID

_read_param_transaction_id()

OVERLAY_ID

_read_param_overlay_id()

ROUTE_DST

_read_param_route_dst()

HIP_TRANSPORT_MODE

_read_param_hip_transport_mode()

HIP_MAC

_read_param_hip_mac()

HIP_MAC_2

_read_param_hip_mac_2()

HIP_SIGNATURE_2

_read_param_hip_signature_2()

HIP_SIGNATURE

_read_param_hip_signature()

ECHO_REQUEST_UNSIGNED

_read_param_echo_request_unsigned()

ECHO_RESPONSE_UNSIGNED

_read_param_echo_response_unsigned()

RELAY_FROM

_read_param_relay_from()

RELAY_TO

_read_param_relay_to()

OVERLAY_TTL

_read_param_overlay_ttl()

ROUTE_VIA

_read_param_route_via()

FROM

_read_param_from()

RVS_HMAC

_read_param_rvs_hmac()

VIA_RVS

_read_param_via_rvs()

RELAY_HMAC

_read_param_relay_hmac()

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, *, extension: bool = False, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Host Identity Protocol']

Name of current protocol.

Return type

Literal[“Host Identity Protocol”]

property alias: str

Acronym of corresponding protocol.

Return type

str

property length: int

Header length of current protocol.

Return type

int

property payload: Protocol | NoReturn

Payload of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

Return type

pcapkit.protocols.protocol.Protocol

property protocol: Optional[str] | NoReturn

Name of next layer protocol (if any).

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protochain: ProtoChain | NoReturn

Protocol chain of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

Return type

ProtoChain | NoReturn

read(length=None, *, extension=False, **kwargs)[source]

Read Host Identity Protocol.

Structure of HIP header [RFC 5201][RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Next Header   | Header Length |0| Packet Type |Version| RES.|1|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Checksum             |           Controls            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                Sender's Host Identity Tag (HIT)               |
|                                                               |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|               Receiver's Host Identity Tag (HIT)              |
|                                                               |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
/                        HIP Parameters                         /
/                                                               /
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • extension (bool) – If the packet is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

HIP

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

_read_hip_param(length, *, version)[source]

Read HIP parameters.

Parameters
  • length (int) – length of parameters

  • version (int) – HIP version

Return type

Parameter

Returns

Extracted HIP parameters.

Raises

ProtocolError – if packet length threshold check failed

_read_param_unassigned(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP unassigned parameters.

Structure of HIP unassigned parameters [RFC 5201][RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type            |C|             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
/                          Contents                             /
/                                               +-+-+-+-+-+-+-+-+
|                                               |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_UnassignedParameter

Returns

Parsed parameter data.

_read_param_esp_info(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ESP_INFO parameter.

Structure of HIP ESP_INFO parameter [RFC 7402]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Reserved            |         KEYMAT Index          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            OLD SPI                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            NEW SPI                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_ESPInfoParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 12.

_read_param_r1_counter(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP R1_COUNTER parameter.

Structure of HIP R1_COUNTER parameter [RFC 5201][RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Reserved, 4 bytes                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                R1 generation counter, 8 bytes                 |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_R1CounterParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 12 or the parameter is NOT used in HIPv1.

_read_param_locator_set(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP LOCATOR_SET parameter.

Structure of HIP LOCATOR_SET parameter [RFC 8046]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |            Length             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Traffic Type   | Locator Type | Locator Length | Reserved   |P|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Locator Lifetime                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Locator                            |
|                                                               |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
.                                                               .
.                                                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Traffic Type   | Locator Type | Locator Length | Reserved   |P|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Locator Lifetime                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Locator                            |
|                                                               |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_LocatorSetParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If locator data is malformed.

_read_param_puzzle(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP PUZZLE parameter.

Structure of HIP PUZZLE parameter [RFC 5201][RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  #K, 1 byte   |    Lifetime   |        Opaque, 2 bytes        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      Random #I, RHASH_len / 8 bytes           |
/                                                               /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_PuzzleParameter

Returns

Parsed parameter data.

Raises

ProtocolError – The parameter is ONLY supported in HIPv1.

_read_param_solution(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP SOLUTION parameter.

Structure of HIP SOLUTION parameter [RFC 5201][RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  #K, 1 byte   |    Lifetime   |        Opaque, 2 bytes        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                      Random #I, n bytes                       |
/                                                               /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Puzzle solution #J, RHASH_len / 8 bytes            |
/                                                               /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_SolutionParameter

Returns

Parsed parameter data.

Raises

ProtocolError – The parameter is ONLY supported in HIPv1.

_read_param_seq(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP SEQ parameter.

Structure of HIP SEQ parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Update ID                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_SEQParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 4.

_read_param_ack(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ACK parameter.

Structure of HIP ACK parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       peer Update ID 1                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                       peer Update ID n                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_ACKParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 4 modulo.

_read_param_dh_group_list(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP DH_GROUP_LIST parameter.

Structure of HIP DH_GROUP_LIST parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| DH GROUP ID #1| DH GROUP ID #2| DH GROUP ID #3| DH GROUP ID #4|
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| DH GROUP ID #n|                Padding                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_DHGroupListParameter

Returns

Parsed parameter data.

_read_param_diffie_hellman(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP DIFFIE_HELLMAN parameter.

Structure of HIP DIFFIE_HELLMAN parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Group ID    |      Public Value Length      | Public Value  /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                               |            Padding            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_DeffieHellmanParameter

Returns

Parsed parameter data.

_read_param_hip_transform(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP HIP_TRANSFORM parameter.

Structure of HIP HIP_TRANSFORM parameter [RFC 5201]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Suite ID #1        |          Suite ID #2          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|            Suite ID #n        |             Padding           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_HIPTransformParameter

Returns

Parsed parameter data.

Raises

ProtocolError – The parameter is ONLY supported in HIPv1.

_read_param_hip_cipher(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP HIP_CIPHER parameter.

Structure of HIP HIP_CIPHER parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Cipher ID #1         |          Cipher ID #2         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Cipher ID #n         |             Padding           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_HIPCipherParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT a 2 modulo.

_read_param_nat_traversal_mode(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP NAT_TRAVERSAL_MODE parameter.

Structure of HIP NAT_TRAVERSAL_MODE parameter [RFC 5770]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Reserved            |            Mode ID #1         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Mode ID #2          |            Mode ID #3         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Mode ID #n          |             Padding           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_NATTraversalModeParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT a 2 modulo.

_read_param_transaction_pacing(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP TRANSACTION_PACING parameter.

Structure of HIP TRANSACTION_PACING parameter [RFC 5770]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                            Min Ta                             |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_TransactionPacingParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 4.

_read_param_encrypted(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ENCRYPTED parameter.

Structure of HIP ENCRYPTED parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           Reserved                            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                              IV                               /
/                                                               /
/                               +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               /
/                        Encrypted data                         /
/                                                               /
/                               +-------------------------------+
/                               |            Padding            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_EncryptedParameter

Returns

Parsed parameter data.

_read_param_host_id(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP HOST_ID parameter.

Structure of HIP HOST_ID parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          HI Length            |DI-Type|      DI Length        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Algorithm            |         Host Identity         /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                               |       Domain Identifier       /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                                               |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_HostIDParameter

Returns

Parsed parameter data.

_read_param_hit_suite_list(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP HIT_SUITE_LIST parameter.

Structure of HIP HIT_SUITE_LIST parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     ID #1     |     ID #2     |     ID #3     |     ID #4     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     ID #n     |                Padding                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_HITSuiteParameter

Returns

Parsed parameter data.

_read_param_cert(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP CERT parameter.

Structure of HIP CERT parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  CERT group   |  CERT count   |    CERT ID    |   CERT type   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                          Certificate                          /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                               |   Padding (variable length)   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_CertParameter

Returns

Parsed parameter data.

_read_param_notification(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP NOTIFICATION parameter.

Structure of HIP NOTIFICATION parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Reserved             |      Notify Message Type      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               /
/                   Notification Data                           /
/                                               +---------------+
/                                               |     Padding   |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_NotificationParameter

Returns

Parsed parameter data.

_read_param_echo_request_signed(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ECHO_REQUEST_SIGNED parameter.

Structure of HIP ECHO_REQUEST_SIGNED parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Opaque data (variable length)                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_EchoRequestSignedParameter

Returns

Parsed parameter data.

_read_param_reg_info(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP REG_INFO parameter.

Structure of HIP REG_INFO parameter [RFC 8003]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Min Lifetime  | Max Lifetime  |  Reg Type #1  |  Reg Type #2  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      ...      |     ...       |  Reg Type #n  |               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    Padding    +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RegInfoParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If the registration type is invalid.

_read_param_reg_request(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP REG_REQUEST parameter.

Structure of HIP REG_REQUEST parameter [RFC 8003]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Lifetime    |  Reg Type #1  |  Reg Type #2  |  Reg Type #3  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      ...      |     ...       |  Reg Type #n  |               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    Padding    +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RegRequestParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If the registration type is invalid.

_read_param_reg_response(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP REG_RESPONSE parameter.

Structure of HIP REG_RESPONSE parameter [RFC 8003]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Lifetime    |  Reg Type #1  |  Reg Type #2  |  Reg Type #3  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      ...      |     ...       |  Reg Type #n  |               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    Padding    +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RegResponseParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If the registration type is invalid.

_read_param_reg_failed(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP REG_FAILED parameter.

Structure of HIP REG_FAILED parameter [RFC 8003]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Lifetime    |  Reg Type #1  |  Reg Type #2  |  Reg Type #3  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|      ...      |     ...       |  Reg Type #n  |               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+    Padding    +
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RegFailedParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If the registration type is invalid.

_read_param_reg_from(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP REG_FROM parameter.

Structure of HIP REG_FROM parameter [RFC 5770]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Port              |    Protocol   |     Reserved  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                            Address                            |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RegFromParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 20.

_read_param_echo_response_signed(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ECHO_RESPONSE_SIGNED parameter.

Structure of HIP ECHO_RESPONSE_SIGNED parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Opaque data (variable length)                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_EchoResponseSignedParameter

Returns

Parsed parameter data.

_read_param_transport_format_list(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP TRANSPORT_FORMAT_LIST parameter.

Structure of HIP TRANSPORT_FORMAT_LIST parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          TF type #1           |           TF type #2          /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/          TF type #n           |             Padding           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_TransportFormatListParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 2 modulo.

_read_param_esp_transform(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ESP_TRANSFORM parameter.

Structure of HIP ESP_TRANSFORM parameter [RFC 7402]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Reserved             |           Suite ID #1         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Suite ID #2          |           Suite ID #3         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Suite ID #n          |             Padding           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_ESPTransformParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 2 modulo.

_read_param_seq_data(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP SEQ_DATA parameter.

Structure of HIP SEQ_DATA parameter [RFC 6078]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_SeqDataParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 4.

_read_param_ack_data(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ACK_DATA parameter.

Structure of HIP ACK_DATA parameter [RFC 6078]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                     Acked Sequence number                     /
/                                                               /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_AckDataParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 4 modulo.

_read_param_payload_mic(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP PAYLOAD_MIC parameter.

Structure of HIP PAYLOAD_MIC parameter [RFC 6078]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Next Header  |                   Reserved                    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                         Payload Data                          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
/                         MIC Value                             /
/                                               +-+-+-+-+-+-+-+-+
|                                               |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_PayloadMICParameter

Returns

Parsed parameter data.

_read_param_transaction_id(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP TRANSACTION_ID parameter.

Structure of HIP TRANSACTION_ID parameter [RFC 6078]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           Identifier                          /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                                               |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_TransactionIDParameter

Returns

Parsed parameter data.

_read_param_overlay_id(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP OVERLAY_ID parameter.

Structure of HIP OVERLAY_ID parameter [RFC 6079]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                           Identifier                          /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                                               |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_OverlayIDParameter

Returns

Parsed parameter data.

_read_param_route_dst(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ROUTE_DST parameter.

Structure of HIP ROUTE_DST parameter [RFC 6028]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Flags             |            Reserved           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                            HIT #1                             |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
.                               .                               .
.                               .                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                            HIT #n                             |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RouteDstParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If the parameter is malformed.

_read_param_hip_transport_mode(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP HIP_TRANSPORT_MODE parameter.

Structure of HIP HIP_TRANSPORT_MODE parameter [RFC 6261]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Port              |           Mode ID #1          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Mode ID #2           |           Mode ID #3          |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Mode ID #n           |             Padding           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_HIPTransportModeParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 2 modulo.

_read_param_hip_mac(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP HIP_MAC parameter.

Structure of HIP HIP_MAC parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                             HMAC                              |
/                                                               /
/                               +-------------------------------+
|                               |            Padding            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_HIPMACParameter

Returns

Parsed parameter data.

_read_param_hip_mac_2(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP HIP_MAC_2 parameter.

Structure of HIP HIP_MAC_2 parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                             HMAC                              |
/                                                               /
/                               +-------------------------------+
|                               |            Padding            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_HIPMAC2Parameter

Returns

Parsed parameter data.

_read_param_hip_signature_2(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP HIP_SIGNATURE_2 parameter.

Structure of HIP HIP_SIGNATURE_2 parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    SIG alg                    |            Signature          /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                               |             Padding           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_HIPSignature2Parameter

Returns

Parsed parameter data.

_read_param_hip_signature(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP HIP_SIGNATURE parameter.

Structure of HIP HIP_SIGNATURE parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    SIG alg                    |            Signature          /
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
/                               |             Padding           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_HIPSignatureParameter

Returns

Parsed parameter data.

_read_param_echo_request_unsigned(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ECHO_REQUEST_UNSIGNED parameter.

Structure of HIP ECHO_REQUEST_UNSIGNED parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Opaque data (variable length)                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_EchoRequestUnsignedParameter

Returns

Parsed parameter data.

_read_param_echo_response_unsigned(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ECHO_RESPONSE_UNSIGNED parameter.

Structure of HIP ECHO_RESPONSE_UNSIGNED parameter [RFC 7401]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                 Opaque data (variable length)                 |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_EchoResponseUnsignedParameter

Returns

Parsed parameter data.

_read_param_relay_from(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP RELAY_FROM parameter.

Structure of HIP RELAY_FROM parameter [RFC 5770]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Port              |    Protocol   |     Reserved  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                            Address                            |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RelayFromParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 20.

_read_param_relay_to(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP RELAY_TO parameter.

Structure of HIP RELAY_TO parameter [RFC 5770]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Port              |    Protocol   |     Reserved  |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                            Address                            |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RelayToParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 20.

_read_param_overlay_ttl(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP OVERLAY_TTL parameter.

Structure of HIP OVERLAY_TTL parameter [RFC 6078]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             TTL               |            Reserved           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_OverlayTTLParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 4.

_read_param_route_via(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP ROUTE_VIA parameter.

Structure of HIP ROUTE_VIA parameter [RFC 6028]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Flags             |            Reserved           |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                            HIT #1                             |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
.                               .                               .
.                               .                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                            HIT #n                             |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RouteViaParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If the parameter is malformed.

_read_param_from(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP FROM parameter.

Structure of HIP FROM parameter [RFC 8004]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                             Address                           |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_FromParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 16.

_read_param_rvs_hmac(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP RVS_HMAC parameter.

Structure of HIP RVS_HMAC parameter [RFC 8004]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                             HMAC                              |
/                                                               /
/                               +-------------------------------+
|                               |            Padding            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RVSHMACParameter

Returns

Parsed parameter data.

_read_param_via_rvs(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP VIA_RVS parameter.

Structure of HIP VIA_RVS parameter [RFC 6028]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|             Type              |             Length            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                            Address                            |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
.                               .                               .
.                               .                               .
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                            Address                            |
|                                                               |
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_ViaRVSParameter

Returns

Parsed parameter data.

Raises

ProtocolError – If clen is NOT 16 modulo.

_read_param_relay_hmac(code, cbit, clen, *, desc, length, version, options)[source]

Read HIP RELAY_HMAC parameter.

Structure of HIP RELAY_HMAC parameter [RFC 5770]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
|                             HMAC                              |
/                                                               /
/                               +-------------------------------+
|                               |            Padding            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • code (int) – parameter code

  • cbit (bool) – critical bit

  • clen (int) – length of contents

  • desc (RegType_Parameter) – parameter type

  • length (int) – remaining packet length

  • version (int) – HIP protocol version

  • options (Parameter) – parsed HIP parameters

Return type

DataType_RelayHMACParameter

Returns

Parsed parameter data.

Data Structures
class pcapkit.protocols.data.internet.hip.HIP(next, length, type, version, chksum, control, shit, rhit)[source]

Bases: Info

Data model for HIP header.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

next: TransType

Next header.

length: int

Header length.

type: Packet

Packet type.

version: int

Version.

chksum: bytes

Checksum.

control: Control

Control

shit: int

Sender’s host identity tag.

rhit: int

Receiver’s host identity tag.

parameters: OrderedMultiDict[RegType_Parameter, Parameter]

HIP parameters.

class pcapkit.protocols.data.internet.hip.Control(anonymous)[source]

Bases: Info

Data model for HIP controls.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

anonymous: bool

Anonymous flag.

class pcapkit.protocols.data.internet.hip.Parameter(type, critical, length)[source]

Bases: Info

Data model for HIP parameter data.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: RegType_Parameter

Parameter type.

critical: bool

Critical flag.

length: int

Content length.

class pcapkit.protocols.data.internet.hip.UnassignedParameter(type, critical, length, contents)[source]

Bases: Parameter

Data model for unassigned parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

contents: bytes

Content.

class pcapkit.protocols.data.internet.hip.ESPInfoParameter(type, critical, length, index, old_spi, new_spi)[source]

Bases: Parameter

Data model for HIP ESP_INFO parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

index: int

KEYMAT index.

old_spi: int

Old SDI.

new_spi: int

New SDI.

class pcapkit.protocols.data.internet.hip.R1CounterParameter(type, critical, length, counter)[source]

Bases: Parameter

Data model for HIP R1_COUNTER parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

counter: int

R1 counter.

class pcapkit.protocols.data.internet.hip.LocatorSetParameter(type, critical, length, locator_set)[source]

Bases: Parameter

Data model for HIP LOCATOR_SET parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

locator_set: tuple[Locator, ...]

Locator set.

class pcapkit.protocols.data.internet.hip.Locator(traffic, type, length, preferred, lifetime, locator)[source]

Bases: Info

Data model for HIP locator.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

traffic: int

Traffic.

type: int

Locator type.

length: int

Locator length.

preferred: bool

Preferred flag.

lifetime: timedelta

Locator lifetime.

locator: LocatorData | IPv4Address

Locator data.

class pcapkit.protocols.data.internet.hip.LocatorData(spi, ip)[source]

Bases: Info

Data model for HIP locator data.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

spi: int

SPI.

ip: IPv4Address

IP address.

class pcapkit.protocols.data.internet.hip.PuzzleParameter(type, critical, length, index, lifetime, opaque, random)[source]

Bases: Parameter

Data model for HIP PUZZLE parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

index: int

Numeric index.

lifetime: timedelta

Lifetime.

opaque: bytes

Puzzle data.

random: int

Random number.

class pcapkit.protocols.data.internet.hip.SolutionParameter(type, critical, length, index, lifetime, opaque, random, solution)[source]

Bases: Parameter

Data model for HIP SOLUTION parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

index: int

Numeric index.

lifetime: timedelta

Lifetime.

opaque: bytes

Solution data.

random: int

Random number.

solution: int

Puzzle solution.

class pcapkit.protocols.data.internet.hip.SEQParameter(type, critical, length, id)[source]

Bases: Parameter

Data model for HIP SEQ parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

id: int

Unique ID.

class pcapkit.protocols.data.internet.hip.ACKParameter(type, critical, length, update_id)[source]

Bases: Parameter

Data model for HIP ACK parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

update_id: tuple[int, ...]

Peer update IDs.

class pcapkit.protocols.data.internet.hip.DHGroupListParameter(type, critical, length, group_id)[source]

Bases: Parameter

Data model for HIP DH_GROUP_LIST parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

group_id: tuple[Group, ...]

DH group list.

class pcapkit.protocols.data.internet.hip.DeffieHellmanParameter(type, critical, length, group_id, pub_len, pub_val)[source]

Bases: Parameter

Data model for HIP DEFFIE_HELLMAN parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

group_id: Group

Group ID.

pub_len: int

Public value length.

pub_val: bytes

Public value.

class pcapkit.protocols.data.internet.hip.HIPTransformParameter(type, critical, length, suite_id)[source]

Bases: Parameter

Data model for HIP HIP_TRANSFORM parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

suite_id: tuple[Suite, ...]

Suite IDs.

class pcapkit.protocols.data.internet.hip.HIPCipherParameter(type, critical, length, cipher_id)[source]

Bases: Parameter

Data model for HIP HIP_CIPHER parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

cipher_id: tuple[Cipher, ...]

Cipher IDs.

class pcapkit.protocols.data.internet.hip.NATTraversalModeParameter(type, critical, length, mode_id)[source]

Bases: Parameter

Data model for HIP NAT_TRAVERSAL_MODE parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

mode_id: tuple[NATTraversal, ...]

Mode IDs

class pcapkit.protocols.data.internet.hip.TransactionPacingParameter(type, critical, length, min_ta)[source]

Bases: Parameter

Data model for HIP TRANSACTION_PACING parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

min_ta: int

Min TA.

class pcapkit.protocols.data.internet.hip.EncryptedParameter(type, critical, length, raw)[source]

Bases: Parameter

Data model for HIP ENCRYPTED parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

raw: bytes

Raw data.

class pcapkit.protocols.data.internet.hip.HostIDParameter(type, critical, length, hi_len, di_type, di_len, algorithm, hi, di)[source]

Bases: Parameter

Data model for HIP HOST_ID parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

hi_len: int

Host identity length.

di_type: DITypes

Domain identifier type.

di_len: int

Domain identifier length.

algorithm: HIAlgorithm

Algorithm type.

hi: HostIdentity | bytes

Host identity.

di: bytes

Domain identifier.

class pcapkit.protocols.data.internet.hip.HostIdentity(curve, pubkey)[source]

Bases: Info

Data model for host identity.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

curve: ECDSACurve | ECDSALowCurve

Curve type.

pubkey: bytes

Public key.

class pcapkit.protocols.data.internet.hip.HITSuiteListParameter(type, critical, length, suite_id)[source]

Bases: Parameter

Data model for HIP HIST_SUITE_LIST parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

suite_id: tuple[HITSuite, ...]

Suite IDs.

class pcapkit.protocols.data.internet.hip.CertParameter(type, critical, length, cert_group, cert_count, cert_id, cert_type, cert)[source]

Bases: Parameter

Data model for HIP CERT parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

cert_group: Group

Certificate group.

cert_count: int

Certificate count.

cert_id: int

Certificate ID.

cert_type: Certificate

Certificate type.

cert: bytes

Certificate.

class pcapkit.protocols.data.internet.hip.NotificationParameter(type, critical, length, msg_type, msg)[source]

Bases: Parameter

Data model for HIP NOTIFICATION parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

msg_type: NotifyMessage

Notify message type.

msg: bytes

Notification data.

class pcapkit.protocols.data.internet.hip.EchoRequestSignedParameter(type, critical, length, opaque)[source]

Bases: Parameter

Data model for HIP ECHO_REQUEST_SIGNED parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

opaque: bytes

Opaque data.

class pcapkit.protocols.data.internet.hip.RegInfoParameter(type, critical, length, lifetime, reg_type)[source]

Bases: Parameter

Data model for HIP REG_INFO parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

lifetime: Lifetime

Registration lifetime.

reg_type: tuple[Registration, ...]

Registration type.

class pcapkit.protocols.data.internet.hip.Lifetime(min, max)[source]

Bases: Info

Data model for registration lifetime.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

min: timedelta

Minimum lifetime.

max: timedelta

Maximum lifetime.

class pcapkit.protocols.data.internet.hip.RegRequestParameter(type, critical, length, lifetime, reg_type)[source]

Bases: Parameter

Data model for HIP REG_REQUEST parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

lifetime: Lifetime

Registration lifetime.

reg_type: tuple[Registration, ...]

Registration type.

class pcapkit.protocols.data.internet.hip.RegResponseParameter(type, critical, length, lifetime, reg_type)[source]

Bases: Parameter

Data model for HIP REG_RESPONSE parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

lifetime: Lifetime

Registration lifetime.

reg_type: tuple[Registration, ...]

Registration type.

class pcapkit.protocols.data.internet.hip.RegFailedParameter(type, critical, length, lifetime, reg_type)[source]

Bases: Parameter

Data model for HIP REG_FAILED parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

lifetime: Lifetime

Registration lifetime.

reg_type: tuple[RegistrationFailure, ...]

Registration failure type.

class pcapkit.protocols.data.internet.hip.RegFromParameter(type, critical, length, port, protocol, address)[source]

Bases: Parameter

Data model for HIP REG_FROM parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

port: int

Port.

protocol: TransType

Protocol.

address: IPv6Address

Address.

class pcapkit.protocols.data.internet.hip.EchoResponseSignedParameter(type, critical, length, opaque)[source]

Bases: Parameter

Data model for HIP ECHO_RESPONSE_SIGNED parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

opaque: bytes

Opaque data.

class pcapkit.protocols.data.internet.hip.TransportFormatListParameter(type, critical, length, tf_type)[source]

Bases: Parameter

Data model for HIP TRANSPORT_FORMAT_LIST parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

tf_type: tuple[int, ...]

Transport format list.

class pcapkit.protocols.data.internet.hip.ESPTransformParameter(type, critical, length, suite_id)[source]

Bases: Parameter

Data model for HIP ESP_TRANSFORM parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

suite_id: tuple[ESPTransformSuite, ...]

ESP transform.

class pcapkit.protocols.data.internet.hip.SeqDataParameter(type, critical, length, seq)[source]

Bases: Parameter

Data model for HIP SEQ_DATA parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

seq: int

Sequence number.

class pcapkit.protocols.data.internet.hip.AckDataParameter(type, critical, length, ack)[source]

Bases: Parameter

Data model for HIP ACK_DATA parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ack: tuple[int, ...]

Acknowledged sequence number.

class pcapkit.protocols.data.internet.hip.PayloadMICParameter(type, critical, length, next, payload, mic)[source]

Bases: Parameter

Data model for HIP PAYLOAD_MIC parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

next: TransType

Next header

payload: bytes

Payload data.

mic: bytes

MIC value.

class pcapkit.protocols.data.internet.hip.TransactionIDParameter(type, critical, length, id)[source]

Bases: Parameter

Data model for HIP TRANSACTION_ID parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

id: int

Identifier.

class pcapkit.protocols.data.internet.hip.OverlayIDParameter(type, critical, length, id)[source]

Bases: Parameter

Data mode HIP OVERLAY_ID parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

id: int

Identifier.

class pcapkit.protocols.data.internet.hip.RouteDstParameter(type, critical, length, flags, hit)[source]

Bases: Parameter

Data model for HIP ROUTE_DST parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: Flags

Flags.

hit: tuple[IPv6Address, ...]

Destination address.

class pcapkit.protocols.data.internet.hip.Flags(symmetric, must_follow)[source]

Bases: Info

Data model for flags in HIP HIP_PARAMETER_FLAGS parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

symmetric: bool

Symmetric flag.

must_follow: bool

Must follow flag.

class pcapkit.protocols.data.internet.hip.HIPTransportModeParameter(type, critical, length, port, mode_id)[source]

Bases: Parameter

Data model for HIP HIP_TRANSPORT_MODE parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

port: int

Port.

mode_id: tuple[Transport, ...]

Mode IDs.

class pcapkit.protocols.data.internet.hip.HIPMACParameter(type, critical, length, hmac)[source]

Bases: Parameter

Data model for HIP HIP_MAC parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

hmac: bytes

HMAC value.

class pcapkit.protocols.data.internet.hip.HIPMAC2Parameter(type, critical, length, hmac)[source]

Bases: Parameter

Data model for HIP HIP_MAC_2 parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

hmac: bytes

HMAC value.

class pcapkit.protocols.data.internet.hip.HIPSignature2Parameter(type, critical, length, algorithm, signature)[source]

Bases: Parameter

Data model for HIP HIP_SIGNATURE_2 parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

algorithm: HIAlgorithm

Signature algorithm.

signature: bytes

Signature value.

class pcapkit.protocols.data.internet.hip.HIPSignatureParameter(type, critical, length, algorithm, signature)[source]

Bases: Parameter

Data model for HIP HIP_SIGNATURE parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

algorithm: HIAlgorithm

Signature algorithm.

signature: bytes

Signature value.

class pcapkit.protocols.data.internet.hip.EchoRequestUnsignedParameter(type, critical, length, opaque)[source]

Bases: Parameter

Data model for HIP ECHO_REQUEST_UNSIGNED parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

opaque: bytes

Opaque data.

class pcapkit.protocols.data.internet.hip.EchoResponseUnsignedParameter(type, critical, length, opaque)[source]

Bases: Parameter

Data model for HIP ECHO_RESPONSE_UNSIGNED parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

opaque: bytes

Opaque data.

class pcapkit.protocols.data.internet.hip.RelayFromParameter(type, critical, length, port, protocol, address)[source]

Bases: Parameter

Data model for HIP RELAY_FROM parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

port: int

Port.

protocol: TransType

Protocol.

address: IPv6Address

Address.

class pcapkit.protocols.data.internet.hip.RelayToParameter(type, critical, length, port, protocol, address)[source]

Bases: Parameter

Data model for HIP RELAY_TO parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

port: int

Port.

protocol: TransType

Protocol.

address: IPv6Address

Address.

class pcapkit.protocols.data.internet.hip.OverlayTTLParameter(type, critical, length, ttl)[source]

Bases: Parameter

Data model for HIP OVERLAY_TTL parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ttl: timedelta

TTL value.

class pcapkit.protocols.data.internet.hip.RouteViaParameter(type, critical, length, flags, hit)[source]

Bases: Parameter

Data model for HIP ROUTE_VIA parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: Flags

Flags.

hit: tuple[IPv6Address, ...]

HIT addresses.

class pcapkit.protocols.data.internet.hip.FromParameter(type, critical, length, address)[source]

Bases: Parameter

Data model for HIP FROM parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

address: IPv6Address

HIT address.

class pcapkit.protocols.data.internet.hip.RVSHMACParameter(type, critical, length, hmac)[source]

Bases: Parameter

Data model for HIP RVS_HMAC parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

hmac: bytes

HMAC value.

class pcapkit.protocols.data.internet.hip.ViaRVSParameter(type, critical, length, address)[source]

Bases: Parameter

Data model for HIP VIA_RVS parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

address: tuple[IPv6Address, ...]

Addresses.

class pcapkit.protocols.data.internet.hip.RelayHMACParameter(type, critical, length, hmac)[source]

Bases: Parameter

Data model for HIP RELAY_HMAC parameter.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

hmac: bytes

HMAC value.


*

https://en.wikipedia.org/wiki/Host_Identity_Protocol

MH - Mobility Header

pcapkit.protocols.internet.mh contains MH only, which implements extractor for Mobility Header (MH) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

mh.next

Next Header

1

8

mh.length

Header Length

2

16

mh.type

Mobility Header Type

3

24

Reserved

4

32

mh.chksum

Checksum

6

48

mh.data

Message Data


Todo

Implements extractor for message data of all MH types.

class pcapkit.protocols.internet.mh.MH(file=None, length=None, **kwargs)[source]

Bases: Internet[MH]

This class implements Mobility Header.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, *, version: Literal[4, 6] = 4, extension: bool = False, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • version (Literal[4, 6]) – IP protocol version.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction argument, please refer to make().

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Mobility Header']

Name of current protocol.

Return type

Literal[‘Mobility Header’]

property length: int

Header length of current protocol.

Return type

int

property payload: Protocol | NoReturn

Payload of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protocol: Optional[str] | NoReturn

Name of next layer protocol (if any).

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

property protochain: ProtoChain | NoReturn

Protocol chain of current instance.

Raises

UnsupportedCall – if the protocol is used as an IPv6 extension header

read(length=None, *, version=4, extension=False, **kwargs)[source]

Read Mobility Header.

Structure of MH header [RFC 6275]:

+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Payload Proto |  Header Len   |   MH Type     |   Reserved    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+                               |
|                                                               |
.                                                               .
.                       Message Data                            .
.                                                               .
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • version (Literal[4, 6]) – IP protocol version.

  • extension (bool) – If the protocol is used as an IPv6 extension header.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

MH

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

Data Structures
class pcapkit.protocols.data.internet.mh.MH(next, length, type, chksum, data)[source]

Bases: Info

Data model for MH protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

next: TransType

Next header.

length: int

Header length.

type: Packet

Mobility header type.

chksum: bytes

Checksum.

data: bytes

Message data.


*

https://en.wikipedia.org/wiki/Mobile_IP#Changes_in_IPv6_for_Mobile_IPv6

IPX - Internetwork Packet Exchange

pcapkit.protocols.internet.ipx contains IPX only, which implements extractor for Internetwork Packet Exchange (IPX) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

ipx.cksum

Checksum

2

16

ipx.len

Packet Length (header includes)

4

32

ipx.count

Transport Control (hop count)

5

40

ipx.type

Packet Type

6

48

ipx.dst

Destination Address

18

144

ipx.src

Source Address


class pcapkit.protocols.internet.ipx.IPX(file=None, length=None, **kwargs)[source]

Bases: Internet[IPX]

This class implements Internetwork Packet Exchange.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Internetwork Packet Exchange']

Name of corresponding protocol.

Return type

Literal[‘Internetwork Packet Exchange’]

property length: Literal[30]

Header length of corresponding protocol.

Return type

Literal[30]

property protocol: TransType

Name of next layer protocol.

Return type

TransType

property src: str

Source IPX address.

Return type

str

property dst: str

Destination IPX address.

Return type

str

read(length=None, **kwargs)[source]

Read Internetwork Packet Exchange.

Args:

length: Length of packet data. **kwargs: Arbitrary keyword arguments.

Returns

Parsed packet data.

Return type

DataType_IPX

Parameters
make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

_read_ipx_address()[source]

Read IPX address field.

Return type

Address

Returns

Parsed IPX address field.

Data Structures
class pcapkit.protocols.data.internet.ipx.IPX(chksum, len, count, type, dst, src)[source]

Bases: Info

Data model for Internetwork Packet Exchange.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

chksum: bytes

Checksum.

len: int

Packet length (header includes).

count: int

Transport control (hop count).

type: Packet

Packet type.

dst: Address

Destination Address.

src: Address

Source Address.

class pcapkit.protocols.data.internet.ipx.Address(network, node, socket, addr)[source]

Bases: Info

Data model for IPX address.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

network: str

Network number (: separated).

node: str

Node number (- separated).

socket: Socket

Socket number (: separated).

addr: str

Full address (: separated).


*

https://en.wikipedia.org/wiki/Internetwork_Packet_Exchange

Todo

Implements ECN, ESP, ICMP, ICMPv6, IGMP, Shim6.

Protocol Registry
pcapkit.protocols.internet.ETHERTYPE

Alias of pcapkit.const.reg.ethertype.EtherType.

Transport Layer Protocols

pcapkit.protocols.transport is collection of all protocols in transport layer, with detailed implementation and methods.

Base Protocol

pcapkit.protocols.transport.transport contains Transport, which is a base class for transport layer protocols, eg. TCP and UDP.

class pcapkit.protocols.transport.transport.Transport(file=None, length=None, **kwargs)[source]

Bases: Protocol[PT], Generic[PT]

Abstract base class for transport layer protocol family.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

property layer: Literal['Transport']

Protocol layer.

Return type

Literal[‘Transport’]

classmethod register(code, module, class_)[source]

Register a new protocol class.

Important

This method must be called from a non-abstract class, as the protocol map should be associated directly with specific transport layer protocol type.

Parameters
  • code (int) – port number

  • module (str) – module name

  • class – class name

  • class_ (str) –

Return type

None

Notes

The full qualified class name of the new protocol class should be as {module}.{class_}.

Return type

None

Parameters
  • code (int) –

  • module (str) –

  • class_ (str) –

classmethod analyze(ports, payload, **kwargs)[source]

Analyse packet payload.

Parameters
  • ports (tuple[int, int]) – Source & destination port numbers.

  • payload (bytes) – Packet payload.

  • **kwargs (Any) – Arbitrary keyword arguments.

Returns

Parsed payload as a Protocol instance.

Return type

Protocol

_decode_next_layer(dict_, ports, length=None)[source]

Decode next layer protocol.

The method will check if the next layer protocol is supported based on the source and destination port numbers. We will use the lower port number from both ports as the primary key to lookup the next layer.

Parameters
  • dict – info buffer

  • ports (tuple[int, int]) – source & destination port numbers

  • length (Optional[int]) – valid (non-padding) length

  • dict_ (PT) –

Returns

Current protocol with next layer extracted.

Return type

PT

__layer__: Optional[Literal['Link', 'Internet', 'Transport', 'Application']] = 'Transport'

Layer of protocol.

__proto__: DefaultDict[int, tuple[str, str]]

Protocol index mapping for decoding next layer, c.f. self._decode_next_layer & self._import_next_layer.

Important

The attribute must be defined and maintained in subclass.

TCP - Transmission Control Protocol

pcapkit.protocols.transport.tcp contains TCP only, which implements extractor for Transmission Control Protocol (TCP) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

tcp.srcport

Source Port

2

16

tcp.dstport

Destination Port

4

32

tcp.seq

Sequence Number

8

64

tcp.ack

Acknowledgement Number (if ACK set)

12

96

tcp.hdr_len

Data Offset

12

100

Reserved (must be \x00)

12

103

tcp.flags.ns

ECN Concealment Protection (NS)

13

104

tcp.flags.cwr

Congestion Window Reduced (CWR)

13

105

tcp.flags.ece

ECN-Echo (ECE)

13

106

tcp.flags.urg

Urgent (URG)

13

107

tcp.flags.ack

Acknowledgement (ACK)

13

108

tcp.flags.psh

Push Function (PSH)

13

109

tcp.flags.rst

Reset Connection (RST)

13

110

tcp.flags.syn

Synchronize Sequence Numbers (SYN)

13

111

tcp.flags.fin

Last Packet from Sender (FIN)

14

112

tcp.window_size

Size of Receive Window

16

128

tcp.checksum

Checksum

18

144

tcp.urgent_pointer

Urgent Pointer (if URG set)

20

160

tcp.opt

TCP Options (if data offset > 5)


class pcapkit.protocols.transport.tcp.TCP(file=None, length=None, **kwargs)[source]

Bases: Transport[TCP]

This class implements Transmission Control Protocol.

This class currently supports parsing of the following protocols, which are registered in the self.__proto__ attribute:

Port Number

Protocol

21

pcapkit.protocols.application.ftp.FTP

80

pcapkit.protocols.application.http.HTTP

This class currently supports parsing of the following TCP options, which are directly mapped to the pcapkit.const.tcp.option.Option enumeration:

Option Code

Option Parser

End_of_Option_List

_read_mode_eool()

No_Operation

_read_mode_nop()

Maximum_Segment_Size

_read_mode_mss()

Window_Scale

_read_mode_ws()

SACK_Permitted

_read_mode_sackpmt()

SACK

_read_mode_sack()

Echo

_read_mode_echo()

Echo_Reply

_read_mode_echore()

Timestamps

_read_mode_ts()

Partial_Order_Connection_Permitted

_read_mode_poc()

Partial_Order_Service_Profile

_read_mode_pocsp()

CC

_read_mode_cc()

CC_NEW

_read_mode_ccnew()

CC_ECHO

_read_mode_ccecho()

TCP_Alternate_Checksum_Request

_read_mode_chkreq()

TCP_Alternate_Checksum_Data

_read_mode_chksum()

MD5_Signature_Option

_read_mode_sig()

Quick_Start_Response

_read_mode_qs()

User_Timeout_Option

_read_mode_timeout()

TCP_Authentication_Option

_read_mode_ao()

Multipath_TCP

_read_mode_mp()

TCP_Fast_Open_Cookie

_read_mode_fastopen()

This class currently supports parsing of the following Multipath TCP options, which are directly mapped to the pcapkit.const.tcp.mp_tcp_option.MPTCPOption enumeration:

Option Code

Option Parser

MP_CAPABLE

_read_mptcp_capable()

MP_JOIN

_read_mptcp_join()

DSS

_read_mptcp_dss()

ADD_ADDR

_read_mptcp_addaddr()

REMOVE_ADDR

_read_mptcp_remove()

MP_PRIO

_read_mptcp_prio()

MP_FAIL

_read_mptcp_fail()

MP_FASTCLOSE

_read_mptcp_fastclose()

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['Transmission Control Protocol']

Name of current protocol.

Return type

Literal[“Transmission Control Protocol”]

property length: int

Header length of current protocol.

Return type

int

property src: int

Source port.

Return type

int

property dst: int

Destination port.

Return type

int

read(length=None, **kwargs)[source]

Read Transmission Control Protocol (TCP).

Structure of TCP header [RFC 793]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Source Port          |       Destination Port        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                        Sequence Number                        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   Acknowledgement Number                      |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Data |           |U|A|P|R|S|F|                               |
| Offset| Reserved  |R|C|S|S|Y|I|            Window             |
|       |           |G|K|H|T|N|N|                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|           Checksum            |         Urgent Pointer        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Options                    |    Padding    |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                             data                              |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

TCP

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

classmethod register_option(code, meth)[source]

Register an option parser.

Parameters
  • code (RegType_Option) – TCP option code.

  • meth (str | OptionParser) – Method name or callable to parse the option.

Return type

None

classmethod register_mp_option(code, meth)[source]

Register an MPTCP option parser.

Parameters
  • code (RegType_MPTCPOption) – MPTCP option code.

  • meth (str | MPOptionParser) – Method name or callable to parse the option.

Return type

None

_read_tcp_options(size)[source]

Read TCP option list.

Parameters

size (int) – length of option list

Return type

Option

Returns

Extracted TCP options.

Raises

ProtocolError – If the threshold is NOT matching.

_read_mode_donone(kind, *, options)[source]

Read options request no process.

Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_UnassignedOption

Returns

Parsed option data.

_read_mode_eool(kind, *, options)[source]

Read TCP End of Option List option.

Structure of TCP end of option list option [RFC 793]:

+--------+
|00000000|
+--------+
 Kind=0
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_EndOfOptionList

Returns

Parsed option data.

_read_mode_nop(kind, *, options)[source]

Read TCP No Operation option.

Structure of TCP maximum segment size option [RFC 793]:

+--------+
|00000001|
+--------+
 Kind=1
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_NoOperation

Returns

Parsed option data.

_read_mode_mss(kind, *, options)[source]

Read TCP max segment size option.

Structure of TCP maximum segment size option [RFC 793]:

+--------+--------+---------+--------+
|00000010|00000100|   max seg size   |
+--------+--------+---------+--------+
 Kind=2   Length=4
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_MaximumSegmentSize

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 4.

_read_mode_ws(kind, *, options)[source]

Read TCP windows scale option.

Structure of TCP window scale option [RFC 7323]:

+---------+---------+---------+
| Kind=3  |Length=3 |shift.cnt|
+---------+---------+---------+
     1         1         1
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_WindowScale

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 3.

_read_mode_sackpmt(kind, *, options)[source]

Read TCP SACK permitted option.

Structure of TCP SACK permitted option [RFC 2018]:

+---------+---------+
| Kind=4  | Length=2|
+---------+---------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_SACKPermitted

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 2.

_read_mode_sack(kind, *, options)[source]

Read TCP SACK option.

Structure of TCP SACK option [RFC 2018]:

                  +--------+--------+
                  | Kind=5 | Length |
+--------+--------+--------+--------+
|      Left Edge of 1st Block       |
+--------+--------+--------+--------+
|      Right Edge of 1st Block      |
+--------+--------+--------+--------+
|                                   |
/            . . .                  /
|                                   |
+--------+--------+--------+--------+
|      Left Edge of nth Block       |
+--------+--------+--------+--------+
|      Right Edge of nth Block      |
+--------+--------+--------+--------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_SACK

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 8.

_read_mode_echo(kind, *, options)[source]

Read TCP echo option.

Structure of TCP echo option [RFC 1072]:

+--------+--------+--------+--------+--------+--------+
| Kind=6 | Length |   4 bytes of info to be echoed    |
+--------+--------+--------+--------+--------+--------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_Echo

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 6.

_read_mode_echore(kind, *, options)[source]

Read TCP echo reply option.

Structure of TCP echo reply option [RFC 1072]:

+--------+--------+--------+--------+--------+--------+
| Kind=7 | Length |    4 bytes of echoed info         |
+--------+--------+--------+--------+--------+--------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_EchoReply

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 6.

_read_mode_ts(kind, *, options)[source]

Read TCP timestamps option.

Structure of TCP timestamp option [RFC 7323]:

+-------+-------+---------------------+---------------------+
|Kind=8 |  10   |   TS Value (TSval)  |TS Echo Reply (TSecr)|
+-------+-------+---------------------+---------------------+
    1       1              4                     4
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_Timestamp

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 10.

_read_mode_poc(kind, *, options)[source]

Read TCP partial order connection service profile option.

Structure of TCP POC-Permitted option [RFC 1693][RFC 6247]:

+-----------+-------------+
|  Kind=9   |  Length=2   |
+-----------+-------------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_PartialOrderConnectionPermitted

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 2.

_read_mode_pocsp(kind, *, options)[source]

Read TCP partial order connection service profile option.

Structure of TCP POC-SP option [RFC 1693][RFC 6247]:

                          1 bit        1 bit    6 bits
+----------+----------+------------+----------+--------+
|  Kind=10 | Length=3 | Start_flag | End_flag | Filler |
+----------+----------+------------+----------+--------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_PartialOrderConnectionProfile

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 3.

_read_mode_cc(kind, *, options)[source]

Read TCP connection count option.

Structure of TCP CC option [RFC 1644]:

+--------+--------+--------+--------+--------+--------+
|00001011|00000110|    Connection Count:  SEG.CC      |
+--------+--------+--------+--------+--------+--------+
 Kind=11  Length=6
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_CC

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 6.

_read_mode_ccnew(kind, *, options)[source]

Read TCP connection count (new) option.

Structure of TCP CC.NEW option [RFC 1644]:

+--------+--------+--------+--------+--------+--------+
|00001100|00000110|    Connection Count:  SEG.CC      |
+--------+--------+--------+--------+--------+--------+
 Kind=12  Length=6
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_CCNew

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 6.

_read_mode_ccecho(kind, *, options)[source]

Read TCP connection count (echo) option.

Structure of TCP CC.ECHO option [RFC 1644]:

+--------+--------+--------+--------+--------+--------+
|00001101|00000110|    Connection Count:  SEG.CC      |
+--------+--------+--------+--------+--------+--------+
 Kind=13  Length=6
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_CCEcho

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 6.

_read_mode_chkreq(kind, *, options)[source]

Read Alternate Checksum Request option.

Structure of TCP CHKSUM-REQ [RFC 1146][RFC 6247]:

+----------+----------+----------+
|  Kind=14 | Length=3 |  chksum  |
+----------+----------+----------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_AlternateChecksumRequest

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 3.

_read_mode_chksum(kind, *, options)[source]

Read Alternate Checksum Data option.

Structure of TCP CHKSUM [RFC 1146][RFC 6247]:

+---------+---------+---------+     +---------+
| Kind=15 |Length=N |  data   | ... |  data   |
+---------+---------+---------+     +---------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_AlternateChecksumData

Returns

Parsed option data.

_read_mode_sig(kind, *, options)[source]

Read MD5 Signature option.

Structure of TCP SIG option [RFC 2385]:

+---------+---------+-------------------+
| Kind=19 |Length=18|   MD5 digest...   |
+---------+---------+-------------------+
|                                       |
+---------------------------------------+
|                                       |
+---------------------------------------+
|                                       |
+-------------------+-------------------+
|                   |
+-------------------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_MD5Signature

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 18.

_read_mode_qs(kind, *, options)[source]

Read Quick-Start Response option.

Structure of TCP QSopt [RFC 4782]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|     Kind      |  Length=8     | Resv. | Rate  |   TTL Diff    |
|               |               |       |Request|               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                   QS Nonce                                | R |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_QuickStartResponse

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 8.

_read_mode_timeout(kind, *, options)[source]

Read User Timeout option.

Structure of TCP TIMEOUT [RFC 5482]:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|   Kind = 28   |   Length = 4  |G|        User Timeout         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_UserTimeout

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 4.

_read_mode_ao(kind, *, options)[source]

Read Authentication option.

Structure of TCP AOopt [RFC 5925]:

+------------+------------+------------+------------+
|  Kind=29   |   Length   |   KeyID    | RNextKeyID |
+------------+------------+------------+------------+
|                     MAC           ...
+-----------------------------------...

...-----------------+
...  MAC (con't)    |
...-----------------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_Authentication

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT larger than or equal to 4.

_read_mode_mp(kind, *, options)[source]

Read Multipath TCP option.

Structure of MP-TCP [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----------------------+
|     Kind      |    Length     |Subtype|                       |
+---------------+---------------+-------+                       |
|                     Subtype-specific data                     |
|                       (variable length)                       |
+---------------------------------------------------------------+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_MPTCP

Returns

Parsed option data.

_read_mode_fastopen(kind, *, options)[source]

Read Fast Open option.

Structure of TCP FASTOPEN [RFC 7413]:

                                +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
                                |      Kind     |    Length     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                                                               |
~                            Cookie                             ~
|                                                               |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters
  • kind (RegType_Option) – option kind value

  • options (Option) – extracted TCP options

Return type

DataType_FastOpenCookie

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT valid.

_read_mptcp_unknown(kind, dlen, bits, *, options)[source]

Read unknown MPTCP subtype.

Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPUnknown

Returns

Parsed option data.

_read_mptcp_capable(kind, dlen, bits, *, options)[source]

Read Multipath Capable option.

Structure of MP_CAPABLE [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-------+---------------+
|     Kind      |    Length     |Subtype|Version|A|B|C|D|E|F|G|H|
+---------------+---------------+-------+-------+---------------+
|                   Option Sender's Key (64 bits)               |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
|                  Option Receiver's Key (64 bits)              |
|                     (if option Length == 20)                  |
|                                                               |
+---------------------------------------------------------------+
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPCapable

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 20 or 32.

_read_mptcp_join(kind, dlen, bits, *, options)[source]

Read Join Connection option.

Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPJoin

Returns

Parsed option data.

Raises

ProtocolError – If the option is not given on a valid SYN/ACK packet.

_read_mptcp_dss(kind, dlen, bits, *, options)[source]

Read Data Sequence Signal (Data ACK and Data Sequence Mapping) option.

Structure of DSS [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+----------------------+
|     Kind      |    Length     |Subtype| (reserved) |F|m|M|a|A|
+---------------+---------------+-------+----------------------+
|                                                              |
|           Data ACK (4 or 8 octets, depending on flags)       |
|                                                              |
+--------------------------------------------------------------+
|                                                              |
|   Data sequence number (4 or 8 octets, depending on flags)   |
|                                                              |
+--------------------------------------------------------------+
|              Subflow Sequence Number (4 octets)              |
+-------------------------------+------------------------------+
|  Data-Level Length (2 octets) |      Checksum (2 octets)     |
+-------------------------------+------------------------------+
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPDSS

Returns

Parsed option data.

_read_mptcp_addaddr(kind, dlen, bits, *, options)[source]

Read Add Address option.

Structure of ADD_ADDR [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-------+---------------+
|     Kind      |     Length    |Subtype| IPVer |  Address ID   |
+---------------+---------------+-------+-------+---------------+
|          Address (IPv4 - 4 octets / IPv6 - 16 octets)         |
+-------------------------------+-------------------------------+
|   Port (2 octets, optional)   |
+-------------------------------+
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPAddAddress

Returns

Parsed option data.

Raises

ProtocolError – Invalid IP version and/or addresses.

_read_mptcp_remove(kind, dlen, bits, *, options)[source]

Read Remove Address option.

Structure of REMOVE_ADDR [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-------+---------------+
|     Kind      |  Length = 3+n |Subtype|(resvd)|   Address ID  | ...
+---------------+---------------+-------+-------+---------------+
                           (followed by n-1 Address IDs, if required)
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPRemoveAddress

Returns

Parsed option data.

Raises

ProtocolError – If the length is smaller than 3.

_read_mptcp_prio(kind, dlen, bits, *, options)[source]

Read Change Subflow Priority option.

Structure of MP_PRIO [RFC 6824]:

                      1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----+-+--------------+
|     Kind      |     Length    |Subtype|     |B| AddrID (opt) |
+---------------+---------------+-------+-----+-+--------------+
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPPriority

Returns

Parsed option data.

Raises

ProtocolError – If the length is smaller than 3.

_read_mptcp_fail(kind, dlen, bits, *, options)[source]

Read Fallback option.

Structure of MP_FAIL [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+----------------------+
|     Kind      |   Length=12   |Subtype|      (reserved)      |
+---------------+---------------+-------+----------------------+
|                                                              |
|                 Data Sequence Number (8 octets)              |
|                                                              |
+--------------------------------------------------------------+
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPFallback

Returns

Parsed option data.

Raises

ProtocolError – If the length is NOT 12.

_read_mptcp_fastclose(kind, dlen, bits, *, options)[source]

Read Fast Close option.

Structure of MP_FASTCLOSE [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----------------------+
|     Kind      |    Length     |Subtype|      (reserved)       |
+---------------+---------------+-------+-----------------------+
|                      Option Receiver's Key                    |
|                            (64 bits)                          |
|                                                               |
+---------------------------------------------------------------+
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPFastclose

Returns

Parsed option data.

Raises

ProtocolError – If the length is NOT 16.

_read_join_syn(kind, dlen, bits, *, options)[source]

Read Join Connection option for Initial SYN.

Structure of MP_JOIN-SYN [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----+-+---------------+
|     Kind      |  Length = 12  |Subtype|     |B|   Address ID  |
+---------------+---------------+-------+-----+-+---------------+
|                   Receiver's Token (32 bits)                  |
+---------------------------------------------------------------+
|                Sender's Random Number (32 bits)               |
+---------------------------------------------------------------+
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPJoinSYN

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 12.

_read_join_synack(kind, dlen, bits, *, options)[source]

Read Join Connection option for Responding SYN/ACK.

Structure of MP_JOIN-SYN/ACK [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----+-+---------------+
|     Kind      |  Length = 16  |Subtype|     |B|   Address ID  |
+---------------+---------------+-------+-----+-+---------------+
|                                                               |
|                Sender's Truncated HMAC (64 bits)              |
|                                                               |
+---------------------------------------------------------------+
|                Sender's Random Number (32 bits)               |
+---------------------------------------------------------------+
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPJoinSYNACK

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 20.

_read_join_ack(kind, dlen, bits, *, options)[source]

Read Join Connection option for Third ACK.

Structure of MP_JOIN-ACK [RFC 6824]:

                     1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+---------------+---------------+-------+-----------------------+
|     Kind      |  Length = 24  |Subtype|      (reserved)       |
+---------------+---------------+-------+-----------------------+
|                                                               |
|                                                               |
|                   Sender's HMAC (160 bits)                    |
|                                                               |
|                                                               |
+---------------------------------------------------------------+
Parameters
  • kind (RegType_MPTCPOption) – option kind value

  • dlen (int) – length of remaining data

  • bits (str) – 4-bit data

  • options (Option) – extracted TCP options

Return type

DataType_MPTCPJoinACK

Returns

Parsed option data.

Raises

ProtocolError – If length is NOT 24.

__proto__: DefaultDict[int, tuple[str, str]]

Protocol index mapping for decoding next layer, c.f. self._decode_next_layer & self._import_next_layer.

Type

DefaultDict[int, tuple[str, str]]

__option__: DefaultDict[int, str | OptionParser]

Option code to method mapping, c.f. _read_tcp_options(). Method names are expected to be referred to the class by _read_mode_${name}, and if such name not found, the value should then be a method that can parse the option by itself.

Type

DefaultDict[RegType_Option, str | OptionParser]

__mp_option__: DefaultDict[int, str | MPOptionParser]

Option code to length mapping,

Type

DefaultDict[RegType_MPTCPOption, str | MPOptionParser]

Data Structures
class pcapkit.protocols.data.transport.tcp.TCP(srcport, dstport, seq, ack, hdr_len, flags, window_size, checksum, urgent_pointer)[source]

Bases: Info

Data model for TCP packet.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

srcport: int

Source port.

dstport: int

Destination port.

seq: int

Sequence number.

ack: int

Acknowledgment number.

hdr_len: int

Data offset.

flags: Flags

Flags.

window_size: int

Window size.

checksum: bytes

Checksum.

urgent_pointer: int

Urgent pointer.

options: OrderedMultiDict[OptionNumber, Option]
class pcapkit.protocols.data.transport.tcp.Flags(ns, cwr, ece, urg, ack, psh, rst, syn, fin)[source]

Bases: Info

Data model for TCP flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ns: bool

ECN-nonce concealment protection.

cwr: bool

Congestion window reduced.

ece: bool

ECN-Echo.

urg: bool

Urgent.

ack: bool

Acknowledgment.

psh: bool

Push function.

rst: bool

Reset connection.

syn: bool

Synchronize sequence numbers.

fin: bool

Last packet from sender.

class pcapkit.protocols.data.transport.tcp.Option(kind, length)[source]

Bases: Info

Data model for TCP options.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

kind: OptionNumber

Option kind.

length: int

Option length.

class pcapkit.protocols.data.transport.tcp.UnassignedOption(kind, length, data)[source]

Bases: Option

Data model for unassigned TCP option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Option data.

class pcapkit.protocols.data.transport.tcp.EndOfOptionList(kind, length)[source]

Bases: Option

Data model for TCP end of option list option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.transport.tcp.NoOperation(kind, length)[source]

Bases: Option

Data model for TCP no operation option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.transport.tcp.MaximumSegmentSize(kind, length, mss)[source]

Bases: Option

Data model for TCP maximum segment size option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

mss: int

Maximum segment size.

class pcapkit.protocols.data.transport.tcp.WindowScale(kind, length, shift)[source]

Bases: Option

Data model for TCP window scale option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

shift: int

Window scale.

class pcapkit.protocols.data.transport.tcp.SACKPermitted(kind, length)[source]

Bases: Option

Data model for TCP SACK permitted option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.transport.tcp.SACK(kind, length, sack)[source]

Bases: Option

Data model for TCP SACK option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

sack: tuple[int, ...]

SACK blocks.

class pcapkit.protocols.data.transport.tcp.Echo(kind, length, data)[source]

Bases: Option

Data model for TCP echo option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Echo data.

class pcapkit.protocols.data.transport.tcp.EchoReply(kind, length, data)[source]

Bases: Option

Data model for TCP echo reply option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Echo data.

class pcapkit.protocols.data.transport.tcp.Timestamp(kind, length, timestamp, echo)[source]

Bases: Option

Data model for TCP timestamp option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

timestamp: int

Timestamp .

echo: bytes

Echo data.

class pcapkit.protocols.data.transport.tcp.PartialOrderConnectionPermitted(kind, length)[source]

Bases: Option

Data model for TCP partial order connection permitted option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.transport.tcp.PartialOrderConnectionProfile(kind, length, start, end)[source]

Bases: Option

Data model for TCP partial order connection profile option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

start: bool

Start flag.

end: bool

End flag.

class pcapkit.protocols.data.transport.tcp.CC(kind, length, cc)[source]

Bases: Option

Data model for TCP CC option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

cc: int

Connection count.

class pcapkit.protocols.data.transport.tcp.CCNew(kind, length, cc)[source]

Bases: Option

Data model for TCP CC.NEW option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

cc: int

Connection count.

class pcapkit.protocols.data.transport.tcp.CCEcho(kind, length, cc)[source]

Bases: Option

Data model for TCP CC.ECHO option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

cc: int

Connection count.

class pcapkit.protocols.data.transport.tcp.AlternateChecksumRequest(kind, length, chksum)[source]

Bases: Option

Data model for TCP alternate checksum request option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

chksum: Checksum

Checksum algorithm.

class pcapkit.protocols.data.transport.tcp.AlternateChecksumData(kind, length, data)[source]

Bases: Option

Data model for TCP alternate checksum data option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Checksum data.

class pcapkit.protocols.data.transport.tcp.MD5Signature(kind, length, digest)[source]

Bases: Option

Data model for TCP MD5 signature option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

digest: bytes

MD5 signature.

class pcapkit.protocols.data.transport.tcp.QuickStartResponse(kind, length, req_rate, ttl_diff, nounce)[source]

Bases: Option

Data model for TCP quick start response option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

req_rate: int

Rate request.

ttl_diff: int

TTL difference.

nounce: int

QS nounce.

class pcapkit.protocols.data.transport.tcp.UserTimeout(kind, length, timeout)[source]

Bases: Option

Data model for TCP user timeout option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

timeout: timedelta

User timeout.

class pcapkit.protocols.data.transport.tcp.Authentication(kind, length, key_id, next_key_id, mac)[source]

Bases: Option

Data model for TCP authentication option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

key_id: int

Key ID.

next_key_id: int

Receive next key ID.

mac: bytes

MAC.

class pcapkit.protocols.data.transport.tcp.FastOpenCookie(kind, length, cookie)[source]

Bases: Option

Data model for TCP fast open cookie option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

cookie: bytes

Cookie.

class pcapkit.protocols.data.transport.tcp.MPTCP(kind, length, subtype)[source]

Bases: Option

Data model for TCP MPTCP option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

subtype: MPTCPOption

Subtype.

class pcapkit.protocols.data.transport.tcp.MPTCPUnknown(kind, length, subtype, data)[source]

Bases: MPTCP

Data model for TCP unknown MPTCP option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: bytes

Data.

class pcapkit.protocols.data.transport.tcp.MPTCPCapable(kind, length, subtype, version, flags, skey, rkey)[source]

Bases: MPTCP

Data model for TCP MP_CAPABLE option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

version: int

Version.

flags: MPTCPCapableFlag

Flags.

skey: int

Option sender’s key.

rkey: Optional[int]

Option receiver’s key.

class pcapkit.protocols.data.transport.tcp.MPTCPCapableFlag(req, ext, hsa)[source]

Bases: Info

Data model for TCP MPTCP capable option flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

req: bool

Checksum require flag.

ext: bool

Extensibility flag.

hsa: bool

HMAC-SHA1 flag.

class pcapkit.protocols.data.transport.tcp.MPTCPJoin(kind, length, subtype)[source]

Bases: MPTCP

Data model for TCP MP_JOIN option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.transport.tcp.MPTCPJoinSYN(kind, length, subtype, connection, backup, addr_id, token, nounce)[source]

Bases: MPTCPJoin

Data model for TCP MP_JOIN-SYN option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

connection: Literal['SYN']

Connection type.

backup: bool

Backup path flag.

addr_id: int

Address ID.

token: bytes

Receiver’s token.

nounce: int

Sendder’s random number.

class pcapkit.protocols.data.transport.tcp.MPTCPJoinSYNACK(kind, length, subtype, connection, backup, addr_id, hmac, nounce)[source]

Bases: MPTCPJoin

Data model for TCP MP_JOIN-SYNACK option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

connection: Literal['SYN/ACK']

Connection type.

backup: bool

Backup path flag.

addr_id: int

Address ID.

hmac: bytes

Sender’s truncated HMAC.

nounce: int

Sendder’s random number.

class pcapkit.protocols.data.transport.tcp.MPTCPJoinACK(kind, length, subtype, connection, hmac)[source]

Bases: MPTCPJoin

Data model for TCP MP_JOIN-ACK option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

connection: Literal['ACK']

Connection type.

hmac: bytes
class pcapkit.protocols.data.transport.tcp.MPTCPDSS(kind, length, subtype, flags, ack, dsn, ssn, dl_len, checksum)[source]

Bases: MPTCP

Data model for TCP DSS option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: MPTCPDSSFlag

Flags.

ack: Optional[int]

Data ACK.

dsn: Optional[int]

Data sequence number.

ssn: Optional[int]

Subflow sequence number.

dl_len: Optional[int]

Data-level length.

checksum: Optional[bytes]

Checksum.

class pcapkit.protocols.data.transport.tcp.MPTCPDSSFlag(data_fin, dsn_oct, data_pre, ack_oct, ack_pre)[source]

Bases: Info

Data model for TCP DSS option flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data_fin: bool

DATA_FIN flag.

dsn_oct: bool

Data sequence number is 8 octets (if not set, DSN is 4 octets).

data_pre: bool

Data Sequence Number (DSN), Subflow Sequence Number (SSN), Data-Level Length, and Checksum present.

ack_oct: bool

Data ACK is 8 octets (if not set, Data ACK is 4 octets).

ack_pre: bool

Data ACK present.

class pcapkit.protocols.data.transport.tcp.MPTCPAddAddress(kind, length, subtype, version, addr_id, addr, port)[source]

Bases: MPTCP

Data model for TCP ADD_ADDR option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

version: int

IP version.

addr_id: int

Address ID.

addr: IPAddress

Address.

port: Optional[int]

Port number.

class pcapkit.protocols.data.transport.tcp.MPTCPRemoveAddress(kind, length, subtype, addr_id)[source]

Bases: MPTCP

Data model for TCP REMOVE_ADDR option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

addr_id: tuple[int, ...]

Address ID.

class pcapkit.protocols.data.transport.tcp.MPTCPPriority(kind, length, subtype, backup, addr_id)[source]

Bases: MPTCP

Data model for TCP MP_PRIO option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

backup: bool

Backup path flag.

addr_id: Optional[int]

Address ID.

class pcapkit.protocols.data.transport.tcp.MPTCPFallback(kind, length, subtype, dsn)[source]

Bases: MPTCP

Data model for TCP MP_FAIL option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

dsn: int

Data sequence number.

class pcapkit.protocols.data.transport.tcp.MPTCPFastclose(kind, length, subtype, rkey)[source]

Bases: MPTCP

Data model for TCP MP_FASTCLOSE option.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

rkey: bytes

Option receiver’s key.


*

https://en.wikipedia.org/wiki/Transmission_Control_Protocol

UDP - User Datagram Protocol

pcapkit.protocols.transport.udp contains UDP only, which implements extractor for User Datagram Protocol (UDP) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

udp.srcport

Source Port

2

16

udp.dstport

Destination Port

4

32

udp.len

Length (header includes)

6

48

udp.checksum

Checksum


class pcapkit.protocols.transport.udp.UDP(file=None, length=None, **kwargs)[source]

Bases: Transport[UDP]

This class implements User Datagram Protocol.

This class currently supports parsing of the following protocols, which are registered in the self.__proto__ attribute:

Port Number

Protocol

80

pcapkit.protocols.application.http.HTTP

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

classmethod __index__()[source]

Numeral registry index of the protocol.

Return type

TransType

Returns

Numeral registry index of the protocol in IANA.

property name: Literal['User Datagram Protocol']

Name of current protocol.

Return type

Literal[‘User Datagram Protocol’]

property length: Literal[8]

Header length of current protocol.

Return type

Literal[8]

property src: int

Source port.

Return type

int

property dst: int

Destination port.

Return type

int

read(length=None, **kwargs)[source]

Read User Datagram Protocol (UDP).

Structure of UDP header [RFC 768]:

 0      7 8     15 16    23 24    31
+--------+--------+--------+--------+
|     Source      |   Destination   |
|      Port       |      Port       |
+--------+--------+--------+--------+
|                 |                 |
|     Length      |    Checksum     |
+--------+--------+--------+--------+
|
|          data octets ...
+---------------- ...
Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

UDP

Returns

Parsed packet data.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

__proto__: DefaultDict[int, tuple[str, str]]

Protocol index mapping for decoding next layer, c.f. self._decode_next_layer & self._import_next_layer.

Type

DefaultDict[int, tuple[str, str]]

Data Structures
class pcapkit.protocols.data.transport.udp.UDP(srcport, dstport, len, checksum)[source]

Bases: Info

Data model for UDP protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

srcport: int

Source port.

dstport: int

Destination port.

len: int

Length (header includes).

checksum: bytes

Checksum.


*

https://en.wikipedia.org/wiki/User_Datagram_Protocol

Todo

Implements DCCP, RSVP, SCTP.

Protocol Registry
pcapkit.protocols.transport.TRANSTYPE

Alias of pcapkit.const.reg.transtype.TransType.

Application Layer Protocols

pcapkit.protocols.application is collection of all protocols in application layer, with detailed implementation and methods.

Base Protocol

pcapkit.protocols.application.application contains only Application, which is a base class for application layer protocols, eg. HTTP/1.*, HTTP/2 and etc.

class pcapkit.protocols.application.application.Application(file=None, length=None, **kwargs)[source]

Bases: Protocol[PT], Generic[PT]

Abstract base class for transport layer protocol family.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

__post_init__(file: BinaryIO, length: Optional[int] = None, **kwargs: Any) None[source]
__post_init__(**kwargs: Any) None

Post initialisation hook.

Parameters
  • file (Optional[BinaryIO]) – Source packet stream.

  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

See also

For construction arguments, please refer to self.make.

Return type

None

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises

IntError – This protocol doesn’t support __index__().

Return type

NoReturn

property layer: Literal['Application']

Protocol layer.

Return type

Literal[‘Application’]

_decode_next_layer(dict_, proto=None, length=None)[source]

Decode next layer protocol.

Raises

UnsupportedCall – This protocol doesn’t support _decode_next_layer().

Return type

NoReturn

Parameters
_import_next_layer(proto, length=None)[source]

Import next layer extractor.

Raises

UnsupportedCall – This protocol doesn’t support _import_next_layer().

Return type

NoReturn

Parameters
__layer__: Optional[Literal['Link', 'Internet', 'Transport', 'Application']] = 'Application'

Layer of protocol.

HTTP - Hypertext Transfer Protocol

pcapkit.protocols.application.http contains HTTP only, which is a base class for Hypertext Transfer Protocol (HTTP) * family, eg. HTTP/1.* and HTTP/2.

class pcapkit.protocols.application.http.HTTP(file=None, length=None, **kwargs)[source]

Bases: Application[HTTP], Generic[PT]

This class implements all protocols in HTTP family.

  • Hypertext Transfer Protocol (HTTP/1.1) [RFC 7230]

  • Hypertext Transfer Protocol version 2 (HTTP/2) [RFC 7540]

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

property name: Literal['Hypertext Transfer Protocol']

Name of current protocol.

Return type

Literal[‘Hypertext Transfer Protocol’]

property alias: Literal['HTTP/0.9', 'HTTP/1.0', 'HTTP/1.1', 'HTTP/2']

Acronym of current protocol.

Return type

Literal[‘HTTP/0.9’, ‘HTTP/1.0’, ‘HTTP/1.1’, ‘HTTP/2’]

property length: int

Header length of current protocol.

Return type

int

property version: Literal['0.9', '1.0', '1.1', '2']

Version of current protocol.

Return type

Literal[‘0.9’, ‘1.0’, ‘1.1’, ‘2’]

classmethod id()[source]

Index ID of the protocol.

Return type

tuple[Literal[“HTTPv1”], Literal[“HTTPv2”]]

read(length=None, *, version=None, **kwargs)[source]

Read (parse) packet data.

Parameters
  • length (Optional[int]) – Length of packet data.

  • version (Optional[Literal[1, 2]]) – Version of HTTP.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

HTTP

Returns

Parsed packet data.

make(*, version, **kwargs)[source]

Make (construct) packet data.

Parameters
  • version (Literal[1, 2]) – Version of HTTP.

  • **kwargs (Any) – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

_guess_version(length, **kwargs)[source]

Guess HTTP version.

Parameters
  • length (int) – Length of packet data.

  • kwargs (Any) –

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Return type

Protocol

Returns

Parsed packet data.

Data Structures
class pcapkit.protocols.data.application.http.HTTP[source]

Bases: Info

Data model for HTTP protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info


*

https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

HTTP/1.* - Hypertext Transfer Protocol

pcapkit.protocols.application.httpv1 contains HTTP only, which implements extractor for Hypertext Transfer Protocol (HTTP/1.*) *, whose structure is described as below:

METHOD URL HTTP/VERSION\r\n :==: REQUEST LINE
<key> : <value>\r\n         :==: REQUEST HEADER
............  (Ellipsis)    :==: REQUEST HEADER
\r\n                        :==: REQUEST SEPARATOR
<body>                      :==: REQUEST BODY (optional)

HTTP/VERSION CODE DESP \r\n :==: RESPONSE LINE
<key> : <value>\r\n         :==: RESPONSE HEADER
............  (Ellipsis)    :==: RESPONSE HEADER
\r\n                        :==: RESPONSE SEPARATOR
<body>                      :==: RESPONSE BODY (optional)
class pcapkit.protocols.application.httpv1.HTTP(file=None, length=None, **kwargs)[source]

Bases: HTTP[HTTP]

This class implements Hypertext Transfer Protocol (HTTP/1.*).

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

property alias: Literal['HTTP/0.9', 'HTTP/1.0', 'HTTP/1.1']

Acronym of current protocol.

Return type

Literal[‘HTTP/0.9’, ‘HTTP/1.0’, ‘HTTP/1.1’]

property version: Literal['0.9', '1.0', '1.1']

Version of current protocol.

Return type

Literal[‘0.9’, ‘1.0’, ‘1.1’]

read(length=None, **kwargs)[source]

Read Hypertext Transfer Protocol (HTTP/1.*).

Structure of HTTP/1.* packet [RFC 7230]:

HTTP-message    :==:    start-line
                        *( header-field CRLF )
                        CRLF
                        [ message-body ]
Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

HTTP

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

classmethod id()[source]

Index ID of the protocol.

Returns

Index ID of the protocol.

Return type

tuple[Literal[“HTTP”]]

_read_http_header(header)[source]

Read HTTP/1.* header.

Structure of HTTP/1.* header [RFC 7230]:

start-line      :==:    request-line / status-line
request-line    :==:    method SP request-target SP HTTP-version CRLF
status-line     :==:    HTTP-version SP status-code SP reason-phrase CRLF
header-field    :==:    field-name ":" OWS field-value OWS
Parameters

header (bytes) – HTTP header data.

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

Return type

tuple[DataType_Header, OrderedMultiDict[str, str]]

_read_http_body(body)[source]

Read HTTP/1.* body.

Parameters

body (bytes) – HTTP body data.

Return type

bytes

Returns

Raw HTTP body.

pcapkit.protocols.application.httpv1.HTTP_METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'DELETE', 'TRACE', 'OPTIONS', 'CONNECT', 'PATCH']

Supported HTTP method.

Data Structures
class pcapkit.protocols.data.application.httpv1.HTTP(receipt, header, body)[source]

Bases: HTTP

Data model for HTTP/1.* protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

receipt: Header

HTTP receipt.

header: OrderedMultiDict[str, str]

HTTP header.

body: Optional[bytes]

HTTP body.

class pcapkit.protocols.data.application.httpv1.Header(type)[source]

Bases: Info

Data model for HTTP/1.* header line.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: Literal['request', 'response']

Receipt type.

class pcapkit.protocols.data.application.httpv1.RequestHeader(type, method, uri, version)[source]

Bases: Header

Data model for HTTP/1.* request header line.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: Literal['request']

HTTP request header line.

method: str

HTTP method.

uri: str

HTTP request URI.

version: str

HTTP request version.

class pcapkit.protocols.data.application.httpv1.ResponseHeader(type, version, status, message)[source]

Bases: Header

Data model for HTTP/1.* response header line.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: Literal['response']

HTTP response header line.

version: str

HTTP response version.

status: int

HTTP response status.

message: str

HTTP response status message.


*

https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol

HTTP/2 - Hypertext Transfer Protocol

pcapkit.protocols.application.httpv2 contains HTTP only, which implements extractor for Hypertext Transfer Protocol (HTTP/2) *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

http.length

Length

3

24

http.type

Type

4

32

http.flags

Flags

5

40

Reserved

5

41

http.sid

Stream Identifier

9

72

http.payload

Frame Payload


class pcapkit.protocols.application.httpv2.HTTP(file=None, length=None, **kwargs)[source]

Bases: HTTP[HTTP]

This class implements Hypertext Transfer Protocol (HTTP/2).

This class currently supports parsing of the following HTTP/2 frames, which are directly mapped to the pcapkit.const.http.frame.Frame enumeration:

Frame Code

Frame Parser

DATA

_read_http_data()

HEADERS

_read_http_headers()

PRIORITY

_read_http_priority()

RST_STREAM

_read_http_rst_stream()

SETTINGS

_read_http_settings()

PUSH_PROMISE

_read_http_push_promise()

PING

_read_http_ping()

GOAWAY

_read_http_goaway()

WINDOW_UPDATE

_read_http_window_update()

CONTINUATION

_read_http_continuation()

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

property alias: Literal['HTTP/2']

Acronym of current protocol.

Return type

Literal[‘HTTP/2’]

property length: Literal[9]

Header length of current protocol.

Return type

Literal[9]

property version: Literal['2']

Version of current protocol.

Return type

Literal[‘2’]

read(length=None, **kwargs)[source]

Read Hypertext Transfer Protocol (HTTP/2).

Structure of HTTP/2 packet [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+=+=============================================================+
|                   Frame Payload (0...)                      ...
+---------------------------------------------------------------+
Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

HTTP

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

make(**kwargs)[source]

Make (construct) packet data.

Parameters

**kwargs (Any) – Arbitrary keyword arguments.

Return type

NoReturn

Returns

Constructed packet data.

classmethod id()[source]

Index ID of the protocol.

Returns

Index ID of the protocol.

Return type

tuple[Literal[“HTTP”]]

classmethod register_frame(code, meth)[source]

Register a frame parser.

Parameters
  • code (RegType_Frame) – HTTP frame type code.

  • meth (str | FrameParser) – Method name or callable to parse the frame.

Return type

None

_read_http_none(frame, length, flags, sid)[source]

Read HTTP packet with unassigned type.

Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

UnassignedFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_data(frame, length, flags, sid)[source]

Read HTTP/2 DATA frames.

Structure of HTTP/2 DATA frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+---------------+-----------------------------------------------+
|Pad Length? (8)|
+---------------+-----------------------------------------------+
|                            Data (*)                         ...
+---------------------------------------------------------------+
|                           Padding (*)                       ...
+---------------------------------------------------------------+
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

DataFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_headers(frame, length, flags, sid)[source]

Read HTTP/2 HEADERS frames.

Structure of HTTP/2 HEADERS frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+---------------+-----------------------------------------------+
|Pad Length? (8)|
+-+-------------+-----------------------------------------------+
|E|                 Stream Dependency? (31)                     |
+-+-------------+-----------------------------------------------+
|  Weight? (8)  |
+-+-------------+-----------------------------------------------+
|                   Header Block Fragment (*)                 ...
+---------------------------------------------------------------+
|                           Padding (*)                       ...
+---------------------------------------------------------------+
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

HeadersFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_priority(frame, length, flags, sid)[source]

Read HTTP/2 PRIORITY frames.

Structure of HTTP/2 PRIORITY frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+-+-------------------------------------------------------------+
|E|                  Stream Dependency (31)                     |
+-+-------------+-----------------------------------------------+
|   Weight (8)  |
+-+-------------+
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

PriorityFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_rst_stream(frame, length, flags, sid)[source]

Read HTTP/2 RST_STREAM frames.

Structure of HTTP/2 RST_STREAM frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+---------------------------------------------------------------+
|                        Error Code (32)                        |
+---------------------------------------------------------------+
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

RstStreamFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_settings(frame, length, flags, sid)[source]

Read HTTP/2 SETTINGS frames.

Structure of HTTP/2 SETTINGS frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+---------------------------------------------------------------+
|       Identifier (16)         |
+-------------------------------+-------------------------------+
|                        Value (32)                             |
+---------------------------------------------------------------+
|                          ......                               |
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

SettingsFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_push_promise(frame, length, flags, sid)[source]

Read HTTP/2 PUSH_PROMISE frames.

Structure of HTTP/2 PUSH_PROMISE frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+---------------+-----------------------------------------------+
|Pad Length? (8)|
+-+-------------+-----------------------------------------------+
|R|                  Promised Stream ID (31)                    |
+-+-----------------------------+-------------------------------+
|                   Header Block Fragment (*)                 ...
+---------------------------------------------------------------+
|                           Padding (*)                       ...
+---------------------------------------------------------------+
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

PushPromiseFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_ping(frame, length, flags, sid)[source]

Read HTTP/2 PING frames.

Structure of HTTP/2 PING frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+---------------------------------------------------------------+
|                                                               |
|                      Opaque Data (64)                         |
|                                                               |
+---------------------------------------------------------------+
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

PingFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_goaway(frame, length, flags, sid)[source]

Read HTTP/2 GOAWAY frames.

Structure of HTTP/2 GOAWAY frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+-+-------------+---------------+-------------------------------+
|R|                  Last-Stream-ID (31)                        |
+-+-------------------------------------------------------------+
|                      Error Code (32)                          |
+---------------------------------------------------------------+
|                  Additional Debug Data (*)                    |
+---------------------------------------------------------------+
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

GoawayFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_window_update(frame, length, flags, sid)[source]

Read HTTP/2 WINDOW_UPDATE frames.

Structure of HTTP/2 WINDOW_UPDATE frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+-+-------------+---------------+-------------------------------+
|R|              Window Size Increment (31)                     |
+-+-------------------------------------------------------------+
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

WindowUpdateFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

_read_http_continuation(frame, length, flags, sid)[source]

Read HTTP/2 CONTINUATION frames.

Structure of HTTP/2 CONTINUATION frame [RFC 7540]:

+-----------------------------------------------+
|                 Length (24)                   |
+---------------+---------------+---------------+
|   Type (8)    |   Flags (8)   |
+-+-------------+---------------+-------------------------------+
|R|                 Stream Identifier (31)                      |
+---------------------------------------------------------------+
|                   Header Block Fragment (*)                 ...
+---------------------------------------------------------------+
Parameters
  • frame (Frame) – Frame type.

  • length (int) – Length of packet data.

  • flags (str) – Flags of the frame.

  • sid (int) – Stream ID.

Return type

ContinuationFrame

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

__frame__: DefaultDict[int, str | FrameParser]

Frame code to method mapping, c.f. read(). Method names are expected to be referred to the class by _read_http_${name}, and if such name not found, the value should then be a method that can parse the frame by itself.

Type

DefaultDict[RegType_Frame, str | FrameParser]

Data Structures
class pcapkit.protocols.data.application.httpv2.HTTP(length, type, flags, sid)[source]

Bases: HTTP

Data model for HTTP/2 protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

length: int

Length.

type: Frame

Frame type.

flags: Optional[Flags]

Flags.

sid: int

Stream ID.

class pcapkit.protocols.data.application.httpv2.Flags[source]

Bases: Info

Data model for HTTP/2 flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

class pcapkit.protocols.data.application.httpv2.UnassignedFrame(length, type, flags, sid, data)[source]

Bases: HTTP

Data model for HTTP/2 unassigned frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

data: Optional[bytes]

Frame payload.

class pcapkit.protocols.data.application.httpv2.DataFrame(length, type, flags, sid, pad_len, data)[source]

Bases: HTTP

Data model for HTTP/2 DATA frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: DataFrameFlags

Flags.

pad_len: int

Padded length.

data: Optional[bytes]

Frame payload.

class pcapkit.protocols.data.application.httpv2.DataFrameFlags(END_STREAM, PADDED)[source]

Bases: Flags

Data model for HTTP/2 DATA frame flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

END_STREAM: bool

END_STREAM flag.

PADDED: bool

PADDED flag.

class pcapkit.protocols.data.application.httpv2.HeadersFrame(length, type, flags, sid, pad_len, excl_dependency, stream_dependency, weight, fragment)[source]

Bases: HTTP

Data model for HTTP/2 HEADERS frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: HeadersFrameFlags

Flags.

pad_len: int

Padded length.

excl_dependency: Optional[bool]

Exclusive dependency.

stream_dependency: Optional[int]

Stream dependency.

weight: Optional[int]

Weight.

fragment: Optional[bytes]

Header block fragment.

class pcapkit.protocols.data.application.httpv2.HeadersFrameFlags(END_STREAM, END_HEADERS, PADDED, PRIORITY)[source]

Bases: Flags

Data model for HTTP/2 HEADERS frame flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

END_STREAM: bool

END_STREAM flag.

END_HEADERS: bool

END_HEADERS flag.

PADDED: bool

PADDED flag.

PRIORITY: bool

PRIORITY flag.

class pcapkit.protocols.data.application.httpv2.PriorityFrame(length, type, flags, sid, excl_dependency, stream_dependency, weight)[source]

Bases: HTTP

Data model for HTTP/2 PRIORITY frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: Literal[None]

Flags.

excl_dependency: bool

Exclusive dependency.

stream_dependency: int

Stream dependency.

weight: int

Weight.

class pcapkit.protocols.data.application.httpv2.RstStreamFrame(length, type, flags, sid, error)[source]

Bases: HTTP

Data model for HTTP/2 RST_STREAM frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: Literal[None]

Flags.

error: ErrorCode

Error code.

class pcapkit.protocols.data.application.httpv2.SettingsFrame(length, type, flags, sid, settings)[source]

Bases: HTTP

Data model for HTTP/2 SETTINGS frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: SettingsFrameFlags

Flags.

settings: OrderedMultiDict[Setting, int]

Settings.

class pcapkit.protocols.data.application.httpv2.SettingsFrameFlags(ACK)[source]

Bases: Flags

Data model for HTTP/2 SETTINGS frame flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ACK: bool

ACK flag.

class pcapkit.protocols.data.application.httpv2.PushPromiseFrame(length, type, flags, sid, pad_len, promised_sid, fragment)[source]

Bases: HTTP

Data model for HTTP/2 PUSH_PROMISE frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: PushPromiseFrameFlags

Flags.

pad_len: int

Padded length.

promised_sid: int

Promised stream ID.

fragment: Optional[bytes]

Header block fragment.

class pcapkit.protocols.data.application.httpv2.PushPromiseFrameFlags(END_HEADERS, PADDED)[source]

Bases: Flags

Data model for HTTP/2 PUSH_PROMISE frame flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

END_HEADERS: bool

END_HEADERS flag.

PADDED: bool

PADDED flag.

class pcapkit.protocols.data.application.httpv2.PingFrame(length, type, flags, sid, data)[source]

Bases: HTTP

Data model for HTTP/2 PING frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: PingFrameFlags

Flags.

data: bytes

Opaque data.

class pcapkit.protocols.data.application.httpv2.PingFrameFlags(ACK)[source]

Bases: Flags

Data model for HTTP/2 PING frame flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

ACK: bool

ACK flag.

class pcapkit.protocols.data.application.httpv2.GoawayFrame(length, type, flags, sid, last_sid, error, debug_data)[source]

Bases: HTTP

Data model for HTTP/2 GOAWAY frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: Literal[None]

Flags.

last_sid: int

Last stream ID.

error: ErrorCode

Error code.

debug_data: Optional[bytes]

Additional debug data.

class pcapkit.protocols.data.application.httpv2.WindowUpdateFrame(length, type, flags, sid, increment)[source]

Bases: HTTP

Data moddel for HTTP/2 WINDOW_UPDATE frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: Literal[None]

Flags.

increment: int

Window size increment.

class pcapkit.protocols.data.application.httpv2.ContinuationFrame(length, type, flags, sid, fragment)[source]

Bases: HTTP

Data model for HTTP/2 CONTINUATION frame.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

flags: ContinuationFrameFlags

Flags.

fragment: Optional[bytes]

Header block fragment.

class pcapkit.protocols.data.application.httpv2.ContinuationFrameFlags(END_HEADERS)[source]

Bases: Flags

Data model for HTTP/2 CONTINUATION frame flags.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

END_HEADERS: bool

END_HEADERS flag.


*

https://en.wikipedia.org/wiki/HTTP/2

FTP - File Transfer Protocol

pcapkit.protocols.application.ftp contains FTP only, which implements extractor for File Transfer Protocol (FTP) *.

class pcapkit.protocols.application.ftp.FTP(file=None, length=None, **kwargs)[source]

Bases: Application[FTP]

This class implements File Transfer Protocol.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

Protocol[PT]

property name: Literal['File Transfer Protocol']

Name of current protocol.

Return type

Literal[‘File Transfer Protocol’]

property length: NoReturn

Header length of current protocol.

Raises

UnsupportedCall – This protocol doesn’t support length.

Return type

NoReturn

read(length=None, **kwargs)[source]

Read File Transfer Protocol (FTP).

Parameters
  • length (Optional[int]) – Length of packet data.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

FTP

Returns

Parsed packet data.

Raises

ProtocolError – If the packet is malformed.

make(**kwargs)[source]

Make (construct) packet data.

Parameters
  • arguments. (Arbitrary keyword) –

  • kwargs (Any) –

Return type

NoReturn

Returns

Constructed packet data.

Data Structures
class pcapkit.protocols.data.application.ftp.FTP(type)[source]

Bases: Info

Data model for FTP protocol.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: Literal['response', 'request']

Type.

class pcapkit.protocols.data.application.ftp.Request(type, command, arg, raw)[source]

Bases: FTP

Data model for FTP request.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: Literal['request']

Type.

command: CommandType

Command.

arg: Optional[str]

Arguments.

raw: Optional[bytes]

Raw data.

class pcapkit.protocols.data.application.ftp.Response(type, code, arg, mf, raw)[source]

Bases: FTP

Data model for FTP response.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

type: Literal['response']

Type.

code: ReturnCode

Return code.

arg: Optional[str]

Arguments.

mf: bool

More data flag.

raw: Optional[bytes]

Raw data.


*

https://en.wikipedia.org/wiki/File_Transfer_Protocol

Todo

Implements BGP, DHCP, DHCPv6, DNS, IMAP, LDAP, MQTT, NNTP, NTP, ONC:RPC, POP, RIP, RTP, SIP, SMTP, SNMP, SSH, TELNET, TLS/SSL, XMPP.

Protocol Registry

pcapkit.protocols.__proto__: dict[str, Type[Protocol]]

Protocol registry.

See also

Please refer to pcapkit.foundation.registry.register_protocol() for more information.

Core Utilities

pcapkit.corekit is the collection of core utilities for pcapkit implementation, including dict like class Info, tuple like class VersionInfo, protocol collection class ProtoChain, and MultiDict family inspired from Werkzeug for multientry dict data mapping.

Info Class

pcapkit.corekit.infoclass contains dict like class Info only, which is originally designed to work alike dataclasses.dataclass() as introduced in PEP 557.

class pcapkit.corekit.infoclass.Info(dict_=None, **kwargs)[source]

Bases: Mapping[str, VT], Generic[VT]

Turn dictionaries into object like instances.

  • Info objects inherit from dict type

  • Info objects are iterable, and support all functions as dict type

  • Info objects are immutable, thus cannot set or delete attributes after initialisation

Important

Info will attempt to rename keys with the same names as the class’s builtin methods, and store the mapping information in the __map__ and __map_reverse__ attributes. However, when accessing such renamed keys, the original key name should always be used, i.e., such renaming is totally transparent to the user.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

__map__: dict[str, str]

Mapping of name conflicts with builtin methods (original names to transformed names).

__map_reverse__: dict[str, str]

Mapping of name conflicts with builtin methods (transformed names to original names).

static __new__(cls, *args, **kwargs)[source]

Create a new instance.

The class will try to automatically generate __init__ method with the same signature as specified in class variables’ type annotations, which is inspired by PEP 557 (dataclasses).

Parameters
  • *args (TypeVar(VT)) – Arbitrary positional arguments.

  • **kwargs (TypeVar(VT)) – Arbitrary keyword arguments.

Return type

Info

classmethod from_dict(dict_=None, **kwargs)[source]

Create a new instance.

  • If dict_ is present and has a .keys() method, then does: for k in dict_: self[k] = dict_[k].

  • If dict_ is present and has no .keys() method, then does: for k, v in dict_: self[k] = v.

  • If dict_ is not present, then does: for k, v in kwargs.items(): self[k] = v.

Parameters
  • dict_ (Optional[Mapping[str, VT] | Iterable[tuple[str, VT]]]) – Source data.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info[VT]

to_dict()[source]

Convert Info into dict.

Important

We only convert nested Info objects into dict if they are the direct value of the Info object’s attribute. Should such Info objects be nested within other data, types, such as list, tuple, set, etc., we shall not convert them into dict and remain them intact.

Return type

dict[str, VT]

Multi-Mapping Dictionary

pcapkit.corekit.multidict contains multi-mapping dictionary classes, which are used to store multiple mappings of the same key. The implementation is inspired and based on the Werkzeug project.

class pcapkit.corekit.multidict.MultiDict(mapping=None)[source]

Bases: dict, Generic[_KT, _VT]

A MultiDict is a dictionary subclass customized to deal with multiple values for the same key.

MultiDict implements all standard dictionary methods. Internally, it saves all values for a key as a list, but the standard dict access methods will only return the first value for a key. If you want to gain access to the other values, too, you have to use the getlist() and similar methods.

Parameters

mapping (Optional[dict[_KT, _VT] | Iterable[tuple[_KT, _VT]]]) – The initial value for the MultiDict. Either a regular dict, an iterable of (key, value) tuples, or None.

It behaves like a normal dict thus all dict functions will only return the first value when multiple values for one key are found.

See also

The class is inspired from and based on the Werkzeug project (c.f. werkzeug.datastructures.MultiDict).

__setitem__(key, value)[source]

Like add() but removes an existing key first.

Parameters
  • key (TypeVar(_KT)) – The key for the value.

  • value (TypeVar(_VT)) – The value to set.

Return type

None

add(key, value)[source]

Adds a new value for the key.

Parameters
  • key (TypeVar(_KT)) – The key for the value.

  • value (TypeVar(_VT)) – The value to add.

Return type

None

get(key: _KT) _VT | _T[source]
get(key: _KT, default: _VT | _T = None) _VT | _T

Return the value for key if key is in the dictionary, else default.

getlist(key)[source]

Return the list of items for a given key.

If that key is not in the MultiDict, the return value will be an empty list.

Parameters

key (_KT) – The key to be looked up.

Returns

A list of all the values for the key.

Return type

list[_VT]

setlist(key, new_list)[source]

Remove the old values for a key and add new ones.

Notes

The list you pass the values in will be shallow-copied before it is inserted in the dictionary.

Parameters
  • key (TypeVar(_KT)) – The key for which the values are set.

  • new_list (Iterable[TypeVar(_VT)]) – An iterable with the new values for the key. Old values are removed first.

Return type

None

setdefault(key, default=None)[source]

If key is in the dictionary, returns its value.

If not, set it to default and return default.

Parameters
Return type

TypeVar(_VT)

Returns

The value of the key.

setlistdefault(key, default_list=None)[source]

Like setdefault() but sets multiple values.

The list returned is not a copy, but the list that is actually used internally. This means that you can put new values into the dict by appending items to the list.

Parameters
  • key (_KT) – The key to be looked up.

  • default_list (Optional[Iterable[_VT]]) – An iterable of default values. It is either copied (in case it was a list) or converted into a list before returned.

Return type

list[_VT]

items(multi=False)[source]

Return an interator of (key, value) paris.

Parameters

multi (bool) – If set to True the iterator returned will have a pair for each value of each key. Otherwise it will only contain pairs for the first value of each key.

Return type

Iterable[tuple[_KT, _VT]]

lists()[source]

Return an iterator of (key, values) pairs, where values is the list of all values associated with the key.

Return type

Iterator[tuple[_KT, list[_VT]]]

values()[source]

Returns an iterator of the first value on every key’s value list.

Return type

Iterator[TypeVar(_VT)]

listvalues()[source]

Return an iterator of all values associated with a key. Zipping keys() and this is the same as calling lists().

Return type

Iterator[list[_VT]]

to_dict(flat: Literal[True] = True) dict[_KT, _VT][source]
to_dict(flat: Literal[False]) dict[_KT, list[_VT]]

Return the contents as regular dict.

If flat is True the returned dict will only have the first item present, if flat is False all values will be returned as lists.

Parameters

flat – If set to False the dict returned will have lists with all the values in it. Otherwise it will only contain the first value for each key.

update(mapping)[source]

update() extends rather than replaces existing key lists.

If the value list for a key in other_dict is empty, no new values will be added to the dict and the key will not be created.

Parameters

mapping (Mapping[_KT, _VT] | Iterable[tuple[_KT, _VT]]) – The extending value for the MultiDict. Either a regular dict, an iterable of (key, value) tuples, or None.

Return type

None

pop(key: _KT) _VT[source]
pop(key: _KT, default: _VT | _T = no value) _VT | _T

Pop the first item for a list on the dict.

Afterwards the key is removed from the dict, so additional values are discarded.

Parameters
  • key – The key to pop.

  • default – If provided the value to return if the key was not in the dictionary.

popitem()[source]

Pop an item from the dict.

Return type

tuple[_KT, _VT]

poplist(key)[source]

Pop the list for a key from the dict.

If the key is not in the dict an empty list is returned.

Notes

If the key does no longer exist a list is returned instead of raising an error.

Parameters

key (_KT) – The key to pop.

Return type

list[_VT]

popitemlist()[source]

Pop a (key, list) tuple from the dict.

Return type

tuple[_KT, list[_VT]]

class pcapkit.corekit.multidict.OrderedMultiDict(mapping=None)[source]

Bases: MultiDict[_KT, _VT]

Works like a regular MultiDict but preserves the order of the fields.

Parameters

mapping (Optional[dict[_KT, _VT] | Iterable[tuple[_KT, _VT]]]) – The initial value for the MultiDict. Either a regular dict, an iterable of (key, value) tuples, or None.

To convert the ordered multi dict into a list you can us the items() method and pass it multi=True.

In general an OrderedMultiDict is an order of magnitude slower than a MultiDict.

Notes

Due to a limitation in Python you cannot convert an ordered multi dict into a regular dict by using dict(multidict). Instead you have to use the to_dict() method, otherwise the internal bucket objects are exposed.

Protocol Chain

pcapkit.corekit.protochain contains special protocol collection class ProtoChain.

class pcapkit.corekit.protochain.ProtoChain(proto, alias=None, *, basis=None)[source]

Bases: Sequence

Protocols chain.

Parameters
  • proto (Protocol | Type[Protocol]) – New protocol class on the top stack.

  • alias (Optional[str]) – New protocol alias on the top stack.

  • basis (Optional[ProtoChain]) – Original protocol chain as base stacks.

property protocols: tuple[Type[Protocol], ...]

List of protocols in the chain.

property aliases: tuple[str, ...]

Protocol names.

property chain: str

Protocol chain string.

Return type

str

classmethod from_list(data)[source]

Create a protocol chain from a list.

Parameters

data (list[Protocol | Type[Protocol]]) – Protocol chain list.

Return type

ProtoChain

index(value, start=None, stop=None)[source]

First index of value.

Parameters
Raises

IndexNotFound – If the value is not present.

Return type

int

count(value)[source]

Number of occurrences of value.

Parameters

value (str | Protocol | Type[Protocol]) – Value to search.

Return type

int

__init__(proto, alias=None, *, basis=None)[source]

Initialisation.

Parameters
  • proto – New protocol class on the top stack.

  • alias – New protocol alias on the top stack.

  • basis – Original protocol chain as base stacks.

__str__()[source]

Returns formatted hex representation of source data stream.

Example

>>> protochain
ProtoChain(Ethernet, IPv6, Raw)
>>> print(protochain)
Ethernet:IPv6:Raw
Return type

str

__repr__()[source]

Returns representation of protocol chain data.

Example

>>> protochain
ProtoChain(Ethernet, IPv6, Raw)
Return type

str

Version Info

pcapkit.corekit.version contains tuple like class VersionInfo, which is originally designed alike sys.version_info.

pcapkit.corekit.version.VersionInfo

VersionInfo is alike sys.version_info.

pcapkit.corekit.version.major: int

Major version number.

pcapkit.corekit.version.minor: int

Minor version number.

Compatibility Tools

pcapkit.toolkit provides several utility functions for compatibility of multiple engine support.

PyPCAPKit Tools

pcapkit.toolkit.default contains all you need for pcapkit handy usage. All functions returns with a flag to indicate if usable for its caller.

pcapkit.toolkit.default.ipv4_reassembly(frame)[source]

Make data for IPv4 reassembly.

Parameters

frame (Frame) – PCAP frame.

Returns

Data for IPv4 reassembly.

  • If the frame can be used for IPv4 reassembly. A frame can be reassembled if it contains IPv4 layer (pcapkit.protocols.internet.ipv4.IPv4) and the DF (IPv4.flags.df) flag is False.

  • If the frame can be reassembled, then the dict mapping of data for IPv4 reassembly (c.f. ipv4.packet) will be returned; otherwise, returns None.

Return type

IP_Packet[IPv4Address] | None

See also

pcapkit.foundation.reassembly.ipv4.IPv4Reassembly

pcapkit.toolkit.default.ipv6_reassembly(frame)[source]

Make data for IPv6 reassembly.

Parameters

frame (Frame) – PCAP frame.

Returns

A tuple of data for IPv6 reassembly.

Return type

Tuple[bool, Dict[str, Any]]

See also

pcapkit.foundation.reassembly.ipv6.IPv6Reassembly

pcapkit.toolkit.default.tcp_reassembly(frame)[source]

Make data for TCP reassembly.

Parameters

frame (Frame) – PCAP frame.

Returns

A tuple of data for TCP reassembly.

  • If the frame can be used for TCP reassembly. A frame can be reassembled if it contains TCP layer (pcapkit.protocols.transport.tcp.TCP).

  • If the frame can be reassembled, then the dict mapping of data for TCP reassembly (tcp.packet) will be returned; otherwise, returns None.

Return type

Tuple[bool, Dict[str, Any]]

See also

pcapkit.foundation.reassembly.tcp.TCPReassembly

pcapkit.toolkit.default.tcp_traceflow(frame, *, data_link)[source]

Trace packet flow for TCP.

Parameters
  • frame (Frame) – PCAP frame.

  • data_link (LinkType) – Data link layer protocol (from global header).

Returns

Data for TCP reassembly.

  • If the packet can be used for TCP flow tracing. A frame can be reassembled if it contains TCP layer (pcapkit.protocols.transport.tcp.TCP).

  • If the frame can be reassembled, then the dict mapping of data for TCP flow tracing (trace.packet) will be returned; otherwise, returns None.

Return type

TF_Packet | None

DPKT Tools

pcapkit.toolkit.dpkt contains all you need for pcapkit handy usage with DPKT engine. All reforming functions returns with a flag to indicate if usable for its caller.

pcapkit.toolkit.dpkt.ipv4_reassembly(packet, *, count=-1)[source]

Make data for IPv4 reassembly.

Parameters
  • packet (Packet) – DPKT packet.

  • count (int) – Packet index. If not provided, default to -1.

Return type

IP_Packet[IPv4Address] | None

Returns

Data for IPv4 reassembly.

  • If the packet can be used for IPv4 reassembly. A packet can be reassembled if it contains IPv4 layer (dpkt.ip.IP) and the DF (dpkt.ip.IP.df) flag is False.

  • If the packet can be reassembled, then the dict mapping of data for IPv4 reassembly (ipv4.packet) will be returned; otherwise, returns None.

See also

pcapkit.foundation.reassembly.ipv4.IPv4Reassembly

pcapkit.toolkit.dpkt.ipv6_reassembly(packet, *, count=-1)[source]

Make data for IPv6 reassembly.

Parameters
  • packet (Packet) – DPKT packet.

  • count (int) – Packet index. If not provided, default to -1.

Return type

IP_Packet[IPv6Address] | None

Returns

Data for IPv6 reassembly.

See also

pcapkit.foundation.reassembly.ipv6.IPv6Reassembly

pcapkit.toolkit.dpkt.tcp_reassembly(packet, *, count=-1)[source]

Make data for TCP reassembly.

Parameters
  • packet (Packet) – DPKT packet.

  • count (int) – Packet index. If not provided, default to -1.

Return type

TCP_Packet | None

Returns

Data for TCP reassembly.

  • If the packet can be used for TCP reassembly. A packet can be reassembled if it contains TCP layer (dpkt.tcp.TCP).

  • If the packet can be reassembled, then the dict mapping of data for TCP reassembly (tcp.packet) will be returned; otherwise, returns None.

See also

pcapkit.foundation.reassembly.tcp.TCPReassembly

pcapkit.toolkit.dpkt.tcp_traceflow(packet, timestamp, *, data_link, count=-1)[source]

Trace packet flow for TCP.

Parameters
  • packet (Packet) – DPKT packet.

  • timestamp (float) – Timestamp of the packet.

  • data_link (RegType_LinkType) – Data link layer protocol (from global header).

  • count (int) – Packet index. If not provided, default to -1.

Return type

TF_Packet | None

Returns

Data for TCP reassembly.

  • If the packet can be used for TCP flow tracing. A packet can be reassembled if it contains TCP layer (dpkt.tcp.TCP).

  • If the packet can be reassembled, then the dict mapping of data for TCP flow tracing (trace.packet) will be returned; otherwise, returns None.

pcapkit.toolkit.dpkt.ipv6_hdr_len(ipv6)[source]

Calculate length of headers before IPv6 Fragment header.

Parameters

ipv6 (IP6) – DPKT IPv6 packet.

Return type

int

Returns

Length of headers before IPv6 Fragment header dpkt.ip6.IP6FragmentHeader (RFC 2460#section-4.5).

As specified in RFC 2460#section-4.1, such headers (before the IPv6 Fragment Header) includes Hop-by-Hop Options header dpkt.ip6.IP6HopOptsHeader (RFC 2460#section-4.3), Destination Options header dpkt.ip6.IP6DstOptHeader (RFC 2460#section-4.6) and Routing header dpkt.ip6.IP6RoutingHeader (RFC 2460#section-4.4).

pcapkit.toolkit.dpkt.packet2chain(packet)[source]

Fetch DPKT packet protocol chain.

Parameters

packet (Packet) – DPKT packet.

Return type

str

Returns

Colon (:) seperated list of protocol chain.

pcapkit.toolkit.dpkt.packet2dict(packet, timestamp, *, data_link)[source]

Convert DPKT packet into dict.

Parameters
  • packet (Packet) – Scapy packet.

  • timestamp (float) – Timestamp of packet.

  • data_link (RegType_LinkType) – Data link type.

Returns

A dict mapping of packet data.

Return type

Dict[str, Any]

PyShark Tools

pcapkit.toolkit.pyshark contains all you need for pcapkit handy usage with PyShark engine. All reforming functions returns with a flag to indicate if usable for its caller.

pcapkit.toolkit.pyshark.tcp_traceflow(packet)[source]

Trace packet flow for TCP.

Parameters

packet (Packet) – Scapy packet.

Returns

A tuple of data for TCP reassembly.

  • If the packet can be used for TCP flow tracing. A packet can be reassembled if it contains TCP layer.

  • If the packet can be reassembled, then the dict mapping of data for TCP flow tracing (trace.packet) will be returned; otherwise, returns None.

Return type

Tuple[bool, Dict[str, Any]]

See also

TraceFlow

pcapkit.toolkit.pyshark.packet2dict(packet)[source]

Convert PyShark packet into dict.

Parameters

packet (Packet) – Scapy packet.

Return type

dict[str, Any]

Returns

A dict mapping of packet data.

Scapy Tools

pcapkit.toolkit.scapy contains all you need for pcapkit handy usage with Scapy engine. All reforming functions returns with a flag to indicate if usable for its caller.

Warning

This module requires installed Scapy engine.

pcapkit.toolkit.scapy.ipv4_reassembly(packet, *, count=-1)[source]

Make data for IPv4 reassembly.

Parameters
  • packet (Packet) – Scapy packet.

  • count (int) – Packet index. If not provided, default to -1.

Return type

IP_Packet[IPv4Address] | None

Returns

Data for IPv4 reassembly.

  • If the packet can be used for IPv4 reassembly. A packet can be reassembled if it contains IPv4 layer (scapy.layers.inet.IP) and the DF (scapy.layers.inet.IP.flags.DF) flag is False.

  • If the packet can be reassembled, then the dict mapping of data for IPv4 reassembly (ipv4.packet) will be returned; otherwise, returns None.

See also

pcapkit.foundation.reassembly.ipv4.IPv4Reassembly

pcapkit.toolkit.scapy.ipv6_reassembly(packet, *, count=-1)[source]

Make data for IPv6 reassembly.

Parameters
  • packet (Packet) – Scapy packet.

  • count (int) – Packet index. If not provided, default to -1.

Return type

IP_Packet[IPv6Address] | None

Returns

Data for IPv6 reassembly.

Raises

ModuleNotFound – If Scapy is not installed.

See also

pcapkit.foundation.reassembly.ipv6.IPv6Reassembly

pcapkit.toolkit.scapy.tcp_reassembly(packet, *, count=-1)[source]

Store data for TCP reassembly.

Parameters
  • packet (Packet) – Scapy packet.

  • count (int) – Packet index. If not provided, default to -1.

Return type

TCP_Packet | None

Returns

Data for TCP reassembly.

  • If the packet can be used for TCP reassembly. A packet can be reassembled if it contains TCP layer (scapy.layers.inet.TCP).

  • If the packet can be reassembled, then the dict mapping of data for TCP reassembly (tcp.packet) will be returned; otherwise, returns None.

See also

pcapkit.foundation.reassembly.tcp.TCPReassembly

pcapkit.toolkit.scapy.tcp_traceflow(packet, *, count=-1)[source]

Trace packet flow for TCP.

Parameters
  • packet (Packet) – Scapy packet.

  • count (int) – Packet index. If not provided, default to -1.

Return type

TF_Packet | None

Returns

Data for TCP reassembly.

  • If the packet can be used for TCP flow tracing. A packet can be reassembled if it contains TCP layer (scapy.layers.inet.TCP).

  • If the packet can be reassembled, then the dict mapping of data for TCP flow tracing (trace.packet) will be returned; otherwise, returns None.

pcapkit.toolkit.scapy.packet2chain(packet)[source]

Fetch Scapy packet protocol chain.

Parameters

packet (Packet) – Scapy packet.

Return type

str

Returns

Colon (:) seperated list of protocol chain.

Raises

ModuleNotFound – If Scapy is not installed.

pcapkit.toolkit.scapy.packet2dict(packet)[source]

Convert Scapy packet into dict.

Parameters

packet (Packet) – Scapy packet.

Return type

dict[str, Any]

Returns

A dict mapping of packet data.

Raises

ModuleNotFound – If Scapy is not installed.

Dump Utilities

pcapkit.dumpkit is the collection of dumpers for pcapkit implementation, which is alike those described in dictdumper.

Null Dumper

pcapkit.dumpkit.null is the dumper for pcapkit implementation, specifically for NotImplemented format, which is alike those described in dictdumper.

Note

This dumper is used when the given format is not supported, as a fallback. It shall not produce any output.

class pcapkit.dumpkit.null.NotImplementedIO(fname, **kwargs)[source]

Bases: Dumper

Unspecified output format.

property kind: Literal['null']

File format of current dumper.

Return type

Literal[‘null’]

PCAP Dumper

pcapkit.dumpkit.pcap is the dumper for pcapkit implementation, specifically for PCAP format, which is alike those described in dictdumper.

class pcapkit.dumpkit.pcap.PCAPIO(fname, *, protocol, byteorder='little', nanosecond=False, **kwargs)[source]

Bases: Dumper

PCAP file dumper.

Parameters
  • fname – output file name

  • protocol – data link type

  • byteorder – header byte order

  • nanosecond – nanosecond-resolution file flag

  • **kwargs – arbitrary keyword arguments

property kind: Literal['pcap']

File format of current dumper.

Return type

Literal[‘pcap’]

Utility Functions & Classes

pcapkit.utilities contains several useful functions and classes which are fundations of pcapkit, including decorater function seekset() and beholder(), and several user-refined exceptions and warnings.

Logging System

pcapkit.utilities.logging contains naïve integration of the Python logging system, i.e. a logging.Logger instance as logger.

pcapkit.utilities.logging.logger

Logger instance named after pcapkit.

Type

logging.Logger

pcapkit.utilities.logging.DEVMODE

Development mode flag.

Note

This variable can be configured through the environment variable PCAPKIT_DEVMODE.

Decorator Functions

pcapkit.utilities.decorators contains several useful decorators, including seekset() and beholder().

@pcapkit.utilities.decorators.seekset(func)[source]

Read file from start then set back to original.

Important

This decorator function is designed for decorating class methods.

The decorator will keep the current offset of self._file, then call the decorated function. Afterwards, it will rewind the offset of self._file to the original and returns the return value from the decorated function.

Note

The decorated function should have following signature:

func(self, *args, **kw)
Parameters

func (Callable[[Protocol, ParamSpec(P)], TypeVar(R)]) – decorated function

Return type

Callable[[ParamSpec(P)], TypeVar(R)]

@pcapkit.utilities.decorators.beholder(func)[source]

Behold extraction procedure.

Important

This decorator function is designed for decorating class methods.

This decorate first keep the current offset of self._file, then try to call the decorated function. Should any exception raised, it will re-parse the self._file as Raw protocol.

Note

The decorated function should have following signature:

func(self, proto, length, *args, **kwargs)
Parameters

func (Callable[[Protocol, int, Optional[int], ParamSpec(P)], TypeVar(R)]) – decorated function

Return type

Callable[[ParamSpec(P)], TypeVar(R)]

Important

pcapkit.utilities.decorators.seekset() and pcapkit.utilities.decorators.beholder() are designed for decorating class methods.

User Defined Exceptions

pcapkit.exceptions refined built-in exceptions. Make it possible to show only user error stack infomation *, when exception raised on user’s operation.

exception pcapkit.utilities.exceptions.BaseError(*args, quiet=False, **kwargs)[source]

Bases: Exception

Base error class of all kinds.

Important

  • Turn off system-default traceback function by set sys.tracebacklimit to 0.

  • But bugs appear in Python 3.6, so we have to set sys.tracebacklimit to None.

    Note

    This note is deprecated since Python fixed the problem above.

  • In Python 2.7, trace.print_stack(limit)() dose not support negative limit.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.DigitError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be (a) number(s).

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.IntError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be integral.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.RealError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The function is not defined for real number.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.ComplexError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The function is not defined for complex instance.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.BoolError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be bool type.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.BytesError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be bytes type.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.StringError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be str type.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.BytearrayError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be bytearray type.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.DictError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be dict type.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.ListError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be list type.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.TupleError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be tuple type.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.IterableError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be iterable.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.IOObjError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be file-like object.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.ProtocolUnbound(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

Protocol slice unbound.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.CallableError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be callable.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.InfoError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be Info instance.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.IPError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be IP address.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.EnumError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be enumeration protocol type.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.ComparisonError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

Rich comparison not supported between instances.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.RegistryError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, TypeError

The argument(s) must be registry type.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.FormatError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, AttributeError

Unknown format(s).

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.UnsupportedCall(*args, quiet=False, **kwargs)[source]

Bases: BaseError, AttributeError

Unsupported function or property call.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.FileError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, OSError

[Errno 5] Wrong file format.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.FileExists(*args, quiet=False, **kwargs)[source]

Bases: BaseError, FileExistsError

[Errno 17] File already exists.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.FileNotFound(*args, quiet=False, **kwargs)[source]

Bases: BaseError, FileNotFoundError

[Errno 2] File not found.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.ProtocolNotFound(*args, quiet=False, **kwargs)[source]

Bases: BaseError, IndexError

Protocol not found in ProtoChain.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.VersionError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, ValueError

Unknown IP version.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.IndexNotFound(*args, quiet=False, **kwargs)[source]

Bases: BaseError, ValueError

Protocol not in ProtoChain.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.ProtocolError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, ValueError

Invalid protocol format.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.EndianError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, ValueError

Invalid endian (byte order).

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.KeyExists(*args, quiet=False, **kwargs)[source]

Bases: BaseError, ValueError

Key already exists.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.ProtocolNotImplemented(*args, quiet=False, **kwargs)[source]

Bases: BaseError, NotImplementedError

Protocol not implemented.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.VendorNotImplemented(*args, quiet=False, **kwargs)[source]

Bases: BaseError, NotImplementedError

Vendor not implemented.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.StructError(*args, eof=False, **kwargs)[source]

Bases: BaseError, error

Unpack failed.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

  • eof (bool) –

  • **kwargs

Return type

None

exception pcapkit.utilities.exceptions.MissingKeyError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, KeyError

Key not found.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.FragmentError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, KeyError

Invalid fragment dict.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.PacketError(*args, quiet=False, **kwargs)[source]

Bases: BaseError, KeyError

Invalid packet dict.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.exceptions.ModuleNotFound(*args, quiet=False, **kwargs)[source]

Bases: BaseError, ModuleNotFoundError

Module not found.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • quiet (bool) – If True, suppress exception message.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

pcapkit.utilities.exceptions.stacklevel()[source]

Fetch current stack level.

The function will walk through the straceback stack (traceback.extract_stack()), and fetch the stack level where the path contains /pcapkit/. So that it won’t display any disturbing internal traceback information when raising errors.

Return type

int

Returns

Stack level until internal stacks, i.e. contains /pcapkit/.


*

See tbtrim project for a modern Pythonic implementation.

User Defined Warnings

pcapkit.warnings refined built-in warnings.

pcapkit.utilities.warnings.warn(message, category, stacklevel=None)[source]

Wrapper function of warnings.warn().

Parameters
Return type

None

exception pcapkit.utilities.warnings.BaseWarning(*args, **kwargs)[source]

Bases: UserWarning

Base warning class of all kinds.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.FormatWarning(*args, **kwargs)[source]

Bases: BaseWarning, ImportWarning

Warning on unknown format(s).

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.EngineWarning(*args, **kwargs)[source]

Bases: BaseWarning, ImportWarning

Unsupported extraction engine.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.InvalidVendorWarning(*args, **kwargs)[source]

Bases: BaseWarning, ImportWarning

Vendor CLI invalid updater.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.FileWarning(*args, **kwargs)[source]

Bases: BaseWarning, RuntimeWarning

Warning on file(s).

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.LayerWarning(*args, **kwargs)[source]

Bases: BaseWarning, RuntimeWarning

Unrecognised layer.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.ProtocolWarning(*args, **kwargs)[source]

Bases: BaseWarning, RuntimeWarning

Unrecognised protocol.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.AttributeWarning(*args, **kwargs)[source]

Bases: BaseWarning, RuntimeWarning

Unsupported attribute.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.DevModeWarning(*args, **kwargs)[source]

Bases: BaseWarning, RuntimeWarning

Run in development mode.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.VendorRequestWarning(*args, **kwargs)[source]

Bases: BaseWarning, RuntimeWarning

Vendor request connection failed.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.VendorRuntimeWarning(*args, **kwargs)[source]

Bases: BaseWarning, RuntimeWarning

Vendor failed during runtime.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.DPKTWarning(*args, **kwargs)[source]

Bases: BaseWarning, ResourceWarning

Warnings on DPKT usage.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.ScapyWarning(*args, **kwargs)[source]

Bases: BaseWarning, ResourceWarning

Warnings on Scapy usage.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.PySharkWarning(*args, **kwargs)[source]

Bases: BaseWarning, ResourceWarning

Warnings on PyShark usage.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.EmojiWarning(*args, **kwargs)[source]

Bases: BaseWarning, ResourceWarning

Warnings on Emoji usage.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

exception pcapkit.utilities.warnings.VendorWarning(*args, **kwargs)[source]

Bases: BaseWarning, ResourceWarning

Warnings on vendor usage.

Parameters
  • *args (Any) – Arbitrary positional arguments.

  • **kwargs (Any) – Arbitrary keyword arguments.

Return type

None

Version Compatibility

pcapkit further provides a compatibility layer for the following objects and functions:

ModuleNotFoundError

Python 3.6+

collections.abc.Collection

Python 3.6+

pathlib

Python 3.5+

functools.cached_property()

Python 3.8+

Constant Enumerations

This module contains all constant enumerations of pcapkit, which are automatically generated from the pcapkit.vendor module.

Protocol Numbers

Protocol Type Registry Constant Enumerations

This module contains all constant enumerations of protocol type registry implementations. Available enumerations include:

LINKTYPE

Link-Layer Header Type Values *

ETHERTYPE

Ethertype IEEE 802 Numbers

TRANSTYPE

Transport Layer Protocol Numbers

class pcapkit.const.reg.linktype.LinkType(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[LinkType] Link-Layer Header Type Values

NULL = 0

[DLT_NULL] BSD loopback encapsulation; the link layer header is a 4-byte field, in host byte order, containing a value of 2 for IPv4 packets, a value of either 24, 28, or 30 for IPv6 packets, a value of 7 for OSI packets, or a value of 23 for IPX packets. All of the IPv6 values correspond to IPv6 packets; code reading files should check for all of them. Note that ``host byte order’’ is the byte order of the machine on that the packets are captured; if a live capture is being done, ``host byte order’’ is the byte order of the machine capturing the packets, but if a ``savefile’’ is being read, the byte order is not necessarily that of the machine reading the capture file.

ETHERNET = 1

[DLT_EN10MB] IEEE 802.3 Ethernet (10Mb, 100Mb, 1000Mb, and up); the 10MB in the DLT_ name is historical.

AX25 = 3

[DLT_AX25] AX.25 packet, with nothing preceding it.

IEEE802_5 = 6

[DLT_IEEE802] IEEE 802.5 Token Ring; the IEEE802, without _5, in the DLT_ name is historical.

ARCNET_BSD = 7

[DLT_ARCNET] ARCNET Data Packets, as described by the ARCNET Trade Association standard ATA 878.1-1999, but without the Starting Delimiter, Information Length, or Frame Check Sequence fields, and with only the first ISU of the Destination Identifier. For most packet types, ARCNET Trade Association draft standard ATA 878.2 is also used. See also RFC 1051 and RFC 1201; for RFC 1051 frames, ATA 878.2 is not used.

SLIP = 8

[DLT_SLIP] SLIP, encapsulated with a LINKTYPE_SLIP header.

PPP = 9

[DLT_PPP] PPP, as per RFC 1661 and RFC 1662; if the first 2 bytes are 0xff and 0x03, it’s PPP in HDLC-like framing, with the PPP header following those two bytes, otherwise it’s PPP without framing, and the packet begins with the PPP header. The data in the frame is not octet-stuffed or bit- stuffed.

FDDI = 10

[DLT_FDDI] FDDI, as specified by ANSI INCITS 239-1994.

PPP_HDLC = 50

[DLT_PPP_SERIAL] PPP in HDLC-like framing, as per RFC 1662, or Cisco PPP with HDLC framing, as per section 4.3.1 of RFC 1547; the first byte will be 0xFF for PPP in HDLC-like framing, and will be 0x0F or 0x8F for Cisco PPP with HDLC framing. The data in the frame is not octet-stuffed or bit- stuffed.

PPP_ETHER = 51

[DLT_PPP_ETHER] PPPoE; the packet begins with a PPPoE header, as per RFC 2516.

ATM_RFC1483 = 100

[DLT_ATM_RFC1483] RFC 1483 LLC/SNAP-encapsulated ATM; the packet begins with an ISO 8802-2 (formerly known as IEEE 802.2) LLC header.

RAW = 101

[DLT_RAW] Raw IP; the packet begins with an IPv4 or IPv6 header, with the version field of the header indicating whether it’s an IPv4 or IPv6 header.

C_HDLC = 104

[DLT_C_HDLC] Cisco PPP with HDLC framing, as per section 4.3.1 of RFC 1547.

IEEE802_11 = 105

[DLT_IEEE802_11] IEEE 802.11 wireless LAN.

FRELAY = 107

[DLT_FRELAY] Frame Relay LAPF frames, beginning with a ITU-T Recommendation Q.922 LAPF header starting with the address field, and without an FCS at the end of the frame.

LOOP = 108

[DLT_LOOP] OpenBSD loopback encapsulation; the link-layer header is a 4-byte field, in network byte order, containing a value of 2 for IPv4 packets, a value of either 24, 28, or 30 for IPv6 packets, a value of 7 for OSI packets, or a value of 23 for IPX packets. All of the IPv6 values correspond to IPv6 packets; code reading files should check for all of them.

LINUX_SLL = 113

[DLT_LINUX_SLL] Linux “cooked” capture encapsulation.

LTALK = 114

[DLT_LTALK] Apple LocalTalk; the packet begins with an AppleTalk LocalTalk Link Access Protocol header, as described in chapter 1 of Inside AppleTalk, Second Edition.

PFLOG = 117

[DLT_PFLOG] OpenBSD pflog; the link-layer header contains a struct pfloghdr structure, as defined by the host on that the file was saved. (This differs from operating system to operating system and release to release; there is nothing in the file to indicate what the layout of that structure is.)

IEEE802_11_PRISM = 119

[DLT_PRISM_HEADER] Prism monitor mode information followed by an 802.11 header.

IP_OVER_FC = 122

[DLT_IP_OVER_FC] RFC 2625 IP-over-Fibre Channel, with the link-layer header being the Network_Header as described in that RFC.

SUNATM = 123

[DLT_SUNATM] ATM traffic, encapsulated as per the scheme used by SunATM devices.

IEEE802_11_RADIOTAP = 127

[DLT_IEEE802_11_RADIO] Radiotap link-layer information followed by an 802.11 header.

ARCNET_LINUX = 129

[DLT_ARCNET_LINUX] ARCNET Data Packets, as described by the ARCNET Trade Association standard ATA 878.1-1999, but without the Starting Delimiter, Information Length, or Frame Check Sequence fields, with only the first ISU of the Destination Identifier, and with an extra two-ISU offset field following the Destination Identifier. For most packet types, ARCNET Trade Association draft standard ATA 878.2 is also used; however, no exception frames are supplied, and reassembled frames, rather than fragments, are supplied. See also RFC 1051 and RFC 1201; for RFC 1051 frames, ATA 878.2 is not used.

APPLE_IP_OVER_IEEE1394 = 138

[DLT_APPLE_IP_OVER_IEEE1394] Apple IP-over-IEEE 1394 cooked header.

MTP2_WITH_PHDR = 139

[DLT_MTP2_WITH_PHDR] Signaling System 7 Message Transfer Part Level 2, as specified by ITU-T Recommendation Q.703, preceded by a pseudo-header.

MTP2 = 140

[DLT_MTP2] Signaling System 7 Message Transfer Part Level 2, as specified by ITU-T Recommendation Q.703.

MTP3 = 141

[DLT_MTP3] Signaling System 7 Message Transfer Part Level 3, as specified by ITU-T Recommendation Q.704, with no MTP2 header preceding the MTP3 packet.

SCCP = 142

[DLT_SCCP] Signaling System 7 Signalling Connection Control Part, as specified by ITU-T Recommendation Q.711, ITU-T Recommendation Q.712, ITU-T Recommendation Q.713, and ITU-T Recommendation Q.714, with no MTP3 or MTP2 headers preceding the SCCP packet.

DOCSIS = 143

[DLT_DOCSIS] DOCSIS MAC frames, as described by the DOCSIS 3.1 MAC and Upper Layer Protocols Interface Specification or earlier specifications for MAC frames.

LINUX_IRDA = 144

[DLT_LINUX_IRDA] Linux-IrDA packets, with a LINKTYPE_LINUX_IRDA header, with the payload for IrDA frames beginning with by the IrLAP header as defined by IrDA Data Specifications, including the IrDA Link Access Protocol specification.

USER0 = 147

[DLT_USER0] Reserved for private use; see above.

USER1 = 148

[DLT_USER1] Reserved for private use; see above.

USER2 = 149

[DLT_USER2] Reserved for private use; see above.

USER3 = 150

[DLT_USER3] Reserved for private use; see above.

USER4 = 151

[DLT_USER4] Reserved for private use; see above.

USER5 = 152

[DLT_USER5] Reserved for private use; see above.

USER6 = 153

[DLT_USER6] Reserved for private use; see above.

USER7 = 154

[DLT_USER7] Reserved for private use; see above.

USER8 = 155

[DLT_USER8] Reserved for private use; see above.

USER9 = 156

[DLT_USER9] Reserved for private use; see above.

USER10 = 157

[DLT_USER10] Reserved for private use; see above.

USER11 = 158

[DLT_USER11] Reserved for private use; see above.

USER12 = 159

[DLT_USER12] Reserved for private use; see above.

USER13 = 160

[DLT_USER13] Reserved for private use; see above.

USER14 = 161

[DLT_USER14] Reserved for private use; see above.

USER15 = 162

[DLT_USER15] Reserved for private use; see above.

IEEE802_11_AVS = 163

[DLT_IEEE802_11_RADIO_AVS] AVS monitor mode information followed by an 802.11 header.

BACNET_MS_TP = 165

[DLT_BACNET_MS_TP] BACnet MS/TP frames, as specified by section 9.3 MS/TP Frame Format of ANSI/ASHRAE Standard 135, BACnet® - A Data Communication Protocol for Building Automation and Control Networks, including the preamble and, if present, the Data CRC.

PPP_PPPD = 166

[DLT_PPP_PPPD] PPP in HDLC-like encapsulation, like LINKTYPE_PPP_HDLC, but with the 0xff address byte replaced by a direction indication—0x00 for incoming and 0x01 for outgoing.

GPRS_LLC = 169

[DLT_GPRS_LLC] General Packet Radio Service Logical Link Control, as defined by 3GPP TS 04.64.

GPF_T = 170

[DLT_GPF_T] Transparent-mapped generic framing procedure, as specified by ITU-T Recommendation G.7041/Y.1303.

GPF_F = 171

[DLT_GPF_F] Frame-mapped generic framing procedure, as specified by ITU-T Recommendation G.7041/Y.1303.

LINUX_LAPD = 177

[DLT_LINUX_LAPD] Link Access Procedures on the D Channel (LAPD) frames, as specified by ITU-T Recommendation Q.920 and ITU-T Recommendation Q.921, captured via vISDN, with a LINKTYPE_LINUX_LAPD header, followed by the Q.921 frame, starting with the address field.

MFR = 182

[DLT_MFR] FRF.16.1 Multi-Link Frame Relay frames, beginning with an FRF.12 Interface fragmentation format fragmentation header.

BLUETOOTH_HCI_H4 = 187

[DLT_BLUETOOTH_HCI_H4] Bluetooth HCI UART transport layer; the frame contains an HCI packet indicator byte, as specified by the UART Transport Layer portion of the most recent Bluetooth Core specification, followed by an HCI packet of the specified packet type, as specified by the Host Controller Interface Functional Specification portion of the most recent Bluetooth Core Specification.

USB_LINUX = 189

[DLT_USB_LINUX] USB packets, beginning with a Linux USB header, as specified by the struct usbmon_packet in the Documentation/usb/usbmon.txt file in the Linux source tree. Only the first 48 bytes of that header are present. All fields in the header are in host byte order. When performing a live capture, the host byte order is the byte order of the machine on that the packets are captured. When reading a pcap file, the byte order is the byte order for the file, as specified by the file’s magic number; when reading a pcapng file, the byte order is the byte order for the section of the pcapng file, as specified by the Section Header Block.

PPI = 192

[DLT_PPI] Per-Packet Information information, as specified by the Per- Packet Information Header Specification, followed by a packet with the LINKTYPE_ value specified by the pph_dlt field of that header.

IEEE802_15_4_WITHFCS = 195

[DLT_IEEE802_15_4_WITHFCS] IEEE 802.15.4 Low-Rate Wireless Networks, with each packet having the FCS at the end of the frame.

SITA = 196

[DLT_SITA] Various link-layer types, with a pseudo-header, for SITA.

ERF = 197

[DLT_ERF] Various link-layer types, with a pseudo-header, for Endace DAG cards; encapsulates Endace ERF records.

BLUETOOTH_HCI_H4_WITH_PHDR = 201

[DLT_BLUETOOTH_HCI_H4_WITH_PHDR] Bluetooth HCI UART transport layer; the frame contains a 4-byte direction field, in network byte order (big-endian), the low-order bit of which is set if the frame was sent from the host to the controller and clear if the frame was received by the host from the controller, followed by an HCI packet indicator byte, as specified by the UART Transport Layer portion of the most recent Bluetooth Core specification, followed by an HCI packet of the specified packet type, as specified by the Host Controller Interface Functional Specification portion of the most recent Bluetooth Core Specification.

AX25_KISS = 202

[DLT_AX25_KISS] AX.25 packet, with a 1-byte KISS header containing a type indicator.

LAPD = 203

[DLT_LAPD] Link Access Procedures on the D Channel (LAPD) frames, as specified by ITU-T Recommendation Q.920 and ITU-T Recommendation Q.921, starting with the address field, with no pseudo-header.

PPP_WITH_DIR = 204

[DLT_PPP_WITH_DIR] PPP, as per RFC 1661 and RFC 1662, preceded with a one-byte pseudo-header with a zero value meaning “received by this host” and a non-zero value meaning “sent by this host”; if the first 2 bytes are 0xff and 0x03, it’s PPP in HDLC-like framing, with the PPP header following those two bytes, otherwise it’s PPP without framing, and the packet begins with the PPP header. The data in the frame is not octet-stuffed or bit-stuffed.

C_HDLC_WITH_DIR = 205

[DLT_C_HDLC_WITH_DIR] Cisco PPP with HDLC framing, as per section 4.3.1 of RFC 1547, preceded with a one-byte pseudo-header with a zero value meaning “received by this host” and a non-zero value meaning “sent by this host”.

FRELAY_WITH_DIR = 206

[DLT_FRELAY_WITH_DIR] Frame Relay LAPF frames, beginning with a one-byte pseudo-header with a zero value meaning “received by this host” (DCE->DTE) and a non-zero value meaning “sent by this host” (DTE->DCE), followed by an ITU-T Recommendation Q.922 LAPF header starting with the address field, and without an FCS at the end of the frame.

LAPB_WITH_DIR = 207

[DLT_LAPB_WITH_DIR] Link Access Procedure, Balanced (LAPB), as specified by ITU-T Recommendation X.25, preceded with a one-byte pseudo-header with a zero value meaning “received by this host” (DCE->DTE) and a non-zero value meaning “sent by this host” (DTE->DCE).

IPMB_LINUX = 209

[DLT_IPMB_LINUX] IPMB over an I2C circuit, with a Linux-specific pseudo- header.

FLEXRAY = 210

[DLT_FLEXRAY] FlexRay automotive bus frames or symbols, preceded by a pseudo-header.

LIN = 212

[DLT_LIN] Local Interconnect Network (LIN) automotive bus, preceded by a pseudo-header.

IEEE802_15_4_NONASK_PHY = 215

[DLT_IEEE802_15_4_NONASK_PHY] IEEE 802.15.4 Low-Rate Wireless Networks, with each packet having the FCS at the end of the frame, and with the PHY- level data for the O-QPSK, BPSK, GFSK, MSK, and RCC DSS BPSK PHYs (4 octets of 0 as preamble, one octet of SFD, one octet of frame length + reserved bit) preceding the MAC-layer data (starting with the frame control field).

USB_LINUX_MMAPPED = 220

[DLT_USB_LINUX_MMAPPED] USB packets, beginning with a Linux USB header, as specified by the struct usbmon_packet in the Documentation/usb/usbmon.txt file in the Linux source tree. All 64 bytes of the header are present. All fields in the header are in host byte order. When performing a live capture, the host byte order is the byte order of the machine on that the packets are captured. When reading a pcap file, the byte order is the byte order for the file, as specified by the file’s magic number; when reading a pcapng file, the byte order is the byte order for the section of the pcapng file, as specified by the Section Header Block. For isochronous transfers, the ndesc field specifies the number of isochronous descriptors that follow.

FC_2 = 224

[DLT_FC_2] Fibre Channel FC-2 frames, beginning with a Frame_Header.

FC_2_WITH_FRAME_DELIMS = 225

[DLT_FC_2_WITH_FRAME_DELIMS] Fibre Channel FC-2 frames, beginning an encoding of the SOF, followed by a Frame_Header, and ending with an encoding of the SOF. The encodings represent the frame delimiters as 4-byte sequences representing the corresponding ordered sets, with K28.5 represented as 0xBC, and the D symbols as the corresponding byte values; for example, SOFi2, which is K28.5 - D21.5 - D1.2 - D21.2, is represented as 0xBC 0xB5 0x55 0x55.

IPNET = 226

[DLT_IPNET] Solaris ipnet pseudo-header, followed by an IPv4 or IPv6 datagram.

CAN_SOCKETCAN = 227

[DLT_CAN_SOCKETCAN] CAN (Controller Area Network) frames, with a pseudo- header followed by the frame payload.

IPV4 = 228

[DLT_IPV4] Raw IPv4; the packet begins with an IPv4 header.

IPV6 = 229

[DLT_IPV6] Raw IPv6; the packet begins with an IPv6 header.

IEEE802_15_4_NOFCS = 230

[DLT_IEEE802_15_4_NOFCS] IEEE 802.15.4 Low-Rate Wireless Network, without the FCS at the end of the frame.

DBUS = 231

[DLT_DBUS] Raw D-Bus messages, starting with the endianness flag, followed by the message type, etc., but without the authentication handshake before the message sequence.

DVB_CI = 235

[DLT_DVB_CI] DVB-CI (DVB Common Interface for communication between a PC Card module and a DVB receiver), with the message format specified by the PCAP format for DVB-CI specification.

MUX27010 = 236

[DLT_MUX27010] Variant of 3GPP TS 27.010 multiplexing protocol (similar to, but not the same as, 27.010).

STANAG_5066_D_PDU = 237

[DLT_STANAG_5066_D_PDU] D_PDUs as described by NATO standard STANAG 5066, starting with the synchronization sequence, and including both header and data CRCs. The current version of STANAG 5066 is backwards-compatible with the 1.0.2 version, although newer versions are classified.

NFLOG = 239

[DLT_NFLOG] Linux netlink NETLINK NFLOG socket log messages.

NETANALYZER = 240

[DLT_NETANALYZER] Pseudo-header for Hilscher Gesellschaft für Systemautomation mbH netANALYZER devices, followed by an Ethernet frame, beginning with the MAC header and ending with the FCS.

NETANALYZER_TRANSPARENT = 241

[DLT_NETANALYZER_TRANSPARENT] Pseudo-header for Hilscher Gesellschaft für Systemautomation mbH netANALYZER devices, followed by an Ethernet frame, beginning with the preamble, SFD, and MAC header, and ending with the FCS.

IPOIB = 242

[DLT_IPOIB] IP-over-InfiniBand, as specified by RFC 4391 section 6.

MPEG_2_TS = 243

[DLT_MPEG_2_TS] MPEG-2 Transport Stream transport packets, as specified by ISO 13818-1/ITU-T Recommendation H.222.0 (see table 2-2 of section 2.4.3.2 “Transport Stream packet layer”).

NG40 = 244

[DLT_NG40] Pseudo-header for ng4T GmbH’s UMTS Iub/Iur-over-ATM and Iub/Iur-over-IP format as used by their ng40 protocol tester, followed by frames for the Frame Protocol as specified by 3GPP TS 25.427 for dedicated channels and 3GPP TS 25.435 for common/shared channels in the case of ATM AAL2 or UDP traffic, by SSCOP packets as specified by ITU-T Recommendation Q.2110 for ATM AAL5 traffic, and by NBAP packets for SCTP traffic.

NFC_LLCP = 245

[DLT_NFC_LLCP] Pseudo-header for NFC LLCP packet captures, followed by frame data for the LLCP Protocol as specified by NFCForum-TS-LLCP_1.1.

INFINIBAND = 247

[DLT_INFINIBAND] Raw InfiniBand frames, starting with the Local Routing Header, as specified in Chapter 5 “Data packet format” of InfiniBand™ Architectural Specification Release 1.2.1 Volume 1 - General Specifications.

SCTP = 248

[DLT_SCTP] SCTP packets, as defined by RFC 4960, with no lower-level protocols such as IPv4 or IPv6.

USBPCAP = 249

[DLT_USBPCAP] USB packets, beginning with a USBPcap header.

RTAC_SERIAL = 250

[DLT_RTAC_SERIAL] Serial-line packet header for the Schweitzer Engineering Laboratories “RTAC” product, followed by a payload for one of a number of industrial control protocols.

BLUETOOTH_LE_LL = 251

[DLT_BLUETOOTH_LE_LL] Bluetooth Low Energy air interface Link Layer packets, in the format described in section 2.1 “PACKET FORMAT” of volume 6 of the Bluetooth Specification Version 4.0 (see PDF page 2200), but without the Preamble.

[DLT_NETLINK] Linux Netlink capture encapsulation.

BLUETOOTH_LINUX_MONITOR = 254

[DLT_BLUETOOTH_LINUX_MONITOR] Bluetooth Linux Monitor encapsulation of traffic for the BlueZ stack.

BLUETOOTH_BREDR_BB = 255

[DLT_BLUETOOTH_BREDR_BB] Bluetooth Basic Rate and Enhanced Data Rate baseband packets.

BLUETOOTH_LE_LL_WITH_PHDR = 256

[DLT_BLUETOOTH_LE_LL_WITH_PHDR] Bluetooth Low Energy link-layer packets.

PROFIBUS_DL = 257

[DLT_PROFIBUS_DL] PROFIBUS data link layer packets, as specified by IEC standard 61158-4-3, beginning with the start delimiter, ending with the end delimiter, and including all octets between them.

PKTAP = 258

[DLT_PKTAP] Apple PKTAP capture encapsulation.

EPON = 259

[DLT_EPON] Ethernet-over-passive-optical-network packets, starting with the last 6 octets of the modified preamble as specified by 65.1.3.2 “Transmit” in Clause 65 of Section 5 of IEEE 802.3, followed immediately by an Ethernet frame.

IPMI_HPM_2 = 260

[DLT_IPMI_HPM_2] IPMI trace packets, as specified by Table 3-20 “Trace Data Block Format” in the PICMG HPM.2 specification. The time stamps for packets in this format must match the time stamps in the Trace Data Blocks.

ZWAVE_R1_R2 = 261

[DLT_ZWAVE_R1_R2] Z-Wave RF profile R1 and R2 packets, as specified by ITU-T Recommendation G.9959, with some MAC layer fields moved.

ZWAVE_R3 = 262

[DLT_ZWAVE_R3] Z-Wave RF profile R3 packets, as specified by ITU-T Recommendation G.9959, with some MAC layer fields moved.

WATTSTOPPER_DLM = 263

[DLT_WATTSTOPPER_DLM] Formats for WattStopper Digital Lighting Management (DLM) and Legrand Nitoo Open protocol common packet structure captures.

ISO_14443 = 264

[DLT_ISO_14443] Messages between ISO 14443 contactless smartcards (Proximity Integrated Circuit Card, PICC) and card readers (Proximity Coupling Device, PCD), with the message format specified by the PCAP format for ISO14443 specification.

RDS = 265

[DLT_RDS] Radio data system (RDS) groups, as per IEC 62106, encapsulated in this form.

USB_DARWIN = 266

[DLT_USB_DARWIN] USB packets, beginning with a Darwin (macOS, etc.) USB header.

SDLC = 268

[DLT_SDLC] SDLC packets, as specified by Chapter 1, “DLC Links”, section “Synchronous Data Link Control (SDLC)” of Systems Network Architecture Formats, GA27-3136-20, without the flag fields, zero-bit insertion, or Frame Check Sequence field, containing SNA path information units (PIUs) as the payload.

LORATAP = 270

[DLT_LORATAP] LoRaTap pseudo-header, followed by the payload, which is typically the PHYPayload from the LoRaWan specification.

VSOCK = 271

[DLT_VSOCK] Protocol for communication between host and guest machines in VMware and KVM hypervisors.

NORDIC_BLE = 272

[DLT_NORDIC_BLE] Messages to and from a Nordic Semiconductor nRF Sniffer for Bluetooth LE packets, beginning with a pseudo-header.

DOCSIS31_XRA31 = 273

[DLT_DOCSIS31_XRA31] DOCSIS packets and bursts, preceded by a pseudo- header giving metadata about the packet.

ETHERNET_MPACKET = 274

[DLT_ETHERNET_MPACKET] mPackets, as specified by IEEE 802.3br Figure 99-4, starting with the preamble and always ending with a CRC field.

DISPLAYPORT_AUX = 275

[DLT_DISPLAYPORT_AUX] DisplayPort AUX channel monitoring data as specified by VESA DisplayPort (DP) Standard preceded by a pseudo-header.

LINUX_SLL2 = 276

[DLT_LINUX_SLL2] Linux “cooked” capture encapsulation v2.

OPENVIZSLA = 278

[DLT_OPENVIZSLA] Openvizsla FPGA-based USB sniffer.

EBHSCR = 279

[DLT_EBHSCR] Elektrobit High Speed Capture and Replay (EBHSCR) format.

VPP_DISPATCH = 280

//fd.io VPP graph dispatch tracer, in the the graph dispatcher trace format.

Type

[DLT_VPP_DISPATCH] Records in traces from the http

DSA_TAG_BRCM = 281

[DLT_DSA_TAG_BRCM] Ethernet frames, with a switch tag inserted between the source address field and the type/length field in the Ethernet header.

DSA_TAG_BRCM_PREPEND = 282

[DLT_DSA_TAG_BRCM_PREPEND] Ethernet frames, with a switch tag inserted before the destination address in the Ethernet header.

IEEE802_15_4_TAP = 283

[DLT_IEEE802_15_4_TAP] IEEE 802.15.4 Low-Rate Wireless Networks, with a pseudo-header containing TLVs with metadata preceding the 802.15.4 header.

DSA_TAG_DSA = 284

[DLT_DSA_TAG_DSA] Ethernet frames, with a switch tag inserted between the source address field and the type/length field in the Ethernet header.

DSA_TAG_EDSA = 285

[DLT_DSA_TAG_EDSA] Ethernet frames, with a programmable Ethernet type switch tag inserted between the source address field and the type/length field in the Ethernet header.

ELEE = 286

[DLT_ELEE] Payload of lawful intercept packets using the ELEE protocol. The packet begins with the ELEE header; it does not include any transport- layer or lower-layer headers for protcols used to transport ELEE packets.

Z_WAVE_SERIAL = 287

[DLT_Z_WAVE_SERIAL] Serial frames transmitted between a host and a Z-Wave chip over an RS-232 or USB serial connection, as described in section 5 of the Z-Wave Serial API Host Application Programming Guide.

USB_2_0 = 288

[DLT_USB_2_0] USB 2.0, 1.1, or 1.0 packet, beginning with a PID, as described by Chapter 8 “Protocol Layer” of the the Universal Serial Bus Specification Revision 2.0.

ATSC_ALP = 289

[DLT_ATSC_ALP] ATSC Link-Layer Protocol frames, as described in section 5 of the A/330 Link-Layer Protocol specification, found at the ATSC 3.0 standards page, beginning with a Base Header.

ETW = 290

[DLT_ETW] Event Tracing for Windows messages, beginning with a pseudo- header.

ZBOSS_NCP = 292

[DLT_ZBOSS_NCP] Serial NCP (Network Co-Processor) protocol for Zigbee stack ZBOSS by DSR. ZBOSS NCP protocol, beginning with a header.

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

LinkType

Ethertype IEEE 802 Numbers

This module contains the constant enumeration for Ethertype IEEE 802 Numbers, which is automatically generated from pcapkit.vendor.reg.ethertype.EtherType.

class pcapkit.const.reg.ethertype.EtherType(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[EtherType] Ethertype IEEE 802 Numbers

XEROX_PUP = 512

XEROX PUP (see 0A00) [Boggs, D., J. Shoch, E. Taft, and R. Metcalfe, “PUP: An Internetwork Architecture”, XEROX Palo Alto Research Center, CSL-79-10, July 1979; also in IEEE Transactions on Communication, Volume COM-28, Number 4, April 1980.][Neil Sembower]

PUP_Addr_Trans_0x0201 = 513

PUP Addr Trans (see 0A01) [Neil Sembower]

Nixdorf = 1024

Nixdorf [Neil Sembower]

XEROX_NS_IDP = 1536

Data Link Layer and Physical Layer Specification”, AA-K759B-TK, Digital Equipment Corporation, Maynard, MA. Also as: “The Ethernet - A Local Area Network”, Version 1.0, Digital Equipment Corporation, Intel Corporation, Xerox Corporation, September 1980. And: “The Ethernet, A Local Area Network: Data Link Layer and Physical Layer Specifications”, Digital, Intel and Xerox, November 1982. And: XEROX, “The Ethernet, A Local Area Network: Data Link Layer and Physical Layer Specification”, X3T51/80-50, Xerox Corporation, Stamford, CT., October 1980.][Neil Sembower]

Type

XEROX NS IDP [“The Ethernet, A Local Area Network

DLOG_0x0660 = 1632

DLOG [Neil Sembower]

DLOG_0x0661 = 1633

DLOG [Neil Sembower]

Internet_Protocol_version_4 = 2048

Internet Protocol version 4 (IPv4) [RFC 7042]

X_75_Internet = 2049

X.75 Internet [Neil Sembower]

NBS_Internet = 2050

NBS Internet [Neil Sembower]

ECMA_Internet = 2051

ECMA Internet [Neil Sembower]

Chaosnet = 2052

Chaosnet [Neil Sembower]

X_25_Level_3 = 2053

X.25 Level 3 [Neil Sembower]

Address_Resolution_Protocol = 2054

Address Resolution Protocol (ARP) [RFC 7042]

XNS_Compatability = 2055

XNS Compatability [Neil Sembower]

Frame_Relay_ARP = 2056

Frame Relay ARP [RFC 1701]

Symbolics_Private = 2076

Symbolics Private [David Plummer]

Ungermann_Bass_net_debugr = 2304

Ungermann-Bass net debugr [Neil Sembower]

Xerox_IEEE802_3_PUP = 2560

Xerox IEEE802.3 PUP [Neil Sembower]

PUP_Addr_Trans_0x0A01 = 2561

PUP Addr Trans [Neil Sembower]

Banyan_VINES = 2989

Banyan VINES [Neil Sembower]

VINES_Loopback = 2990

VINES Loopback [RFC 1701]

VINES_Echo = 2991

VINES Echo [RFC 1701]

Berkeley_Trailer_nego = 4096

Berkeley Trailer nego [Neil Sembower]

Valid_Systems = 5632

Valid Systems [Neil Sembower]

TRILL = 8947

TRILL [RFC 6325]

L2_IS_IS = 8948

L2-IS-IS [RFC 6325]

PCS_Basic_Block_Protocol = 16962

PCS Basic Block Protocol [Neil Sembower]

BBN_Simnet = 21000

BBN Simnet [Neil Sembower]

DEC_Unassigned_0x6000 = 24576

DEC Unassigned (Exp.) [Neil Sembower]

DEC_MOP_Dump_Load = 24577

DEC MOP Dump/Load [Neil Sembower]

DEC_MOP_Remote_Console = 24578

DEC MOP Remote Console [Neil Sembower]

DEC_DECNET_Phase_IV_Route = 24579

DEC DECNET Phase IV Route [Neil Sembower]

DEC_LAT = 24580

DEC LAT [Neil Sembower]

DEC_Diagnostic_Protocol = 24581

DEC Diagnostic Protocol [Neil Sembower]

DEC_Customer_Protocol = 24582

DEC Customer Protocol [Neil Sembower]

DEC_LAVC_SCA = 24583

DEC LAVC, SCA [Neil Sembower]

Trans_Ether_Bridging = 25944

Trans Ether Bridging [RFC 1701]

Raw_Frame_Relay = 25945

Raw Frame Relay [RFC 1701]

Ungermann_Bass_download = 28672

Ungermann-Bass download [Neil Sembower]

Ungermann_Bass_dia_loop = 28674

Ungermann-Bass dia/loop [Neil Sembower]

Proteon = 28720

Proteon [Neil Sembower]

Cabletron = 28724

Cabletron [Neil Sembower]

Cronus_VLN = 32771

Cronus VLN [RFC 824][Daniel Tappan]

Cronus_Direct = 32772

Cronus Direct [RFC 824][Daniel Tappan]

HP_Probe = 32773

HP Probe [Neil Sembower]

Nestar = 32774

Nestar [Neil Sembower]

AT_T_0x8008 = 32776

AT&T [Neil Sembower]

Excelan = 32784

Excelan [Neil Sembower]

SGI_diagnostics = 32787

SGI diagnostics [Andrew Cherenson]

SGI_network_games = 32788

SGI network games [Andrew Cherenson]

SGI_reserved = 32789

SGI reserved [Andrew Cherenson]

SGI_bounce_server = 32790

SGI bounce server [Andrew Cherenson]

Apollo_Domain = 32793

Apollo Domain [Neil Sembower]

Tymshare = 32814

Tymshare [Neil Sembower]

Tigan_Inc = 32815

Tigan, Inc. [Neil Sembower]

Reverse_Address_Resolution_Protocol = 32821

Reverse Address Resolution Protocol (RARP) [RFC 903][Joseph Murdock]

Aeonic_Systems = 32822

Aeonic Systems [Neil Sembower]

DEC_LANBridge = 32824

DEC LANBridge [Neil Sembower]

DEC_Ethernet_Encryption = 32829

DEC Ethernet Encryption [Neil Sembower]

DEC_Unassigned_0x803E = 32830

DEC Unassigned [Neil Sembower]

DEC_LAN_Traffic_Monitor = 32831

DEC LAN Traffic Monitor [Neil Sembower]

Planning_Research_Corp = 32836

Planning Research Corp. [Neil Sembower]

AT_T_0x8046 = 32838

AT&T [Neil Sembower]

AT_T_0x8047 = 32839

AT&T [Neil Sembower]

ExperData = 32841

ExperData [Neil Sembower]

Stanford_V_Kernel_exp = 32859

Stanford V Kernel exp. [Neil Sembower]

Stanford_V_Kernel_prod = 32860

Stanford V Kernel prod. [Neil Sembower]

Evans_Sutherland = 32861

Evans & Sutherland [Neil Sembower]

Little_Machines = 32864

Little Machines [Neil Sembower]

Counterpoint_Computers = 32866

Counterpoint Computers [Neil Sembower]

Univ_of_Mass_Amherst_0x8065 = 32869

Univ. of Mass. @ Amherst [Neil Sembower]

Univ_of_Mass_Amherst_0x8066 = 32870

Univ. of Mass. @ Amherst [Neil Sembower]

Veeco_Integrated_Auto = 32871

Veeco Integrated Auto. [Neil Sembower]

General_Dynamics = 32872

General Dynamics [Neil Sembower]

AT_T_0x8069 = 32873

AT&T [Neil Sembower]

Autophon = 32874

Autophon [Neil Sembower]

ComDesign = 32876

ComDesign [Neil Sembower]

Computgraphic_Corp = 32877

Computgraphic Corp. [Neil Sembower]

Matra = 32890

Matra [Neil Sembower]

Dansk_Data_Elektronik = 32891

Dansk Data Elektronik [Neil Sembower]

Merit_Internodal = 32892

Merit Internodal [Hans Werner Braun]

Vitalink TransLAN III [Neil Sembower]

Appletalk = 32923

Appletalk [Neil Sembower]

Spider_Systems_Ltd = 32927

Spider Systems Ltd. [Neil Sembower]

Nixdorf_Computers = 32931

Nixdorf Computers [Neil Sembower]

Banyan_Systems_0x80C4 = 32964

Banyan Systems [Neil Sembower]

Banyan_Systems_0x80C5 = 32965

Banyan Systems [Neil Sembower]

Pacer_Software = 32966

Pacer Software [Neil Sembower]

Applitek_Corporation = 32967

Applitek Corporation [Neil Sembower]

IBM_SNA_Service_on_Ether = 32981

IBM SNA Service on Ether [Neil Sembower]

Varian_Associates = 32989

Varian Associates [Neil Sembower]

Retix = 33010

Retix [Neil Sembower]

AppleTalk_AARP = 33011

AppleTalk AARP (Kinetics) [Neil Sembower]

Apollo_Computer = 33015

Apollo Computer [Neil Sembower]

Wellfleet_Communications = 33023

Wellfleet Communications [Neil Sembower]

Customer_VLAN_Tag_Type = 33024

Customer VLAN Tag Type (C-Tag, formerly called the Q-Tag) (initially Wellfleet) [RFC 7042]

Hayes_Microcomputers = 33072

Hayes Microcomputers [Neil Sembower]

VG_Laboratory_Systems = 33073

VG Laboratory Systems [Neil Sembower]

Logicraft = 33096

Logicraft [Neil Sembower]

Network_Computing_Devices = 33097

Network Computing Devices [Neil Sembower]

Alpha_Micro = 33098

Alpha Micro [Neil Sembower]

SNMP = 33100

SNMP [Joyce K Reynolds]

BIIN_0x814D = 33101

BIIN [Neil Sembower]

BIIN_0x814E = 33102

BIIN [Neil Sembower]

Technically_Elite_Concept = 33103

Technically Elite Concept [Neil Sembower]

Rational_Corp = 33104

Rational Corp [Neil Sembower]

XTP = 33149

XTP [Neil Sembower]

SGI_Time_Warner_prop = 33150

SGI/Time Warner prop. [Neil Sembower]

HIPPI_FP_encapsulation = 33152

HIPPI-FP encapsulation [Neil Sembower]

STP_HIPPI_ST = 33153

STP, HIPPI-ST [Neil Sembower]

Reserved_for_HIPPI_6400_0x8182 = 33154

Reserved for HIPPI-6400 [Neil Sembower]

Reserved_for_HIPPI_6400_0x8183 = 33155

Reserved for HIPPI-6400 [Neil Sembower]

Motorola_Computer = 33165

Motorola Computer [Neil Sembower]

ARAI_Bunkichi = 33188

ARAI Bunkichi [Neil Sembower]

SECTRA = 34523

SECTRA [Neil Sembower]

Delta_Controls = 34526

Delta Controls [Neil Sembower]

Internet_Protocol_version_6 = 34525

Internet Protocol version 6 (IPv6) [RFC 7042]

ATOMIC = 34527

ATOMIC [Joe Touch]

TCP_IP_Compression = 34667

TCP/IP Compression [RFC 1144][RFC 1701]

IP_Autonomous_Systems = 34668

IP Autonomous Systems [RFC 1701]

Secure_Data = 34669

Secure Data [RFC 1701]

IEEE_Std_802_3_Ethernet_Passive_Optical_Network = 34824

IEEE Std 802.3 - Ethernet Passive Optical Network (EPON) [EPON][RFC 7042]

Slow_Protocols = 34825

Slow Protocols (Link Aggregation, OAM, etc.) [IEEE]

Point_to_Point_Protocol = 34827

Point-to-Point Protocol (PPP) [RFC 7042]

General_Switch_Management_Protocol = 34828

General Switch Management Protocol (GSMP) [RFC 7042]

Ethernet_NIC_hardware_and_software_testing = 34850

Ethernet NIC hardware and software testing [Wind River]

MPLS = 34887

MPLS [RFC 5332]

MPLS_with_upstream_assigned_label = 34888

MPLS with upstream-assigned label [RFC 5332]

Multicast_Channel_Allocation_Protocol = 34913

Multicast Channel Allocation Protocol (MCAP) [RFC 7042]

PPP_over_Ethernet_Discovery_Stage = 34915

PPP over Ethernet (PPPoE) Discovery Stage [RFC 2516]

PPP_over_Ethernet_Session_Stage = 34916

PPP over Ethernet (PPPoE) Session Stage [RFC 2516][RFC 8822]

IEEE_Std_802_1X_Port_based_network_access_control = 34958

IEEE Std 802.1X - Port-based network access control [IEEE]

IEEE_Std_802_1Q_Service_VLAN_tag_identifier = 34984

IEEE Std 802.1Q - Service VLAN tag identifier (S-Tag) [IEEE]

IEEE_Std_802_Local_Experimental_Ethertype_0x88B5 = 34997

IEEE Std 802 - Local Experimental Ethertype [IEEE]

IEEE_Std_802_Local_Experimental_Ethertype_0x88B6 = 34998

IEEE Std 802 - Local Experimental Ethertype [IEEE]

IEEE_Std_802_OUI_Extended_Ethertype = 34999

IEEE Std 802 - OUI Extended Ethertype [IEEE]

IEEE_Std_802_11_Pre_Authentication = 35015

IEEE Std 802.11 - Pre-Authentication (802.11i) [IEEE]

IEEE Std 802.1AB - Link Layer Discovery Protocol (LLDP) [IEEE]

IEEE_Std_802_1AE_Media_Access_Control_Security = 35045

IEEE Std 802.1AE - Media Access Control Security [IEEE]

Provider_Backbone_Bridging_Instance_tag = 35047

Provider Backbone Bridging Instance tag [IEEE Std 802.1Q-2014]

IEEE_Std_802_1Q_Multiple_VLAN_Registration_Protocol = 35061

IEEE Std 802.1Q - Multiple VLAN Registration Protocol (MVRP) [IEEE]

IEEE_Std_802_1Q_Multiple_Multicast_Registration_Protocol = 35062

IEEE Std 802.1Q - Multiple Multicast Registration Protocol (MMRP) [IEEE]

IEEE_Std_802_11_Fast_Roaming_Remote_Request = 35085

IEEE Std 802.11 - Fast Roaming Remote Request (802.11r) [IEEE]

IEEE_Std_802_21_Media_Independent_Handover_Protocol = 35095

IEEE Std 802.21 - Media Independent Handover Protocol [IEEE]

IEEE_Std_802_1Qbe_Multiple_I_SID_Registration_Protocol = 35113

IEEE Std 802.1Qbe - Multiple I-SID Registration Protocol [IEEE]

TRILL_Fine_Grained_Labeling = 35131

TRILL Fine Grained Labeling (FGL) [RFC 7172]

IEEE_Std_802_1Qbg_ECP_Protocol = 35136

IEEE Std 802.1Qbg - ECP Protocol (also used in 802.1BR) [IEEE]

TRILL_RBridge_Channel = 35142

TRILL RBridge Channel [RFC 7178]

GeoNetworking_as_defined_in_ETSI_EN_302_636_4_1 = 35143

GeoNetworking as defined in ETSI EN 302 636-4-1 [IEEE]

NSH = 35151

NSH (Network Service Header) [RFC 8300]

Loopback = 36864

Loopback [Neil Sembower]

EtherType_3Com_XNS_Sys_Mgmt = 36865

3Com(Bridge) XNS Sys Mgmt [Neil Sembower]

EtherType_3Com_TCP_IP_Sys = 36866

3Com(Bridge) TCP-IP Sys [Neil Sembower]

EtherType_3Com_loop_detect = 36867

3Com(Bridge) loop detect [Neil Sembower]

Multi_Topology = 39458

Multi-Topology [RFC 8377]

LoWPAN_encapsulation = 41197

LoWPAN encapsulation [RFC 7973]

The_Ethertype_will_be_used_to_identify_a_Channel_in_which_control_messages_are_encapsulated_as_payload_of_GRE_packets_When_a_GRE_packet_tagged_with_the_Ethertype_is_received_the_payload_will_be_handed_to_the_network_processor_for_processing = 47082

The Ethertype will be used to identify a “Channel” in which control messages are encapsulated as payload of GRE packets. When a GRE packet tagged with the Ethertype is received, the payload will be handed to the network processor for processing. [RFC 8157]

BBN_VITAL_LanBridge_cache = 65280

BBN VITAL-LanBridge cache [Neil Sembower]

Reserved = 65535

Reserved [RFC 1701]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

EtherType

Transport Layer Protocol Numbers

This module contains the constant enumeration for Transport Layer Protocol Numbers, which is automatically generated from pcapkit.vendor.reg.transtype.TransType.

class pcapkit.const.reg.transtype.TransType(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[TransType] Transport Layer Protocol Numbers

HOPOPT = 0

IPv6 Hop-by-Hop Option [RFC 8200]

ICMP = 1

Internet Control Message [RFC 792]

IGMP = 2

Internet Group Management [RFC 1112]

GGP = 3

Gateway-to-Gateway [RFC 823]

IPv4 = 4

IPv4 encapsulation [RFC 2003]

ST = 5

Stream [RFC 1190][RFC 1819]

TCP = 6

Transmission Control [RFC-ietf-tcpm-rfc793bis-28]

CBT = 7

CBT [Tony Ballardie]

EGP = 8

Exterior Gateway Protocol [RFC 888][David Mills]

IGP = 9

any private interior gateway (used by Cisco for their IGRP) [Internet Assigned Numbers Authority]

BBN_RCC_MON = 10

BBN RCC Monitoring [Steve Chipman]

NVP_II = 11

Network Voice Protocol [RFC 741][Steve Casner]

PUP = 12

An Internetwork Architecture”, XEROX Palo Alto Research Center, CSL-79-10, July 1979; also in IEEE Transactions on Communication, Volume COM-28, Number 4, April 1980.][XEROX]

Type

PUP [Boggs, D., J. Shoch, E. Taft, and R. Metcalfe, “PUP

ARGUS = 13

ARGUS (deprecated)) [Robert W Scheifler]

EMCON = 14

EMCON [<mystery contact>]

XNET = 15

Cross Net Debugger [Haverty, J., “XNET Formats for Internet Protocol Version 4”, IEN 158, October 1980.][Jack Haverty]

CHAOS = 16

Chaos [J Noel Chiappa]

UDP = 17

User Datagram [RFC 768][Jon Postel]

MUX = 18

Multiplexing [Cohen, D. and J. Postel, “Multiplexing Protocol”, IEN 90, USC/Information Sciences Institute, May 1979.][Jon Postel]

DCN_MEAS = 19

DCN Measurement Subsystems [David Mills]

HMP = 20

Host Monitoring [RFC 869][Bob Hinden]

PRM = 21

Packet Radio Measurement [Zaw Sing Su]

XNS_IDP = 22

Data Link Layer and Physical Layer Specification”, AA-K759B-TK, Digital Equipment Corporation, Maynard, MA. Also as: “The Ethernet - A Local Area Network”, Version 1.0, Digital Equipment Corporation, Intel Corporation, Xerox Corporation, September 1980. And: “The Ethernet, A Local Area Network: Data Link Layer and Physical Layer Specifications”, Digital, Intel and Xerox, November 1982. And: XEROX, “The Ethernet, A Local Area Network: Data Link Layer and Physical Layer Specification”, X3T51/80-50, Xerox Corporation, Stamford, CT., October 1980.][XEROX]

Type

XEROX NS IDP [“The Ethernet, A Local Area Network

TRUNK_1 = 23

Trunk-1 [Barry Boehm]

TRUNK_2 = 24

Trunk-2 [Barry Boehm]

LEAF_1 = 25

Leaf-1 [Barry Boehm]

LEAF_2 = 26

Leaf-2 [Barry Boehm]

RDP = 27

Reliable Data Protocol [RFC 908][Bob Hinden]

IRTP = 28

Internet Reliable Transaction [RFC 938][Trudy Miller]

ISO_TP4 = 29

ISO Transport Protocol Class 4 [RFC 905][<mystery contact>]

NETBLT = 30

Bulk Data Transfer Protocol [RFC 969][David Clark]

MFE_NSP = 31

MFE Network Services Protocol [Shuttleworth, B., “A Documentary of MFENet, a National Computer Network”, UCRL-52317, Lawrence Livermore Labs, Livermore, California, June 1977.][Barry Howard]

MERIT_INP = 32

MERIT Internodal Protocol [Hans Werner Braun]

DCCP = 33

Datagram Congestion Control Protocol [RFC 4340]

TransType_3PC = 34

Third Party Connect Protocol [Stuart A Friedberg]

IDPR = 35

Inter-Domain Policy Routing Protocol [Martha Steenstrup]

XTP = 36

XTP [Greg Chesson]

DDP = 37

Datagram Delivery Protocol [Wesley Craig]

IDPR_CMTP = 38

IDPR Control Message Transport Proto [Martha Steenstrup]

TP = 39

TP++ Transport Protocol [Dirk Fromhein]

IL = 40

IL Transport Protocol [Dave Presotto]

IPv6 = 41

IPv6 encapsulation [RFC 2473]

SDRP = 42

Source Demand Routing Protocol [Deborah Estrin]

IPv6_Route = 43

Routing Header for IPv6 [Steve Deering]

IPv6_Frag = 44

Fragment Header for IPv6 [Steve Deering]

IDRP = 45

Inter-Domain Routing Protocol [Sue Hares]

RSVP = 46

Reservation Protocol [RFC 2205][RFC 3209][Bob Braden]

GRE = 47

Generic Routing Encapsulation [RFC 2784][Tony Li]

DSR = 48

Dynamic Source Routing Protocol [RFC 4728]

BNA = 49

BNA [Gary Salamon]

ESP = 50

Encap Security Payload [RFC 4303]

AH = 51

Authentication Header [RFC 4302]

I_NLSP = 52

Integrated Net Layer Security TUBA [K Robert Glenn]

SWIPE = 53

IP with Encryption (deprecated)) [John Ioannidis]

NARP = 54

NBMA Address Resolution Protocol [RFC 1735]

MOBILE = 55

IP Mobility [Charlie Perkins]

TLSP = 56

Transport Layer Security Protocol using Kryptonet key management [Christer Oberg]

SKIP = 57

SKIP [Tom Markson]

IPv6_ICMP = 58

ICMP for IPv6 [RFC 8200]

IPv6_NoNxt = 59

No Next Header for IPv6 [RFC 8200]

IPv6_Opts = 60

Destination Options for IPv6 [RFC 8200]

any_host_internal_protocol = 61

any host internal protocol [Internet Assigned Numbers Authority]

CFTP = 62

CFTP [Forsdick, H., “CFTP”, Network Message, Bolt Beranek and Newman, January 1982.][Harry Forsdick]

any_local_network = 63

any local network [Internet Assigned Numbers Authority]

SAT_EXPAK = 64

SATNET and Backroom EXPAK [Steven Blumenthal]

KRYPTOLAN = 65

Kryptolan [Paul Liu]

RVD = 66

MIT Remote Virtual Disk Protocol [Michael Greenwald]

IPPC = 67

Internet Pluribus Packet Core [Steven Blumenthal]

any_distributed_file_system = 68

any distributed file system [Internet Assigned Numbers Authority]

SAT_MON = 69

SATNET Monitoring [Steven Blumenthal]

VISA = 70

VISA Protocol [Gene Tsudik]

IPCV = 71

Internet Packet Core Utility [Steven Blumenthal]

CPNX = 72

Computer Protocol Network Executive [David Mittnacht]

CPHB = 73

Computer Protocol Heart Beat [David Mittnacht]

WSN = 74

Wang Span Network [Victor Dafoulas]

PVP = 75

Packet Video Protocol [Steve Casner]

BR_SAT_MON = 76

Backroom SATNET Monitoring [Steven Blumenthal]

SUN_ND = 77

SUN ND PROTOCOL-Temporary [William Melohn]

WB_MON = 78

WIDEBAND Monitoring [Steven Blumenthal]

WB_EXPAK = 79

WIDEBAND EXPAK [Steven Blumenthal]

ISO_IP = 80

ISO Internet Protocol [Marshall T Rose]

VMTP = 81

VMTP [Dave Cheriton]

SECURE_VMTP = 82

SECURE-VMTP [Dave Cheriton]

VINES = 83

VINES [Brian Horn]

TTP = 84

Transaction Transport Protocol [Jim Stevens]

IPTM = 84

Internet Protocol Traffic Manager [Jim Stevens]

NSFNET_IGP = 85

NSFNET-IGP [Hans Werner Braun]

DGP = 86

Dissimilar Gateway Protocol [M/A-COM Government Systems, “Dissimilar Gateway Protocol Specification, Draft Version”, Contract no. CS901145, November 16, 1987.][Mike Little]

TCF = 87

TCF [Guillermo A Loyola]

EIGRP = 88

EIGRP [RFC 7868]

OSPFIGP = 89

OSPFIGP [RFC 1583][RFC 2328][RFC 5340][John Moy]

Sprite_RPC = 90

Sprite RPC Protocol [Welch, B., “The Sprite Remote Procedure Call System”, Technical Report, UCB/Computer Science Dept., 86/302, University of California at Berkeley, June 1986.][Bruce Willins]

LARP = 91

Locus Address Resolution Protocol [Brian Horn]

MTP = 92

Multicast Transport Protocol [Susie Armstrong]

AX_25 = 93

AX.25 Frames [Brian Kantor]

IPIP = 94

IP-within-IP Encapsulation Protocol [John Ioannidis]

MICP = 95

Mobile Internetworking Control Pro. (deprecated)) [John Ioannidis]

SCC_SP = 96

Semaphore Communications Sec. Pro. [Howard Hart]

ETHERIP = 97

Ethernet-within-IP Encapsulation [RFC 3378]

ENCAP = 98

Encapsulation Header [RFC 1241][Robert Woodburn]

any_private_encryption_scheme = 99

any private encryption scheme [Internet Assigned Numbers Authority]

GMTP = 100

GMTP [RXB5]

IFMP = 101

Ipsilon Flow Management Protocol [Bob Hinden][November 1995, 1997.]

PNNI = 102

PNNI over IP [Ross Callon]

PIM = 103

Protocol Independent Multicast [RFC 7761][Dino Farinacci]

ARIS = 104

ARIS [Nancy Feldman]

SCPS = 105

SCPS [Robert Durst]

QNX = 106

QNX [Michael Hunter]

A_N = 107

Active Networks [Bob Braden]

IPComp = 108

IP Payload Compression Protocol [RFC 2393]

SNP = 109

Sitara Networks Protocol [Manickam R Sridhar]

Compaq_Peer = 110

Compaq Peer Protocol [Victor Volpe]

IPX_in_IP = 111

IPX in IP [CJ Lee]

VRRP = 112

Virtual Router Redundancy Protocol [RFC 5798]

PGM = 113

PGM Reliable Transport Protocol [Tony Speakman]

any_0_hop_protocol = 114

any 0-hop protocol [Internet Assigned Numbers Authority]

L2TP = 115

Layer Two Tunneling Protocol [RFC 3931][Bernard Aboba]

DDX = 116

D-II Data Exchange (DDX) [John Worley]

IATP = 117

Interactive Agent Transfer Protocol [John Murphy]

STP = 118

Schedule Transfer Protocol [Jean Michel Pittet]

SRP = 119

SpectraLink Radio Protocol [Mark Hamilton]

UTI = 120

UTI [Peter Lothberg]

SMP = 121

Simple Message Protocol [Leif Ekblad]

SM = 122

Simple Multicast Protocol (deprecated)) [Jon Crowcroft][draft-perlman- simple-multicast]

PTP = 123

Performance Transparency Protocol [Michael Welzl]

ISIS_over_IPv4 = 124

[Tony Przygienda]

FIRE = 125

[Criag Partridge]

CRTP = 126

Combat Radio Transport Protocol [Robert Sautter]

CRUDP = 127

Combat Radio User Datagram [Robert Sautter]

SSCOPMCE = 128

[Kurt Waber]

IPLT = 129

[Hollbach]

SPS = 130

Secure Packet Shield [Bill McIntosh]

PIPE = 131

Private IP Encapsulation within IP [Bernhard Petri]

SCTP = 132

Stream Control Transmission Protocol [Randall R Stewart]

FC = 133

Fibre Channel [Murali Rajagopal][RFC 6172]

RSVP_E2E_IGNORE = 134

[RFC 3175]

Mobility_Header = 135

[RFC 6275]

UDPLite = 136

[RFC 3828]

MPLS_in_IP = 137

[RFC 4023]

manet = 138

MANET Protocols [RFC 5498]

HIP = 139

Host Identity Protocol [RFC 7401]

Shim6 = 140

Shim6 Protocol [RFC 5533]

WESP = 141

Wrapped Encapsulating Security Payload [RFC 5840]

ROHC = 142

Robust Header Compression [RFC 5858]

Ethernet = 143

Ethernet [RFC 8986]

Use_for_experimentation_and_testing_253 = 253

Use for experimentation and testing [RFC 3692]

Use_for_experimentation_and_testing_254 = 254

Use for experimentation and testing [RFC 3692]

Reserved_255 = 255

[Internet Assigned Numbers Authority]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

TransType


*

http://www.tcpdump.org/linktypes.html

https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml#ieee-802-numbers-1

https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml#protocol-numbers-1

Internet Layer

HIP Constant Enumerations

This module contains all constant enumerations of HIP implementations. Available enumerations include:

HIP_Certificate

HIP Certificate Types *

HIP_Cipher

HIP Cipher IDs

HIP_DITypes

DI-Types

HIP_ECDSACurve

ECDSA Curve Label §

HIP_ECDSALowCurve

ECDSA_LOW Curve Label

HIP_ESPTransformSuite

ESP Transform Suite IDs #

HIP_Group

Group IDs

HIP_HIAlgorithm

HI Algorithm

HIP_HITSuite

HIT Suite IDs

HIP_NATTraversal

HIP NAT Traversal Modes

HIP_NotifyMessage

Notify Message Types **

HIP_Packet

Packet Types ††

HIP_Parameter

Parameter Types ‡‡

HIP_Registration

Registration Types §§

HIP_RegistrationFailure

Registration Failure Types ¶¶

HIP_Suite

Suite IDs ##

HIP_Transport

HIP Transport Modes ♠♠

HIP Certificate Types

This module contains the constant enumeration for HIP Certificate Types, which is automatically generated from pcapkit.vendor.hip.certificate.Certificate.

class pcapkit.const.hip.certificate.Certificate(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Certificate] HIP Certificate Types

Reserved_0 = 0

Reserved [RFC 8002]

X_509_v3 = 1

X.509 v3 [RFC 8002]

Obsoleted_2 = 2

Obsoleted [RFC 8002]

Hash_and_URL_of_X_509_v3 = 3

Hash and URL of X.509 v3 [RFC 8002]

Obsoleted_4 = 4

Obsoleted [RFC 8002]

LDAP_URL_of_X_509_v3 = 5

LDAP URL of X.509 v3 [RFC 8002]

Obsoleted_6 = 6

Obsoleted [RFC 8002]

Distinguished_Name_of_X_509_v3 = 7

Distinguished Name of X.509 v3 [RFC 8002]

Obsoleted_8 = 8

Obsoleted [RFC 8002]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Certificate

Cipher IDs

This module contains the constant enumeration for Cipher IDs, which is automatically generated from pcapkit.vendor.hip.cipher.Cipher.

class pcapkit.const.hip.cipher.Cipher(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Cipher] Cipher IDs

RESERVED_0 = 0

RESERVED [RFC 7401]

NULL_ENCRYPT = 1

NULL-ENCRYPT [RFC 7401]

AES_128_CBC = 2

AES-128-CBC [RFC 7401]

RESERVED_3 = 3

RESERVED [RFC 7401]

AES_256_CBC = 4

AES-256-CBC [RFC 7401]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Cipher

DI-Types

This module contains the constant enumeration for DI-Types, which is automatically generated from pcapkit.vendor.hip.di.DITypes.

class pcapkit.const.hip.di.DITypes(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[DITypes] DI-Types

none_included = 0

none included [RFC 7401]

FQDN = 1

FQDN [RFC 7401]

NAI = 2

NAI [RFC 7401]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

DITypes

ECDSA Curve Label

This module contains the constant enumeration for ECDSA Curve Label, which is automatically generated from pcapkit.vendor.hip.ecdsa_curve.ECDSACurve.

class pcapkit.const.hip.ecdsa_curve.ECDSACurve(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ECDSACurve] ECDSA Curve Label

RESERVED_0 = 0

RESERVED [RFC 7401]

NIST_P_256 = 1

NIST P-256 [RFC 7401]

NIST_P_384 = 2

NIST P-384 [RFC 7401]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ECDSACurve

ECDSA_LOW Curve Label

This module contains the constant enumeration for ECDSA_LOW Curve Label, which is automatically generated from pcapkit.vendor.hip.ecdsa_low_curve.ECDSALowCurve.

class pcapkit.const.hip.ecdsa_low_curve.ECDSALowCurve(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ECDSALowCurve] ECDSA_LOW Curve Label

RESERVED_0 = 0

RESERVED [RFC 7401]

SECP160R1 = 1

SECP160R1 [RFC 7401]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ECDSALowCurve

ESP Transform Suite IDs

This module contains the constant enumeration for ESP Transform Suite IDs, which is automatically generated from pcapkit.vendor.hip.esp_transform_suite.ESPTransformSuite.

class pcapkit.const.hip.esp_transform_suite.ESPTransformSuite(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ESPTransformSuite] ESP Transform Suite IDs

RESERVED_0 = 0

RESERVED [RFC 7402]

AES_128_CBC_with_HMAC_SHA1 = 1

AES-128-CBC with HMAC-SHA1 [RFC 3602][RFC 2404]

DEPRECATED_2 = 2

DEPRECATED [RFC 7402]

DEPRECATED_3 = 3

DEPRECATED [RFC 7402]

DEPRECATED_4 = 4

DEPRECATED [RFC 7402]

DEPRECATED_5 = 5

DEPRECATED [RFC 7402]

DEPRECATED_6 = 6

DEPRECATED [RFC 7402]

NULL_with_HMAC_SHA_256 = 7

NULL with HMAC-SHA-256 [RFC 2410][RFC 4868]

AES_128_CBC_with_HMAC_SHA_256 = 8

AES-128-CBC with HMAC-SHA-256 [RFC 3602][RFC 4868]

AES_256_CBC_with_HMAC_SHA_256 = 9

AES-256-CBC with HMAC-SHA-256 [RFC 3602][RFC 4868]

AES_CCM_8 = 10

AES-CCM-8 [RFC 4309]

AES_CCM_16 = 11

AES-CCM-16 [RFC 4309]

AES_GCM_with_an_8_octet_ICV = 12

AES-GCM with an 8 octet ICV [RFC 4106]

AES_GCM_with_a_16_octet_ICV = 13

AES-GCM with a 16 octet ICV [RFC 4106]

AES_CMAC_96 = 14

AES-CMAC-96 [RFC 4493][RFC 4494]

AES_GMAC = 15

AES-GMAC [RFC 4543]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ESPTransformSuite

Group IDs

This module contains the constant enumeration for Group IDs, which is automatically generated from pcapkit.vendor.hip.group.Group.

class pcapkit.const.hip.group.Group(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Group] Group IDs

Reserved_0 = 0

Reserved [RFC 7401]

Group_384_bit_group = 1

384-bit group (DEPRECATED) [RFC 5201]

OAKLEY_well_known_group_1 = 2

OAKLEY well known group 1 (DEPRECATED) [RFC 5201]

Group_1536_bit_MODP_group = 3

1536-bit MODP group [RFC 7401]

Group_3072_bit_MODP_group = 4

3072-bit MODP group [RFC 7401]

Group_6144_bit_MODP_group = 5

6144-bit MODP group (DEPRECATED) [RFC 5201]

Group_8192_bit_MODP_group = 6

8192-bit MODP group (DEPRECATED) [RFC 5201]

NIST_P_256 = 7

NIST P-256 [RFC 7401]

NIST_P_384 = 8

NIST P-384 [RFC 7401]

NIST_P_521 = 9

NIST P-521 [RFC 7401]

SECP160R1 = 10

SECP160R1 [RFC 7401]

Group_2048_bit_MODP_group = 11

2048-bit MODP group [RFC 7401]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Group

HI Algorithm

This module contains the constant enumeration for HI Algorithm, which is automatically generated from pcapkit.vendor.hip.hi_algorithm.HIAlgorithm.

class pcapkit.const.hip.hi_algorithm.HIAlgorithm(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[HIAlgorithm] HI Algorithm

RESERVED_0 = 0

RESERVED [RFC 7401]

NULL_ENCRYPT = 1

NULL-ENCRYPT [RFC 2410]

Unassigned_2 = 2

Unassigned

DSA = 3

DSA [RFC 7401]

Unassigned_4 = 4

Unassigned

RSA = 5

RSA [RFC 7401]

Unassigned_6 = 6

Unassigned

ECDSA = 7

ECDSA [RFC 7401]

Unassigned_8 = 8

Unassigned

ECDSA_LOW = 9

ECDSA_LOW [RFC 7401]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

HIAlgorithm

HIT Suite ID

This module contains the constant enumeration for HIT Suite ID, which is automatically generated from pcapkit.vendor.hip.hit_suite.HITSuite.

class pcapkit.const.hip.hit_suite.HITSuite(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[HITSuite] HIT Suite ID

RESERVED_0 = 0

RESERVED [RFC 7401]

RSA_DSA_SHA_256 = 1

RSA,DSA/SHA-256 [RFC 7401]

ECDSA_SHA_384 = 2

ECDSA/SHA-384 [RFC 7401]

ECDSA_LOW_SHA_1 = 3

ECDSA_LOW/SHA-1 [RFC 7401]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

HITSuite

HIP NAT Traversal Modes

This module contains the constant enumeration for HIP NAT Traversal Modes, which is automatically generated from pcapkit.vendor.hip.nat_traversal.NATTraversal.

class pcapkit.const.hip.nat_traversal.NATTraversal(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[NATTraversal] HIP NAT Traversal Modes

Reserved_0 = 0

Reserved [RFC 5770]

UDP_ENCAPSULATION = 1

UDP-ENCAPSULATION [RFC 5770]

ICE_STUN_UDP = 2

ICE-STUN-UDP [RFC 5770]

ICE_HIP_UDP = 3

ICE-HIP-UDP [RFC 9028]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

NATTraversal

Notify Message Types

This module contains the constant enumeration for Notify Message Types, which is automatically generated from pcapkit.vendor.hip.notify_message.NotifyMessage.

class pcapkit.const.hip.notify_message.NotifyMessage(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[NotifyMessage] Notify Message Types

Reserved_0 = 0

Reserved [RFC 7401]

UNSUPPORTED_CRITICAL_PARAMETER_TYPE = 1

UNSUPPORTED_CRITICAL_PARAMETER_TYPE [RFC 7401]

INVALID_SYNTAX = 7

INVALID_SYNTAX [RFC 7401]

NO_DH_PROPOSAL_CHOSEN = 14

NO_DH_PROPOSAL_CHOSEN [RFC 7401]

INVALID_DH_CHOSEN = 15

INVALID_DH_CHOSEN [RFC 7401]

NO_HIP_PROPOSAL_CHOSEN = 16

NO_HIP_PROPOSAL_CHOSEN [RFC 7401]

INVALID_HIP_CIPHER_CHOSEN = 17

INVALID_HIP_CIPHER_CHOSEN [RFC 7401]

NO_ESP_PROPOSAL_CHOSEN = 18

NO_ESP_PROPOSAL_CHOSEN [RFC 7402]

INVALID_ESP_TRANSFORM_CHOSEN = 19

INVALID_ESP_TRANSFORM_CHOSEN [RFC 7402]

UNSUPPORTED_HIT_SUITE = 20

UNSUPPORTED_HIT_SUITE [RFC 7401]

AUTHENTICATION_FAILED = 24

AUTHENTICATION_FAILED [RFC 7401]

Unassigned_25 = 25

Unassigned

CHECKSUM_FAILED = 26

CHECKSUM_FAILED [RFC 7401]

Unassigned_27 = 27

Unassigned

HIP_MAC_FAILED = 28

HIP_MAC_FAILED [RFC 7401]

ENCRYPTION_FAILED = 32

ENCRYPTION_FAILED [RFC 7401]

INVALID_HIT = 40

INVALID_HIT [RFC 7401]

Unassigned_41 = 41

Unassigned

BLOCKED_BY_POLICY = 42

BLOCKED_BY_POLICY [RFC 7401]

Unassigned_43 = 43

Unassigned

RESPONDER_BUSY_PLEASE_RETRY = 44

RESPONDER_BUSY_PLEASE_RETRY [RFC 7401]

Unassigned_45 = 45

Unassigned

LOCATOR_TYPE_UNSUPPORTED = 46

LOCATOR_TYPE_UNSUPPORTED [RFC 8046]

Unassigned_47 = 47

Unassigned

CREDENTIALS_REQUIRED = 48

CREDENTIALS_REQUIRED [RFC 8002]

Unassigned_49 = 49

Unassigned

INVALID_CERTIFICATE = 50

INVALID_CERTIFICATE [RFC 8002]

REG_REQUIRED = 51

REG_REQUIRED [RFC 8003]

NO_VALID_NAT_TRAVERSAL_MODE_PARAMETER = 60

NO_VALID_NAT_TRAVERSAL_MODE_PARAMETER [RFC 5770]

CONNECTIVITY_CHECKS_FAILED = 61

CONNECTIVITY_CHECKS_FAILED [RFC 5770]

MESSAGE_NOT_RELAYED = 62

MESSAGE_NOT_RELAYED [RFC 5770]

SERVER_REFLEXIVE_CANDIDATE_ALLOCATION_FAILED = 63

SERVER_REFLEXIVE_CANDIDATE_ALLOCATION_FAILED [RFC 9028]

RVS_HMAC_PROHIBITED_WITH_RELAY = 64

RVS_HMAC_PROHIBITED_WITH_RELAY [RFC 9028]

OVERLAY_TTL_EXCEEDED = 70

OVERLAY_TTL_EXCEEDED [RFC 6079]

UNKNOWN_NEXT_HOP = 90

UNKNOWN_NEXT_HOP [RFC 6028]

NO_VALID_HIP_TRANSPORT_MODE = 100

NO_VALID_HIP_TRANSPORT_MODE [RFC 6261]

I2_ACKNOWLEDGEMENT = 16384

I2_ACKNOWLEDGEMENT [RFC 7401]

NAT_KEEPALIVE = 16385

NAT_KEEPALIVE [RFC 9028]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

NotifyMessage

HIP Packet Types

This module contains the constant enumeration for HIP Packet Types, which is automatically generated from pcapkit.vendor.hip.packet.Packet.

class pcapkit.const.hip.packet.Packet(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Packet] HIP Packet Types

Reserved_0 = 0

Reserved [RFC 7401]

I1 = 1

I1 the HIP Initiator Packet [RFC 7401]

R1 = 2

R1 the HIP Responder Packet [RFC 7401]

I2 = 3

I2 the Second HIP Initiator Packet [RFC 7401]

R2 = 4

R2 the Second HIP Responder Packet [RFC 7401]

UPDATE = 16

UPDATE the HIP Update Packet [RFC 7401]

NOTIFY = 17

NOTIFY the HIP Notify Packet [RFC 7401]

CLOSE = 18

CLOSE the HIP Association Closing Packet [RFC 7401]

CLOSE_ACK = 19

CLOSE_ACK the HIP Closing Acknowledgment Packet [RFC 7401]

HDRR = 20

HDRR (HIP Distributed Hash Table Resource Record) [RFC 6537]

HIP_DATA = 32

HIP_DATA [RFC 6078]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Packet

HIP Parameter Types

This module contains the constant enumeration for HIP Parameter Types, which is automatically generated from pcapkit.vendor.hip.parameter.Parameter.

class pcapkit.const.hip.parameter.Parameter(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Parameter] HIP Parameter Types

ESP_INFO = 65
Type

ESP_INFO [RFC 7402] (Length

R1_Counter(v1 only) [:rfc:`5201`] (Length: 12) = 128
Type

R1_Counter (v1 only) [RFC 5201] (Length

R1_COUNTER = 129
Type

R1_COUNTER [RFC 7401] (Length

LOCATOR_SET = 193

LOCATOR_SET [RFC 8046]

PUZZLE = 257
Type

PUZZLE [RFC 7401] (Length

SOLUTION = 321
Type

SOLUTION [RFC 7401] (Length

SEQ = 385
Type

SEQ [RFC 7401] (Length

ACK = 449

ACK [RFC 7401]

DH_GROUP_LIST = 511

DH_GROUP_LIST [RFC 7401]

Unassigned_512 = 512

Unassigned

DIFFIE_HELLMAN = 513

DIFFIE_HELLMAN [RFC 7401]

HIP_TRANSFORM = 577

HIP_TRANSFORM (v1 only) [RFC 5201]

Unassigned_578 = 578

Unassigned

HIP_CIPHER = 579

HIP_CIPHER [RFC 7401]

NAT_TRAVERSAL_MODE = 608

NAT_TRAVERSAL_MODE [RFC 5770]

Unassigned_609 = 609

Unassigned

TRANSACTION_PACING = 610
Type

TRANSACTION_PACING [RFC 5770] (Length

ENCRYPTED = 641

ENCRYPTED [RFC 7401]

HOST_ID = 705

HOST_ID [RFC 7401]

HIT_SUITE_LIST = 715

HIT_SUITE_LIST [RFC 7401]

CERT = 768

CERT [RFC 7401][RFC 8002]

NOTIFICATION = 832

NOTIFICATION [RFC 7401]

ECHO_REQUEST_SIGNED = 897

ECHO_REQUEST_SIGNED [RFC 7401]

REG_INFO = 930

REG_INFO [RFC 8003]

Unassigned_931 = 931

Unassigned

REG_REQUEST = 932

REG_REQUEST [RFC 8003]

Unassigned_933 = 933

Unassigned

REG_RESPONSE = 934

REG_RESPONSE [RFC 8003]

Unassigned_935 = 935

Unassigned

REG_FAILED = 936

REG_FAILED [RFC 8003]

REG_FROM = 950
Type

REG_FROM [RFC 5770] (Length

ECHO_RESPONSE_SIGNED = 961

ECHO_RESPONSE_SIGNED [RFC 7401]

TRANSPORT_FORMAT_LIST = 2049

TRANSPORT_FORMAT_LIST [RFC 7401]

ESP_TRANSFORM = 4095

ESP_TRANSFORM [RFC 7402]

SEQ_DATA = 4481
Type

SEQ_DATA [RFC 6078] (Length

ACK_DATA = 4545

ACK_DATA [RFC 6078]

PAYLOAD_MIC = 4577

PAYLOAD_MIC [RFC 6078]

TRANSACTION_ID = 4580

TRANSACTION_ID [RFC 6078]

OVERLAY_ID = 4592

OVERLAY_ID [RFC 6079]

ROUTE_DST = 4601

ROUTE_DST [RFC 6028]

RELAYED_ADDRESS = 4650
Type

RELAYED_ADDRESS [RFC 9028] (Length

MAPPED_ADDRESS = 4660
Type

MAPPED_ADDRESS [RFC 9028] (Length

PEER_PERMISSION = 4680
Type

PEER_PERMISSION [RFC 9028] (Length

CANDIDATE_PRIORITY = 4700
Type

CANDIDATE_PRIORITY [RFC 9028] (Length

NOMINATE = 4710
Type

NOMINATE [RFC 9028] (Length

HIP_TRANSPORT_MODE = 7680

HIP_TRANSPORT_MODE [RFC 6261]

HIP_MAC = 61505

HIP_MAC [RFC 7401]

HIP_MAC_2 = 61569

HIP_MAC_2 [RFC 7401]

HIP_SIGNATURE_2 = 61633

HIP_SIGNATURE_2 [RFC 7401]

HIP_SIGNATURE = 61697

HIP_SIGNATURE [RFC 7401]

ECHO_REQUEST_UNSIGNED = 63661

ECHO_REQUEST_UNSIGNED [RFC 7401]

ECHO_RESPONSE_UNSIGNED = 63425

ECHO_RESPONSE_UNSIGNED [RFC 7401]

RELAY_FROM = 63998
Type

RELAY_FROM [RFC 5770] (Length

RELAY_TO = 64002
Type

RELAY_TO [RFC 5770] (Length

OVERLAY_TTL = 64011
Type

OVERLAY_TTL [RFC 6079] (Length

ROUTE_VIA = 64017

ROUTE_VIA [RFC 6028]

FROM = 65498
Type

FROM [RFC 8004] (Length

Unassigned_65499 = 65499

Unassigned

RVS_HMAC = 65500

RVS_HMAC [RFC 8004]

Unassigned_65501 = 65501

Unassigned

VIA_RVS = 65502

VIA_RVS [RFC 8004]

RELAY_HMAC = 65520

RELAY_HMAC [RFC 5770]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Parameter

Registration Types

This module contains the constant enumeration for Registration Types, which is automatically generated from pcapkit.vendor.hip.registration.Registration.

class pcapkit.const.hip.registration.Registration(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Registration] Registration Types

Unassigned_0 = 0

Unassigned

RENDEZVOUS = 1

RENDEZVOUS [RFC 8004]

RELAY_UDP_HIP = 2

RELAY_UDP_HIP [RFC 5770]

RELAY_UDP_ESP = 3

RELAY_UDP_ESP [RFC 9028]

CANDIDATE_DISCOVERY = 4

CANDIDATE_DISCOVERY [RFC 9028]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Registration

Registration Failure Types

This module contains the constant enumeration for Registration Failure Types, which is automatically generated from pcapkit.vendor.hip.registration_failure.RegistrationFailure.

class pcapkit.const.hip.registration_failure.RegistrationFailure(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[RegistrationFailure] Registration Failure Types

Registration_requires_additional_credentials = 0

Registration requires additional credentials [RFC 8003]

Registration_type_unavailable = 1

Registration type unavailable [RFC 8003]

Insufficient_resources = 2

Insufficient resources [RFC 8003]

Invalid_certificate = 3

Invalid certificate [RFC 8003]

Bad_certificate = 4

Bad certificate [RFC 8003]

Unsupported_certificate = 5

Unsupported certificate [RFC 8003]

Certificate_expired = 6

Certificate expired [RFC 8003]

Certificate_other = 7

Certificate other [RFC 8003]

Unknown_CA = 8

Unknown CA [RFC 8003]

Simultaneous_Rendezvous_and_Control_Relay_Service_usage_prohibited = 9

Simultaneous Rendezvous and Control Relay Service usage prohibited [RFC 9028]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

RegistrationFailure

Suite IDs

This module contains the constant enumeration for Suite IDs, which is automatically generated from pcapkit.vendor.hip.suite.Suite.

class pcapkit.const.hip.suite.Suite(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Suite] Suite IDs

Reserved_0 = 0

Reserved [RFC 5201]

AES_CBC_with_HMAC_SHA1 = 1

AES-CBC with HMAC-SHA1 [RFC 5201]

Suite_3DES_CBC_with_HMAC_SHA1 = 2

3DES-CBC with HMAC-SHA1 [RFC 5201]

Suite_3DES_CBC_with_HMAC_MD5 = 3

3DES-CBC with HMAC-MD5 [RFC 5201]

BLOWFISH_CBC_with_HMAC_SHA1 = 4

BLOWFISH-CBC with HMAC-SHA1 [RFC 5201]

NULL_ENCRYPT_with_HMAC_SHA1 = 5

NULL-ENCRYPT with HMAC-SHA1 [RFC 5201]

NULL_ENCRYPT_with_HMAC_MD5 = 6

NULL-ENCRYPT with HMAC-MD5 [RFC 5201]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Suite

HIP Transport Modes

This module contains the constant enumeration for HIP Transport Modes, which is automatically generated from pcapkit.vendor.hip.transport.Transport.

class pcapkit.const.hip.transport.Transport(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Transport] HIP Transport Modes

RESERVED_0 = 0

RESERVED [RFC 6261]

DEFAULT = 1

DEFAULT [RFC 6261]

ESP = 2

ESP [RFC 6261]

ESP_TCP = 3

ESP-TCP [RFC 6261]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Transport


*

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#certificate-types

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-cipher-id

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-7

§

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#ecdsa-curve-label

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#ecdsa-low-curve-label

#

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#esp-transform-suite-ids

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-5

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hi-algorithm

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hit-suite-id

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#nat-traversal

**

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-9

††

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-1

‡‡

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-4

§§

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-11

¶¶

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-13

##

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-6

♠♠

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#transport-modes

IPv4 Constant Enumerations

This module contains all constant enumerations of IPv4 implementations. Available enumerations include:

IPv4_ClassificationLevel

Classification Level Encodings

IPv4_OptionClass

Option Classes

IPv4_OptionNumber

IP Option Numbers *

IPv4_ProtectionAuthority

Protection Authority Bit Assignments

IPv4_QSFunction

QS Functions

IPv4_RouterAlert

IPv4 Router Alert Option Values

IPv4_ToSDelay

ToS (DS Field) Delay

IPv4_ToSECN

ToS ECN Field

IPv4_ToSPrecedence

ToS (DS Field) Precedence

IPv4_ToSReliability

ToS (DS Field) Reliability

IPv4_ToSThroughput

ToS (DS Field) Throughput

IPv4_TSFlag

TS Flag

Classification Level Encodings

This module contains the constant enumeration for Classification Level Encodings, which is automatically generated from pcapkit.vendor.ipv4.classification_level.ClassificationLevel.

class pcapkit.const.ipv4.classification_level.ClassificationLevel(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ClassificationLevel] Classification Level Encodings

Reserved_4 = 1
Top_Secret = 61
Secret = 90
Confidential = 150
Reserved_3 = 102
Reserved_2 = 204
Unclassified = 171
Reserved_1 = 241
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ClassificationLevel

Option Classes

This module contains the constant enumeration for Option Classes, which is automatically generated from pcapkit.vendor.ipv4.option_class.OptionClass.

class pcapkit.const.ipv4.option_class.OptionClass(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[OptionClass] Option Classes

control = 0
reserved_for_future_use_1 = 1
debugging_and_measurement = 2
reserved_for_future_use_3 = 3
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

OptionClass

IP Option Numbers

This module contains the constant enumeration for IP Option Numbers, which is automatically generated from pcapkit.vendor.ipv4.option_number.OptionNumber.

class pcapkit.const.ipv4.option_number.OptionNumber(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[OptionNumber] IP Option Numbers

EOOL = 0

EOOL, End of Options List [RFC 791][Jon Postel]

NOP = 1

NOP, No Operation [RFC 791][Jon Postel]

SEC = 130

SEC, Security [RFC 1108]

LSR = 131

LSR, Loose Source Route [RFC 791][Jon Postel]

TS = 68

TS, Time Stamp [RFC 791][Jon Postel]

E_SEC = 133

E-SEC, Extended Security [RFC 1108]

CIPSO = 134

CIPSO, Commercial Security [draft-ietf-cipso-ipsecurity-01]

RR = 7

RR, Record Route [RFC 791][Jon Postel]

SID = 136

SID, Stream ID [RFC 791][Jon Postel][RFC 6814]

SSR = 137

SSR, Strict Source Route [RFC 791][Jon Postel]

ZSU = 10

ZSU, Experimental Measurement [ZSu]

MTUP = 11

MTUP, MTU Probe [RFC 1063][RFC 1191]

MTUR = 12

MTUR, MTU Reply [RFC 1063][RFC 1191]

FINN = 205

FINN, Experimental Flow Control [Greg Finn]

VISA = 142

VISA, Experimental Access Control [Deborah Estrin][RFC 6814]

ENCODE = 15

ENCODE, ??? [VerSteeg][RFC 6814]

IMITD = 144

IMITD, IMI Traffic Descriptor [Lee]

EIP = 145

EIP, Extended Internet Protocol [RFC 1385][RFC 6814]

TR = 82

TR, Traceroute [RFC 1393][RFC 6814]

ADDEXT = 147

ADDEXT, Address Extension [Ullmann IPv7][RFC 6814]

RTRALT = 148

RTRALT, Router Alert [RFC 2113]

SDB = 149

SDB, Selective Directed Broadcast [Charles Bud Graff][RFC 6814]

Unassigned_150 = 150

Unassigned (Released 18 October 2005)

DPS = 151

DPS, Dynamic Packet State [Andy Malis][RFC 6814]

UMP = 152

UMP, Upstream Multicast Pkt. [Dino Farinacci][RFC 6814]

QS = 25

QS, Quick-Start [RFC 4782]

EXP_30 = 30

EXP, RFC3692-style Experiment [RFC 4727]

EXP_94 = 94

EXP, RFC3692-style Experiment [RFC 4727]

EXP_158 = 158

EXP, RFC3692-style Experiment [RFC 4727]

EXP_222 = 222

EXP, RFC3692-style Experiment [RFC 4727]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

OptionNumber

Protection Authority Bit Assignments

This module contains the constant enumeration for Protection Authority Bit Assignments, which is automatically generated from pcapkit.vendor.ipv4.protection_authority.ProtectionAuthority.

class pcapkit.const.ipv4.protection_authority.ProtectionAuthority(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ProtectionAuthority] Protection Authority Bit Assignments

GENSER = 0
SIOP_ESI = 1
SCI = 2
NSA = 3
DOE = 4
Unassigned_5 = 5
Unassigned_6 = 6
Field_Termination_Indicator = 7
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ProtectionAuthority

QS Functions

This module contains the constant enumeration for QS Functions, which is automatically generated from pcapkit.vendor.ipv4.qs_function.QSFunction.

class pcapkit.const.ipv4.qs_function.QSFunction(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[QSFunction] QS Functions

Quick_Start_Request = 0
Report_of_Approved_Rate = 8
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

QSFunction

IPv4 Router Alert Option Values

This module contains the constant enumeration for IPv4 Router Alert Option Values, which is automatically generated from pcapkit.vendor.ipv4.router_alert.RouterAlert.

class pcapkit.const.ipv4.router_alert.RouterAlert(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[RouterAlert] IPv4 Router Alert Option Values

Aggregated_Reservation_Nesting_Level_0 = 1

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_1 = 2

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_2 = 3

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_3 = 4

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_4 = 5

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_5 = 6

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_6 = 7

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_7 = 8

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_8 = 9

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_9 = 10

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_10 = 11

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_11 = 12

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_12 = 13

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_13 = 14

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_14 = 15

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_15 = 16

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_16 = 17

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_17 = 18

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_18 = 19

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_19 = 20

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_20 = 21

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_21 = 22

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_22 = 23

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_23 = 24

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_24 = 25

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_25 = 26

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_26 = 27

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_27 = 28

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_28 = 29

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_29 = 30

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_30 = 31

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_31 = 32

Aggregated Reservation Nesting Level [RFC 3175]

QoS_NSLP_Aggregation_Level_0 = 33

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_1 = 34

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_2 = 35

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_3 = 36

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_4 = 37

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_5 = 38

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_6 = 39

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_7 = 40

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_8 = 41

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_9 = 42

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_10 = 43

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_11 = 44

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_12 = 45

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_13 = 46

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_14 = 47

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_15 = 48

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_16 = 49

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_17 = 50

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_18 = 51

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_19 = 52

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_20 = 53

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_21 = 54

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_22 = 55

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_23 = 56

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_24 = 57

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_25 = 58

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_26 = 59

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_27 = 60

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_28 = 61

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_29 = 62

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_30 = 63

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_31 = 64

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

NSIS_NATFW_NSLP = 65

NSIS NATFW NSLP [RFC 5973]

Reserved_65535 = 65535

Reserved [RFC 5350]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

RouterAlert

ToS (DS Field) Delay

This module contains the constant enumeration for ToS (DS Field) Delay, which is automatically generated from pcapkit.vendor.ipv4.tos_del.ToSDelay.

class pcapkit.const.ipv4.tos_del.ToSDelay(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ToSDelay] ToS (DS Field) Delay

NORMAL = 0
LOW = 1
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ToSDelay

ToS ECN Field

This module contains the constant enumeration for ToS ECN Field, which is automatically generated from pcapkit.vendor.ipv4.tos_ecn.ToSECN.

class pcapkit.const.ipv4.tos_ecn.ToSECN(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ToSECN] ToS ECN Field

Not_ECT = 0
ECT_0b01 = 1
ECT_0b10 = 2
CE = 3
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ToSECN

ToS (DS Field) Precedence

This module contains the constant enumeration for ToS (DS Field) Precedence, which is automatically generated from pcapkit.vendor.ipv4.tos_pre.ToSPrecedence.

class pcapkit.const.ipv4.tos_pre.ToSPrecedence(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ToSPrecedence] ToS (DS Field) Precedence

Network_Control = 7
Internetwork_Control = 6
CRITIC_ECP = 5
Flash_Override = 4
Flash = 3
Immediate = 2
Priority = 1
Routine = 0
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ToSPrecedence

ToS (DS Field) Reliability

This module contains the constant enumeration for ToS (DS Field) Reliability, which is automatically generated from pcapkit.vendor.ipv4.tos_rel.ToSReliability.

class pcapkit.const.ipv4.tos_rel.ToSReliability(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ToSReliability] ToS (DS Field) Reliability

NORMAL = 0
HIGH = 1
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ToSReliability

ToS (DS Field) Throughput

This module contains the constant enumeration for ToS (DS Field) Throughput, which is automatically generated from pcapkit.vendor.ipv4.tos_thr.ToSThroughput.

class pcapkit.const.ipv4.tos_thr.ToSThroughput(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ToSThroughput] ToS (DS Field) Throughput

NORMAL = 0
HIGH = 1
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ToSThroughput

TS Flag

This module contains the constant enumeration for TS Flag, which is automatically generated from pcapkit.vendor.ipv4.ts_flag.TSFlag.

class pcapkit.const.ipv4.ts_flag.TSFlag(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[TSFlag] TS Flag

Timestamp_Only = 0
IP_with_Timestamp = 1
Prespecified_IP_with_Timestamp = 3
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

TSFlag


*

https://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml#ip-parameters-1

https://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml#ipv4-router-alert-option-values

IPv6 Constant Enumerations

This module contains all constant enumerations of IPv6 implementations. Available enumerations include:

IPv6_Extension_Header

IPv6 Extension Header Types *

IPv6_Option

Destination Options and Hop-by-Hop Options

IPv6_QSFunction

IPv6 QS Functions

IPv6_RouterAlert

IPv6 Router Alert Option Values

IPv6_Routing

Routing Types §

IPv6_SeedID

Seed-ID Types

IPv6_SMFDPDMode

Simplified Multicast Forwarding Duplicate Packet Detection (SMF_DPD) Options

IPv6_TaggerID

Tagger-ID Types

IPv6 Extension Header Types

This module contains the constant enumeration for IPv6 Extension Header Types, which is automatically generated from pcapkit.vendor.ipv6.extension_header.ExtensionHeader.

class pcapkit.const.ipv6.extension_header.ExtensionHeader(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ExtensionHeader] IPv6 Extension Header Types

HOPOPT = 0

HOPOPT, IPv6 Hop-by-Hop Option [RFC 8200]

IPv6_Route = 43

IPv6-Route, Routing Header for IPv6 [Steve Deering]

IPv6_Frag = 44

IPv6-Frag, Fragment Header for IPv6 [Steve Deering]

ESP = 50

ESP, Encap Security Payload [RFC 4303]

AH = 51

AH, Authentication Header [RFC 4302]

IPv6_Opts = 60

IPv6-Opts, Destination Options for IPv6 [RFC 8200]

Mobility_Header = 135

Mobility Header [RFC 6275]

HIP = 139

HIP, Host Identity Protocol [RFC 7401]

Shim6 = 140

Shim6, Shim6 Protocol [RFC 5533]

Use_for_experimentation_and_testing_253 = 253

Use for experimentation and testing [RFC 3692]

Use_for_experimentation_and_testing_254 = 254

Use for experimentation and testing [RFC 3692]

Destination Options and Hop-by-Hop Options

This module contains the constant enumeration for Destination Options and Hop-by-Hop Options, which is automatically generated from pcapkit.vendor.ipv6.option.Option.

class pcapkit.const.ipv6.option.Option(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Option] Destination Options and Hop-by-Hop Options

Pad1 = 0

Pad1 [RFC 2460]

PadN = 1

PadN [RFC 2460]

Jumbo_Payload = 194

Jumbo Payload [RFC 2675]

RPL_Option_0x23 = 35

RPL Option [RFC 9008]

RPL_Option_0x63 = 99

RPL Option (DEPRECATED) [RFC 6553][RFC 9008]

Tunnel_Encapsulation_Limit = 4

Tunnel Encapsulation Limit [RFC 2473]

Router_Alert = 5

Router Alert [RFC 2711]

Quick_Start = 38

Quick-Start [RFC 4782][RFC Errata 2034]

CALIPSO = 7

CALIPSO [RFC 5570]

SMF_DPD = 8

SMF_DPD [RFC 6621]

Home_Address = 201

Home Address [RFC 6275]

Endpoint_Identification = 138

Endpoint Identification (DEPRECATED) [CHARLES LYNN]

ILNP_Nonce = 139

ILNP Nonce [RFC 6744]

Line_Identification_Option = 140

Line-Identification Option [RFC 6788]

Deprecated = 77

Deprecated [RFC 7731]

MPL_Option = 109

MPL Option [RFC 7731]

IP_DFF = 238

IP_DFF [RFC 6971]

PDM = 15

Performance and Diagnostic Metrics (PDM) [RFC 8250]

Path_MTU_Record_Option = 48

Path MTU Record Option [RFC-ietf-6man-mtu-option-15]

IOAM_0x11 = 17

IOAM (TEMPORARY - registered 2020-04-16, extension registered 2022-04-12, expires 2023-04-16) [draft-ietf-ippm-ioam-ipv6-options-05]

IOAM_0x31 = 49

IOAM (TEMPORARY - registered 2020-04-16, extension registered 2022-04-12, expires 2023-04-16) [draft-ietf-ippm-ioam-ipv6-options-05]

RFC3692_style_Experiment_0x1E = 30

RFC3692-style Experiment [RFC 4727]

RFC3692_style_Experiment_0x3E = 62

RFC3692-style Experiment [RFC 4727]

RFC3692_style_Experiment_0x5E = 94

RFC3692-style Experiment [RFC 4727]

RFC3692_style_Experiment_0x7E = 126

RFC3692-style Experiment [RFC 4727]

RFC3692_style_Experiment_0x9E = 158

RFC3692-style Experiment [RFC 4727]

RFC3692_style_Experiment_0xBE = 190

RFC3692-style Experiment [RFC 4727]

RFC3692_style_Experiment_0xDE = 222

RFC3692-style Experiment [RFC 4727]

RFC3692_style_Experiment_0xFE = 254

RFC3692-style Experiment [RFC 4727]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Option

QS Functions

This module contains the constant enumeration for QS Functions, which is automatically generated from pcapkit.vendor.ipv6.qs_function.QSFunction.

class pcapkit.const.ipv6.qs_function.QSFunction(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[QSFunction] QS Functions

Quick_Start_Request = 0
Report_of_Approved_Rate = 8
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

QSFunction

IPv6 Router Alert Option Values

This module contains the constant enumeration for IPv6 Router Alert Option Values, which is automatically generated from pcapkit.vendor.ipv6.router_alert.RouterAlert.

class pcapkit.const.ipv6.router_alert.RouterAlert(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[RouterAlert] IPv6 Router Alert Option Values

Datagram_contains_a_Multicast_Listener_Discovery_message = 0

Datagram contains a Multicast Listener Discovery message [RFC 2710]

Datagram_contains_RSVP_message = 1

Datagram contains RSVP message [RFC 2711]

Datagram_contains_an_Active_Networks_message = 2

Datagram contains an Active Networks message [RFC 2711]

Reserved_3 = 3

Reserved [RFC 5350]

Aggregated_Reservation_Nesting_Level_0 = 4

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_1 = 5

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_2 = 6

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_3 = 7

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_4 = 8

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_5 = 9

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_6 = 10

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_7 = 11

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_8 = 12

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_9 = 13

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_10 = 14

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_11 = 15

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_12 = 16

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_13 = 17

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_14 = 18

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_15 = 19

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_16 = 20

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_17 = 21

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_18 = 22

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_19 = 23

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_20 = 24

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_21 = 25

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_22 = 26

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_23 = 27

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_24 = 28

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_25 = 29

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_26 = 30

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_27 = 31

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_28 = 32

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_29 = 33

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_30 = 34

Aggregated Reservation Nesting Level [RFC 3175]

Aggregated_Reservation_Nesting_Level_31 = 35

Aggregated Reservation Nesting Level [RFC 3175]

QoS_NSLP_Aggregation_Level_0 = 36

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_1 = 37

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_2 = 38

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_3 = 39

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_4 = 40

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_5 = 41

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_6 = 42

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_7 = 43

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_8 = 44

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_9 = 45

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_10 = 46

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_11 = 47

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_12 = 48

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_13 = 49

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_14 = 50

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_15 = 51

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_16 = 52

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_17 = 53

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_18 = 54

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_19 = 55

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_20 = 56

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_21 = 57

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_22 = 58

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_23 = 59

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_24 = 60

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_25 = 61

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_26 = 62

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_27 = 63

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_28 = 64

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_29 = 65

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_30 = 66

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

QoS_NSLP_Aggregation_Level_31 = 67

QoS NSLP Aggregation Levels 0-31 [RFC 5974]

NSIS_NATFW_NSLP = 68

NSIS NATFW NSLP [RFC 5973]

MPLS_OAM = 69

MPLS OAM [RFC 7506]

Reserved_65535 = 65535

Reserved [The Internet Assigned Numbers Authority]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

RouterAlert

IPv6 Routing Types

This module contains the constant enumeration for IPv6 Routing Types, which is automatically generated from pcapkit.vendor.ipv6.routing.Routing.

class pcapkit.const.ipv6.routing.Routing(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Routing] IPv6 Routing Types

Source_Route = 0

Source Route (DEPRECATED) [RFC 2460][RFC 5095]

Nimrod(DEPRECATED 2009-05-06) = 1

Nimrod (DEPRECATED 2009-05-06)

Type_2_Routing_Header = 2

Type 2 Routing Header [RFC 6275]

RPL_Source_Route_Header = 3

RPL Source Route Header [RFC 6554]

Segment_Routing_Header = 4

Segment Routing Header (SRH) [RFC 8754]

CRH_16 = 5

CRH-16 (TEMPORARY - registered 2021-06-07, extension registered 2022-04-25, expires 2023-06-07) [draft-bonica-6man-comp-rtg-hdr-26]

CRH_32 = 6

CRH-32 (TEMPORARY - registered 2021-06-07, extension registered 2022-04-25, expires 2023-06-07) [draft-bonica-6man-comp-rtg-hdr-26]

RFC3692_style_Experiment_1 = 253

RFC3692-style Experiment 1 [RFC 4727]

RFC3692_style_Experiment_2 = 254

RFC3692-style Experiment 2 [RFC 4727]

Reserved_255 = 255

Reserved

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Routing

Seed-ID Types

This module contains the constant enumeration for Seed-ID Types, which is automatically generated from pcapkit.vendor.ipv6.seed_id.SeedID.

class pcapkit.const.ipv6.seed_id.SeedID(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[SeedID] Seed-ID Types

IPV6_SOURCE_ADDRESS = 0
SEEDID_16_BIT_UNSIGNED_INTEGER = 1
SEEDID_64_BIT_UNSIGNED_INTEGER = 2
SEEDID_128_BIT_UNSIGNED_INTEGER = 3
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

SeedID

Simplified Multicast Forwarding Duplicate Packet Detection (SMF_DPD) Options

This module contains the constant enumeration for Simplified Multicast Forwarding Duplicate Packet Detection (``SMF_DPD``) Options, which is automatically generated from pcapkit.vendor.ipv6.smf_dpd_mode.SMFDPDMode.

class pcapkit.const.ipv6.smf_dpd_mode.SMFDPDMode(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[SMFDPDMode] Simplified Multicast Forwarding Duplicate Packet Detection (SMF_DPD) Options

I_DPD = 0
H_DPD = 1
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

SMFDPDMode

TaggerID Types

This module contains the constant enumeration for TaggerID Types, which is automatically generated from pcapkit.vendor.ipv6.tagger_id.TaggerID.

class pcapkit.const.ipv6.tagger_id.TaggerID(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[TaggerID] TaggerID Types

NULL = 0

NULL [RFC 6621]

DEFAULT = 1

DEFAULT [RFC 6621]

IPv4 = 2

IPv4 [RFC 6621]

IPv6 = 3

IPv6 [RFC 6621]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

TaggerID


*

https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#extension-header

https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#ipv6-parameters-2

https://www.iana.org/assignments/ipv6-routeralert-values/ipv6-routeralert-values.xhtml#ipv6-routeralert-values-1

§

https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#ipv6-parameters-3

https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#taggerId-types

IPX Constant Enumerations

This module contains all constant enumerations of IPX implementations. Available enumerations include:

IPX_Packet

IPX Packet Types *

IPX_Socket

IPX Socket Types

IPX Packet Types

This module contains the constant enumeration for IPX Packet Types, which is automatically generated from pcapkit.vendor.ipx.packet.Packet.

class pcapkit.const.ipx.packet.Packet(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Packet] IPX Packet Types

Unknown = 0

Unknown

RIP = 1

RIP, Routing Information Protocol ([RFC 1582], [RFC 2091])

Echo_Packet = 2

Echo Packet

Error_Packet = 3

Error Packet

PEP = 4

PEP, Packet Exchange Protocol, used for SAP (Service Advertising Protocol)

SPX = 5

SPX, Sequenced Packet Exchange

NCP = 17

NCP, NetWare Core Protocol

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Packet

Socket Types

This module contains the constant enumeration for Socket Types, which is automatically generated from pcapkit.vendor.ipx.socket.Socket.

class pcapkit.const.ipx.socket.Socket(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Socket] Socket Types

Routing_Information_Packet = 1

Routing Information Packet

Echo_Protocol_Packet = 2

Echo Protocol Packet

Error_Handling_Packet = 3

Error Handling Packet

NetWare_Core_Protocol = 1105

NetWare Core Protocol, NCP – used by Novell NetWare servers

Service_Advertising_Protocol = 1106

Service Advertising Protocol, SAP

Routing_Information_Protocol = 1107

Routing Information Protocol, RIP

NetBIOS = 1109

NetBIOS

Diagnostic_Packet = 1110

Diagnostic Packet

Serialization_Packet = 1111

Serialization Packet, used for NCP as well

Used_by_Novell_NetWare_Client = 16387

Used by Novell NetWare Client

IPX = 32864

IPX

TCP_over_IPXF = 37009

TCP over IPXF

UDP_over_IPXF = 37010

UDP over IPXF

IPXF = 37011

IPXF, IPX Fragmentation Protocol

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Socket


*

https://en.wikipedia.org/wiki/Internetwork_Packet_Exchange#IPX_packet_structure

https://en.wikipedia.org/wiki/Internetwork_Packet_Exchange#Socket_number

MH Constant Enumerations

This module contains all constant enumerations of MH implementations. Available enumerations include:

MH_Packet

Mobility Header Types *

Mobility Header Types - for the MH Type field in the Mobility Header

This module contains the constant enumeration for Mobility Header Types - for the MH Type field in the Mobility Header, which is automatically generated from pcapkit.vendor.mh.packet.Packet.

class pcapkit.const.mh.packet.Packet(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Packet] Mobility Header Types - for the MH Type field in the Mobility Header

Binding_Refresh_Request = 0

Binding Refresh Request [RFC 6275]

Home_Test_Init = 1

Home Test Init [RFC 6275]

Care_of_Test_Init = 2

Care-of Test Init [RFC 6275]

Home_Test = 3

Home Test [RFC 6275]

Care_of_Test = 4

Care-of Test [RFC 6275]

Binding_Update = 5

Binding Update [RFC 6275]

Binding_Acknowledgement = 6

Binding Acknowledgement [RFC 6275]

Binding_Error = 7

Binding Error [RFC 6275]

Fast_Binding_Update = 8

Fast Binding Update [RFC 5568]

Fast_Binding_Acknowledgment = 9

Fast Binding Acknowledgment [RFC 5568]

Fast_Neighbor_Advertisement = 10

Fast Neighbor Advertisement (Deprecated) [RFC 5568]

Experimental_Mobility_Header = 11

Experimental Mobility Header [RFC 5096]

Home_Agent_Switch_Message = 12

Home Agent Switch Message [RFC 5142]

Heartbeat_Message = 13

Heartbeat Message [RFC 5847]

Handover_Initiate_Message = 14

Handover Initiate Message [RFC 5568]

Handover_Acknowledge_Message = 15

Handover Acknowledge Message [RFC 5568]

Binding_Revocation_Message = 16

Binding Revocation Message [RFC 5846]

Localized_Routing_Initiation = 17

Localized Routing Initiation [RFC 6705]

Localized_Routing_Acknowledgment = 18

Localized Routing Acknowledgment [RFC 6705]

Update_Notification = 19

Update Notification [RFC 7077]

Update_Notification_Acknowledgement = 20

Update Notification Acknowledgement [RFC 7077]

Flow_Binding_Message = 21

Flow Binding Message [RFC 7109]

Subscription_Query = 22

Subscription Query [RFC 7161]

Subscription_Response = 23

Subscription Response [RFC 7161]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Packet


*

https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1

Transport Layer

TCP Constant Enumerations

This module contains all constant enumerations of TCP implementations. Available enumerations include:

TCP_Checksum

TCP Checksum *

TCP_MPTCPOption

Multipath TCP options

TCP_Option

TCP Option Kind Numbers

TCP Checksum

This module contains the constant enumeration for TCP Checksum, which is automatically generated from pcapkit.vendor.tcp.checksum.Checksum.

class pcapkit.const.tcp.checksum.Checksum(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Checksum] TCP Checksum [RFC 1146]

TCP_checksum = 0
Checksum_8_bit_Fletcher_s_algorithm = 1
Checksum_16_bit_Fletcher_s_algorithm = 2
Redundant_Checksum_Avoidance = 3
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Checksum

Multipath TCP options

This module contains the constant enumeration for Multipath TCP options, which is automatically generated from pcapkit.vendor.tcp.mp_tcp_option.MPTCPOption.

class pcapkit.const.tcp.mp_tcp_option.MPTCPOption(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[MPTCPOption] Multipath TCP options [RFC 6824]

MP_CAPABLE = 0
MP_JOIN = 1
DSS = 2
ADD_ADDR = 3
REMOVE_ADDR = 4
MP_PRIO = 5
MP_FAIL = 6
MP_FASTCLOSE = 7
classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

MPTCPOption

TCP Option Kind Numbers

This module contains the constant enumeration for TCP Option Kind Numbers, which is automatically generated from pcapkit.vendor.tcp.option.Option.

class pcapkit.const.tcp.option.Option(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Option] TCP Option Kind Numbers

End_of_Option_List = 0

End of Option List [RFC-ietf-tcpm-rfc793bis-28]

No_Operation = 1

No-Operation [RFC-ietf-tcpm-rfc793bis-28]

Maximum_Segment_Size = 2

Maximum Segment Size [RFC-ietf-tcpm-rfc793bis-28]

Window_Scale = 3

Window Scale [RFC 7323]

SACK_Permitted = 4

SACK Permitted [RFC 2018]

SACK = 5

SACK [RFC 2018]

Echo = 6

Echo (obsoleted by option 8) [RFC 1072][RFC 6247]

Echo_Reply = 7

Echo Reply (obsoleted by option 8) [RFC 1072][RFC 6247]

Timestamps = 8

Timestamps [RFC 7323]

Partial_Order_Connection_Permitted = 9

Partial Order Connection Permitted (obsolete) [RFC 1693][RFC 6247]

Partial_Order_Service_Profile = 10

Partial Order Service Profile (obsolete) [RFC 1693][RFC 6247]

CC = 11

CC (obsolete) [RFC 1644][RFC 6247]

CC_NEW = 12

CC.NEW (obsolete) [RFC 1644][RFC 6247]

CC_ECHO = 13

CC.ECHO (obsolete) [RFC 1644][RFC 6247]

TCP_Alternate_Checksum_Request = 14

TCP Alternate Checksum Request (obsolete) [RFC 1146][RFC 6247]

TCP_Alternate_Checksum_Data = 15

TCP Alternate Checksum Data (obsolete) [RFC 1146][RFC 6247]

Skeeter = 16

Skeeter [Stev Knowles]

Bubba = 17

Bubba [Stev Knowles]

Trailer_Checksum_Option = 18

Trailer Checksum Option [Subbu Subramaniam][Monroe Bridges]

MD5_Signature_Option = 19

MD5 Signature Option (obsoleted by option 29) [RFC 2385]

SCPS_Capabilities = 20

SCPS Capabilities [Keith Scott]

Selective_Negative_Acknowledgements = 21

Selective Negative Acknowledgements [Keith Scott]

Record_Boundaries = 22

Record Boundaries [Keith Scott]

Corruption_experienced = 23

Corruption experienced [Keith Scott]

SNAP = 24

SNAP [Vladimir Sukonnik]

Unassigned_25 = 25

Unassigned (released 2000-12-18)

TCP_Compression_Filter = 26

TCP Compression Filter [Steve Bellovin]

Quick_Start_Response = 27

Quick-Start Response [RFC 4782]

User_Timeout_Option = 28

User Timeout Option (also, other known unauthorized use) [***][1] [RFC 5482]

TCP_Authentication_Option = 29

TCP Authentication Option (TCP-AO) [RFC 5925]

Multipath_TCP = 30

Multipath TCP (MPTCP) [RFC 8684]

Reserved_31 = 31

Reserved (known unauthorized use without proper IANA assignment) [**]

Reserved_32 = 32

Reserved (known unauthorized use without proper IANA assignment) [**]

Reserved_33 = 33

Reserved (known unauthorized use without proper IANA assignment) [**]

TCP Fast Open Cookie [RFC 7413]

Encryption_Negotiation = 69

Encryption Negotiation (TCP-ENO) [RFC 8547]

Reserved_70 = 70

Reserved (known unauthorized use without proper IANA assignment) [**]

Reserved_76 = 76

Reserved (known unauthorized use without proper IANA assignment) [**]

Reserved_77 = 77

Reserved (known unauthorized use without proper IANA assignment) [**]

Reserved_78 = 78

Reserved (known unauthorized use without proper IANA assignment) [**]

RFC3692_style_Experiment_1 = 253

RFC3692-style Experiment 1 (also improperly used for shipping products) [*] [RFC 4727]

RFC3692_style_Experiment_2 = 254

RFC3692-style Experiment 2 (also improperly used for shipping products) [*] [RFC 4727]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Option


*

https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml#tcp-parameters-2

https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml#tcp-parameters-1

Application Layer

FTP Constant Enumerations

This module contains all constant enumerations of FTP implementations. Available enumerations include:

FTP_Command

FTP Commands *

FTP_ReturnCode

FTP Return Codes

FTP Command

This module contains the constant enumeration for FTP Command, which is automatically generated from pcapkit.vendor.ftp.command.Command.

pcapkit.const.ftp.command.Command: defaultInfo[CommandType]

FTP commands.

class pcapkit.const.ftp.command.CommandType(*args, **kwargs)[source]

Bases: Info

FTP command type.

Parameters
  • args (VT) –

  • kwargs (VT) –

Return type

Info

name: str

Name of command.

feat: Optional[str]

Feature of command.

desc: Optional[str]

Description of command.

type: Optional[tuple[str, ...]]

Type of command.

conf: Optional[str]

Conformance of command.

note: Optional[tuple[str, ...]]

Note of command.

class pcapkit.const.ftp.command.defaultInfo(*args, **kwargs)[source]

Bases: Info[CommandType]

Extended Info with default values.

Parameters
  • *args (VT) – Arbitrary positional arguments.

  • **kwargs (VT) – Arbitrary keyword arguments.

Return type

Info

__getitem__(key)[source]

Missing keys as specified in RFC 3659.

Parameters

key (str) – Key of missing command.

Return type

CommandType

FTP Server Return Code

This module contains the constant enumeration for FTP Server Return Code, which is automatically generated from pcapkit.vendor.ftp.return_code.ReturnCode.

class pcapkit.const.ftp.return_code.ReturnCode(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ReturnCode] FTP Server Return Code

CODE_110 = 110

Restart marker replay. In this case, the text is exact and not left to the particular implementation; it must read: MARK yyyy = mmmm where yyyy is User-process data stream marker, and mmmm server’s equivalent marker (note the spaces between markers and “=”).

CODE_120 = 120

Service ready in nnn minutes.

CODE_125 = 125

Data connection already open; transfer starting.

CODE_150 = 150

File status okay; about to open data connection.

CODE_202 = 202

Command not implemented, superfluous at this site.

CODE_211 = 211

System status, or system help reply.

CODE_212 = 212

Directory status.

CODE_213 = 213

File status.

CODE_214 = 214

Help message. Explains how to use the server or the meaning of a particular non-standard command. This reply is useful only to the human user.

CODE_215 = 215

NAME system type. Where NAME is an official system name from the registry kept by IANA.

CODE_220 = 220

Service ready for new user.

CODE_221 = 221

Service closing control connection.

CODE_225 = 225

Data connection open; no transfer in progress.

CODE_226 = 226

Closing data connection. Requested file action successful (for example, file transfer or file abort).

CODE_227 = 227

Entering Passive Mode (h1,h2,h3,h4,p1,p2).

CODE_228 = 228

Entering Long Passive Mode (long address, port).

CODE_229 = 229

Entering Extended Passive Mode (|||port|).

CODE_230 = 230

User logged in, proceed. Logged out if appropriate.

CODE_231 = 231

User logged out; service terminated.

CODE_232 = 232

Logout command noted, will complete when transfer done.

CODE_234 = 234

Specifies that the server accepts the authentication mechanism specified by the client, and the exchange of security data is complete. A higher level nonstandard code created by Microsoft.

CODE_250 = 250

Requested file action okay, completed.

CODE_257 = 257

“PATHNAME” created.

CODE_331 = 331

User name okay, need password.

CODE_332 = 332

Need account for login.

CODE_350 = 350

Requested file action pending further information

CODE_421 = 421

Service not available, closing control connection. This may be a reply to any command if the service knows it must shut down.

CODE_425 = 425

Can’t open data connection.

CODE_426 = 426

Connection closed; transfer aborted.

CODE_430 = 430

Invalid username or password

CODE_434 = 434

Requested host unavailable.

CODE_450 = 450

Requested file action not taken.

CODE_451 = 451

Requested action aborted. Local error in processing.

CODE_452 = 452

Requested action not taken. Insufficient storage space in system. File unavailable (e.g., file busy).

CODE_501 = 501

Syntax error in parameters or arguments.

CODE_502 = 502

Command not implemented.

CODE_503 = 503

Bad sequence of commands.

CODE_504 = 504

Command not implemented for that parameter.

CODE_530 = 530

Not logged in.

CODE_532 = 532

Need account for storing files.

CODE_534 = 534

Could Not Connect to Server - Policy Requires SSL

CODE_550 = 550

Requested action not taken. File unavailable (e.g., file not found, no access).

CODE_551 = 551

Requested action aborted. Page type unknown.

CODE_552 = 552

Requested file action aborted. Exceeded storage allocation (for current directory or dataset).

CODE_553 = 553

Requested action not taken. File name not allowed.

CODE_631 = 631

Integrity protected reply.

CODE_632 = 632

Confidentiality and integrity protected reply.

CODE_633 = 633

Confidentiality protected reply.

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ReturnCode


*

https://www.iana.org/assignments/ftp-commands-extensions/ftp-commands-extensions.xhtml#ftp-commands-extensions-2

https://en.wikipedia.org/wiki/List_of_FTP_server_return_codes

HTTP Constant Enumerations

This module contains all constant enumerations of HTTP implementations. Available enumerations include:

HTTP_ErrorCode

HTTP/2 Error Code *

HTTP_Frame

HTTP/2 Frame Type

HTTP_Setting

HTTP/2 Settings

HTTP/2 Error Code

This module contains the constant enumeration for HTTP/2 Error Code, which is automatically generated from pcapkit.vendor.http.error_code.ErrorCode.

class pcapkit.const.http.error_code.ErrorCode(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[ErrorCode] HTTP/2 Error Code

NO_ERROR = 0

NO_ERROR, Graceful shutdown [:rfc:`9113, Section 7`]

PROTOCOL_ERROR = 1

PROTOCOL_ERROR, Protocol error detected [:rfc:`9113, Section 7`]

INTERNAL_ERROR = 2

INTERNAL_ERROR, Implementation fault [:rfc:`9113, Section 7`]

FLOW_CONTROL_ERROR = 3

FLOW_CONTROL_ERROR, Flow-control limits exceeded [:rfc:`9113, Section 7`]

SETTINGS_TIMEOUT = 4

SETTINGS_TIMEOUT, Settings not acknowledged [:rfc:`9113, Section 7`]

STREAM_CLOSED = 5

STREAM_CLOSED, Frame received for closed stream [:rfc:`9113, Section 7`]

FRAME_SIZE_ERROR = 6

FRAME_SIZE_ERROR, Frame size incorrect [:rfc:`9113, Section 7`]

REFUSED_STREAM = 7

REFUSED_STREAM, Stream not processed [:rfc:`9113, Section 7`]

CANCEL = 8

CANCEL, Stream cancelled [:rfc:`9113, Section 7`]

COMPRESSION_ERROR = 9

COMPRESSION_ERROR, Compression state not updated [:rfc:`9113, Section 7`]

CONNECT_ERROR = 10

9113, Section 7]

Type

CONNECT_ERROR, TCP connection error for CONNECT method [

Type

rfc

ENHANCE_YOUR_CALM = 11

ENHANCE_YOUR_CALM, Processing capacity exceeded [:rfc:`9113, Section 7`]

INADEQUATE_SECURITY = 12

9113, Section 7]

Type

INADEQUATE_SECURITY, Negotiated TLS parameters not acceptable [

Type

rfc

HTTP_1_1_REQUIRED = 13

HTTP_1_1_REQUIRED, Use HTTP/1.1 for the request [:rfc:`9113, Section 7`]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

ErrorCode

HTTP/2 Frame Type

This module contains the constant enumeration for HTTP/2 Frame Type, which is automatically generated from pcapkit.vendor.http.frame.Frame.

class pcapkit.const.http.frame.Frame(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Frame] HTTP/2 Frame Type

DATA = 0

DATA [:rfc:`9113, Section 6.1`]

HEADERS = 1

HEADERS [:rfc:`9113, Section 6.2`]

PRIORITY = 2

PRIORITY [:rfc:`9113, Section 6.3`]

RST_STREAM = 3

RST_STREAM [:rfc:`9113, Section 6.4`]

SETTINGS = 4

SETTINGS [:rfc:`9113, Section 6.5`]

PUSH_PROMISE = 5

PUSH_PROMISE [:rfc:`9113, Section 6.6`]

PING = 6

PING [:rfc:`9113, Section 6.7`]

GOAWAY = 7

GOAWAY [:rfc:`9113, Section 6.8`]

WINDOW_UPDATE = 8

WINDOW_UPDATE [:rfc:`9113, Section 6.9`]

CONTINUATION = 9

CONTINUATION [:rfc:`9113, Section 6.10`]

ALTSVC = 10

ALTSVC [:rfc:`7838, Section 4`]

Unassigned_0x0B = 11

Unassigned

ORIGIN = 12

ORIGIN [RFC 8336]

PRIORITY_UPDATE = 16

PRIORITY_UPDATE [RFC 9218]

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Frame

HTTP/2 Settings

This module contains the constant enumeration for HTTP/2 Settings, which is automatically generated from pcapkit.vendor.http.setting.Setting.

class pcapkit.const.http.setting.Setting(value=<no_arg>, names=None, module=None, qualname=None, type=None, start=1, boundary=None)[source]

Bases: IntEnum

[Setting] HTTP/2 Settings

Reserved_0x0000 = 0

Reserved [RFC 9113]

HEADER_TABLE_SIZE = 1
Type

HEADER_TABLE_SIZE [:rfc:`9113, Section 6.5.2`] (Initial Value

ENABLE_PUSH = 2
Type

ENABLE_PUSH [:rfc:`9113, Section 6.5.2`] (Initial Value

MAX_CONCURRENT_STREAMS = 3

MAX_CONCURRENT_STREAMS [:rfc:`9113, Section 6.5.2`] (Initial Value: infinite)

INITIAL_WINDOW_SIZE = 4
Type

INITIAL_WINDOW_SIZE [:rfc:`9113, Section 6.5.2`] (Initial Value

MAX_FRAME_SIZE = 5
Type

MAX_FRAME_SIZE [:rfc:`9113, Section 6.5.2`] (Initial Value

MAX_HEADER_LIST_SIZE = 6

MAX_HEADER_LIST_SIZE [:rfc:`9113, Section 6.5.2`] (Initial Value: infinite)

Unassigned_0x0007 = 7

Unassigned

SETTINGS_ENABLE_CONNECT_PROTOCOL = 8
Type

SETTINGS_ENABLE_CONNECT_PROTOCOL [RFC 8441] (Initial Value

SETTINGS_NO_RFC7540_PRIORITIES = 9
Type

SETTINGS_NO_RFC7540_PRIORITIES [RFC 9218] (Initial Value

TLS_RENEG_PERMITTED = 16

TLS_RENEG_PERMITTED [MS-HTTP2E][Gabriel Montenegro] (Initial Value: 0x00)

classmethod _missing_(value)[source]

Lookup function used when value is not found.

Parameters

value (int) – Value to get enum item.

Return type

Setting


*

https://www.iana.org/assignments/http2-parameters/http2-parameters.xhtml#error-code

https://www.iana.org/assignments/http2-parameters/http2-parameters.xhtml#frame-type

https://www.iana.org/assignments/http2-parameters/http2-parameters.xhtml#settings

Vendor Crawlers

This module contains all web crawlers of pcapkit, which are automatically generating from the pcapkit.const module’s constant enumerations.

Base Crawler

Base Crawler

pcapkit.vendor.default contains Vendor only, which is the base meta class for all vendor crawlers.

Vendor Crawler
class pcapkit.vendor.default.Vendor[source]

Bases: object

Default vendor generator.

Inherit this class with FLAG & LINK attributes, etc., to implement a new vendor generator.

Return type

Vendor

static __new__(cls)[source]

Subclassing checkpoint.

Raises

VendorNotImplemented – If cls is not a subclass of Vendor.

Return type

Vendor

__init__()[source]

Generate new constant files.

Return type

None

static wrap_comment(text)[source]

Wraps long-length text to shorter lines of comments.

Parameters

text (str) – Source text.

Return type

str

Returns

Wrapped comments.

safe_name(name)[source]

Convert enumeration name to enum.Enum friendly.

Parameters

name (str) – original enumeration name

Return type

str

Returns

Converted enumeration name.

rename(name, code, *, original=None)[source]

Rename duplicated fields.

Parameters
  • name (str) – Field name.

  • code (str) – Field code.

  • original (Optional[str]) – Original field name (extracted from CSV records).

Return type

str

Returns

Revised field name.

Example

If name has multiple occurrences in the source registry, the field name will be sanitised as ${name}_${code}.

Otherwise, the plain name will be returned.

process(data)[source]

Process CSV data.

Parameters

data (list[str]) – CSV data.

Returns

Enumeration fields and missing fields.

Return type

tuple[list[str], list[str]]

count(data)[source]

Count field records.

Parameters

data (list[str]) – CSV data.

Returns

Field recordings.

Return type

Counter[str]

context(data)[source]

Generate constant context.

Parameters

data (list[str]) – CSV data.

Returns

Constant context.

Return type

str

request(text=None)[source]

Fetch CSV file.

Parameters

text (Optional[str]) – Context from LINK.

Returns

CSV data.

Return type

list[str]

_request()[source]

Fetch CSV data from LINK.

This is the low-level call of request().

If LINK is None, it will directly call the upper method request() with NO arguments.

The method will first try to GET the content of LINK. Should any exception raised, it will first try with proxy settings from get_proxies().

Note

Since some LINK links are from Wikipedia, etc., they might not be available in certain areas, e.g. the amazing PRC :)

Would proxies failed again, it will prompt for user intervention, i.e. it will use webbrowser.open() to open the page in browser for you, and you can manually load that page and save the HTML source at the location it provides.

Returns

CSV data.

Warns

VendorRequestWarning – If connection failed with and/or without proxies.

Return type

list[str]

See also

request()

NAME: str

Name of constant enumeration.

Type

str

DOCS: str

Docstring of constant enumeration.

Type

str

FLAG: str

Value limit checker.

Type

str

Link to registry.

Type

str

Crawler Template
pcapkit.vendor.default.LINE(NAME, DOCS, FLAG, ENUM, MISS, MODL)

Default constant template of enumeration registry from IANA CSV.

Parameters
  • NAME (str) – name of the constant enumeration class

  • DOCS (str) – docstring for the constant enumeration class

  • FLAG (str) – threshold value validator (range of valid values)

  • ENUM (str) – enumeration data (class attributes)

  • MISS (str) – missing value handler (default value)

  • MODL (str) – module name of the constant enumeration class

Return type

str

Crawler Proxy
pcapkit.vendor.default.get_proxies()[source]

Get proxy for blocked sites.

The function will read PCAPKIT_HTTP_PROXY and PCAPKIT_HTTPS_PROXY, if any, for the proxy settings of requests.

Returns

Proxy settings for requests.

Return type

dict[str, str]

Protocol Numbers

Protocol Type Registry Vendor Crawlers

This module contains all vendor crawlers of protocol type registry implementations. Available enumerations include:

LINKTYPE

Link-Layer Header Type Values *

ETHERTYPE

Ethertype IEEE 802 Numbers

TRANSTYPE

Transport Layer Protocol Numbers

Ethertype IEEE 802 Numbers

This module contains the vendor crawler for Ethertype IEEE 802 Numbers, which is automatically generating pcapkit.const.reg.ethertype.EtherType.

class pcapkit.vendor.reg.ethertype.EtherType[source]

Bases: Vendor

Ethertype IEEE 802 Numbers

Return type

Vendor

FLAG: str = 'isinstance(value, int) and 0x0000 <= value <= 0xFFFF'

Value limit checker.

LINK: str = 'https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers-1.csv'

Link to registry.


*

http://www.tcpdump.org/linktypes.html

https://www.iana.org/assignments/ieee-802-numbers/ieee-802-numbers.xhtml#ieee-802-numbers-1

https://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml#protocol-numbers-1

Internet Layer

HIP Vendor Crawlers

This module contains all vendor crawlers of HIP implementations. Available crawlers include:

HIP_Certificate

HIP Certificate Types *

HIP_Cipher

HIP Cipher IDs

HIP_DITypes

DI-Types

HIP_ECDSACurve

ECDSA Curve Label §

HIP_ECDSALowCurve

ECDSA_LOW Curve Label

HIP_ESPTransformSuite

ESP Transform Suite IDs #

HIP_Group

Group IDs

HIP_HIAlgorithm

HI Algorithm

HIP_HITSuite

HIT Suite IDs

HIP_NATTraversal

HIP NAT Traversal Modes

HIP_NotifyMessage

Notify Message Types **

HIP_Packet

Packet Types ††

HIP_Parameter

Parameter Types ‡‡

HIP_Registration

Registration Types §§

HIP_RegistrationFailure

Registration Failure Types ¶¶

HIP_Suite

Suite IDs ##

HIP_Transport

HIP Transport Modes ♠♠


*

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#certificate-types

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-cipher-id

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-7

§

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#ecdsa-curve-label

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#ecdsa-low-curve-label

#

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#esp-transform-suite-ids

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-5

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hi-algorithm

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hit-suite-id

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#nat-traversal

**

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-9

††

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-1

‡‡

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-4

§§

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-11

¶¶

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-13

##

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#hip-parameters-6

♠♠

https://www.iana.org/assignments/hip-parameters/hip-parameters.xhtml#transport-modes

IPv4 Vendor Crawlers

This module contains all vendor crawlers of IPv4 implementations. Available crawlers include:

IPv4_ClassificationLevel

Classification Level Encodings

IPv4_OptionClass

Option Classes

IPv4_OptionNumber

IP Option Numbers *

IPv4_ProtectionAuthority

Protection Authority Bit Assignments

IPv4_QSFunction

QS Functions

IPv4_RouterAlert

IPv4 Router Alert Option Values

IPv4_ToSDelay

ToS (DS Field) Delay

IPv4_ToSECN

ToS ECN Field

IPv4_ToSPrecedence

ToS (DS Field) Precedence

IPv4_ToSReliability

ToS (DS Field) Reliability

IPv4_ToSThroughput

ToS (DS Field) Throughput


*

https://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml#ip-parameters-1

https://www.iana.org/assignments/ip-parameters/ip-parameters.xhtml#ipv4-router-alert-option-values

IPv6 Vendor Crawlers

This module contains all vendor crawlers of IPv6 implementations. Available crawlers include:

IPv6_Extension_Header

IPv6 Extension Header Types *

IPv6_Option

Destination Options and Hop-by-Hop Options

IPv6_QSFunction

IPv6 QS Functions

IPv6_RouterAlert

IPv6 Router Alert Option Values

IPv6_Routing

Routing Types §

IPv6_SeedID

Seed-ID Types

IPv6_SMFDPDMode

Simplified Multicast Forwarding Duplicate Packet Detection (SMF_DPD) Options

IPv6_TaggerID

Tagger-ID Types


*

https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#extension-header

https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#ipv6-parameters-2

https://www.iana.org/assignments/ipv6-routeralert-values/ipv6-routeralert-values.xhtml#ipv6-routeralert-values-1

§

https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#ipv6-parameters-3

https://www.iana.org/assignments/ipv6-parameters/ipv6-parameters.xhtml#taggerId-types

IPX Vendor Crawlers

This module contains all vendor crawlers of IPX implementations. Available crawlers include:

IPX_Packet

IPX Packet Types *

IPX_Socket

IPX Socket Types


*

https://en.wikipedia.org/wiki/Internetwork_Packet_Exchange#IPX_packet_structure

https://en.wikipedia.org/wiki/Internetwork_Packet_Exchange#Socket_number

MH Vendor Crawlers

This module contains all vendor crawlers of MH implementations. Available enumerations include:

MH_Packet

Mobility Header Types *


*

https://www.iana.org/assignments/mobility-parameters/mobility-parameters.xhtml#mobility-parameters-1

Transport Layer

TCP Vendor Crawlers

This module contains all vendor crawlers of TCP implementations. Available enumerations include:

TCP_Checksum

TCP Checksum *

TCP_MPTCPOption

Multipath TCP options

TCP_Option

TCP Option Kind Numbers


*

https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml#tcp-parameters-2

https://www.iana.org/assignments/tcp-parameters/tcp-parameters.xhtml#tcp-parameters-1

Application Layer

FTP Vendor Crawler

This module contains all vendor crawlers of FTP implementations. Available crawlers include:

FTP_Command

FTP Commands *

FTP_ReturnCode

FTP Return Codes


*

https://www.iana.org/assignments/ftp-commands-extensions/ftp-commands-extensions.xhtml#ftp-commands-extensions-2

https://en.wikipedia.org/wiki/List_of_FTP_server_return_codes

HTTP Venddor Crawlers

This module contains all vendor crawlers of HTTP implementations. Available vendor crawlers include:

HTTP_ErrorCode

HTTP/2 Error Code *

HTTP_Frame

HTTP/2 Frame Type

HTTP_Setting

HTTP/2 Settings


*

https://www.iana.org/assignments/http2-parameters/http2-parameters.xhtml#error-code

https://www.iana.org/assignments/http2-parameters/http2-parameters.xhtml#frame-type

https://www.iana.org/assignments/http2-parameters/http2-parameters.xhtml#settings

usage: pcapkit-vendor [-h] [-V] ...

update constant enumerations

positional arguments:
  target         update targets, supply none to update all

optional arguments:
  -h, --help     show this help message and exit
  -V, --version  show program's version number and exit

Command Line Tool

Important

This module requires emoji package to be installed.

pcapkit.__main__ was originally the module file of jspcapy, which is now deprecated and merged with pcapkit.

usage: pcapkit-cli [-h] [-V] [-o file-name] [-f format] [-j] [-p] [-t] [-a]
                   [-v] [-F] [-E PKG] [-P PROTOCOL] [-L LAYER]
                   input-file-name

PCAP file extractor and formatted dumper

positional arguments:
  input-file-name       The name of input pcap file. If ".pcap" omits, it will
                        be automatically appended.

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit
  -o file-name, --output file-name
                        The name of input pcap file. If format extension
                        omits, it will be automatically appended.
  -f format, --format format
                        Print a extraction report in the specified output
                        format. Available are all formats supported by
                        dictdumper, e.g.: json, plist, and tree.
  -j, --json            Display extraction report as json. This will yield
                        "raw" output that may be used by external tools. This
                        option overrides all other options.
  -p, --plist           Display extraction report as macOS Property List
                        (plist). This will yield "raw" output that may be used
                        by external tools. This option overrides all other
                        options.
  -t, --tree            Display extraction report as tree view text. This will
                        yield "raw" output that may be used by external tools.
                        This option overrides all other options.
  -a, --auto-extension  If output file extension omits, append automatically.
  -v, --verbose         Show more information.
  -F, --files           Split each frame into different files.
  -E PKG, --engine PKG  Indicate extraction engine. Note that except default
                        or pcapkit engine, all other engines need support of
                        corresponding packages.
  -P PROTOCOL, --protocol PROTOCOL
                        Indicate extraction stops after which protocol.
  -L LAYER, --layer LAYER
                        Indicate extract frames until which layer.

Library Index

pcapkit has defined various and numerous functions and classes, which have different features and purposes. To make a simple index for this library, pcapkit.all contains all things from pcapkit.

How to …

Basic Samples

pcapkit is quite easy to use, with simply three verbs as its main interface. Several scenarios are shown as below.

  1. extract a PCAP file and dump the result to a specific file (with no reassembly)

    from pcapkit import extract
    # dump to a PLIST file with no frame storage (property frame disabled)
    plist = extract(fin='in.pcap', fout='out.plist', format='plist', store=False)
    # dump to a JSON file with no extension auto-complete
    json = extract(fin='in.cap', fout='out.json', format='json', extension=False)
    # dump to a folder with each tree-view text file per frame
    tree = extract(fin='in.pcap', fout='out', format='tree', files=True)
    
  2. extract a PCAP file and fetch IP packet (both IPv4 and IPv6) from a frame (with no output file)

    from pcapkit import IP, extract
    extraction = extract(fin='in.pcap', nofile=True)
    frame0 = extraction.frame[0]
    # check if IP (IPv4 or IPv6) in this frame
    flag = IP in frame0
    if IP in frame0:
       # fetch the IP packet from this frame
       ip = frame0[IP]
    
  3. extract a PCAP file and reassemble TCP payload (with no output file nor frame storage)

    from pcapkit import HTTP, extract
    # set strict to make sure full reassembly
    extraction = extract(fin='in.pcap', store=False, nofile=True, tcp=True, strict=True)
    # print extracted packet if HTTP in reassembled payloads
    for datagram in extraction.reassembly.tcp:
        if datagram.packet is not None and HTTP in datagram.packet:
            print(datagram.packet[HTTP])
    

CLI Samples

The CLI (command line interface) of pcapkit has two different access.

  • through console scripts

    Use command name pcapkit-cli [...] directly (as shown in samples).

  • through Python module

    python -m pypcapkit [...] works exactly the same as above.

Here are some usage samples:

  1. export to a macOS Property List (Xcode has special support for this format)

    $ pcapkit-cli in --format plist --verbose
    🚨Loading file 'in.pcap'
    Frame   1: Ethernet:IPv6:IPv6_ICMP
    Frame   2: Ethernet:IPv6:IPv6_ICMP
    Frame   3: Ethernet:IPv4:TCP
    Frame   4: Ethernet:IPv4:TCP
    Frame   5: Ethernet:IPv4:TCP
    Frame   6: Ethernet:IPv4:UDP:Raw
    🍺Report file stored in 'out.plist'
    
  2. export to a JSON file (with no format specified)

    $ pcapkit-cli in --output out.json --verbose
    🚨Loading file 'in.pcap'
    Frame   1: Ethernet:IPv6:IPv6_ICMP
    Frame   2: Ethernet:IPv6:IPv6_ICMP
    Frame   3: Ethernet:IPv4:TCP
    Frame   4: Ethernet:IPv4:TCP
    Frame   5: Ethernet:IPv4:TCP
    Frame   6: Ethernet:IPv4:UDP:Raw
    🍺Report file stored in 'out.json'
    
  3. export to a text tree view file (without extension autocorrect)

    $ pcapkit-cli in --output out.txt --format tree --verbose
    🚨Loading file 'in.pcap'
    Frame   1: Ethernet:IPv6:IPv6_ICMP
    Frame   2: Ethernet:IPv6:IPv6_ICMP
    Frame   3: Ethernet:IPv4:TCP
    Frame   4: Ethernet:IPv4:TCP
    Frame   5: Ethernet:IPv4:TCP
    Frame   6: Ethernet:IPv4:UDP:Raw
    🍺Report file stored in 'out.txt'
    

Help Wanted

Important

This is a copy of the discussion thread started on the GitHub. The documentation is only used as a backup reference to the original discussion thread.

As PyPCAPKit reaches its 16k lines of code and 800th commit, I figure it would be a better idea to record the project enchancement proposals here in the discussion thread. The proposals and/or notes will be documented and maintained here.

Pull requests for the existing proposals and any new ideas are highly welcomed and encouraged. Should you have any questions, please leave a note either in this thread or under the Q&A category discussions.

Wish you enjoy PyPCAPKit!!!

More Protocols, More!!!

As you may have noticed, there are some protocol-named files under the NotImplemented folders. These protocols are what I planned to implement but not yet done. Namely, grouped by each TCP/IP layer and ordered by protocol name alphabetically,

  • Link Layer: DSL, EAPOL, FDDI, ISDN, PPP

  • Internet Layer: ECN, ESP, ICMP, ICMPv6, IGMP, NDP, Shim6

  • Transport Layer: DCCP, QUIC, RSVP, SCTP

  • Application Layer: BGP, DHCP, DHCPv6, DNS, IMAP, LDAP, MQTT, NNTP, NTP, ONC/RPC, POP, RIP, RTP, SIP, SMTP, SNMP, SSH, Telnet, TLS/SSL, XMPP

Specifically, I have attempted to implement ESP several years ago, and I abandoned the implementation in the NotImplemented folder due to some design flaws within PyPCAPKit at that time. But now, the protocol should be able to implement quite smoothly.

More over, MH requires some help to implement all the message data types, you can find more information in the specific file.

Also, for the existing protocols, I am looking for a helping hand to implement the construction features, as defined in the Protocol.make method. You can find some reference from the PCAP’s Frame header class.

PCAPNG Support

As mentioned in #35, PyPCAPKit does not support parsing PCAPNG files with its builtin default engine at the moment – partly because I could not understand the file format specifications.

If you are to help with it, please refer to the implementation of PCAP format support in pcapkit.protocols.misc.pcap module.

Maybe Even Faster?

Based on my recent benchmarking, PyPCAPKit’s builtin default engine is only 4 times slower than Scapy and 10 times to DPKT. Considering the general overhead and verbose features provided by PyPCAPKit’s builtin default engine, such performance difference is acceptable.

However, there might still be a way to further accelerate the protocol implementation – merge and concatenation _read_xxxxxx methods within one single file.read(), such that we shall decrease the overall number of IO calls and reduce the duplicated struct.unpack() calls, etc. I am not yet confident about the performance improvement, but this is the most efficient way to accelerate PyPCAPKit at the moment, inspired from the implementation of Scapy and DPKT themselves.

Specifically, as the following code from pcapkit.protocols.misc.pcap.Frame.read(),

_tsus = self._read_unpack(4, lilendian=True)
_ilen = self._read_unpack(4, lilendian=True)
_olen = self._read_unpack(4, lilendian=True)

we might be able to rewrite it as

_tsus, _ilen, _olen = self._read_fields(unpack(4, lilendian=True), unpack(4, lilendian=True), unpack(4, lilendian=True))

and the PoC of _read_fields would be something like

def _read_fields(self, *fields: 'Field') -> 'tuple[Any, ...]':
    # built template
    fmt = ''.join(field.template for field in fields)
    len = sum([field.length for field in fields])

    # read from buffer & do unpack
    buf = self._file.read(fmt)
    tmp = struct.unpack(fmt, buf)

    # do post-processing based on field-specific implementations
    ret = []
    for field, val in itertools.chain(fields, tmp):
         ret.append(field.post_process(val))
    return ret

Logging Integration

As PyPCAPKit now has the pcapkit.utilities.logging.logger in place, I’m expecting to fully extend its functionality in the entire module. Ideas and contributions are welcomed to integrate the logging system into PyPCAPKit.

New Engines

Although PyPCAPKit already has support for some popular PCAP parsing libraries, I’m expecting to extend the list of supported engines furthermore. The candidate engines include:

Implementation for support of new engines would include adding corresponding handler methods and code blocks into pcapkit.foundation.extraction.Extractor (see support for Scapy, DPKT, and/or PyShark), as well as, the unified auxiliary tools located in pcapkit.toolkit.

About

PyPCAPKit is an independent open source library, using only DictDumper as its formatted output dumper.

Note

There is a project called jspcapy works on pcapkit, which is a command line tool for PCAP extraction.

Deprecated since version 0.8.0: The jspcapy project is deprecated and has been merged into the PyPCAPKit project as its CLI support.

Unlike popular PCAP file extractors, such as Scapy, dpkt, PyShark, and etc, pcapkit uses streaming strategy to read input files. That is to read frame by frame, decrease occupation on memory, as well as enhance efficiency in some way.

Module Structure

In pcapkit, all files can be described as following eight parts.

  • Interface (pcapkit.interface)

    User interface for the pcapkit library, which standardises and simplifies the usage of this library.

  • Foundation (pcapkit.foundation)

    Synthesises file I/O and protocol analysis, coordinates information exchange in all network layers, as well as provides the foundamental functions for pcapkit.

  • Protocols (pcapkit.protocols)

    Collection of all protocol family, with detailed implementation and methods.

  • Utilities (pcapkit.utilities)

    Auxiliary functions and tools for pcapkit.

  • CoreKit (pcapkit.corekit)

    Core utilities for pcapkit implementation, mainly for internal data structure and processing.

  • ToolKit (pcapkit.toolkit)

    Auxiliary tools for pcapkit to support the multiple extraction engines with a unified interface.

  • DumpKit (pcapkit.dumpkit)

    File output formatters for pcapkit.

  • Constants (pcapkit.const)

    Constant enumerations used in pcapkit for protocol family extraction and representation.

Engine Comparison

Due to the general overhead of pcapkit, its extraction procedure takes around 0.0008 seconds per packet, which is already impressive but not enough comparing to other popular extration engines availbale on the market. Thus pcapkit introduced alternative extractionengines to accelerate this procedure. By now pcapkit supports Scapy, DPKT, and PyShark.

Test Environment

Operating System

macOS Monterey

Processor Name

Intel Core i7

Processor Speed

2.6 GHz

Total Number of Cores

6

Memory

16 GB

Test Results

Engine

Performance (seconds per packet)

dpkt

0.00006832083066304525

scapy

0.0002489296595255534

pcapkit

0.0008274253209431966

pyshark

0.039607704480489093


Installation

Note

pcapkit supports Python versions since 3.6.

Simply run the following to install the current version from PyPI:

pip install pypcapkit

Or install the latest version from the gi repository:

git clone https://github.com/JarryShaw/PyPCAPKit.git
cd pypcapkit
pip install -e .
# and to update at any time
git pull

And since pcapkit supports various extraction engines, and extensive plug-in functions, you may want to install the optional ones:

# for DPKT only
pip install pypcapkit[DPKT]
# for Scapy only
pip install pypcapkit[Scapy]
# for PyShark only
pip install pypcapkit[PyShark]
# and to install all the optional packages
pip install pypcapkit[all]
# or to do this explicitly
pip install pypcapkit dpkt scapy pyshark

For CLI usage, you will need to install the optional packages:

pip install pypcapkit[cli]
# or explicitly...
pip install pypcapkit emoji

Indices and tables