The Layered Network Model — OSI, TCP/IP, and L4 vs L7
Why a layered model?
Networking is hard because a single request crosses many concerns at once: physical signalling, addressing, reliable delivery, encryption, and application semantics. The industry tames this with layering — each layer solves one problem and hands a clean abstraction to the layer above. You will not memorise the OSI model to build systems, but the vocabulary it gives you ("that's an L4 load balancer", "TLS sits at the session/presentation boundary", "this is an L7 routing rule") is how engineers talk about where a behaviour lives.
The OSI seven layers
OSI is the conceptual reference. Read it bottom-up — bits become frames, frames become packets, packets become reliable streams, streams carry application messages:
- Physical — raw bits over a medium (copper, fibre, radio).
- Data link — framing and MAC addressing on a local segment (Ethernet, Wi-Fi).
- Network — logical addressing and routing across networks (IP).
- Transport — end-to-end delivery, ports, reliability (TCP, UDP).
- Session — establishing, managing, and tearing down connections.
- Presentation — encoding, serialization, encryption (where TLS conceptually lives).
- Application — the protocol your software speaks (HTTP, gRPC, SMTP, DNS).

TCP/IP — the model the internet actually runs on
The OSI model is a teaching tool; the internet is built on the leaner TCP/IP stack, which collapses OSI's top three layers into a single Application layer: Link → Internet (IP) → Transport (TCP/UDP) → Application. When people say "the network stack", this is usually what they mean.
TCP vs UDP — the transport choice that matters most
At the transport layer you pick reliability or speed. TCP is connection-oriented: a three-way handshake, ordered delivery, retransmission, and flow/congestion control. It is the right default for anything where correctness beats latency — web pages, APIs, file transfer.

UDP is connectionless: fire-and-forget datagrams with no handshake, no ordering, and no retransmission. You trade guarantees for the lowest possible latency, which is why it underpins DNS lookups, real-time voice/video, and gaming — and why QUIC (the basis of HTTP/3) is built on UDP while re-implementing reliability in user space.

L4 vs L7 — the distinction you will use constantly
"Layer 4" and "Layer 7" are shorthand for how much of the request a piece of infrastructure understands:
| L4 (Transport) | L7 (Application) | |
|---|---|---|
| Sees | IP addresses + TCP/UDP ports | The full request: URL, headers, cookies, body |
| Decisions | Forward this connection to a backend | Route /api/* here, /img/* there; rewrite headers; terminate TLS |
| Cost | Cheap, extremely fast | More CPU, but content-aware |
| Example | An L4 TCP load balancer | An L7 reverse proxy / API gateway |
This is exactly why your load balancer can operate at L4 or L7, and why an API gateway is an L7 device — it has to read paths and headers to route. TLS termination happening "at the edge" means the L7 proxy decrypts so it can see the application data underneath.
Takeaways
- Layering = one concern per layer; the value is a shared vocabulary for where behaviour lives.
- The internet runs on TCP/IP; OSI is the conceptual map laid over it.
- TCP = reliable/ordered (default); UDP = fast/lossy (real-time, DNS, QUIC).
- L4 routes by address+port; L7 routes by request content. Memorise this one.
Re-authored for this guide, with concepts and diagrams adapted from Karan Pratap Singh’s System Design (course, MIT licence) and the System Design Primer (CC BY 4.0). Diagrams © their respective authors.
🤖 Don't fully get this? Learn it with Claude
Stuck on The Layered Network Model — OSI, TCP/IP, and L4 vs L7? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.
Build the mental picture, not memorization.
I just read a lesson on **The Layered Network Model — OSI, TCP/IP, and L4 vs L7** (System Design) and want to truly understand it. Explain The Layered Network Model — OSI, TCP/IP, and L4 vs L7 from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
Socratic — adapts to where you're stuck.
Teach me **The Layered Network Model — OSI, TCP/IP, and L4 vs L7** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
Active recall exposes what you missed.
Quiz me on **The Layered Network Model — OSI, TCP/IP, and L4 vs L7** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
Intuition + hook + flashcards for long-term memory.
Help me remember **The Layered Network Model — OSI, TCP/IP, and L4 vs L7** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.