The OSI & TCP/IP Models
Layers, encapsulation, and the vocabulary of networking
01Why layers?
Layering separates concerns. Each layer provides a service to the one above and hides implementation details. This is why you can swap Ethernet for Wi-Fi without rewriting HTTP, and why a browser does not need to know about cable types.
02The 7 OSI layers
From bottom to top. OSI is a teaching/reference model; memorize the names and the responsibilities.
Layers let one part change without breaking the others. You can replace Wi-Fi with Ethernet and HTTP does not care. The model is a map of those separate jobs.
- ▸L1 Physical: bits on wire, signals, cables
- ▸L2 Data Link: frames, MAC, switches
- ▸L3 Network: packets, IP, routing
- ▸L4 Transport: segments, TCP/UDP, ports
- ▸L5 Session: dialog control, checkpoints
- ▸L6 Presentation: encoding, TLS, compression
- ▸L7 Application: HTTP, DNS, SMTP, FTP
The seven layers, in three dimensions
Drag to orbit, scroll to zoom, click a slab to inspect its job.
- What it does
- Adds ports, splits data into segments, and decides whether to guarantee delivery.
- Examples
- TCP, UDP, QUIC
- Why it exists
- One IP address can run many conversations at once. Ports tell them apart. TCP adds ordering and retransmission; UDP skips that when speed matters more than certainty.
03TCP/IP model
The practical 4-layer model the internet actually runs: Link (L1+L2), Internet (L3), Transport (L4), Application (L5-L7 combined). OSI is the vocabulary; TCP/IP is the implementation.
04Encapsulation
As data descends the stack, each layer adds a header (and sometimes a trailer). On receive, headers are stripped in reverse. Think envelope inside envelope. This is how a packet carries an HTTP request inside TCP inside IP inside Ethernet.
Like mailing a letter: you write a message (data), put it in an envelope with a recipient address (transport header), put that envelope in a bigger envelope with a street address (network header), then a mailbag label (link header). Each layer only reads its own envelope.
One packet, four wrappers
Drag to orbit, click a slab to see what that wrapper adds.
IP adds the source and destination addresses, a TTL and a protocol number. These stay the same from sender to receiver, even as the frame around them is replaced at every hop.
05PDU names
Each layer has its own name for the data unit.