TCP/IP Model — How the 4/5-Layer Model Maps to Reality vs OSI
The TCP/IP model is the layered stack the actual internet is built on. Where OSI is the idealized seven-layer reference map, TCP/IP is the territory — the leaner four-layer stack standardized in RFC 1122 that really ships, and where real things like TLS and sockets have crisp homes. The two models agree exactly in the middle and differ only at the edges. And the reason the whole thing scaled is a single design property: an hourglass with one narrow waist — IP — that everything funnels through.
Key Components
- TCP/IP model
- The layered organization of the deployed internet, defined in RFC 1122 (1989) as four layers — Application, Transport, Internet, Link. Most textbooks teach a five-layer variant that splits Link into Data Link + Physical. The two are the same stack with one extra seam, not a disagreement. Note that "TCP/IP" also names the protocol suite (TCP, IP, UDP, ICMP, ARP…); context disambiguates.
- Application layer
- The top layer: the protocols programs actually speak — HTTP, DNS, SMTP, SSH — plus everything OSI would have called Session and Presentation. TCP/IP gives those no dedicated layers, so encoding, encryption and session management are simply the application's own responsibility. This is why TLS lives here rather than in a layer of its own.
- Transport layer & the socket boundary
- End-to-end delivery between processes, addressed by port number: TCP (ordered, reliable, connection-oriented) or UDP (unordered, best-effort, connectionless). The socket — the
socket()/bind()/listen()/send()API — sits exactly on the Application↔Transport boundary. It is the seam where your code stops and the kernel's networking begins, and TCP/IP makes that seam crisp where OSI blurred it across three layers. - Internet layer
- Addressing and routing across independent networks: IP plus its control companion ICMP. It moves a packet from any host to any other host, hop by hop, with no delivery guarantee. This is a router's entire world — and, as the visual model shows, it is the layer everything else is forced to agree on.
- Link layer
- Delivery across one hop, on one physical medium: Ethernet, Wi-Fi, ARP, and the wires, fiber and radio underneath. RFC 1122's four-layer model lumps signalling and framing together here; the five-layer textbook model splits them into Data Link (framing, MAC addressing) and Physical (the actual signals), matching OSI's bottom two.
- Narrow waist (the hourglass)
- The shape of the stack when you count implementations rather than layers: many application protocols on top, many link technologies on the bottom, and exactly one protocol in the middle — IP. The slogan is "IP over everything, and everything over IP." Because the only mandatory agreement is that single waist, the top and bottom evolved independently and without anyone's permission.
Concrete Example
Take a single ordinary act: a program fetches https://example.com/. Reading the layers off that one request is the fastest way to make the model stop feeling like trivia.
At the Application layer, two protocols are stacked inside one layer — TLS wrapping HTTP — with no layer boundary between them, because TCP/IP has nowhere else to put encryption:
Application ── TLS record { HTTP/1.1 request }
GET / HTTP/1.1
Host: example.com
The application hands those bytes down through a socket. This is the App↔Transport boundary made literal — every line below is the application layer, and send() is the exact moment the Transport layer takes over:
import socket, ssl
raw = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # SOCK_STREAM → TCP
raw.connect(("93.184.216.34", 443)) # (IP address, port)
# TLS is *not* a separate layer — it is application code wrapping the socket.
tls = ssl.create_default_context().wrap_socket(raw, server_hostname="example.com")
tls.send(b"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n") # ← App hands bytes to Transport
print(tls.recv(4096))
Notice what the socket call already contains: a port (443 — a Transport-layer concept) and an IP address (93.184.216.34 — an Internet-layer concept). The API deliberately exposes exactly the two layers below it and nothing further down. Your code never names an Ethernet MAC address or a Wi-Fi channel; those are the Link layer's business, decided hop by hop and invisible from here.
On the wire, the same request appears as nested headers, one per layer below the application — the shape that encapsulation produces:
Link | Ethernet dst=aa:bb:cc:dd:ee:ff src=... type=0x0800 ← one hop only
Internet | IP src=192.168.1.20 dst=93.184.216.34 proto=6 ← host to host
Transport | TCP src=51514 dst=443 seq=... ← process to process
Application| TLS record → HTTP/1.1 GET / ← what the app means
Each layer answers a different question, and each answer has a different lifetime. The Ethernet header is rewritten at every router hop, because "the next machine on this cable" changes constantly. The IP header survives the whole journey end to end. The TCP header identifies the two processes. And the application payload is the only part anyone actually wanted to send.
Mapping the things a working engineer touches onto that stack:
| What you touch | TCP/IP layer | What it buys you |
|---|---|---|
| HTTP, DNS, SMTP, SSH | Application | the protocols programs speak to each other |
| TLS / SSL | Application (top of it) | no dedicated layer — the app secures its own data |
| Sockets API | boundary of App ↔ Transport | where your code plugs into TCP/UDP |
| TCP, UDP | Transport | ports, and optionally reliability and ordering |
| IP, ICMP, routing tables | Internet | addressing and routing — a router's whole job |
| Ethernet, Wi-Fi, ARP, switches | Link | one-hop delivery and MAC addressing |
| cables, fiber, radio | Link (or Physical, in the 5-layer split) | the actual signals |
Visual Model
Two questions usually get asked separately, so they get answered separately — and that is why the topic feels muddled. "How does OSI map onto TCP/IP?" and "why is IP special?" are the same picture seen from two sides. Line the models up as columns and the mapping is obvious: the middle never moves, and only the top and bottom get reorganized. Now look at the same vertical bands from the right, counting how many real protocols sit in each one, and the stack stops being a rectangle. It bulges at the top (every app protocol ever written), bulges at the bottom (every transmission technology ever built), and pinches to a single point in the middle. That pinch is IP.
The diagram below is one figure doing both jobs. Height means layer on both sides: whatever row you are reading in the columns on the left is the same row you are reading in the hourglass on the right. Step through it, then hover or click any protocol name in the hourglass to watch it funnel through the waist.
Loading…
Hover or focus any protocol box in the hourglass to trace its path through the IP waist.
The payoff of the right-hand side is historical, not aesthetic. Because the only thing every party had to agree on was IP, a new application could be invented without asking any network operator's permission, and a new transmission technology could be deployed without asking any application author's permission. Neither side had to coordinate with the other — they only had to meet at the waist. That is the concrete mechanism behind "the internet scaled explosively," and it is the same narrow-waist argument that shows up later in API and platform design.
Deeper — Edge Cases & Gotchas
Why a second model exists at all
The awkwardness of having two models is entirely a story about process. OSI was produced by an international standards committee (ISO) across the late 1970s and 80s: a complete, elegant seven-layer blueprint, designed first and implemented later. TCP/IP grew out of DARPA and the ARPANET in the 1970s: built first and standardized later — RFC 1122 documents in 1989 a stack that had already been running for years and had already shipped inside Unix as BSD sockets.
The IETF's motto settled the contest: "We reject kings, presidents, and voting. We believe in rough consensus and running code." OSI was the beautiful design that arrived late and heavy; TCP/IP was the pragmatic thing that already worked. The result is a split verdict worth memorizing: OSI won the vocabulary; TCP/IP won the internet. Learn OSI in order to talk about networking — "that's a layer 7 problem", "put it behind an L4 load balancer" — and learn TCP/IP because it is what is actually deployed.
"Which layer is TLS?" — the question that exposes the difference
In OSI this question has no clean answer. Encryption is nominally Presentation (layer 6), but TLS also manages sessions (layer 5) and is invoked by the application (layer 7), so people argue about it endlessly and settle on unsatisfying phrases like "layer 6-ish" or "between 4 and 7". In TCP/IP the question dissolves: there is no Presentation or Session layer, so encryption is by definition the application's own job, and TLS is simply part of the Application layer. The Python snippet above is the proof — wrap_socket is ordinary application code wrapping an ordinary socket, with no kernel layer boundary crossed.
The corollary matters: Session and Presentation did not disappear. Their work — encryption, character encoding, serialization, session management — still happens on every connection. TCP/IP just declines to give that work its own layers and assigns it to the application instead.
Four layers or five is not a real disagreement
RFC 1122 says four; Kurose and Tanenbaum teach five. The entire difference is whether the bottom is one Link layer or two (Data Link + Physical). Nothing above it changes, no protocol moves, and no exam answer turns on it beyond stating which convention is in use. Say which model you mean and the ambiguity evaporates.
ARP — asks "which MAC has IP 192.168.1.1?"
consumes an Internet-layer address (IP)
produces a Link-layer address (MAC)
is carried directly in an Ethernet frame, NOT inside an IP packet
→ belongs to neither layer cleanly; it straddles the boundary
Why it breaks: the layers are a conceptual organization invented to make the system explainable, not a partition that the protocols were built to respect. ARP is the standard counterexample, but it is not the only one — ICMP rides inside IP yet exists to control IP, and QUIC implements transport features (ordering, retransmission, congestion control) in userspace on top of UDP, putting Transport-layer machinery in the Application layer. Insisting on a single correct layer number for these produces confident wrong answers.
Why it breaks: like OSI, the TCP/IP model is a conceptual organization, not an implementation map. Real stacks blur it constantly — TLS is a userspace library, QUIC is a userspace transport, offloads push checksums and segmentation into the network card's firmware, and a single kernel path may touch several layers without any module boundary between them. Use the model to reason and to communicate; do not expect to find it in a directory listing.
One term, two meanings
"TCP/IP" names both the model (the four- or five-layer stack described here) and the protocol suite (TCP, IP, UDP, ICMP, ARP and the rest). "The TCP/IP model has four layers" and "the machine has a TCP/IP stack installed" use the phrase in different senses. Context always resolves it, but noticing the ambiguity prevents a class of confused conversations.
See Also
OSI 7-Layer Model — What Each Layer Does and Why the Split Exists The reference map this entry maps from — the seven layers in full, and the L2-vs-L3 vocabulary TCP/IP borrows but never replaced. Encapsulation & Decapsulation — Segments → Packets → Frames → Bits The mechanism that turns the layer stack into bytes on a wire: the nested-header shape shown in the Concrete Example, layer by layer. How the Internet Works End-to-End — A Packet's Journey The same stack in motion — one request traversing every layer of it, from DNS lookup through hop-by-hop routing and back.Sources consulted
- RFC 1122 — Requirements for Internet Hosts, Communication Layers (1989)
Test Yourself
OSI has seven layers and the official TCP/IP model has four. Which OSI layers merged, and into what?
Why is "which layer is TLS?" a straightforward question in TCP/IP but an argument in OSI?
Suppose the internet had standardized on three competing network-layer protocols instead of one. Using the hourglass, describe concretely what would have become harder — and for whom.