Address Resolution Protocol (ARP)

Using the Ethernet protocol and sending an Internet Protocol packet, the sender needs to know MAC address of remote node. To resolve the IP address of the remote host, we use the DNS protocol. After the IP address is found, we need to resolve the IP address of the destination host into the MAC address of corresponding machine, using the Address Resolution Protocol (ARP).

if ( (IP_dest & netmask_src) == (IP_src & netmask_src) )
{
    // CASE 1

    //The source and the destination are in the same network (LAN)

    //Broadcast the packet to all the hosts in the LAN, specifying the IP_dest

    //The host with IP equal to IP_dest, replies with a unicast ARP response to the sender host specifying its MAC address as MAC_dest
}
else
{
    //CASE 2
    
    //The source and the destination are not in the same network (LAN)

    //Broadcast the packet to all the hosts in the LAN, specifying the gateway IP as IP_dest
    
    //The host with IP equal to gateway IP, replies with a unicast ARP response to the sender host specifying its MAC address as MAC_dest
}

ARP message

  • Hardware type Hardware type (0x0001=Ethernet protocol).

  • Protocol type Protocol type (0x0800=Internet protocol).

  • Hardware Address Length Length of Hardware Address in bytes (6= MAC address).

  • Protocol Address Length Length of Protocol Address in bytes (4= IP address).

  • Opcode code representing the type of ARP message. RARP protocol works as ARP but it's used to obtain IP address from the MAC address. This is usually used trying to connect to wireless networks. In this case, the user needs to have a specific IP address to connect to Internet and through ARP he can obtain it. Today RARP protocol is not used anymore because we use DHCP, an evolution of RARP.

    Code
    Description

    0x01

    ARP request

    0x02

    ARP reply

    0x03

    RARP request

    0x04

    RARP reply

  • Sender Hardware Address Hardware Address of whom sends ARP message.

  • Sender Protocol Address Protocol Address of whom sends ARP message.

  • Target Hardware Address Hardware Address we want to obtaint through ARP or Hardware address we want to solve through RARP (all zeros in ARP request).

  • Target Protocol Address Protocol Address that we want to solve or protocol Address we want to obtain through RARP ( all zeros in ARP request).

Last updated