Two Models to Rule Them All
Networking is complex โ data passes through many layers of hardware and software before reaching its destination. To make this complexity manageable, we use reference models that break the process into logical layers. There are two main models: the OSI model and the TCP/IP model.
The OSI Model
The Open Systems Interconnection (OSI) model was developed by the International Organization for Standardization (ISO) in 1984. It divides networking into 7 layers, each with a specific job:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Layer 7: Application โ โ User interfaces (HTTP, FTP, DNS)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 6: Presentation โ โ Data format, encryption, compression
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 5: Session โ โ Managing connections between apps
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 4: Transport โ โ End-to-end delivery (TCP, UDP)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 3: Network โ โ Routing & IP addressing
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 2: Data Link โ โ MAC addresses, frames, switching
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Layer 1: Physical โ โ Cables, signals, bits on the wire
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Mnemonic: "Please Do Not Throw Sausage Pizza Away" (Physical, Data Link, Network, Transport, Session, Presentation, Application) โ from bottom to top.
How the Layers Work Together
When you send data, it flows down through the layers (encapsulation). Each layer adds its own header (and sometimes trailer) to the data. When the data arrives at the destination, it flows back up through the layers (de-encapsulation), with each layer stripping off its header.
SENDER RECEIVER
โโโโโโ โโโโโโโ
Application โโโ Data Data โโโ Application
Presentation โโโ [Header] + Data [Header] + Data โโโ Presentation
Session โโโ [Header] + ... [Header] + ... โโโ Session
Transport โโโ Segment Segment โโโ Transport
Network โโโ Packet Packet โโโ Network
Data Link โโโ Frame Frame โโโ Data Link
Physical โโโ Bits โโโโโโโโโโโโโโโ Bits โโโ Physical
Think of it like putting a letter in an envelope, then in a package, then in a shipping box. Each layer adds its own packaging. The receiving side unpacks each layer in reverse order.
The TCP/IP Model
The TCP/IP model is the practical model used on the real internet. It simplifies the OSI model into 4 layers:
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Application โ โ OSI Layers 5-7 combined
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Transport โ โ TCP, UDP
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Internet โ โ IP, routing
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Network Access (Link) โ โ OSI Layers 1-2 combined
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
The TCP/IP model is what the internet actually uses. The OSI model is more of a teaching tool โ it's great for understanding concepts, but real-world protocols don't map neatly to all 7 layers.
OSI vs TCP/IP
OSI Model TCP/IP Model Real Protocols
โโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโ
Application โ
Presentation โโโ Application HTTP, DNS, FTP, SMTP
Session โ
Transport โ Transport TCP, UDP
Network โ Internet IP, ICMP, ARP
Data Link โ
Physical โโโ Network Access Ethernet, Wi-Fi
Both models are important to understand. The OSI model helps you think about networking in structured layers. The TCP/IP model shows you how the internet actually works.