OSI Model
Context & Purpose
The Open Systems Interconnection (OSI) Model is a conceptual framework that standardizes the functions of a telecommunication or computing system into seven distinct abstraction layers. It exists to allow diverse communication systems to interoperate using standard protocols.
Mechanism / Architecture
The model splits communication into 7 layers, where each layer serves the one above it and is served by the one below it.
Flow Note: Data flows DOWN for transmission (Encapsulation) and UP for reception (Decapsulation).
Layer Breakdown & PDU (Protocol Data Units)
- Physical (PDU: Bits): Transmission of raw bit streams (Cables, Radio).
- Data Link (PDU: Frames): Node-to-node transfer (MAC, Ethernet).
- Network (PDU: Packets): Routing and addressing (IP, routers).
- Transport (PDU: Segments): End-to-end connections and reliability (TCP, UDP).
- Session (PDU: Data): Connection management between applications.
- Presentation (PDU: Data): Data formatting and encryption.
- Application (PDU: Data): Network process to application (HTTP, DNS).
Analysis & Trade-offs
Pros
- Separation of Concerns: Engineers can focus on one layer (e.g., building a React app) without worrying about how bits are transmitted over wire.
- Interoperability: Different vendors can build hardware/software that works together if they follow the standard.
Cons
- Theoretical vs. Practical: The TCP/IP model is the standard implementation.
OSI vs. TCP/IP Comparison
| OSI Layer | TCP/IP Layer | PDU |
|---|---|---|
| 7. Application | Application | Data |
| 6. Presentation | Application | Data |
| 5. Session | Application | Data |
| 4. Transport | Transport | Segment / Datagram |
| 3. Network | Internet | Packet |
| 2. Data Link | Network Access | Frame |
| 1. Physical | Network Access | Bit |
- Overhead: Strict adherence to all layers can introduce latency.
Real-world Usage
- Troubleshooting: "Is it a Layer 1 issue?" (Is the cable plugged in?) vs "Is it a Layer 7 issue?" (Is the API returning 500?).
- Load Balancers: L4 Load Balancers (HAProxy in TCP mode) vs L7 Load Balancers (Nginx, AWS ALB).
Interview Check
- What is the difference between an L4 and L7 Load Balancer?
- L4 routes based on IP/Port (packet level). L7 routes based on HTTP headers/URL (application content). L7 is smarter but more resource-intensive.
- Where does SSL/TLS fit?
- Historically Presentation (L6), but in practice, it wraps the Application data before Transport.