|IP Network - ARP|
Even though we specify the source and destination of a packet in the form of IP address, when the packets move along the physical infrastructure of a network, it just jumps from one node to another neghbouring node using link layer address (MAC address), not the IP address. So when a node (e.g, a PC) send a packet to another neighbouring, the source node has to figure out the MAC address (Link Layer address) of the neighbouring node. (Note : Neigbouring node means a node which belongs to the same subnet). ARP is a kind of protocol that enable a node (source node, e.g, a source PC) to find MAC address of another neiboursing node.
An example would give you more clear idea on how this works. Following is a wireshark log for an ARP request and ARP response.
Step 1 : The source Node (e.g, a PC which wants to send a packet) broadcast a 'ARP request' message as shown below. This example is saying "Hey.. Listen everybody, I want to talk to 192.168.0.1. If any of you has this IP address, let me know your the MAC address. My IP address is 192.168.0.13 and my MAC address is 68:5d:43:8b:f9:de"
Let's look into details of the message(ARP request packet).
(1)(a) : This field carries the MAC address of the source Node
(2)(e) : This field carries the destination address of the packet. In this case, the address is 'Broadcast' address, it means that all the nodes which recieves this frame has to decode it and check if it has to do any action for it or not.
(3) : This field carries the IP address of the source node.
(4): This field carries the IP address of the node which the source wants to deliver the packet to.
(5) : This field is for the MAC address of the destination node(192.168.0.13), but this is set to be all 0 because the MAC address is not known yet.
Step 2 : All the nodes (PCs, Routers etc) connected to the PC 192.168.0.13 decode the ARP Request frame and check if the packet is destined for it. If the packet is not for it, just discard the frame and do nothing and if the frame is for it (the reciever), it has to move to step 3.
Step 3 : Generate ARP reply frame(Packet) and send it back to the node (the PC which sent ARP Request). This ARP reply packet is saying "Hey.. I am the node (PC) you are looking for and here goes my MAC address".
The detailed contents of the message is as follows :
(5)(f)(8) : This field carries the MAC address of the node 192.168.0.1. This is exactly what the PC 192.168.0.13 wants to get through this ARP process.
(6)(h) : This field carries the MAC address of the reciever (the PC 192.168.0.13 in this example). Note that this is the unit cast address, not the broadcast address as in ARP request. This is because the MAC address of the reciever is already known from ARP request packet.
(7)(g) : This field carries the IP address of the sender.
(i) : This field carries the IP address of the reciever.