Wiki DE Start in the browser

Wiki › Protocols

ARP

How a device finds the MAC address for an IP address in its own network – with a broadcast request, a reply and a cache.

Layer
zwischen 2 und 3
Standard
RFC 826, RFC 5227
See an example
See demo

What for

A frame in the local network needs a destination MAC address, but a program only knows the IP address. The Address Resolution Protocol (ARP) links the two: “Who has 192.168.1.11? Tell 192.168.1.10.”

Sequence

  1. PC 1 wants to send to 192.168.1.11 and looks into its ARP cache. Empty.
  2. It sends an ARP request as a broadcast (ff:ff:ff:ff:ff:ff). The switch distributes it to all ports.
  3. Only PC 2 recognises its address and replies as unicast with its MAC.
  4. PC 1 stores the mapping in the cache and now sends the actual packet.
ARP request as broadcast, reply as unicast, then the pingARP request as broadcast, reply as unicast, then the ping
Slow motion ARP request as broadcast, reply as unicast, then the ping

If the destination is in another network, the PC does not ask for the destination but for the MAC of its default gateway (How routing works).

FieldRequestReply
Operation1 (request)2 (reply)
Sender MAC / IPPC 1PC 2
Target MAC00:00:00:00:00:00 (unknown)PC 1
Target IP192.168.1.11192.168.1.10

The EtherType of ARP is 0x0806.

The whole structure according to RFC 826, with the values of an ARP request from the simulation. The message is only 28 bytes long, so Ethernet pads it to 46 bytes.

ARPMessage · RFC 826
0481216202428
Hardware type16 bits1
Protocol type16 bits0x0800
HW length8 bits6
Protocol length8 bits4
Operation16 bits1
Sender MAC48 bits02:00:00:00:02:00
Sender MACcontinued
Sender IP32 bits192.168.1.10
Sender IPcontinued
Target MAC48 bits00:00:00:00:00:00
Target MACcontinued
Target IP32 bits192.168.1.11
Each row has 32 bits (4 bytes), bit 0 on the left, as the RFCs draw their headers. Dashed: variable or optional. Point at a field for an explanation.
FieldLengthExample valueMeaning
Hardware type16 bits (2 bytes)11 = Ethernet.
Protocol type16 bits (2 bytes)0x0800Protocol address being resolved, 0x0800 = IPv4.
HW length8 bits6Length of a MAC address: 6.
Protocol length8 bits4Length of an IPv4 address: 4.
Operation16 bits (2 bytes)11 = request (who has …?), 2 = reply.
Sender MAC48 bits (6 bytes)02:00:00:00:02:00MAC address of the sender.
Sender IP32 bits (4 bytes)192.168.1.10Its IPv4 address.
Target MAC48 bits (6 bytes)00:00:00:00:00:00MAC address being looked for; still 00:00:00:00:00:00 in the request.
Target IP32 bits (4 bytes)192.168.1.11The IPv4 address whose MAC address is wanted.
Values: Real frame from the demo “ARP and ping in the LAN” (no. 1, 64 bytes), exactly as the packet list in leyoNET shows it.

Special forms

  • Gratuitous ARP: a device announces its own address, e.g. after starting or when roaming on Wi-Fi. If someone answers, the address is assigned twice.
  • Proxy ARP: a router answers on behalf of an address that lies behind it, e.g. with static NAT.

Try it in leyoNET

C:\> arp -a
C:\> ping 192.168.1.11
C:\> arp -a
C:\> arp -d

In the packet list with the filter arp, request and reply appear; the detail view shows all fields and their bytes.

See an example

  • ARP and ping in the LAN

    Three computers on a switch, all in 192.168.1.0/24.

    PC 1 asks for PC 2's MAC with an ARP broadcast, then four ICMP echoes follow. The switch learns its MAC table.

    Watch live Project file

“Watch live” opens the network in leyoNET, the simulation runs in a loop. In the app you find it under File → Demo networks, with a step-by-step tour.

Practise

  • ★☆☆☆☆ Capture packets · 2 goals · Worksheet (German)
  • ★★★★☆ Protocol analysis – Task 3: ARP, DNS and HTTP · 7 goals · Worksheet (German)
  • ★★★☆☆ UE05 VLAN theory check: who receives the broadcast? · 3 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

What leyoNET simplifies

ProtocolLayerSimplification in the simulation
ARP, gratuitous ARP, proxy ARP2none

Standards

  • RFC 826 – An Ethernet Address Resolution Protocol
  • RFC 5227 – IPv4 Address Conflict Detection

Read on

Found a mistake or have an idea? Source of this page on GitHub.