loc bengaluru, ist | local --:-- srijanshukla18@gmail.com →
[post]/you-a-junior-infra-techie/networking

networking

/ 5 min read· infra

My mental model of networking from IP packets to HTTP, written down for juniors with a postal-system analogy. IP is the address, TCP/UDP the postage, DNS the phone book, TLS the sealed envelope, HTTP the letter.

I’ve found it a lil tough to translate my mental model about networking into words for juniors. I can explain it to them fine on a call, but I’m making up half the analogies on the fly when I do that. So writing this down properly once.

If you are a junior SRE or backend dev working in the cloud, the easiest way to picture how networking layers fit together from IP packets up to HTTP is a postal system.

Data travels across the internet in small chunks called packets, and each networking layer adds one specific thing on top:

1. IP (Internet Protocol) = the address on the envelope (Layer 3)

IP’s only job is routing packets from one machine to another across networks.

Every machine on a network gets an IP address (like 10.0.1.45 internally or 203.0.113.5 publicly). Routers along the way look at the destination IP address and forward the packet one hop closer.

Note that raw IP is best-effort. It just tosses the envelope toward the destination - it doesn’t care if packets get dropped, duplicated, or arrive out of order.

How this shows up in AWS/cloud:

  • VPC (Virtual Private Cloud) & Subnets: Your private neighborhood of IP addresses (e.g. 10.0.0.0/16).
  • Route Tables: Rules telling the subnet where to send packets next.
  • NAT Gateway: Lets private-subnet servers talk out to the internet using one shared public IP, while blocking random people on the internet from initiating connections inward.

2. TCP vs UDP = how you mail it (Layer 4)

IP only gets a packet to the right machine (the IP address). Ports (like :443 or :5432) tell the OS which specific process on that machine should get the packet. And TCP / UDP sit at Layer 4 to decide how delivery works:

  • TCP (Transmission Control Protocol): Like registered mail with return receipts. Before sending data, client and server do a 3-way handshake (SYN, SYN-ACK, ACK). Every packet is numbered, the receiver acknowledges what it got, lost packets get retransmitted automatically, and bytes are handed to your app in exact order. Use this for almost everything: HTTP, Postgres, SSH, Redis.
  • UDP (User Datagram Protocol): Fire and forget. No handshake, no retries, no ordering. If packet #4 drops, UDP doesn’t stop and wait for it, it just keeps going with packet #5. Why would you want that? Live video/audio (WebRTC), gaming, DNS queries - where waiting 200ms to retransmit an old frame is worse than just dropping it and showing the current frame.

In the cloud: Security Groups (stateful firewalls) and NLBs (Network Load Balancers) operate here on IP + Port + Protocol (TCP/UDP).

3. DNS = the phonebook

Humans remember api.srijanshukla.com, routers only care about 203.0.113.5.

DNS (Domain Name System) translates the domain name into the IP address before your browser or app can open a TCP connection. In AWS this is Route 53, in GCP it’s Cloud DNS, and inside a Kubernetes cluster it’s CoreDNS (resolving stuff like my-svc.default.svc.cluster.local).

4. TLS / SSL = sealing the envelope

Plain TCP sends bytes in cleartext - anyone sitting on the network path (Wi-Fi router, ISP, middleboxes) can read the packets.

TLS runs a cryptographic handshake right after the TCP handshake: the server proves its identity using a certificate (e.g. from AWS ACM or Let’s Encrypt), both sides agree on a symmetric session key, and everything after that is encrypted on the wire.

5. HTTP = the actual letter inside (Layer 7)

Once TCP has a reliable pipe open and TLS has encrypted it, the two apps still need to agree on how to format requests and responses. That’s HTTP:

  • Request: GET /writing HTTP/1.1, headers (Host, Authorization), body
  • Response: status code (200 OK, 502 Bad Gateway), headers, response body

In the cloud: ALBs (Application Load Balancers), API Gateways, and CDNs (CloudFront / Cloudflare) sit at Layer 7 because they actually read the HTTP hostname, URL path (/api/v1/*), and headers to route or cache traffic.

Putting it all together (curl https://example.com/health)

Every time you run that curl, these steps happen in exact order:

  1. DNS lookup (UDP :53): Ask DNS resolver “what is the IP for example.com?” -> gets back 93.184.216.34.
  2. TCP handshake (TCP :443): Send SYN to 93.184.216.34:443, get SYN-ACK, send ACK. Connection is open.
  3. TLS handshake: Verify server cert, agree on encryption keys.
  4. HTTP request: Send encrypted GET /health over the connection -> server sends back 200 OK.

Whenever you’re debugging a network failure in prod, walk up that exact stack from bottom to top: did DNS resolve? Can TCP connect to the IP:port (Security Group / NACL / route table)? Did TLS fail (expired cert / wrong hostname)? Or did the app return an HTTP 5xx?