skipnothing/HTTP & Networking
UNIT 02

Wire & Bytes

TCP handshake, connection lifecycle, UDP, and what packets actually carry

TCP turns an unreliable packet stream into an ordered byte stream. This unit shows the handshake, the windows, the retransmits, and the cases UDP exists for instead.

Loading…
TOPICS
#6

TCP Handshake

Send SYN, SYN-ACK, and ACK across two endpoints, predict which packet flips each side to ESTABLISHED, and read a real tcpdump capture line by line where each ack is the previous seq plus one.

connect() looks instant in your code, but the socket sits quiet for one round trip first, while two machines trade three small messages to agree on where each will start counting bytes.

13 min
#7

Connection Lifecycle

Close each direction of a connection on its own, predict why only the active closer lingers in TIME-WAIT, and read the FIN, RST, and CLOSE-WAIT rows an abort or a leak leaves in ss -tan.

ss -tan can show a socket sitting idle for a full minute after your program moved on: the side that closed first, still answering for a conversation that has already ended.

13 min
#8

Windows & Retransmits

Meter the sender's in-flight bytes against a receive window that shrinks as the receiver's buffer fills, watch three duplicate acknowledgments fire a fast retransmit while a lost tail draws a tail loss probe before the doubling timer, and unshift a scaled win value off tcpdump.

tcpdump prints a line like win 502 on nearly every acknowledgment, and that one field encodes a live ceiling: send past the ceiling and the receiver has offered no room for the bytes, so the sender waits.

13 min
#9

UDP & Connectionless

Strip TCP's twenty-byte header down to UDP's eight, trace a two-packet DNS exchange against TCP's setup-and-teardown, and decide which workloads go connectionless by weighing a resend's wait against a lost message's cost.

dig example.com answers in a single round trip: one packet out, one packet back, and the server holds nothing after it replies. The same fetch over a fresh TCP connection must set the link up before the request can leave.

12 min
#10

MTU & Fragmentation

Size a packet to the smallest link on its path, predict whether an oversize one splits into all-or-nothing fragments or bounces back a too-big report, and read TCP's mss as the handshake-time ceiling that avoids fragmentation, until a filtered report hangs the transfer.

ping -M do -s 1372 example.com goes through, but -s 1373 draws a router's "Frag needed and DF set" reply: one byte past a limit set not by your machine, but by a link somewhere along the way.

12 min
UNLOCKS
All units