Networking can feel overwhelming until we realize it’s built in layers. Each layer handles one job and passes data to the next. The two models we need to know are OSI (theoretical, 7 layers) and TCP/IP (practical, 4 layers).
OSI vs TCP/IP Side by Side
In practice, we use the TCP/IP model. The OSI model is mostly for interviews and understanding concepts.
The 7 OSI Layers — With Analogies
Think of sending a letter. Each layer adds something to it:
- Physical — The road the mail truck drives on. Cables, Wi-Fi signals, electrical pulses.
- Data Link — The mail truck itself. Handles delivery between directly connected devices using MAC addresses. Ethernet lives here.
- Network — The postal routing system. Decides which path to take across networks using IP addresses. Routers operate here.
- Transport — The tracking number on our package. TCP ensures reliable delivery (with confirmation). UDP is like dropping a postcard in the mailbox — faster but no guarantee.
- Session — Opening and closing the conversation. Keeps track of “who’s talking to whom.”
- Presentation — Translation and formatting. Encryption (TLS), compression, character encoding.
- Application — The actual letter content. HTTP, DNS, SMTP, FTP — the protocols our apps talk.
How Data Flows — Encapsulation
When we send an HTTP request, data travels down the layers. Each layer wraps the data with its own header. This is called encapsulation.
Application: [HTTP Data]
Transport: [TCP Header][HTTP Data] → called a "segment"
Network: [IP Header][TCP Header][Data] → called a "packet"
Data Link: [Frame Header][IP][TCP][Data][FCS] → called a "frame"
Physical: 01101001011... (bits on the wire)
On the receiving end, each layer strips off its header and passes the data up. Like opening nested envelopes.
Which Protocols Live Where
| Layer | Protocols | Devices |
|---|---|---|
| Application | HTTP, HTTPS, DNS, FTP, SSH, SMTP | - |
| Transport | TCP, UDP | - |
| Network | IP, ICMP, ARP | Routers |
| Data Link | Ethernet, Wi-Fi (802.11) | Switches |
| Physical | Cables, fiber, radio waves | Hubs, repeaters |
Why This Matters for DevOps
When debugging network issues, layers help us isolate the problem:
- Can’t reach the server at all? Probably Layer 3 (routing, IP).
- Connection drops after opening? Layer 4 (TCP, firewall blocking ports).
- Getting 502 errors? Layer 7 (application, reverse proxy misconfigured).
In simple language, the OSI model is just a way to organize how computers talk to each other. Each layer has one job, and they stack on top of each other like building blocks.