Address Resolution Protocol

The Address Resolution Protocol (ARP) is a communication protocol used for discovering the link layer address, such as a MAC address, associated with a given internet layer address, typically an IPv4 address. This mapping is a critical function in the Internet protocol suite.

ARP has been implemented with many combinations of network and data link layer technologies, such as IPv4, Chaosnet, DECnet and Xerox PARC Universal Packet (PUP) using IEEE 802 standards, FDDI, X.25, Frame Relay and Asynchronous Transfer Mode (ATM).

In Internet Protocol Version 6 (IPv6) networks, the functionality of ARP is provided by the Neighbor Discovery Protocol (NDP).

Operating scope

The Address Resolution Protocol is a request-response protocol. Its messages are directly encapsulated by a link layer protocol. It is communicated within the boundaries of a single network, never routed across internetworking nodes.

Frame Structure

The Address Resolution Protocol uses a simple message format containing one address resolution request or response. The packets are carried at the data link layer of the underlying network as raw payload. In the case of Ethernet, a 0x0806 EtherType value is used to identify ARP frames.

Frame Header

The EtherType for ARP is 0x0806. This appears in the Ethernet frame header when the payload is an ARP packet and is not to be confused with PTYPE, which appears within this encapsulated ARP packet.

A typical header of ARP frame is 14 bytes

6-byte destination mac address | 6-byte source mac address | 2-byte EtherType

ARP Packet structure

The size of the ARP message depends on the link layer and network layer address sizes. The message header specifies the types of network in use at each layer as well as the size of addresses of each. The message header is completed with the operation code for request and reply . The payload of the packet consists of four addresses, the hardware and protocol address of the sender and receiver hosts.

The principal packet structure of ARP packets is shown in the following table which illustrates the case of IPv4 networks running on Ethernet. In this scenario, the packet has 48-bit fields for the sender hardware address (SHA) and target hardware address (THA), and 32-bit fields for the corresponding sender and target protocol addresses (SPA and TPA). The ARP packet size in this case is 28 bytes.

ARP protocol parameter values have been standardized and are maintained by the Internet Assigned Numbers Authority (IANA).[2]

Hardware type (HTYPE)

This field specifies the network link protocol type. Example: Ethernet is 1

Protocol type (PTYPE)

This field specifies the internetwork protocol for which the ARP request is intended. For IPv4, this has the value 0x0800. The permitted PTYPE values share a numbering space with those for EtherType

Hardware length (HLEN)

Length (in octets) of a hardware address. Ethernet address length is 6.

Protocol length (PLEN)

Length (in octets) of internetwork addresses. The internetwork protocol is specified in PTYPE. Example: IPv4 address length is 4.

Operation

Specifies the operation that the sender is performing: 1 for request, 2 for reply.

Sender hardware address (SHA)

Media address of the sender. In an ARP request this field is used to indicate the address of the host sending the request. In an ARP reply this field is used to indicate the address of the host that the request was looking for.

Sender protocol address (SPA)

Internetwork address of the sender.

Target hardware address (THA)

Media address of the intended receiver. In an ARP request this field is ignored. In an ARP reply this field is used to indicate the address of the host that originated the ARP request.

Target protocol address (TPA)

Internetwork address of the intended receiver.

Frame Examples

Run the following command to capture arp packet

sudo tcpdump -i [interface name] arp -ne -xx

The packet captured

06:55:28.198569 d4:d2:52:ad:c6:bd > 52:54:00:8d:63:62, ethertype ARP (0x0806), length 60: Request who-has 192.168.9.154 (52:54:00:8d:63:62) tell 192.168.9.142, length 46
0x0000: 5254 008d 6362 d4d2 52ad c6bd 0806 0001
0x0010: 0800 0604 0001 d4d2 52ad c6bd c0a8 098e
0x0020: 5254 008d 6362 c0a8 099a 0000 0000 0000
0x0030: 0000 0000 0000 0000 62f2 9c01
  • Length 60 is because, the minimum legal length of ethernet packet is 64 octets, including the FCS. ARP requests from local are 42 octets long, ARP requests from remote are 60 octets long. Normal Ethernet padding for packets smaller than 64 bytes (header + user data + FCS). If FCS is not displayed, the packets you observe are 60 bytes long.
06:55:28.198620 52:54:00:8d:63:62 > d4:d2:52:ad:c6:bd, ethertype ARP (0x0806), length 42: Reply 192.168.9.154 is-at 52:54:00:8d:63:62, length 28
0x0000: d4d2 52ad c6bd 5254 008d 6362 0806 0001
0x0010: 0800 0604 0002 5254 008d 6362 c0a8 099a
0x0020: d4d2 52ad c6bd c0a8 098e
  • Length 28 is hex, equal to decimal 42
  • Frame header: destination mac addr [d4d2 52ad c6bd] source mac addr [5254 008d 6362] ethertype ARP [0806] request/reply [0001]
  • ARP packet: protocol type [0800] hardware addr length [06] protocol addr length [04] operation, 1:request,2:reply [0002]

    sender hardware addr [5254 008d 6362] sender protocol addr [c0a8 099a]

    target hardware addr [d4d2 52ad c6bd] target protocol addr [c0a8 098e]

