Skip to content

Computer Networks

~13 min

In short

Networking questions check whether you can explain how a request travels from a browser to a server and back, and why the protocols make the choices they do. Keep your answers layered. Start with the big picture, then go one level deeper only when asked. Most follow-ups are about what breaks and what the protocol does about it.

Checklist

  • [ ] What are the layers of the TCP/IP model? How do they compare with OSI?
  • [ ] What is the difference between TCP and UDP?
  • [ ] Explain the TCP three-way handshake.
  • [ ] What do flow control and congestion control do?
  • [ ] When would you choose UDP? Name two real uses.
  • [ ] What is an IP address? What is a port?
  • [ ] What is the difference between IPv4 and IPv6?
  • [ ] What is a subnet? What does a suffix like /24 mean?
  • [ ] What is HTTP, and why is it called stateless?
  • [ ] Compare GET, POST, PUT, PATCH and DELETE. Which are idempotent?
  • [ ] What do status codes 200, 301, 404 and 500 mean?
  • [ ] What are cookies used for?
  • [ ] What is the difference between HTTP/1.1, HTTP/2 and HTTP/3?
  • [ ] What does DNS do? Walk through a lookup.
  • [ ] What is a DNS TTL?
  • [ ] What is the difference between an A record and a CNAME record?
  • [ ] What does TLS provide? What is a certificate for?
  • [ ] What is the difference between HTTP and HTTPS?
  • [ ] What happens when you type a URL and press Enter?
  • [ ] What does a load balancer do, and why use one?

Key ideas

Layers. The TCP/IP model is usually described with four layers: application (HTTP, DNS), transport (TCP, UDP), internet (IP) and link (Ethernet, Wi-Fi). The OSI model has seven layers and is mainly a teaching model. Know both names and be ready to map an example onto either.

TCP and UDP. TCP is connection-oriented. It sets up a connection with a three-way handshake (SYN, SYN-ACK, ACK), numbers the bytes, retransmits lost data, delivers data in order, and adjusts its sending rate through flow and congestion control. UDP sends independent datagrams with no handshake, no retransmission and no ordering guarantee, so it has less overhead and delay. DNS queries and live video or games commonly use UDP. QUIC, which HTTP/3 runs on, is built on UDP.

IP, ports and subnets. IP addresses identify hosts, and IP routes packets between networks on a best-effort basis. Ports identify the application on a host: 80 for HTTP, 443 for HTTPS, 53 for DNS. In a /24 network the first 24 bits are the network part, leaving 8 bits for hosts.

HTTP. HTTP is a request-response protocol. A request has a method, a path and headers. A response has a status code and headers. GET, HEAD, OPTIONS, PUT and DELETE are defined as idempotent, so repeating them gives the same server state. POST generally is not. Status classes are 2xx for success, 3xx for redirects, 4xx for client errors and 5xx for server errors. HTTP itself is stateless, so cookies or tokens carry state across requests. HTTP/2 multiplexes many requests over one connection. HTTP/3 runs over QUIC.

DNS. DNS maps names to records. A records hold IPv4 addresses, AAAA records hold IPv6 addresses, CNAME records are aliases, and MX records name mail servers. A lookup goes from the browser and OS caches to a recursive resolver, which asks a root server, then a top-level domain server, then the domain's authoritative server. Answers are cached for their TTL.

TLS. TLS sets up an encrypted, tamper-checked channel. The server proves its identity with a certificate that chains to a certificate authority the client trusts. Client and server agree on keys, and then the data is encrypted. HTTPS is simply HTTP carried over TLS. TLS 1.3 is specified in RFC 8446.

What happens when you type a URL. The browser parses the URL and checks its caches. It resolves the host name with DNS. It opens a TCP connection to that IP address and port. For HTTPS it performs a TLS handshake. It sends an HTTP request, and the server, often behind a load balancer or CDN, returns a response, which may be a redirect. The browser parses the HTML, fetches the CSS, JavaScript and images, and renders the page. Keep-alive and HTTP/2 reuse connections, which avoids repeating handshakes for every resource.

Load balancers. A load balancer spreads requests across several servers. That adds capacity and lets the service keep running when one server fails. Design-level detail belongs in system design, linked below.

Try this

Open a terminal. Run dig example.com to see the DNS answer, then curl -v https://example.com. On paper, label each part of the output: the DNS answer, the TCP connection, the TLS handshake details and the HTTP status line. Explain the whole output out loud in under a minute.

Sources