Contents Menu Expand Light mode Dark mode Auto light/dark, in light mode Auto light/dark, in dark mode Skip to content
PyPCAPKit
PyPCAPKit

API Reference

  • Module Documentation
    • User Interface
      • Core Interface
      • Auxiliary Interface
      • Registry Helpers
    • Library Foundation
      • File Extractor
      • Engine Support
        • Base Engine
        • Built-in Engines
        • 3rd-Party Engines
      • Packets Reassembly
        • Reassembly Base Class
        • IP Datagram Reassembly
          • IP Reassembly Base Class
          • IPv4 Datagram Reassembly
          • IPv6 Datagram Reassembly
        • TCP Datagram Reassembly
        • DTLS Handshake-Message Reassembly
      • Reassembled Payload Analysis
        • IP Datagram Analysis
        • TCP Datagram Analysis
        • DTLS Handshake-Message Analysis
      • Flow Tracing
        • Flow Tracing Base Class
        • Follow TCP Stream
      • Registry Management
    • Protocol Family
      • Root Protocol
      • Link Layer
        • Link Layer Base Protocol
        • Ethernet Protocol
        • ARP - Address Resolution Protocol
        • InARP - Inverse Address Resolution Protocol
        • FRAD - Frame Relay Access Device
        • GRE - Generic Routing Encapsulation
        • IEEE 802.11 - Wireless LAN MAC Header
        • L2TP - Layer Two Tunnelling Protocol
        • L2TPv2 - Layer Two Tunnelling Protocol Version 2
        • LinuxSLL - Linux “Cooked” Capture Encapsulation Family
        • Linux “Cooked” Capture Encapsulation
        • Linux “Cooked” Capture Encapsulation v2
        • BSD Loopback Encapsulation
        • Netlink - Linux Netlink Socket Framing
        • Radiotap - IEEE 802.11 Radiotap Header
        • VLAN - 802.1Q/802.1ad VLAN Tag Types
        • C_Tag - 802.1Q Customer VLAN Tag Type
        • S_Tag - 802.1ad Service VLAN Tag Type
      • Internet Layer
        • Internet Layer Base Protocol
        • IP - Internet Protocol
        • IPv4 - Internet Protocol Version 4
        • IPv6 - Internet Protocol Version 6
        • IPv6-Ext - IPv6 Extension Header
        • IPv6-Frag - Fragment Header for IPv6
        • IPv6-Opts - Destination Options for IPv6
        • IPv6-Route - Routing Header for IPv6
        • HOPOPT - IPv6 Hop-by-Hop Options
        • IPv6 Options - Shared Option Helpers
        • MH - Mobility Header
        • IPsec - Internet Protocol Security
        • AH - Authentication Header
        • ESP - Encapsulating Security Payload
        • ICMP - Internet Control Message Protocol
        • ICMPv4 - Internet Control Message Protocol
        • ICMPv6 - Internet Control Message Protocol for IPv6
        • HIP - Host Identity Protocol
        • IGMP - Internet Group Management Protocol
        • IGMPv1 - Internet Group Management Protocol Version 1
        • IGMPv2 - Internet Group Management Protocol Version 2
        • IGMPv3 - Internet Group Management Protocol Version 3
        • IPX - Internetwork Packet Exchange
      • Transport Layer
        • Transport Layer Base Protocol
        • DCCP - Datagram Congestion Control Protocol
        • SCTP - Stream Control Transmission Protocol
        • TCP - Transmission Control Protocol
        • UDP - User Datagram Protocol
      • Application Layer
        • Application Layer Base Protocol
        • HTTP - Hypertext Transfer Protocol
        • HTTP/1.* - Hypertext Transfer Protocol
        • HTTP/2 - Hypertext Transfer Protocol
        • FTP - File Transfer Protocol
        • FTP_DATA - FTP Data Channel
        • NGAP - NG Application Protocol
        • OSPF - Open Shortest Path First
        • RARP - Reverse Address Resolution Protocol
        • DRARP - Dynamic Reverse Address Resolution Protocol
        • SSL - Secure Sockets Layer
        • SSLv2 - Secure Sockets Layer Version 2
        • TLS/SSL - Transport Layer Security
        • SSLv3 - Secure Sockets Layer Version 3
        • DTLS - Datagram Transport Layer Security
      • Auxiliary Protocols
        • PCAP File Headers
        • PCAP-NG File Format
        • Raw Packet Data
        • No-Payload Packet
        • Checksums
    • Module Utilities
      • User Defined Exceptions
      • User Defined Warnings
      • Logging System
      • Configuration
      • Character Set Detection
      • Timestamp Conversion
      • Pickle Reductions
      • Shared Context Variables
      • Lazy Imports
      • Abstract Classes
    • Core Utilities
      • Protocol Fields
        • Base Fields
        • Numerical Fields
        • Text Fields
        • IP Address Fields
        • Container Fields
        • Miscellaneous Fields
      • Checksums
        • Internet Checksum
      • Parsing Context
      • Decorator Functions
      • Enumeration Base
      • Info Class
      • I/O Objects
      • Module Descriptor
      • Multi-Mapping Dictionary
      • Deferred Packet
      • Protocol Chain
      • Schema Helpers
        • Byte-Order Helpers
        • IP Address Conversion
        • Jumbo Payload Lookup
        • Padding Arithmetic
        • Short-Read Replay
      • Sentinel Objects
      • Version Info
    • Compatibility Tools
      • Built-in Support
      • 3rd-Party Support
    • Dump Utilities
      • Common Utilities
      • PCAP Dumper
      • Null Dumper
    • Constant Enumerations
      • Protocol Type Registry Constant Enumerations
      • ARP Constant Enumerations
      • IEEE802_11 Constant Enumerations
      • L2TP Constant Enumerations
      • Linux-Specific Constant Enumerations
      • Radiotap Constant Enumerations
      • VLAN Constant Enumerations
      • ESP Constant Enumerations
      • HIP Constant Enumerations
      • ICMPv4 Constant Enumerations
      • ICMPv6 Constant Enumerations
      • IGMP Constant Enumerations
      • IPv4 Constant Enumerations
      • IPv6 Constant Enumerations
      • IPX Constant Enumerations
      • MH Constant Enumerations
      • DCCP Constant Enumerations
      • SCTP Constant Enumerations
      • TCP Constant Enumerations
      • FTP Constant Enumerations
      • HTTP Constant Enumerations
      • NGAP Constant Enumerations
      • OSPF Constant Enumerations
      • SSLv2 Constant Enumerations
      • SSL Constant Enumerations
      • PCAPNG Constant Enumerations
    • Vendor Crawlers
      • Base Crawler
      • Protocol Type Registry Vendor Crawlers
      • ARP Vendor Crawlers
      • IEEE802_11 Vendor Crawlers
      • L2TP Vendor Crawlers
      • Linux-Specific Vendor Crawlers
      • Radiotap Vendor Crawlers
      • VLAN Vendor Crawlers
      • ESP Vendor Crawlers
      • HIP Vendor Crawler
      • ICMPv4 Vendor Crawlers
      • ICMPv6 Vendor Crawlers
      • IGMP Vendor Crawlers
      • IPv4 Vendor Crawlers
      • IPv6 Vendor Crawlers
      • IPX Vendor Crawlers
      • MH Vendor Crawlers
      • DCCP Vendor Crawlers
      • SCTP Vendor Crawlers
      • TCP Vendor Crawlers
      • FTP Vendor Crawlers
      • HTTP Vendor Crawler
      • NGAP Vendor Crawlers
      • OSPF Vendor Crawlers
      • SSLv2 Vendor Crawlers
      • SSL Vendor Crawlers
      • PCAPNG Vendor Crawlers

