ARP - Address Resolution Protocol
In questa pagina 6
The problem
An IP datagram travels inside a frame, and to send the frame on the physical link the MAC address of the next node is needed, because the link layer does not understand IP addresses. The sender knows the destination IP and the IP of the next router (from its routing table); the MAC is obtained with ARP. (Names are translated to IPs by DNS: DNS - Domain Name SystemDNS translates names such as www.amazon.com into IP addresses; it is a distributed hierarchical database (an inverted tree of up to 128 levels, with 13 root servers and domains registered through ICANN-accredited registrars), each ISP has a local DNS whose address the host gets from DHCP, the host asks it (usually over UDP) and it queries root, top-level and organisation servers, every server caches what it learns marking answers as non-authoritative until the TTL expires, records are (name, type, value, class, TTL), with NAT the DNS must return the public address, and there are four types of attack including cache poisoning.DNS - Domain Name System →.)
Definition. ARP is an auxiliary network-layer protocol that, given the IP address of a node on the same local network, finds its MAC address, using the broadcast capability of the underlying link.
Who to ask: destination or router?
The sender computes destination IP AND own mask and compares it with its own network address (Network Layer and IPv4 AddressingThe network layer delivers datagrams host to host through routers (encapsulation, routing, forwarding); an IPv4 address is 32 bits split into a network prefix and a host suffix, and modern classless addressing (CIDR) gives a block of 2^(32-n) addresses from a.b.c.d/n, with network and broadcast addresses computed through the netmask.Network Layer and IPv4 Addressing →). Alice : (a) destination gives the same network, direct forwarding, ARP asks for the MAC of ; (b) destination gives , indirect forwarding: the frame goes to the default router (e.g. ) and ARP asks for the MAC of the router, not of , which would never answer a broadcast of this network (Forwarding and Routing TablesForwarding moves each packet one hop at a time toward its destination; it is direct when the destination is on a local network (ARP gives its MAC) and indirect otherwise (the packet goes to the next hop or default gateway given by the routing table). With netmasks, delivery is direct on interface x if the destination AND the mask equals the interface address AND the mask; otherwise the table is scanned from the longest mask (longest prefix match) and the default route 0.0.0.0/0 always matches; route aggregation shortens tables.Forwarding and Routing Tables →). The IP destination inside the datagram stays .
Operation
Each host has an ARP table (cache) of recently learned (IP, MAC) pairs, consulted before sending; if the pair is missing:
- ARP request (broadcast). Contains sender MAC and IP and the target IP; the target MAC field is zero. The frame destination is
FF:FF:FF:FF:FF:FF. - ARP reply (unicast). Every host receives the request, but only the node whose IP matches answers, with its IP and MAC, directly to the requester.
- Cache update. The requester stores the pair and sends the frame; the target may also learn the requester's pair.
| field | request | reply |
|---|---|---|
| frame destination MAC | FF:FF:FF:FF:FF:FF |
requester's MAC |
| frame source MAC | requester | target |
| sender IP and MAC (in message) | requester's | target's |
| target IP and MAC (in message) | wanted IP, MAC | requester's |
Example. Alice (, MAC B2:34:55:10:22:10) wants Bob (, MAC A4:6E:F4:59:83:AB, unknown). Request: frame destination FF:FF:FF:FF:FF:FF, source B2:34:55:10:22:10; message sender (, B2:...:10), target (, 00:00:00:00:00:00). Reply: frame destination B2:34:55:10:22:10, source A4:6E:F4:59:83:AB; message sender (, A4:...:AB), target (Alice's pair). Alice stores A4:6E:F4:59:83:AB.
Packet format
| field | length | meaning |
|---|---|---|
| Hardware Type | 16 bit | link technology: 0x0001 Ethernet |
| Protocol Type | 16 bit | IPv4 0x0800 |
| HLEN | 8 bit | MAC length: 6 bytes |
| PLEN | 8 bit | IP length: 4 bytes |
| Operation | 16 bit | 1 ARP request, 2 ARP reply, 3 RARP request, 4 RARP reply |
| sender hardware address | HLEN bytes | sender MAC |
| sender protocol address | PLEN bytes | sender IP |
| target hardware address | HLEN bytes | all 0 in a request |
| target protocol address | PLEN bytes | target IP |
For Ethernet and IPv4 the packet is bytes; since the minimum Ethernet payload is 46 bytes, bytes of padding are added.
ARP over several hops: always the next hop
ARP never resolves the final destination, only the next node on the current link. Alice sends through routers R1 and R2 to Bob: Alice looks up the next hop in her routing table (R1), uses ARP to get R1's MAC, builds the frame; R1 decapsulates, finds the next hop (R2) in its table, uses ARP to get R2's MAC and re-encapsulates; and so on. Addresses along the path:
| hop | MAC dest | MAC source | IP dest | IP source |
|---|---|---|---|---|
| Alice to R1 | ||||
| R1 to R2 | ||||
| R2 to Bob |
IP addresses stay the same end to end; MAC addresses are rewritten at every hop.
Broadcast domains and proxy ARP
Each IP subnet is a separate broadcast domain, and an ARP message cannot leave the sender's subnet. Proxy ARP, implemented in the router joining the subnets, intercepts ARP requests for addresses of other subnets and answers with its own MAC, then forwards the frames carrying its MAC to the right subnet. It allows dividing a network into subnets without configuring routing tables in every host. Switches do not affect ARP: a broadcast is flooded on all ports. Related protocols: RARP, BOOTP and DHCP (DHCP - Dynamic Host ConfigurationBOOTP (obsolete) statically maps MAC addresses to IP addresses, while DHCP assigns addresses dynamically on lease, even after the operating system has started; the client-server dialogue runs over UDP (server port 67, client port 68) with DHCPDISCOVER, DHCPOFFER, DHCPREQUEST and DHCPACK (plus DHCPRELEASE), and the ACK delivers IP address, netmask, default gateway and DNS server, with lease renewal at 50 percent and rebinding at 87.5 percent of the lease.DHCP - Dynamic Host Configuration →) assign an IP address to a host joining the network.
Versione ripasso
- Frames need the MAC of the next node; ARP maps an IP on the same network to its MAC using broadcast.
- Whom to resolve: destination if on the same network ( equal to own network), otherwise the default router. Alice : direct; via router (Forwarding and Routing TablesForwarding moves each packet one hop at a time toward its destination; it is direct when the destination is on a local network (ARP gives its MAC) and indirect otherwise (the packet goes to the next hop or default gateway given by the routing table). With netmasks, delivery is direct on interface x if the destination AND the mask equals the interface address AND the mask; otherwise the table is scanned from the longest mask (longest prefix match) and the default route 0.0.0.0/0 always matches; route aggregation shortens tables.Forwarding and Routing Tables →).
- Request: broadcast, destination MAC
FF:FF:FF:FF:FF:FF, carries sender IP+MAC and target IP (target MAC ). Reply: unicast, carries target IP+MAC. Pair stored in the ARP cache. - Format: Hardware Type (Ethernet
0x0001), Protocol Type (IPv40x0800), HLEN 6, PLEN 4, Operation (1 request, 2 reply, 3-4 RARP), 4 address fields. Ethernet/IPv4 packet bytes, padded by . - Per hop: ARP resolves only the next hop. IP addresses constant end to end; MAC addresses rewritten at every hop.
- Proxy ARP: broadcasts do not cross subnets, so the router answers with its own MAC and forwards the frames. Switches flood ARP broadcasts.
- Typical errors: ARP for the remote destination instead of the router; believing MAC addresses survive across routers.