Computer Networks Interview Questions · Question 07

How does ARP resolve an IP address into a MAC address?

Interview preparation resource from Gate Smashers.

Interview-ready answer

ARP resolves an IPv4 next-hop address to a MAC address on the local network. A host first checks its ARP cache. If no valid mapping exists, it broadcasts an ARP Request asking which device has the target IPv4 address. The device that owns that address normally sends an ARP Reply with its MAC address. The sender caches the mapping and uses that MAC address as the destination address in the Ethernet frame. For an off-link IP destination, the host ARPs for the default gateway's IPv4 address, not for the remote host.

Computer Networks Interview Questions diagram explaining How does ARP resolve an IP address into a MAC address
Understand it clearly

Purpose of ARP

ARP, the Address Resolution Protocol, maps an IPv4 address to a link-layer address such as an Ethernet MAC address. It is used to deliver an Ethernet frame to the appropriate local next hop.

Before using ARP, the sender determines whether the IP destination is on the local network. For a local destination, the next hop is the destination host. For a remote destination, the next hop is usually the default gateway.

ARP resolution process

When a host needs the MAC address for a local next-hop IPv4 address, it first looks for a valid entry in its ARP cache. If an entry is available, it can send the Ethernet frame without issuing a new request.

If no valid entry exists, the host sends an ARP Request in an Ethernet broadcast frame. All devices in the local broadcast domain can receive the request, but the device owning the requested IPv4 address normally responds.

The responding device sends an ARP Reply containing its MAC address, typically directly to the requester. The requester records the IPv4-to-MAC mapping in its ARP cache and sends the pending Ethernet frame using the learned destination MAC address.

  • 1. Cache lookup: Check for an existing IPv4-to-MAC mapping.
  • 2. ARP Request: Broadcast a request for the target local next-hop IPv4 address.
  • 3. ARP Reply: The target device returns its MAC address.
  • 4. Frame transmission: Cache the mapping and use the MAC address in the Ethernet frame.

Local-link scope

ARP requests are limited to the local broadcast domain because routers do not forward ordinary Layer 2 broadcasts between routed networks. Therefore, ARP does not obtain the MAC address of a host on a remote network.

For remote traffic, the IP packet still carries the remote destination IP address, but the Ethernet frame is addressed to the MAC address of the local router or other configured next hop.

IPv6 equivalent

IPv6 does not use ARP. It uses Neighbor Discovery, based on ICMPv6, for address resolution and related local-link functions.