Skip to content
AI360Xpert

Network Protocols (TCP/UDP/HTTP/WebSockets)

Network Protocols (TCP/UDP/HTTP/WebSockets) architecture
Network Protocols (TCP/UDP/HTTP/WebSockets) architecture

Overview

Networking foundations are the core protocols that move data across the internet: DNS resolves human-readable names to IP addresses, HTTP and HTTPS carry web requests and responses, and TCP and UDP are the two transport protocols that actually ship the bytes. Together they underpin every distributed system.

🧠 Mental model: DNS is the phone book (name -> number). TCP is a phone call (reliable, ordered conversation). UDP is shouting across the room (fast, but some words get lost). HTTP is the language you speak on the call.

Key Concepts

DNS (Domain Name System) is the internet's phone book: it translates a domain like example.com into an IP address. A resolver walks a hierarchy (root, then top-level domain, then the authoritative server), and results are cached with a TTL to avoid repeating the lookup. DNS is also a coarse traffic-routing tool, returning different IP addresses by geography or health.

IP delivers packets between addresses. On top of it sit the two transport protocols:

  • TCP (Transmission Control Protocol) is connection-oriented and reliable. It performs a three-way handshake, guarantees in-order delivery, retransmits lost packets, and applies flow and congestion control. The cost is added latency and overhead.
  • UDP (User Datagram Protocol) is connectionless and best-effort. It simply sends datagrams - no handshake, no ordering, no retransmission - which makes it lean and fast but lossy.

HTTP (HyperText Transfer Protocol) is the request-response application protocol of the web. A client sends a method (GET, POST, and so on) to a URL; the server returns a status code and a body. HTTP is stateless - each request stands alone.

HTTPS (HTTP Secure) is HTTP layered over TLS. It encrypts the connection so data cannot be read or tampered with in transit, and it authenticates the server through certificates. It is now the default for all public traffic.

TCP vs UDP

Dimension TCP UDP
Connection Connection-oriented (handshake) Connectionless
Reliability Guaranteed, retransmits lost data Best-effort, may drop
Ordering In-order delivery No ordering
Overhead / latency Higher Lower
Typical use Web, APIs, file transfer Video/voice, gaming, DNS

Where these protocols carry application traffic is the subject of client-server communication patterns, and static assets often travel from a nearby content delivery network rather than the origin server.

Trade-offs

The central transport trade-off is reliability versus speed: TCP guarantees delivery at the cost of handshakes and retransmission latency, while UDP is fast and lightweight but leaves loss handling to the application. Choose TCP when correctness matters (web pages, payments) and UDP when timeliness beats completeness (live video, telemetry). HTTPS adds a small handshake cost over HTTP but is non-negotiable for security.

Interview Tips

  • When asked "TCP or UDP?", answer with the reliability-versus-latency trade-off, not just a label.
  • Mention DNS as the first hop when tracing a request end to end.
  • Assume HTTPS everywhere, and call out TLS termination as a load balancer concern.
  • Know that "HTTP is stateless" is why sessions need cookies or a shared session store.

Summary

  • DNS maps names to IP addresses and can route traffic by geography or health.
  • TCP is reliable and ordered but heavier; UDP is fast and lightweight but best-effort.
  • HTTP is the stateless request-response web protocol; HTTPS adds TLS encryption and server authentication.
  • Pick TCP for correctness-critical traffic and UDP for latency-critical traffic.
  • These protocols underpin content delivery, load balancing, and real-time communication.