Sindhuja Gudala

Packet Flow in the Same Network

For transferring a packet from the source host to the destination host in the network we require both the MAC and IP address of the destination host. ARP (Address Resolution Protocol) is a protocol from the second layer i.e, the Data link layer in the OSI model that connects a dynamic Internet Protocol (IP) address to a unique physical machine address i.e, media access control (MAC) address in a local area network (LAN). ARP protocol helps when the destination’s IP address is unknown and MAC address is known. Firstly it will resolve these issues and send the packet to the destination node/host.

Introduction

The transmission of a packet from one host to another host is performed with the help of both the MAC and IP address of the destination host. But the real problem with the transmission is when we know the IP address but the MAC address is unknown. To resolve this issue we use ARP protocol which is present in the second layer i.e., the Datalink layer of the OSI model. With the help of this protocol, we can find the MAC address of the destination host with the known IP address of the destination host, MAC, and IP address of the source host. Few rules have to be followed for the transmission of a packet in the network. They are mentioned below:

  • Firstly, we need to check whether the destination host is present in the same network as the source host. If so, then the packet is transferred directly.
  • Secondly, if they are in the same network then the transmission of the packet is mainly delivered using the MAC address.
  • Lastly, the MAC address never crosses the broadcast domain i.e. it is always less than (FFFF).

How to obtain a MAC address when the IP address of the host is known can be understood clearly with the help of ARP protocol which is discussed in the below article.

ARP ( Address Resolution Protocol )

ARP protocol helps in resolving the issue of delivering the package to the destination host whose MAC address is unknown but whose IP address is known. There are some important terms associated with ARP protocol:

ARP Cache

ARP cache is a table that is created by the ARP request which contains the mapping of IP addresses with the respective MAC address of the hosts in the network. ARP cache contains two types of entries i.e, dynamic entries also known as learned entries, and static entries also known as user-configured entries. Dynamic entry in the ARP cache in which the Network layer device learns a device’s MAC address from an ARP request or ARP reply from the device. Secondly, static entry means when the MAC address is added dynamically. The below image clearly shows how the ARP cache looks in the network.

arp-cache-table

ARP Request

The ARP request is a broadcast message that consists of the source MAC address, source IP address, and destination IP address. Every host in the network gets this message as this is a broadcast message.

ARP Reply

Whenever an ARP request is sent to all hosts in the network. The host with the matching destination IP address sends an ARP reply packet to the source with its matching destination MAC address.

arp-functionality

ARP Protocol in the networking is as follows:

  • Firstly, an ARP cache is checked to verify whether the ARP is resolved or not. If it is not resolved then an ARP request is sent to all hosts in the network, and the packet is transferred to the destination host directly.
  • Secondly, if the host’s IP address is matching with the destination host’s address then it updates in the ARP cache.
  • After this the destination host replies with the packet of the destination host’s MAC address.
  • Lastly, using this MAC address of the destination a packet is delivered to it successfully.

Packet Flow in the Same Network

As we have a clear idea about the working nature of ARP protocol in the second Data link layer, let’s look into how to transfer a packet from the source host to the destination host within the same network. The below section of the article clearly explains the transmission of the packet within the same network.

  • Firstly it has to know whether both the source and destination host are present in the same network. This can be clarified using AND operation between the source IP address, source subnet mask, and destination IP address, source subnet mask. If the resultant of both the AND operations is the same then the given source and destination are in the same network.
  • In the below network let’s assume that we need to deliver a packet from host C to host D. We can observe that both are in the same network. Firstly, we need to check whether the ARP is resolved or not. Since host D has not communicated before the ARP is not resolved.
packet-flow-in-same-network

To resolve ARP, we need to send an ARP request to all other hosts in the network. Therefore two packets are generated at the source host which are an ICMP packet and an ARP request. This is clearly shown in the below image.

packet-flow-in-same-network-with-icmp-and-arp
  • This ARP package is sent as a broadcast message to all hosts present in the network. The broadcast is performed with the help of a switch. This is clearly shown in the below image.
broadcast-performed-with-switch
  • Now it checks whether the destination’s IP address is matching with the host’s IP. If it matches an ARP reply specifying its MAC address. Host D unicast/ deliver the reply to host C with the help of the switch.
  • As the ARP is resolved, ICMP is unicasted to host D from host C which is clearly shown in the below image:
icmp-network-sample
icmp-network-sample2
  • Now the ICMP acknowledgment packet will be delivered from host D to host C which indicates that host D is successfully pinged from host C which is clearly shown in the below image.
icmp-packet-flow
icmp-packet-flow2

Conclusion

  • This article mainly explains the packet flow in the same network.
  • When the packet has to be delivered from the source host to the destination host in the same network whose destination host’s MAC address is unknown, can be resolved using ARP protocol.
  • ARP protocol finds the destination’s MAC address using the ARP request by sending a broadcast message of source IP, MAC address, and destination IP address. If the destination’s IP address matches the host’s IP address then an ARP reply is sent along with the destination’s MAC address.
  • After finding the MAC address of the destination host the packet is delivered via a switch in the network.
  • This way the packet flow within the same network is performed using ARP protocol.

Author