The Network Stack

Every backend engineer relies on the network constantly and understands it vaguely — until a mysterious timeout, a TLS error, or a latency spike forces a reckoning. The layered model of networking is the map that makes those problems legible: each layer does one job, hides the one below it, and fails in its own characteristic way. Learn the layers and the network stops being magic.

You make an HTTP request and data arrives. Underneath that simple act is a stack of protocols, each solving one piece of the problem of moving bytes between two machines that may be on opposite sides of the planet. This series is that stack, explained for backend engineers — IP, TCP/UDP, DNS, TLS, HTTP, load balancing — and it starts with the layered model itself, because the single most useful mental tool in networking is knowing which layer you’re dealing with.

Why networking is layered

Moving data between two computers reliably over an unreliable, global, heterogeneous network is a huge problem. The foundational engineering decision is to decompose it into layers, each responsible for one concern and each building on the layer below without needing to know how that layer works internally:

This layering is why the internet works at all: it lets different technologies interoperate (any link type, any application) by agreeing on the interfaces between layers. And for you, the engineer, it’s a diagnostic map: when something breaks, the question “which layer?” narrows an infinite problem to a specific one. A DNS failure, a TCP timeout, a TLS handshake error, and an HTTP 500 are problems at four different layers, with four different causes and fixes — and confusing them is why network debugging feels hopeless until you think in layers.

The TCP/IP model

There are two common layer models: the theoretical 7-layer OSI model and the practical 4-layer TCP/IP model that the internet actually uses. This series uses the TCP/IP model because it maps to what you actually work with:

  ┌─────────────────────────────────────────────┐
  │ Application   │ HTTP, DNS, TLS               │  what your app speaks
  ├─────────────────────────────────────────────┤
  │ Transport     │ TCP, UDP                     │  process-to-process delivery
  ├─────────────────────────────────────────────┤
  │ Internet      │ IP                           │  host-to-host addressing/routing
  ├─────────────────────────────────────────────┤
  │ Link          │ Ethernet, Wi-Fi              │  the physical hop
  └─────────────────────────────────────────────┘

The key relationships: IP addresses hosts, TCP/UDP addresses processes on those hosts (via ports), and the application layer gives meaning to the bytes. Most backend engineers live at the application layer (HTTP) but hit problems that originate lower (a TCP timeout, a DNS failure, a TLS mismatch) — which is exactly why understanding the whole stack pays off.

Encapsulation: how the layers combine

The layers cooperate through encapsulation — each layer wraps the data from the layer above with its own header, like nested envelopes:

Sending (wrapping):                    Receiving (unwrapping):
  App:   [ HTTP request ]                Link strips its header →
  TCP:   [TCP hdr][ HTTP request ]       IP strips its header →
  IP:    [IP hdr][TCP hdr][ HTTP ]       TCP strips its header →
  Link:  [Link hdr][IP][TCP][ HTTP ]     App receives the HTTP request
         → bytes on the wire

The elegance: each layer only reads its own header and treats everything above as opaque payload. This is what makes the layers independent — TCP doesn’t parse HTTP, IP doesn’t parse TCP. Encapsulation is the mechanism that turns the conceptual layering into an actual working protocol stack.

Why this matters for backend engineers

You might ask why an application developer needs the lower layers. Because the abstractions leak, and when they do, only layer-thinking saves you:

The map is the payoff: when you hold the stack in your head, a networking problem becomes “isolate the layer, then diagnose within it,” which is tractable, instead of “the network is broken,” which is despair. The rest of the series walks up the stack — IP and routing, TCP/UDP, DNS, TLS, HTTP, load balancing — giving you the working knowledge of each layer that backend engineering quietly demands.

Key takeaways

Further reading

Sources & References

How the web works