Ethernet Protocol

pcapkit.protocols.link.ethernet contains Ethernet only, which implements extractor for Ethernet Protocol *, whose structure is described as below:

Octets

Bits

Name

Description

0

0

eth.dst

Destination MAC Address

1

8

eth.src

Source MAC Address

2

16

eth.type

Protocol (Internet Layer)


class pcapkit.protocols.link.ethernet.Ethernet(file=None, length=None, **kwargs)[source]

Bases: pcapkit.protocols.link.link.Link

This class implements Ethernet Protocol.

classmethod __index__()[source]

Numeral registry index of the protocol.

Raises

UnsupportedCall – This protocol has no registry entry.

__length_hint__()[source]

Return an estimated length for the object.

Return type

Literal[14]

_read_mac_addr()[source]

Read MAC address.

Returns

Colon (:) seperated hex encoded MAC address.

Return type

str

make(**kwargs)[source]

Make (construct) packet data.

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Returns

Constructed packet data.

Return type

bytes

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

Read Ethernet Protocol [RFC 7042].

Parameters

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

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Returns

Parsed packet data.

Return type

DataType_Ethernet

property dst

Destination mac address.

Return type

str

property length

Header length of current protocol.

Return type

Literal[14]

property name

Name of current protocol.

Return type

Literal[‘Ethernet Protocol’]

property protocol

Name of next layer protocol.

Return type

pcapkit.const.reg.ethertype.EtherType

property src

Source mac address.

Return type

str

Data Structure

Important

Following classes are only for documentation purpose. They do NOT exist in the pcapkit module.

class pcapkit.protocols.link.ethernet.DataType_Ethernet
Bases

TypedDict

Ethernet header.

dst: str

destination MAC address

src: str

source MAC address

type: pcapkit.const.reg.ethertype.EtherType

protocol (Internet layer)


*

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