Computer Networks · ARP and RARP
ARP Request and Reply Working (Broadcast Request, Unicast Reply)
Overview
ARP (Address Resolution Protocol) sits between the network layer (IP) and the data link layer, and its job is to find the MAC address that corresponds to a given destination IP address so that an IP datagram can be placed inside a data link layer frame.
The data link layer does not discover the destination MAC address itself; ARP supplies it. The mechanism works through a broadcast request and a unicast reply.
Key concepts
- ARP (Address Resolution Protocol): works between the network layer (IP) and the data link layer; given a destination IP address, it finds the corresponding MAC address so the IP datagram can be placed inside a data link layer frame.
- Role of the data link layer: it does not discover the destination MAC address. It only needs (i) the packet from the IP layer and (ii) the MAC address supplied by ARP.
- ARP request: a broadcast — the destination MAC address is all ones.
- ARP reply: a unicast — sent only back to the requester.
- Same network vs. different network: decided using the subnet mask.
If the destination is in the same network, the frame carries the destination host's own MAC address; if it is in another network, the frame carries the router's MAC address.
How it works
- Host A (which may be a router) wants to send a message to host B. A first decides, using the subnet mask, whether B is in the same network or a different network. Assume B is in the same network.
- The packet comes down from the upper layers to IP. IP hands it to ARP, which resolves the MAC address and hands the result to the data link layer, which builds the frame.
- At the network layer the datagram has source IP address and destination IP address . A does not yet know B's MAC address.
- ARP creates an ARP request packet: "I know your IP address is , but I do not know your MAC address. Please send me your MAC address if you are in the same network."
- The request is put in a frame with source MAC address and destination MAC address all ones (because the destination MAC is unknown).
All ones means broadcasting, so every station on the network sees the request, but only the station whose IP address is (B) replies. - B prepares the ARP reply: "My IP address is and my MAC address is ." The reply frame has source MAC address and destination MAC address — B knows because the request stated it came from .
- A now learns that B's MAC address is . The actual data packet is placed in a frame with destination MAC address and source MAC address .
- In general, whenever any packet is given to IP, IP gives it to ARP before the data link layer.
ARP finds the MAC address for the destination IP address and passes it to the data link layer along with the IP packet, so the data link layer has all the information it needs.
Formulas
- : IP address of host A
- : IP address of host B
- : MAC address of host A
- : MAC address of host B
Worked examples
A sends to B, with B in the same network:
- A checks the subnet mask and concludes B is in the same network.
- IP datagram at A: source IP = , destination IP = .
- ARP request frame (broadcast): source MAC = , destination MAC = all ones; content: "Who has IP ? Tell me your MAC address."
- All stations receive the broadcast; only B (IP = ) responds.
- ARP reply frame (unicast): source MAC = , destination MAC = ; content: " is at ."
- Actual data frame from A to B: source MAC = , destination MAC = .
Comparison
| Property | ARP Request | ARP Reply |
|---|---|---|
| Destination MAC | All ones (broadcast) | (unicast) |
| Source MAC | ||
| Who receives it | Every station on the network | Only the requester (A) |
| Who responds/acts | Only the station with IP = | A (learns ) |
Revision summary
- ARP sits between the IP layer and the data link layer; it resolves an IP address to a MAC address.
- The data link layer does not find the destination MAC address — ARP supplies it together with the IP packet.
- Whether the destination is in the same network is decided using the subnet mask.
- Same network → frame's destination MAC = destination host's MAC;
different network → frame's destination MAC = router's MAC. - ARP request is broadcast (destination MAC all ones); ARP reply is unicast (back to the requester's MAC).
- The request includes the source MAC , which is how B knows to unicast the reply to .
- After the reply, the actual data frame uses destination MAC = and source MAC = .
Previous-year exam insights
- ARP is used only within the same subnet/LAN; to reach a host in a different network, the sender ARPs for the IP address of the default gateway (router) and puts the router's MAC address as the frame's destination MAC, while the destination IP in the datagram remains the final host's IP.
Asked inGATE 2019 - ARP request is sent as a link-layer broadcast (destination MAC all ones) but is addressed at the IP level to the target host's IP; the reply is unicast directly to the requester's MAC address, so the destination MAC of an ARP reply is never a broadcast address.
Asked inGATE 2021 - ARP is a network-layer-to-link-layer address resolution protocol that operates within the local link; it is not used to resolve addresses across routers, and routers do not forward ARP broadcasts.
Asked inGATE 2019 - ARP messages are carried directly in link-layer frames (e.g., Ethernet type 0x0806) and are not encapsulated in IP datagrams or UDP; ARP packets therefore have no IP header.
- To reduce broadcast traffic, resolved IP-to-MAC bindings are kept in an ARP cache with a timeout; gratuitous ARP (an unsolicited request/reply for one's own IP) is used to detect duplicate IP addresses and to update other hosts' caches after a change.
- RARP (Reverse ARP) performs the reverse mapping, MAC address to IP address, and was used by diskless hosts to obtain their IP address from a RARP server; it is broadcast at the link layer and has been largely replaced by BOOTP/DHCP.