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: pcapkit.protocols.link.link.Link

This class implements all protocols in ARP family.

  • Address Resolution Protocol (ARP) [RFC 826]

  • Reverse Address Resolution Protocol (RARP) [RFC 903]

  • Dynamic Reverse Address Resolution Protocol (DRARP) [RFC 1931]

  • Inverse Address Resolution Protocol (InARP) [RFC 2390]

_acnm: Literal['ARP', 'InARP', 'RARP', 'DRARP']

Acronym of corresponding protocol.

The value is based on operation type (oper).

_name: Literal['Dynamic Reverse Address Resolution Protocol', 'Inverse Address Resolution Protocol', 'Reverse Address Resolution Protocol', 'Address Resolution Protocol']

Name of current protocol.

The value is based on operation type (oper).

classmethod __index__()[source]

Numeral registry index of the protocol.

Returns

Numeral registry index of the protocol in IANA.

Return type

pcapkit.const.reg.ethertype.EtherType

__length_hint__()[source]

Return an estimated length for the object.

Return type

Literal[28]

_read_addr_resolve(length, htype)[source]

Resolve headware address according to protocol.

Parameters
  • length (int) – Hardware address length.

  • htype (int) – Hardware type.

Returns

Hardware address. If htype is 1, i.e. MAC address, returns : seperated hex encoded MAC address.

Return type

str

_read_proto_resolve(length, ptype)[source]

Resolve protocol address according to protocol.

Positional arguments:

length (int): Protocol address length. ptype (int): Protocol type.

Returns

Protocol address. If ptype is 0x0800, i.e. IPv4 adddress, returns an IPv4Address object; if ptype is 0x86dd, i.e. IPv6 address, returns an IPv6Address object; otherwise, returns a raw str representing the protocol address.

Return type

Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str]

classmethod id()[source]

Index ID of the protocol.

Returns

Index ID of the protocol.

Return type

Tuple[Literal[‘ARP’], Literal[‘InARP’]]

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 Address Resolution Protocol [RFC 826].

Parameters

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

Keyword Arguments

**kwargs – Arbitrary keyword arguments.

Returns

Parsed packet data.

Return type

DataType_ARP

property alias

Acronym of corresponding protocol.

Return type

Literal[‘ARP’, ‘InARP’, ‘RARP’, ‘DRARP’]

property dst

Target hardware & protocol address.

Return type

Tuple[str, Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str]]

property length

Header length of current protocol.

Return type

int

property name

Name of current protocol.

Return type

Literal[‘Dynamic Reverse Address Resolution Protocol’, ‘Inverse Address Resolution Protocol’, ‘Reverse Address Resolution Protocol’, ‘Address Resolution Protocol’]

property src

Sender hardware & protocol address.

Return type

Tuple[str, Union[ipaddress.IPv4Address, ipaddress.IPv6Address, str]]

property type

Hardware & protocol type.

Return type

Tuple[pcapkit.const.arp.hardware.Hardware, pcapkit.const.reg.ethertype.EtherType]

Data Structure

Important

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

class pcapkit.protocols.link.arp.DataType_ARP
Bases

TypedDict

ARP header [RFC 826].

htype: pcapkit.const.arp.Headware

hardware type

ptype: Union[pcapkit.const.reg.ethertype.EtherType, str]

protocol type

hlen: int

headware address length

plen: int

protocol address length

oper: pcapkit.const.arp.operation.Operation

operation

sha: str

sender hardware address


*

http://en.wikipedia.org/wiki/Address_Resolution_Protocol