Working of Different layers in Computer Network


Have you ever wondered how different layers of the network work together to send messages? Before going into details, let us first understand some basic terms.

  • Address Resolution Protocol (ARP) request is a protocol that converts IP addresses to MAC addresses.

  • A routing table  is a set of rules, usually displayed in tabular format, used to determine the routing location of data packets transmitted over an Internet Protocol (IP) network.

In a typical network, the host device or main computer has all the layers and on the other hand, the router has a network, data link layer and a physical layer.

Example

Assuming that we want to send a message to a receiver on Host 2 that is on a different network.

The IP and MAC addresses of Host1 are I1, M1, and the IP and MAC addresses of Host2 are I2, M2.

Assume that the standard gateway of Host1 is router1 (IP address is IR1, Mac address is MR1), and the standard gateway of Host2 is router2 (IP address is IR2, Mac address is MR2).

For Host 1:

Suppose the application layer wants to send a message "M" to Host2.

  • The application layer of Host1 passes it to the transport layer of Host1.

  • The transport layer adds a header to message M, which contains the port number of Host1, Host2 (x, y). So, the message is now (M, x, y) and is passed to the network layer of Host1.

  • The network layer also adds a header to the message containing the IP addresses of Host1 and Host2. The message is now (M, x, y, I1, I2) and is passed to the Data Link layer.

  • The data link layer also adds a header to the message before it is passed to the physical layer. Since Host2 is not in the same network, it will enter the MAC address of host1 and the MAC address of the standard gateway (by sending an ARP request to know the MAC address). The message is now (M, x, y, I1, I2, M1, MR1) and is passed to the physical layer.

  • The physical layer converts the given message into bits and sends it to router 1.

In Router 1:

  • After the data link layer of Router1 sees the data packet, it sends an acknowledgement to the data link layer of Host1 and deletes the header information added to the host1 DLL before forwarding it to the network layer of Router1.

  • The message received by the network layer is (M, x, y, I1, I2).

  • The network layer sees the target IP address. Since the target does not exist in its network, it will decide to forward it to Router2.

  • The network layer of Router 1 decides this after looking at the routing table of Router 1 and will make a decision.

  • Now the router's DLL adds a header to the message. This time, the source MAC address is MR1, and the destination MAC address is MR2 (to find out with Arp).

  • In this way, the receiver only knows the source's IP address but never knows the source's MAC address. The message is now (M, x, y, I1, I2, MR1, MR2) and is sent to the physical layer.

  • The physical layer converts it into bits and sends it to router 2.

For Router 2:

  • Bits are converted into messages by the Physical Layer and it notifies the DLL of Router 2.

  • Now, Router2's DLL sends an acknowledgement to Router1's DLL after seeing the message.

  • The DLL of Router2 deletes the MAC address and forwards it to the network layer.

  • The network layer finds that host2 is on the same network by checking the routing table that exists on router2.

  • Now the message is (M, x, y, I1, I2, MR2, M2) and passed to the physical layer, which converts it into bits and sends it to host 2.

Using Host 2:

  • The physical layer converts them to bits and forwards the message to the DLL.

  • The DLL sends an acknowledgement to router2's DLL and deletes the MAC address from the message passed to the Network Layer.

  • Now the network layer deletes the IP address and provides it to the transport layer.

  • The transport layer of host 2 sends an acknowledgement to the transport layer of Host1 and deletes the port number and provides the message to the process (or application) at the location.

Updated on: 21-Nov-2022

206 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements