ARP/InARP - (Inverse) Address Resolution Protocol#

pcapkit.protocols.link.arp contains ARP only, which implements extractor for (Inverse) Address Resolution Protocol (ARP/InARP) [*], whose structure is described as below:

Octets

Bits

Name

Description

0

0

arp.htype

Hardware Type

2

16

arp.ptype

Protocol Type

4

32

arp.hlen

Hardware Address Length

5

40

arp.plen

Protocol Address Length

6

48

arp.oper

Operation

8

64

arp.sha

Sender Hardware Address

14

112

arp.spa

Sender Protocol Address

18

144

arp.tha

Target Hardware Address

24

192

arp.tpa

Target Protocol Address

class pcapkit.protocols.link.arp.ARP(file=None, length=None, **kwargs)[source]#

Bases: Link[ARP, ARP]

This class implements all protocols in ARP family.

property name: Literal['Dynamic Reverse Address Resolution Protocol', 'Inverse Address Resolution Protocol', 'Reverse Address Resolution Protocol', 'Address Resolution Protocol']#

Name of current protocol.

property alias: Literal['ARP', 'InARP', 'RARP', 'DRARP']#

Acronym of corresponding protocol.

property length: int#

Header length of current protocol.

property src: Address#

Sender hardware & protocol address.

property dst: Address#

Target hardware & protocol address.

property type: Type#

Hardware & protocol type.

classmethod id()[source]#

Index ID of the protocol.

Return type:

tuple[Literal['ARP']]

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

Read Address Resolution Protocol.

Data structure of ARP Request header [RFC 826]:

 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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|          Hdr Type             |         Proto Type            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|    Hdr Len    |   Proto Len   |          Operation            |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\                       Sender Hdr Addr                         \
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\                      Sender Proto Addr                        \
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\                       Target Hdr Addr                         \
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
\                      Target Proto Addr                        \
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Parameters:
  • length (Optional[int]) – Length of packet data.

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

Return type:

ARP

Returns:

Parsed packet data.

make(*, htype=Hardware.Ethernet, htype_default=None, htype_namespace=None, htype_reversed=False, ptype=EtherType.Internet_Protocol_version_4, ptype_default=None, ptype_namespace=None, ptype_reversed=False, hlen=6, plen=4, oper=Operation.REQUEST, oper_default=None, oper_namespace=None, oper_reversed=False, sha='00:00:00:00:00:00', spa='0.0.0.0', tha='00:00:00:00:00:00', tpa='0.0.0.0', payload=b'', **kwargs)[source]#

Make (construct) packet data.

Parameters:
Return type:

ARP

Returns:

Constructed packet data.

classmethod _make_data(data)[source]#

Create key-value pairs from data for protocol construction.

Parameters:

data (ARP) – protocol data

Return type:

dict[str, Any]

Returns:

Key-value pairs for protocol construction.

classmethod __index__()[source]#

Numeral registry index of the protocol.

Return type:

EtherType

Returns:

Numeral registry index of the protocol in IANA.

class pcapkit.protocols.link.arp.InARP(file=None, length=None, **kwargs)[source]#

Bases: ARP

This class implements Inverse Address Resolution Protocol.

classmethod id()[source]#

Index ID of the protocol.

Return type:

tuple[Literal['InARP']]

Header Schemas#

class pcapkit.protocols.schema.link.arp.ARP(dict_=None, **kwargs)[source]#

Bases: Schema

Header schema for ARP packet.

Data Models#

class pcapkit.protocols.data.link.arp.ARP(*args: VT, **kwargs: VT)[source]#

Bases: Protocol

Data model for ARP packet.

htype: Hardware#

Hardware type.

ptype: EtherType#

Protocol type.

hlen: int#

Hardware address length.

plen: int#

Protocol address length.

oper: Operation#

Operation code.

sha: str#

Sender hardware address.

spa: str | IPv4Address | IPv6Address#

Sender protocol address.

tha: str#

Target hardware address.

tpa: str | IPv4Address | IPv6Address#

Target protocol address.

len: int#

Header length.

class pcapkit.protocols.data.link.arp.Address(*args: VT, **kwargs: VT)[source]#

Bases: Data

Data model for ARP addresses.

hardware: str#

Hardware address.

protocol: str | IPv4Address | IPv6Address#

Protocol address.

class pcapkit.protocols.data.link.arp.Type(*args: VT, **kwargs: VT)[source]#

Bases: Data

Data model for ARP type.

hardware: Hardware#

Hardware type.

protocol: EtherType | str#

Protocol type.

Footnotes