The OSI Model (Open Systems Interconnection Model) is a conceptual model that explains how data travels between two systems over a network.
It divides network communication into 7 layers. Each layer has a specific responsibility.
1. The 7 OSI Layers
flowchart TD
Application["7. Application"]
Presentation["6. Presentation"]
Session["5. Session"]
Transport["4. Transport"]
Network["3. Network"]
DataLink["2. Data Link"]
Physical["1. Physical"]
Application --> Presentation
Presentation --> Session
Session --> Transport
Transport --> Network
Network --> DataLink
DataLink --> Physical
| Layer | Name | Main Responsibility |
|---|---|---|
| 7 | Application | Application-level network services |
| 6 | Presentation | Data format, encryption, compression |
| 5 | Session | Managing communication sessions |
| 4 | Transport | End-to-end communication |
| 3 | Network | IP addressing and routing |
| 2 | Data Link | Local network communication |
| 1 | Physical | Bits and physical transmission |
2. Layer 7 — Application
This layer provides network functionality used by applications.
Examples include:
HTTP
HTTPS
DNS
FTP
SMTP
For an ASP.NET Core application, HTTP communication is primarily associated with the application layer.
3. Layer 6 — Presentation
This layer deals with how data is represented, including concepts such as data formatting, encryption, and compression.
Examples:
JSON
Encryption
Compression
Character Encoding
4. Layer 5 — Session
The session layer is responsible for establishing, managing, and terminating communication sessions between systems.
In modern applications, session-related responsibilities are often handled through protocols and application frameworks rather than a separate OSI layer implementation.
5. Layer 4 — Transport
The transport layer provides end-to-end communication between applications.
The two important protocols are:
TCP
UDP
TCP provides reliable, ordered delivery, while UDP provides connectionless communication with lower protocol overhead.
flowchart LR
Application --> Transport
Transport --> TCP
Transport --> UDP
6. Layer 3 — Network
The network layer is responsible for logical addressing and routing packets between networks.
IP is the key protocol associated with this layer.
flowchart LR
Client["Client"]
Router["Router"]
Server["Server"]
Client --> Router
Router --> Server
Routers use network addressing information to determine where packets should be forwarded.
7. Layer 2 — Data Link
The data link layer handles communication between devices on the same local network.
Concepts commonly associated with this layer include:
MAC Address
Ethernet
Frames
Switches
8. Layer 1 — Physical
The physical layer deals with the actual transmission of bits through a physical medium.
Electrical Signals
Radio Signals
Fiber Optic Signals
Network Cables
9. How the Layers Work Together
Suppose a browser sends an HTTPS request to an API.
flowchart TD
Application["Application - HTTP/HTTPS"]
Transport["Transport - TCP"]
Network["Network - IP"]
DataLink["Data Link - Ethernet"]
Physical["Physical - Signals"]
Application --> Transport
Transport --> Network
Network --> DataLink
DataLink --> Physical
At the receiving system, the data moves back up through the layers until it reaches the application.
10. OSI vs TCP/IP Model
In real-world networking, the TCP/IP model is more commonly used. The OSI model is mainly useful for understanding and troubleshooting network communication.
flowchart TD
OSI["OSI Model - 7 Layers"]
TCPIP["TCP/IP Model - 4 Layers"]
OSI --> TCPIP
11. Easy Way to Remember the Layers
7 → Application
6 → Presentation
5 → Session
4 → Transport
3 → Network
2 → Data Link
1 → Physical
For interviews, remember the most important practical mapping:
HTTP / HTTPS → Application
TCP / UDP → Transport
IP → Network
Ethernet → Data Link
Signals → Physical
12. Important Interview Questions
- What is the OSI model?
- What are the 7 layers of the OSI model?
- What happens at the transport layer?
- Which layer is responsible for IP?
- Which layer contains TCP and UDP?
- What is the difference between Layer 2 and Layer 3?
- What is the physical layer?
- What is the difference between OSI and TCP/IP?
- Which OSI layer does HTTP belong to?
Key Takeaways
- OSI is a 7-layer conceptual model for network communication.
- Application is Layer 7.
- Transport is Layer 4 and includes TCP and UDP.
- Network is Layer 3 and is associated with IP and routing.
- Data Link is Layer 2 and deals with local network communication.
- Physical is Layer 1 and deals with transmission of bits.
- The OSI model is especially useful for understanding and troubleshooting networking.
Conclusion
The OSI model provides a structured way to understand how data moves from an application through the network and eventually reaches another system.
For system design interviews, focus especially on Application, Transport, Network, Data Link, and Physical layers and know where HTTP, TCP, UDP, and IP fit.