2.1 · OSI vs the real internet
| OSI layer | What it does | Real example |
|---|---|---|
| L7 Application | Semantic protocol | HTTP, gRPC, SMTP, SSH, DNS |
| L6 Presentation | Encoding | TLS, gzip, JSON, protobuf |
| L5 Session | Conversations | RPC, NetBIOS (rare today) |
| L4 Transport | End-to-end channel | TCP, UDP, QUIC |
| L3 Network | Routing across networks | IPv4, IPv6, ICMP |
| L2 Data link | Frames within a link | Ethernet, Wi-Fi (802.11) |
| L1 Physical | Bits on a wire / radio | Copper, fibre, RF |
In practice, engineers think in four layers: Link · Internet · Transport · Application.
2.2 · IP, subnets, routing
- IPv4: 32-bit; ~4.3B addresses; CIDR notation
192.168.1.0/24= mask of 24 leading bits. - IPv6: 128-bit; vast space; written in hex with
::compression. - Private ranges (IPv4): 10/8, 172.16/12, 192.168/16, plus 169.254/16 link-local.
- NAT: routers translate between private and public addresses. Most home + corporate networks.
- VPC / subnet: cloud equivalent — a private network you own; subnets per AZ.
- Routing table: longest-prefix match decides the next hop.
2.3 · TCP — anatomy
- Reliable, ordered, byte-stream protocol.
- Congestion control: CUBIC (default Linux), BBR (Google) — different curves.
- Flow control: receive window prevents the sender from overwhelming the receiver.
- TIME_WAIT: 2× MSL (~60s) after close; matters under high connection churn — tune SO_REUSEADDR / use connection pools.
- Nagle's algorithm + delayed ACK can interact badly;
TCP_NODELAYfor latency-critical small writes.
2.4 · UDP & QUIC
- UDP: no handshake, no ordering, no delivery guarantees. Tiny header. Used by DNS, NTP, video / VoIP, QUIC.
- QUIC (RFC 9000): TLS 1.3 + multiplexed streams + connection migration, all over UDP. Underpins HTTP/3.
- Why QUIC wins over TCP+TLS: 0-RTT handshakes, no head-of-line blocking across streams, survives IP changes.
2.5 · DNS
| Record | What it is |
|---|---|
| A / AAAA | Hostname → IPv4 / IPv6. |
| CNAME | Alias to another name (no IP). |
| MX | Mail server for the domain. |
| TXT | Free text — SPF, DKIM, domain verification. |
| SRV | Service location with port + priority. |
| NS | Authoritative name servers. |
| CAA | Which CA may issue certs for the domain. |
| SVCB / HTTPS | Modern; advertises alt-svc + HTTP/3 endpoints. |
Resolvers cache; TTL controls propagation speed. DNS-over-HTTPS / DoT encrypt resolver traffic.
2.6 · TLS 1.3 — what's actually happening
- Client sends ClientHello with supported versions, ciphers, ALPN, extensions, key share.
- Server sends ServerHello + certificate + key share + Finished — all in one round trip.
- Client verifies cert chain against trust store, sends Finished.
- Application data flows encrypted with AEAD ciphers (AES-GCM, ChaCha20-Poly1305).
- mTLS: server also requires client cert (used in service mesh).
- SNI: client signals which hostname; allows multi-tenant TLS termination.
- 0-RTT: send early data on resumed sessions; beware replay risk.
- HSTS: HTTP header forcing TLS for future visits.
- Post-quantum: hybrid Kyber+X25519 key exchange shipping in 2024–2026.
2.7 · HTTP/1.1
- Text-based; one request per connection (or keep-alive serial pipelining — rarely safe).
- Verbs, status codes, headers, chunked transfer encoding.
- Head-of-line blocking: a slow response blocks the rest on the same connection.
- Workaround: browsers open 6 parallel connections per origin.
2.8 · HTTP/2
- Binary framing; multiplexed streams over one TCP connection.
- HPACK header compression.
- Server push (largely abandoned; replaced by 103 Early Hints).
- Still suffers TCP-level head-of-line blocking — fixed in HTTP/3.
2.9 · HTTP/3 (over QUIC)
- HTTP semantics unchanged; transport is QUIC over UDP.
- No TCP-level HOL blocking; faster handshakes; connection migration across IPs.
- Adopted by all major CDNs and browsers; enabled via Alt-Svc / HTTPS RR.
- Cost: more CPU per connection; harder to debug than TCP.
2.10 · Load balancers & proxies
| Layer | What it does | Examples |
|---|---|---|
| L4 | Routes by TCP/UDP 5-tuple. Fast; no payload inspection. | AWS NLB, HAProxy (TCP mode), F5. |
| L7 | Reads HTTP; routes by host, path, headers; SSL terminates. | Nginx, Envoy, HAProxy, AWS ALB, Cloudflare. |
| Service mesh sidecar | L7 proxy per pod; mTLS, retries, telemetry. | Envoy in Istio / Linkerd. |
Strategies: round-robin, least-connections, consistent hashing, weighted, IP hash, slow-start, outlier detection (eject 5xx-y instances).
2.11 · CDNs & anycast
- CDN edges cache content near users; cache-control headers govern policy.
- Anycast: one IP advertised from many locations; BGP routes the user to the nearest.
- Edge compute: V8 isolates (Cloudflare Workers), Edge Functions (Vercel), Compute@Edge (Fastly).
- Origin shielding to reduce origin load.
2.12 · WebSockets, SSE, WebRTC
| Protocol | Use case |
|---|---|
| WebSocket | Bi-directional, low-latency, persistent over HTTP upgrade. |
| SSE (EventSource) | Server → client only; survives proxies; built-in reconnect. |
| WebRTC | Peer-to-peer media + data (ICE/STUN/TURN); video chat, low-latency gaming. |
| WebTransport | QUIC-based, bi-directional streams + datagrams; replacing WS slowly. |
2.13 · BGP & the public internet
- The protocol by which Autonomous Systems exchange routes.
- Path-vector; relies on policy + trust — historically vulnerable to hijacks.
- RPKI + BGP-SEC add cryptographic verification.
- When AWS / Cloudflare has a "global outage" it's almost always BGP, DNS, or TLS — in that order.
2.14 · Self-check
Q1 · HTTP/3 sits over which transport?
TCP
SCTP
QUIC (over UDP)
UDP directly