Computer Networks Interview Questions
Both TCP (Transmission Control Protocol) and UDP (User Datagram Protocol) operate at the Transport Layer of the OSI Model but offer completely different service characteristics:
- TCP: A connection-oriented protocol that ensures reliable delivery. It establishes a session using a 3-way handshake (SYN, SYN-ACK, ACK), performs error checking, guarantees packet ordering, and throttles speed using flow control and congestion control.
- UDP: A connectionless, lightweight protocol. It sends packets ('datagrams') directly to the destination without establishing a connection. It makes no guarantees about packet delivery, ordering, or receipt, resulting in significantly lower overhead and latency.
Common Uses: - TCP: Web browsing (HTTP/HTTPS), email (SMTP/IMAP), file transfers (FTP), database connections. - UDP: Live video streaming, online gaming, VoIP, DNS queries.
Key Points
Connection-oriented vs Connectionless, Reliability, 3-way handshake, Overhead
Common Follow-ups
Explain the mechanism of a TCP 3-way handshake.
DNS (Domain Name System) translates human-readable domain names (like google.com) into IP addresses.
Resolution Steps:
1. Browser Cache: Chrome/Firefox checks its local DNS cache.
2. OS Cache: If not found, the OS checks its resolver cache (nscd or similar).
3. Router Cache: Some routers cache DNS entries from previous resolutions.
4. ISP Recursive Resolver: If all caches miss, the query goes to the ISP's DNS resolver (or custom resolver like Cloudflare 1.1.1.1).
5. Root Nameserver: The resolver queries one of 13 root nameservers, which responds with the TLD server address (e.g., .com, .org).
6. TLD Nameserver: The resolver queries the TLD server, which responds with the authoritative nameserver for the domain.
7. Authoritative Nameserver: The resolver queries the domain's authoritative nameserver, which returns the actual IP address (A or AAAA record).
8. Caching: The resolver caches the result (TTL-controlled) and returns the IP to the browser.
Record Types: - A: Maps domain to IPv4 address. - AAAA: Maps domain to IPv6 address. - CNAME: Canonical name (alias). - MX: Mail exchange records. - NS: Nameserver records.
Key Points
Recursive vs Iterative queries, TTL, Root servers, TLD servers, Authoritative servers, Caching layers
Common Follow-ups
What is DNS poisoning and how does DNSSEC prevent it?
| Feature | HTTP/1.1 | HTTP/2 | HTTP/3 |
|---|---|---|---|
| Transport | TCP | TCP | QUIC (over UDP) |
| Multiplexing | No (head-of-line blocking) | Yes (multiple streams over one TCP) | Yes (native QUIC streams) |
| Header Compression | None | HPACK | QPACK |
| Server Push | No | Yes | Yes |
| Connection Reuse | Keep-Alive (persistent) | Yes (multiplexed) | Yes (connection migration) |
HTTP/1.1 issues: Head-of-line blocking at the application layer (one request blocks others behind it). Workaround: Domain sharding (loading resources from multiple domains).
HTTP/2 improvements: Binary framing layer allows multiplexed streams within a single TCP connection, eliminating HOL blocking at the application layer. Server push sends resources before the client requests them.
HTTP/3 (QUIC): Built on UDP instead of TCP to eliminate TCP-level head-of-line blocking. Provides 0-RTT connection establishment, connection migration (seamless switching between WiFi and cellular), and built-in encryption.
Key Points
Multiplexing, HOL blocking, Binary framing, QUIC, 0-RTT, Connection migration
Common Follow-ups
How does QUIC handle packet loss differently from TCP?