Guides & Changelog

  • Engine Comparison
  • Customisation & Extensions
  • How to …
  • Glossary
  • Changelog
    • 1.6.1 – 2026-11-05
    • 1.6.0 – 2026-11-05
    • 1.5.1 – 2026-10-30
    • 1.5.0 – 2026-10-29
    • 1.4.1 – 2026-08-22
    • 1.4.0 – 2026-08-21
    • 1.3.5 – 2024-11-16
    • 1.3.4 – 2024-11-14
    • 1.3.3 – 2024-11-03
    • 1.3.1 – 2023-12-21
    • 1.3.0 – 2023-10-04
    • 1.2.2 – 2023-09-14
    • 1.2.1 – 2023-08-27
    • 1.2.0 – 2023-08-26
    • 1.1.1 – 2023-08-15
    • 1.1.0 – 2023-07-09
    • 1.0.3 – 2023-06-29
    • 1.0.2 – 2023-06-05
    • 1.0.1 – 2023-05-14
    • 1.0.0 – 2023-05-09
    • 0.16.3 – 2022-10-31
    • 0.16.2 – 2022-08-03
    • 0.16.1 – 2022-06-07
    • 0.16.0 – 2022-05-31
    • 0.15.5 – 2020-10-11
    • 0.15.4 – 2020-08-28
    • 0.15.3 – 2020-08-17
    • 0.15.2 – 2020-06-27
    • 0.15.1 – 2020-06-18
    • 0.15.0 – 2020-06-07
    • 0.14.5 – 2019-10-24
    • 0.14.4 – 2019-09-01
    • 0.14.3 – 2019-08-08
    • 0.14.2 – 2019-03-28
    • 0.14.1 – 2019-03-07
    • 0.14.0 – 2019-03-02
    • 0.13.3 – 2019-02-26
    • 0.13.2 – 2019-01-24
    • 0.13.1 – 2019-01-23
    • 0.13.0 – 2018-12-08