Minimum Packet Size

1

If you look more carefully, you will notice that all frames which are shorter than the minimum frame size (60 bytes without FCS) are frames which are transmitted by your machine. Received frames should be padded to 60 bytes without FCS; they contain the “Padding” field under “Ethernet II” in the Wireshark “Packet Details” window, which corresponds to those extra bytes.

At least in Linux, all transmitted frames which are shorter than 60 bytes should be automatically padded by the network driver (or even NIC hardware) before the transmission, but Wireshark does not show this, because frames are copied to the packet socket used by Wireshark before that padding is added.

Originally the minimum frame size was specified to make the CSMA/CD protocol used for the shared Ethernet medium work properly — reliable collision detection requires that the time needed to transmit a frame (which is proportional to its size together with all headers and preamble) must be greater than the signal propagation time between any two stations. Current Ethernet is in most cases not actually a shared medium (switches with full-duplex links do not perform collision detection). Technically enforcing a minimum frame size would not be required on a full-duplex link, but it is still done for compatibility reasons.

Since Gigabit Ethernet the 64-byte minimum frame size is no longer enough for collision detection when using practical cable lengths, and simply increasing the minimum frame size would lead to significant waste of bandwidth, therefore the Carrier Extension mechanism is introduced for half-duplex gigabit links (see also here for more information). Carrier extension is implemented in network hardware and not visible to software. In theory, using carrier extension makes enforcing the minimum frame size optional for half-duplex links, and with full-duplex links neither carrier extension nor minimum frame size are needed. However, the 64-byte minimum frame size is still kept, probably for compatibility with old software which could expect it.

2

The entire frame has to be at least 64 bytes. This is not just the payload, this includes the headers and the frame check sequence. The FCS takes up 4 bytes at the end. An Ethernet header consists of two 6 byte MAC addresses plus a 2 byte type field, 14 bytes in total. 64-4-14 = 46. IPv4 packets have an additional header of at least 20 bytes on top of the Ethernet header, making the minimum payload size 26 bytes. TCP and UDP add more headers on top of that.

Another thing to note is that the size of a minimum length frame on the wire is actually larger than 64 bytes - there is an 8 byte preamble/start of frame delimiter and a 12 byte interframe gap that get attached to every packet, making a 64 byte packet take up 64+8+12 = 84 bytes on the wire.

The 41 byte answer on the other question is only considering TCP and IP headers. If you send a TCP packet with 0 data bytes, it will have 40 bytes of headers; it's not possible to make a valid TCP packet smaller than this. But if you try to send this packet, it will get zero padded out to 46 bytes before the Ethernet FCS is attached.

The reason this was originally done with Ethernet was to ensure a minimum frame length on the wire so that collisions could be reliably detected by all devices over the specified maximum cable length. This is required because early incarnations of 10M Ethernet used a shared coaxial medium and connected devices had to be able to detect when two of them tried to transmit on the shared medium at the same time. Slightly less ancient 10M and 100M Ethernet networks over twisted pair that were built with hubs instead of switches also needed to be able to detect collisions. However, most modern Ethernet networks are switched and do not use a shared medium, so this is no longer strictly necessary, but it's still part of the spec for compatibility reasons. Frames shorter than 64 bytes are called runt frames, and if you see runt frames in a network that usually indicates some sort of configuration or hardware issue.

C Code Of Generating AN ARP Packet

Links

