OSI Model and TCP/IP

beginner networking osi tcp-ip layers

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

OSI (7 Layers) vs TCP/IP (4 Layers)
OSI Model
7. Application (HTTP, DNS, FTP)
6. Presentation (TLS, JPEG, JSON)
5. Session (sockets, sessions)
4. Transport (TCP, UDP)
3. Network (IP, ICMP, routing)
2. Data Link (Ethernet, MAC)
1. Physical (cables, signals)
TCP/IP Model
Application
combines OSI layers 5-7
Transport
same as OSI layer 4
Internet
same as OSI layer 3
Network Access
combines OSI layers 1-2

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:

  1. Physical — The road the mail truck drives on. Cables, Wi-Fi signals, electrical pulses.
  2. Data Link — The mail truck itself. Handles delivery between directly connected devices using MAC addresses. Ethernet lives here.
  3. Network — The postal routing system. Decides which path to take across networks using IP addresses. Routers operate here.
  4. 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.
  5. Session — Opening and closing the conversation. Keeps track of “who’s talking to whom.”
  6. Presentation — Translation and formatting. Encryption (TLS), compression, character encoding.
  7. 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

LayerProtocolsDevices
ApplicationHTTP, HTTPS, DNS, FTP, SSH, SMTP-
TransportTCP, UDP-
NetworkIP, ICMP, ARPRouters
Data LinkEthernet, Wi-Fi (802.11)Switches
PhysicalCables, fiber, radio wavesHubs, 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.