Contributing

  • Testing
  • House Conventions
    • Minting an Unrecognised Value
    • Naming a Sentinel
    • The Registry Protocol
    • Extension-Header Base Classes
    • Protocol Family Grouping
    • Protocol Member Order
    • Protocol Layer Placement
    • Running the Repository
    • Writing the Documentation
    • Testing a Change
    • Choosing Between utilities and corekit
    • Reassembly Integration
    • Const-Vendor Pairing
  • Release Process
  • GitHub Actions Workflows
  • Maintenance Workflow
  • Help Wanted
Back to top
View this page
Edit this page

Link Layer Base Protocol¶

pcapkit.protocols.link.link contains Link, which is a base class for link layer protocols, e.g. ARP/InARP, Ethernet, L2TP and VLAN.

class pcapkit.protocols.link.link.Link[_PT: Data, _ST: Schema](file=None, length=None, **kwargs)[source]¶

Bases: ProtocolBase[_PT, _ST], Generic[_PT, _ST]

Abstract base class for link layer protocol family.

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

Index

Protocol

Address_Resolution_Protocol

pcapkit.protocols.link.arp.protocol.ARP

Reverse_Address_Resolution_Protocol

pcapkit.protocols.application.rarp.protocol.RARP

Customer_VLAN_Tag_Type

pcapkit.protocols.link.c_tag.protocol.C_Tag

IEEE_Std_802_1Q_Service_VLAN_tag_identifier

pcapkit.protocols.link.s_tag.protocol.S_Tag

Internet_Protocol_version_4

pcapkit.protocols.internet.ipv4.protocol.IPv4

Internet_Protocol_version_6

pcapkit.protocols.internet.ipv6.protocol.IPv6

0x8137

pcapkit.protocols.internet.ipx.protocol.IPX

__layer__: Literal['Link'] = 'Link'¶

Layer of protocol.

__proto__: DefaultDict[int | EtherType, ModuleDescriptor[ProtocolBase] | Type[ProtocolBase]]¶

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

__proto_key__: ClassVar[tuple[Type[EnumRegistry], bool]]¶

What __proto__ is keyed by – the enum a key must be a member of, and whether a bare int is a valid key too. Declared by the class owning the registry and read by register_protocol_code(), so a code= key is checked as register_ethertype() checks its own. A class keeping its own registry, such as Loopback, declares its own pairing or none (#2268).

property layer: Literal['Link']¶

Protocol layer.

classmethod register(code, protocol)[source]¶

Register a new protocol class.

Notes

The fully qualified class name of the new protocol class should be {protocol.module}.{protocol.name}.

Parameters:
  • code (EtherType) – protocol code as in EtherType

  • protocol (ModuleDescriptor[ProtocolBase] | Type[ProtocolBase]) – module descriptor or a ProtocolBase subclass

Raises:

pcapkit.utilities.exceptions.RegistryError – If protocol is not a class, or not a ProtocolBase subclass.

Warns:

pcapkit.utilities.warnings.RegistryWarning – If this EtherType is already registered, naming the displaced entry and its replacement so a caller can tell what was lost. Fires only when the incumbent differs from the replacement – see Protocol.register for the guard this shares with register_protocol, and for the shipped descriptor that a restore puts back (#1504).

Changed in version 1.3.0: Takes the protocol as one protocol argument, a ModuleDescriptor or a ProtocolBase subclass, in place of the module and class_ names.

classmethod from_data(data, **kwargs)[source]¶

Create protocol instance from data.

Parameters:
  • data (_PT | dict[str, Any]) – Protocol data.

  • **kwargs (Any) – Construction keywords, as for Protocol.from_data.

Return type:

Self

Returns:

Protocol instance, cut back to what was captured when the header it was parsed from was cut short (#1458).

__post_init__(file=None, length=None, **kwargs)[source]¶

Post initialisation hook.

Parameters:
  • file (IO[bytes] | bytes | None) – Source packet stream.

  • length (int | None) – Length of packet data.

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

Return type:

None

Notes

A header the data ends inside keeps that in its info, so that from_data() rebuilds only what was captured (#1458).

Next
Ethernet Protocol
Previous
Link Layer
Copyright © 2017-2026, Jarry Shaw
Made with Sphinx and @pradyunsg's Furo