OSI vs TCP/IP model
OSI is the 7-layer textbook model; TCP/IP is the 4-layer model the internet actually runs on.
OSI has 7 layers, TCP/IP has 4. OSI is a teaching tool from 1984; TCP/IP is what shipped and runs every packet on the internet today. Know both, use TCP/IP in practice.
The 7 OSI layers, top down
- Layer 7 Application: HTTP, gRPC, DNS, SMTP. What your code touches.
- Layer 6 Presentation: TLS, compression, encoding (UTF-8, JSON).
- Layer 5 Session: connection lifecycle, NetBIOS, RPC sessions.
- Layer 4 Transport: TCP, UDP, QUIC. Ports, reliability.
- Layer 3 Network: IP, ICMP, routing. IP addresses.
- Layer 2 Data Link: Ethernet, Wi-Fi (802.11), MAC addresses, ARP.
- Layer 1 Physical: copper, fiber, radio. Volts and photons.
The 4 TCP/IP layers
- Application: collapses OSI 5, 6, 7. HTTP, TLS, DNS all sit here.
- Transport: TCP, UDP, QUIC. Same as OSI L4.
- Internet: IP, routing. Same as OSI L3.
- Link: Ethernet, Wi-Fi. Collapses OSI L1 and L2.
Why the difference matters
OSI was designed by committee before the internet won. It is clean but academic. TCP/IP is what ARPANET shipped, what the IETF standardized, and what your laptop runs. When somebody says "layer 7 load balancer" they mean an HTTP-aware proxy like nginx. When somebody says "layer 4 load balancer" they mean a TCP/UDP proxy like HAProxy in TCP mode or AWS NLB.
Quick mental model
Each layer wraps the one above. On receive, you unwrap in reverse. This is encapsulation, and it is the entire trick.
When this comes up in interviews
- "Where does TLS sit?" Presentation in OSI (L6), application in TCP/IP.
- "What is an L7 vs L4 LB?" L7 inspects HTTP headers and can route by path or host. L4 just forwards TCP connections by IP and port.
- "Why does QUIC matter?" It moves reliability and encryption out of the kernel (TCP+TLS) into userspace over UDP. Same OSI layer count, very different deployment story.
Learn more
- Paper
- DocsHigh Performance Browser NetworkingIlya Grigorik