ARP(Address Resolution Protocol) Packet的更多相关文章

  1. arp:地址解析协议(Address Resolution Protocol)(来自维基百科)

    地址解析协议(Address Resolution Protocol),其基本功能为通过目标设备的IP地址,查询目标设备的MAC地址,以保证通信的顺利进行。它是IPv4中网络层必不可少的协议,不过在I ...

  2. ARP(Address Resolution Protocol)地址解析协议初识

    ARP址解析协议是根据IP地址获取物理地址的一个TCP/IP协议.它工作在OSI七层模型的中第二层——数据链路层. 使用ARP地址解析协议,可根据网络层IP数据包包头中的IP地址信息解析出目标硬件地址 ...

  3. Neighbor Discovery Protocol Address Resolution Protocol

    https://en.wikipedia.org/wiki/Address_Resolution_Protocol The Address Resolution Protocol (ARP) is a ...

  4. ARP(Adress Resolution Protocol): 地址解析协议

    地址解析协议(Address Resolution Protoclol),其基本功能为通过目标设备的IP地址,查询目标设备的MAC地址,以保证通信的顺利.它是IPV4中网络层必不可少的协议.不过在IP ...

  5. 地址解析协议ARP(Address Resolution Protocol)

    1.引言 说明: ARP的作用,解决了什么问题: 以太网中的链路层,可能会采用不同的网络技术,而且不以ip作为路由依据. 链路层以mac地址作为路由依据. ARP的功能是在32 bit的IP地址和采用 ...

  6. ARP Poisoning Attack and Mitigation Techniques ARP欺骗 中间人攻击 Man-In-The-Middle (MITM) attack 嗅探 防范 Can one MAC address have two different IP addresses within the network?

    小结: 1. ARP缓存投毒,窃听中毒者之间的通信: 2. ARP Poisoning Attack and Mitigation Techniques - Ciscohttps://www.cisc ...

  7. 防止ARP欺骗的方法!!!

    防止ARP欺骗的方法!!! 根据鄙人上网经常掉线,怀疑可能是某人使用网络剪刀手,网络执行官,局域网终结者等工具.经过搜索有关资料,有了一点点防范经验,借以参考~! 一 首先我们来了解下这类攻击工具的原 ...

  8. TCP/IP Protocol Fundamentals Explained with a Diagram

    最近准备系统学习网络相关的知识,主要学习tcp/ip, websocket 知识. 原文地址:http://www.thegeekstuff.com/2011/11/tcp-ip-fundamenta ...

  9. 应用负载均衡之LVS(二):VS_TUN和VS_DR的arp问题

    */ .hljs { display: block; overflow-x: auto; padding: 0.5em; color: #333; background: #f8f8f8; } .hl ...

  10. 透析ARP原理

    对于ARP协议, 我本来是不了解的,只是解决了两个ARP相关的P2的Bug后,也就懂了.本文将从原理的角度对ARP做一个透析. 1. 什么是ARP? ARP(Address Resolution Pr ...

随机推荐

  1. 解决Ubuntu 20.04下VS code无法使用中文输入法的问题

    技术背景 在Ubuntu 20.04下,如果从应用商城中直接下载VS code,有可能会导致无法使用中文输入法的问题,那么就只能从其他地方写了中文再复制过来,非常的麻烦.从一些文章中收集到的信息来看, ...

  2. APB Slave Design

    APB Slave Design module apb_slave #( REG1_ADDR = 8'h00, REG2_ADDR = 8'h04, REG3_ADDR = 8'h08 ) ( // ...

  3. 【ThreadX-NetX】Azure RTOS NetX概述

    Azure RTOS NetX是工业级TCP / IP IPv4嵌入式网络堆栈,专门针对深度嵌入式,实时和IoT应用程序而设计.Azure RTOS NetX是Microsoft最初的IPv4网络堆栈 ...

  4. 【Spring 5核心原理】1设计模式

    1.1开闭原则 开闭原则(open-closed principle,OCP)是指一个软件实体(如类,模块和函数)应该对扩展开放,对修改关闭.所谓的开闭,也正是对扩展和修改两个行为的一个原则. 强调用 ...

  5. Cloudquery的学习安装与使用

    Cloudquery的学习安装与使用 下载 官方下载地址: https://www.cloudquery.club/download https://pan.baidu.com/s/1a7XOrnMU ...

  6. [转帖]expect 实现 ssh免密登录的脚本

    expect 实现 ssh免密登录的脚本 #!/bin/bash #Author:cosann #Version:0.2 #date:2022/7/27 #description:批量部署SSH免密登 ...

  7. [转帖]gcc与makefile常用操作(绝对常用,也绝对够用)

    makefile与gcc常用操作 一.温故知新 1.可执行程序的生成过程 2.gcc的常用操作 二.make操作 三.编写Makefile文件时常用操作 注意:在Makefile文件中 空格和缩进是完 ...

  8. [转帖]Native Memory Tracking 详解(4):使用 NMT 协助排查内存问题案例

    https://www.modb.pro/db/557714 从前面几篇文章,我们了解了 NMT 的基础知识以及 NMT 追踪区域分析的相关内容,本篇文章将为大家介绍一下使用 NMT 协助排查内存问题 ...

  9. [1036]kvm虚拟机访问时提示no route to host分析

    环境 宿主机: IP: 10.110.136.43 版本:Kylin Linux Advanced Server release V10 (Sword) KVM vm: IP: 10.110.136. ...

  10. 一种轻量分表方案-MyBatis拦截器分表实践

    背景 部门内有一些亿级别核心业务表增速非常快,增量日均100W,但线上业务只依赖近一周的数据.随着数据量的迅速增长,慢SQL频发,数据库性能下降,系统稳定性受到严重影响.本篇文章,将分享如何使用MyB ...