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: pcapkit.protocols.protocol.Protocol

Abstract base class for internet layer protocol family.

__layer__ = '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. The values should be a tuple representing the module name and class name.

Code

Module

Class

0

pcapkit.protocols.internet.hopopt

HOPOPT

4

pcapkit.protocols.internet.ipv4

IPv4

6

pcapkit.protocols.transport.tcp

TCP

17

pcapkit.protocols.transport.udp

UDP

41

pcapkit.protocols.internet.ipv6

IPv6

43

pcapkit.protocols.internet.ipv6_route

IPv6_Route

44

pcapkit.protocols.internet.ipv6_frag

IPv6_Frag

51

pcapkit.protocols.internet.ah

AH

60

pcapkit.protocols.internet.ipv6_opts

IPv6_Opts

111

pcapkit.protocols.internet.ipx

IPX

135

pcapkit.protocols.internet.mh

MH

139

pcapkit.protocols.internet.hip

HIP

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

Decode next layer extractor.

Parameters
  • dict (dict) – info buffer

  • proto (int) – next layer protocol index

  • length (int) – valid (non-padding) length

Keyword Arguments
Returns

current protocol with next layer extracted

Return type

dict

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

Import next layer extractor.

This method currently supports following protocols as registered in TransType:

proto

Class

0

HOPOPT

4

IPv4

6

TCP

17

UDP

41

IPv6

43

IPv6_Route

44

IPv6_Frag

51

AH

60

IPv6_Opts

111

IPX

135

MH

139

HIP

Parameters
  • proto (int) – next layer protocol index

  • length (int) – valid (non-padding) length

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

  • extension (bool) – if is extension header

Returns

instance of next layer

Return type

pcapkit.protocols.protocol.Protocol

_read_protos(size)[source]

Read next layer protocol type.

Parameters

size (int) – buffer size

Returns

next layer’s protocol enumeration

Return type

pcapkit.const.reg.transtype.TransType

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

Register a new protocol class.

Parameters
  • code (int) – protocol code as in TransType

  • module (str) – module name

  • class (str) – class name

Notes

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

property layer

Protocol layer.

Return type

Literal[‘Internet’]