Skip to main content
Foundations: web, servers, containersLesson 2 of 13

Under One Request: TCP/IP Layers

When You Type an Address showed a request going from the browser to a server. This lesson opens that arrow. Follow one connection to 203.0.113.10:443 through the TCP/IP layers: what each layer adds, which address it uses, and where it breaks.

LayerApplication (OSI 7)
Addresses203.0.113.10:443
TTL—
TCP stateCLOSED
Your LAN · 192.168.1.0/24Server networkClient192.168.1.20SwitchBy MACRouterDefault gatewayInternetRouter hopsFirewallAllow · dropServer203.0.113.10nginxListens :443
RequestResponse / reportWatchAppears in a later step

What you will learn

  • Each layer wraps the data in its own header: segment, packet, frame
  • The routing table and the default gateway pick the next hop
  • ARP finds the MAC address of that next hop
  • The three-way handshake and how lost data is resent
  • Refused vs timed out, and the MTU black hole

Layers, units and addresses​

TCP/IP layerOSI layerUnitAddressExample tool
Application7 (5–7)Message (HTTP request)URL, host namecurl -v
Transport4Segment (TCP)Portss -tlnp
Internet3PacketIP addressip route, traceroute
Link2 (and 1)FrameMAC addressip neigh, tcpdump -e

Refused or timed out?​

SymptomWhat happenedCheck
Connection refused, instantlyHost replied RST: nothing listens on that port and addressss -tlnp on the server. Is the app up, on the right port, bound to 0.0.0.0 and not only 127.0.0.1?
Connection timed out, after a long waitSYN got no answer: dropped on the pathFirewall rules, security groups, routes (traceroute)
No route to hostA router or firewall sent back an ICMP error, or ARP for the next hop got no answerip route, ip neigh, the host is up
Connects, then large responses hangPath MTU smaller than the packets, and the ICMP that would say so is blockedping -M do -s 1472 <host>, tunnel MTU, MSS clamping

Try it yourself​

ip route # default via <gateway> — where off-subnet traffic goes
ip neigh # ARP / neighbor cache: IP → MAC on this LAN
traceroute -n <host> # each router hop (uses TTL expiry)
ss -tlnp # listening TCP sockets and the process holding each (run on the server)
curl -v http://<host>:8080/ # "Connected to" vs "Connection refused" vs timeout
sudo tcpdump -ni any 'tcp port 443 and tcp[tcpflags] & (tcp-syn|tcp-rst) != 0' # watch SYN, SYN-ACK and RST

Check yourself

  1. curl to port 8080 fails instantly with "Connection refused". What should you check first?
  2. A packet travels across 12 routers to the server. What normally changes at every hop?
  3. Over a VPN, the connection opens and small requests work, but large downloads stall. What is the most likely cause?

Further reading: RFC 9293: TCP · RFC 791: IP · RFC 826: ARP · RFC 1191: Path MTU Discovery · ip-route(8) · ss(8) · When You Type an Address · A Packet from Pod to Pod