map / networking / layers

Networking · principle 1 of 6

Packets & layers

Each layer wraps the one above it, so every problem lives at a specific layer — find the layer, and you’ve halved the search.

01 · Why it’s true

Each layer only talks to the layer directly above and below it. HTTP doesn’t know about routing, and IP doesn’t know about HTTP. On the way out, every layer adds its own header around the data from the layer above (encapsulation); on the way in, each layer strips its header and hands the rest up.

Because responsibilities are split cleanly, symptoms point to layers: a name that won’t resolve (DNS), a refused connection (TCP), a certificate error (TLS), and a 503 (HTTP) are different problems with different owners. Working out which layer is failing is usually the fastest way to cut the search space in half.

02 · Picture it

1HTTPapplication — methods, paths, status codes2TLSsecurity — encryption, server identity3TCPtransport — ports, reliable ordered bytes4IPnetwork — addresses, routing between networks5Ethernet / Wi-Filink — frames on one physical networksending: each layer wraps the data in its own headerreceiving: each layer strips one headerEvery symptom lives at one layer: a DNS failure, a refused connection, a certificateerror and a 503 are four different layers — find the layer first.
1HTTPapplication — methods,paths, status codes2TLSsecurity — encryption,server identity3TCPtransport — ports, reliableordered bytes4IPnetwork — addresses, routingbetween networks5Ethernet / Wi-Filink — frames on onephysical networksending: each layer wraps the data inits own headerreceiving: each layer strips one headerEvery symptom lives at one layer: aDNS failure, a refused connection, acertificate error and a 503 are fourdifferent layers — find the layerfirst.
Each layer only talks to its neighbours, so every failure belongs to one layer.

03 · In the interview

  • Structuring a debugging answer: start at one end of the stack and move one layer at a time, saying what you’ve ruled out.
  • Knowing which tool sees which layer: dig (DNS), ping and traceroute (IP), ss and tcpdump (TCP), openssl s_client (TLS), curl -v (HTTP).

04 · Practice question

“A service can’t reach its database. Walk me through how you’d narrow it down.”

A strong answer covers

  1. Name resolution: does the hostname resolve to the address you expect (dig)?
  2. Reachability: is there a route, and is anything in between dropping traffic (firewalls, security groups)?
  3. Transport: does a TCP connection to the port succeed, get refused (nothing listening), or time out (filtered or dead host)?
  4. Above TCP: TLS errors, authentication failures, or the database refusing connections (for example, a connection limit).
  5. Say which layer you’ve confirmed at each step so the interviewer can follow the elimination.