Computer Networking & Web Protocols
The networking stack from sockets to the application layer: DNS recursive resolvers, TLS 1.3 handshakes, TCP flow control and congestion windows, and HTTP/2 multiplexing.
The Anatomy of a URL Request & HTTP Protocol Evolution
When typing https://programmersos.com into a browser address bar, a complex cascade of low-level network transactions is executed across the OSI stack before the first HTML byte renders.
- 1. DNS Hierarchy Resolution:Browser Cache -> OS Resolver Cache -> Local DNS Resolver -> Root Server (.) -> TLD Server (.com) -> Authoritative Nameserver (IP resolved).
- 2. HTTP/1.1 Head-of-Line (HoL) Blocking:A slow HTTP request on a single TCP connection blocks all subsequent queued requests in the pipeline, forcing browsers to open up to 6 parallel TCP connections per host.
- 3. HTTP/2 Binary Multiplexing:Splits messages into independent binary frames multiplexed over a single persistent TCP connection. Solved application-layer HoL blocking, but TCP-layer packet loss still stalls all streams.
- 4. HTTP/3 with QUIC (UDP Transport):Replaces TCP with QUIC over UDP, providing true independent stream recovery (loss on stream A does not stall stream B) and zero-RTT connection resumption.
- Recursive DNS Resolution: The resolver queries the Root servers, gets referral to .com TLD server, queries TLD for NS records, and fetches the final A/AAAA record from the domain's authoritative DNS server.
- TCP + TLS 1.3 Combined Handshake: In 1 Round-Trip Time (1-RTT), the client sends SYN + TLS KeyShare; server responds with SYN-ACK + TLS ServerHello + EncryptedExtensions + Finished.
- HTTP/2 Binary Stream Transfer: Headers are compressed via HPACK (RFC 7541) into HEADERS frames; request payload is divided into DATA frames with stream IDs.
The ability to interleave multiple bidirectional request and response message frames concurrently over a single underlying TCP connection without blocking or connection re-establishment.
Handshake Latency Comparison
HTTP Protocol Evolution Matrix
| Protocol | Transport | Multiplexing | Header Compression | Head-of-Line Blocking |
|---|---|---|---|---|
| HTTP/1.1 | TCP | No (Sequential Pipeline) | None (Plaintext) | Application & TCP Level |
| HTTP/2 | TCP | Yes (Binary Frames) | HPACK | TCP Level Only |
| HTTP/3 | QUIC (UDP) | Yes (Independent Streams) | QPACK | Zero HoL BlockingOptimal |
For real-time bidirectional messaging (chat applications, live trade updates), WebSockets provide continuous full-duplex TCP streams with minimal 2-byte framing overhead after an initial HTTP 101 Switching Protocols upgrade.
1# Demonstration of HTTP/2 Multiplexed Binary Framing2class HTTP2Stream:3 def __init__(self, stream_id, path):4 self.stream_id = stream_id5 self.path = path6 self.chunks = [f'DATA chunk 1 for {path}', f'DATA chunk 2 for {path}']78# Two concurrent streams over ONE connection9s1 = HTTP2Stream(stream_id=1, path='/index.html')10s2 = HTTP2Stream(stream_id=3, path='/style.css')1112# Interleaved transmission over single TCP socket13transmission_pipe = [14 (s1.stream_id, s1.chunks[0]),15 (s2.stream_id, s2.chunks[0]),16 (s1.stream_id, s1.chunks[1]),17 (s2.stream_id, s2.chunks[1]),18]1920print('HTTP/2 Wire Frame Transmission:')21for sid, frame in transmission_pipe:22 print(f' [Stream #{sid}] Received: {frame}')
HTTP/2 Wire Frame Transmission: [Stream #1] Received: DATA chunk 1 for /index.html [Stream #3] Received: DATA chunk 1 for /style.css [Stream #1] Received: DATA chunk 2 for /index.html [Stream #3] Received: DATA chunk 2 for /style.css
1# Test HTTP/3 QUIC connection2curl --http3 -I https://cloudflare.com34# Inspect HTTP/2 frames and HPACK header compression5curl --http2 -v https://programmersos.com
HTTP/3 200 OK alt-svc: h3=":443"; ma=86400
Quick Syntax & Reference Sheet
| Concept / Rule | Syntax / Usage |
|---|---|
| WebSocket Upgrade | GET /ws HTTP/1.1
Upgrade: websocket
Connection: Upgrade
Sec-WebSocket-Key: dGhlIHNhbXBsZQ== |
| DNS Record Types | A (IPv4), AAAA (IPv6), CNAME (Alias), MX (Mail), TXT (SPF/DKIM), NS (Nameserver) |
Common Pitfalls & Developer Mistakes
Setting DNS TTL (Time To Live) too high during domain or IP migrations
Why it happens: Resolvers cache DNS responses for the full TTL duration. If an IP changes, clients with cached high TTLs continue sending traffic to the old decommissioned server.
# In Zone File:
@ IN A 300 192.0.2.1