Type a branch, a subject or a topic — “round robin”, “paging”, “civil”.

OSI and TCP/IP Layers

Seven layers against four — including the two OSI layers nobody ever implemented.

Skip to the animation

OSI is a seven-layer reference model; TCP/IP is the four-layer model the internet actually runs — and the mapping between them is most of what is worth knowing about either.

The mapping

#OSITCP/IPDoesExample
7ApplicationApplicationthe protocol a program speaksHTTP, DNS
6PresentationApplicationencoding, encryption— (never separate)
5SessionApplicationdialogue control— (never separate)
4TransportTransportwhich program; reliabilityTCP, UDP
3NetworkInternetwhich machine; routingIP
2Data linkLinkone hop; framing; MACEthernet
1PhysicalLinkbits as signalscable, radio

Layers 5 and 6 have no separate implementation in any real stack. That is the honest reason TCP/IP has four layers rather than seven.

The vocabulary

Protocol data unit
What the thing is called at each layer: segment at transport, packet at network, frame at link. Different names for the same bytes with different amounts of header wrapped round them.
Encapsulation
A layer treats everything it receives from above as opaque payload and prepends its own header. It never looks inside, which is precisely what makes layers replaceable.
Peer layers
A layer only ever meaningfully talks to the same layer at the other end. TCP at one end reads the header TCP at the other end wrote, and nothing in between touches it.
Propagation vs transmission delay
Propagation is how long a bit takes to travel the distance — set by physics. Transmission is how long it takes to push all the bits out — set by bandwidth. Only the second improves when you buy a faster link.
Round-trip time (RTT)
Send to reply. Every acknowledgement-based protocol is ultimately paced by this, which is why the interesting question is always how much you can send before one arrives.

Where each layer's addressing applies

  • MAC address (layer 2) — identifies the two ends of one hop, and is rewritten at every hop along the path.
  • IP address (layer 3) — identifies the two ends of the whole journey, and is unchanged from source to destination.
  • Port (layer 4) — identifies which program on a machine, not the machine itself.

A packet's IP addresses stay fixed while its MAC addresses change a dozen times crossing the internet. That difference is exactly the distinction between routing and forwarding, and it is the most commonly muddled point in the whole model.

Why layering was worth it

Each layer treats what it receives from above as opaque payload and adds only its own header, so it can be replaced without disturbing anything else. Ethernet became Wi-Fi and TCP never noticed. QUIC replaced much of TCP without touching applications.

The cost is header overhead and some duplicated work — error checking happens at layers 2 and 4 both. In practice the modularity has been worth it for fifty years, which is a stronger endorsement than any argument.

Advantages and disadvantages

Advantages

  • Layers can be replaced independently, which is how the internet evolved without redesign.
  • Each layer solves one problem, so each can be understood and taught separately.
  • The interfaces are stable enough that hardware and software vendors can specialise.

Disadvantages

  • OSI's seven layers overspecify — two of them were never built.
  • Headers at every layer are real overhead, painful for small messages.
  • Some functions genuinely span layers, and TLS in particular fits nowhere cleanly.

Watch it work

loading visualisation…

Check yourself

question 1 / 4

One question at a time. Pick an answer to see why it is right or wrong, then move on — there is no score to keep and nothing is saved.

Which OSI layers have no separate implementation in real stacks?
Reliability lives at the transport layer rather than the network layer because:
Which mapping from OSI to TCP/IP is correct?
What does layering actually buy, in one sentence?

0 / 4

4 still unanswered — the dots above jump straight to them.