The TCP/IP & OSI models
How layered networking models organize communication, comparing the OSI seven layers with the TCP/IP four layers.
12 cards · 7 quiz questions · 8 min read
Getting a message from your laptop to a server on the other side of the planet is an extraordinarily complicated task. It involves electrical signals, local network hardware, routing across dozens of intermediate machines, error recovery, and finally the application that knows what the data means. No single piece of software could sensibly handle all of that at once. The solution that networking settled on is layering — and two models, OSI and TCP/IP, describe how the layers fit together.
Why layers at all?
Layering breaks the monstrous problem of networking into a stack of smaller problems, each handled by an independent layer with one job. Every layer relies on the services of the layer below it and offers services to the layer above. The benefit is modularity: you can swap out Wi-Fi for Ethernet at the bottom without touching the web browser at the top, because each layer only has to honour its contract with its neighbours.
The OSI model: seven layers
The OSI (Open Systems Interconnection) model is the classic teaching framework. It defines seven layers, which from bottom to top are:
- Physical — transmits raw bits over a medium like copper, fiber, or radio. It deals in voltages and signals, not meaning.
- Data Link — moves frames between directly connected nodes on the same local network, using hardware MAC addresses and catching transmission errors. Ethernet lives here.
- Network — routes packets across multiple networks using logical addresses. This is the home of IP, which forwards packets toward their destination.
- Transport — provides end-to-end delivery between processes, with reliability, ordering, and flow control. TCP and UDP operate here.
- Session — manages and synchronizes ongoing conversations between applications.
- Presentation — translates data formats, handling encoding, compression, and encryption.
- Application — the protocols software uses directly, such as HTTP, DNS, and SMTP.
A common mnemonic for the bottom-to-top order is “Please Do Not Throw Sausage Pizza Away.”
The TCP/IP model: four layers
The OSI model is a reference framework, but the actual internet runs on the leaner TCP/IP model, which uses just four layers:
- Link — combines OSI’s Physical and Data Link work: getting bits onto the local wire.
- Internet — corresponds to OSI’s Network layer; this is where IP routes packets between networks.
- Transport — same role as in OSI; TCP and UDP live here.
- Application — rolls OSI’s Session, Presentation, and Application layers into one, covering everything the application protocols need.
In practice, the two models map onto each other neatly: TCP/IP simply groups several of OSI’s finer distinctions into broader layers. OSI is the better vocabulary for analysis and teaching; TCP/IP is what the network actually implements.
Encapsulation: the headers within headers
How does data physically traverse this stack? Through encapsulation. As your data descends from the application layer toward the wire, each layer wraps it in its own header containing the information that layer needs — port numbers at the transport layer, IP addresses at the network layer, MAC addresses at the link layer.
The result is like a set of nested envelopes. The receiving machine reverses the process, stripping one header at each layer on the way up, so every layer reads only the envelope addressed to it and hands the contents upward.
This is what lets the layers stay independent. The network layer never has to understand what the application data means; it only reads its own header and forwards the packet.
TCP versus UDP: a tale of two transports
The transport layer offers a meaningful choice that shapes how applications behave. TCP is connection-oriented and reliable: it establishes a connection, guarantees that data arrives in order, and retransmits anything lost. That reliability costs overhead and latency, but it is essential for web pages, file transfers, and email, where a missing byte would corrupt the result.
UDP is connectionless and lightweight: it fires packets off without setting up a connection and makes no promise about delivery or order. That sounds worse, but for live video, voice calls, and online games, speed matters more than perfection — a momentarily dropped video frame is better than a stall while the network waits for a retransmission.
Why this matters
You rarely think about these layers when a web page loads, and that is precisely the point — the abstraction works. But the moment something breaks, the layered model becomes your diagnostic map. Is the cable dead (physical), is the local network unreachable (link), is routing failing (network), is the connection timing out (transport), or is the server returning an error (application)? Knowing which layer owns which problem turns a baffling outage into a methodical search, which is why these models remain foundational knowledge for anyone who works with networks.
How many layers does the OSI model define?
Sources
- Andrew S. Tanenbaum — Computer Networks book Classic text on layered network models, including OSI and TCP/IP.
- Kurose & Ross — Computer Networking: A Top-Down Approach book Widely used text contrasting the OSI and TCP/IP layering models.