Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
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 has all the layers of the OSI model, while routers typically operate at the network, data link, and physical layers.
Message Transmission Example
Let's examine how a message travels from Host 1 to Host 2 across different networks, where:
-
Host 1: IP address
I1, MAC addressM1 -
Host 2: IP address
I2, MAC addressM2 -
Router 1 (Host 1's gateway): IP address
IR1, MAC addressMR1 -
Router 2 (Host 2's gateway): IP address
IR2, MAC addressMR2
At Host 1 (Source)
-
Application Layer: Initiates message "M" to be sent to Host 2
-
Transport Layer: Adds port numbers (x, y) creating message
(M, x, y) -
Network Layer: Adds IP addresses creating message
(M, x, y, I1, I2) -
Data Link Layer: Adds MAC addresses. Since Host 2 is on different network, uses router's MAC address via ARP request:
(M, x, y, I1, I2, M1, MR1) -
Physical Layer: Converts message to bits and transmits to Router 1
At Router 1 (Intermediate)
-
Physical Layer: Receives bits and converts to digital message
-
Data Link Layer: Removes MAC header, sends acknowledgment to Host 1
-
Network Layer: Examines destination IP
I2, consults routing table, determines next hop is Router 2 -
Data Link Layer: Adds new MAC header with Router 2's address:
(M, x, y, I1, I2, MR1, MR2) -
Physical Layer: Transmits to Router 2
At Router 2 (Gateway to Destination)
-
Physical Layer: Receives and processes bits
-
Data Link Layer: Removes MAC header, sends acknowledgment
-
Network Layer: Determines Host 2 is on local network
-
Data Link Layer: Adds Host 2's MAC address:
(M, x, y, I1, I2, MR2, M2) -
Physical Layer: Transmits to Host 2
At Host 2 (Destination)
-
Physical Layer: Receives bits and forwards to data link layer
-
Data Link Layer: Removes MAC addresses, sends acknowledgment to Router 2
-
Network Layer: Removes IP addresses and forwards to transport layer
-
Transport Layer: Removes port information, sends acknowledgment to Host 1
-
Application Layer: Receives original message "M"
Key Points
-
Layer Encapsulation: Each layer adds its own header information as the message travels down the stack
-
MAC Address Changes: MAC addresses change at each hop, but IP addresses remain constant throughout the journey
-
Router Function: Routers operate at layers 1-3, making forwarding decisions based on IP addresses and routing tables
Conclusion
Network layers work together through encapsulation and de-encapsulation processes, where each layer adds specific information needed for successful data transmission. While IP addresses remain constant end-to-end, MAC addresses change at each network hop as routers forward packets toward their destination.
