The Network Stack

Understanding the layers that HTTP runs on and how data travels across the Internet

Where HTTP Sits

HTTP is an application-layer protocol. It doesn't deal with packets, routing, or reliable delivery — it delegates that to lower layers. Understanding where HTTP sits in the stack helps you debug network issues and understand performance.

The TCP/IP Model (4 Layers)

┌────────────────────────────────────────────────────────────┐
│  Layer 4: Application                                      │
│  HTTP, HTTPS, FTP, SMTP, DNS, SSH                          │
│  "What do I want to say?"                                  │
├────────────────────────────────────────────────────────────┤
│  Layer 3: Transport                                        │
│  TCP (reliable, ordered) or UDP (fast, best-effort)        │
│  "How do I ensure delivery?"                               │
├────────────────────────────────────────────────────────────┤
│  Layer 2: Internet                                         │
│  IP (IPv4 / IPv6) — addressing and routing                 │
│  "Where does it go?"                                       │
├────────────────────────────────────────────────────────────┤
│  Layer 1: Link / Network Access                            │
│  Ethernet, WiFi, fiber optics                              │
│  "How does it physically travel?"                          │
└────────────────────────────────────────────────────────────┘

Key Protocols in the Stack

DNS (Domain Name System) — translates human-readable domain names (example.com) into IP addresses (93.184.216.34). This is the first thing that happens when you type a URL. Without DNS, you'd need to memorize IP addresses.

TCP (Transmission Control Protocol) — provides reliable, ordered delivery of data. Before any HTTP data flows, TCP establishes a connection with a three-way handshake:

Client                                Server
  │                                      │
  │──── SYN (I want to connect) ────────>│
  │                                      │
  │<─── SYN-ACK (OK, I'm ready too) ────│
  │                                      │
  │──── ACK (Great, let's talk) ────────>│
  │                                      │
  │     Connection established           │
  │     HTTP request/response can flow   │
  │                                      │

IP (Internet Protocol) — handles addressing and routing. Every device on the Internet has an IP address. IPv4 addresses look like 192.168.1.1 (32-bit, ~4 billion addresses). IPv6 addresses look like 2001:0db8::1 (128-bit, effectively unlimited).