Networking 2: TCP, UDP and Ports
How programs talk over the network — ports and sockets, TCP's reliable delivery, UDP's speed, and NAT.
- Module 4 of 8
- Intermediate
- 12 chapters
- 1 h
Addresses get data to the right machine; ports and TCP get it to the right program, complete and in order. Timeouts, dropped connections and “connection refused” all start here.
What you will be able to do
- Explain ports and sockets
- Walk through the TCP handshake and how TCP keeps its promise
- Choose between TCP and UDP for a given job
- Explain NAT, firewalls and what each new connection costs
Chapters
1. PortsThe IP address is the building (03networking1addresses.md Ch 4).5 min2. Sockets: How a Program Uses the Network"Address already in use" when starting a server — another process is already listening on that port.5 min3. UDP: Fast Postcards, No GuaranteesA postcard: you write it, drop it in the box, done. No envelope, no tracking, no confirmation. Usually2 min4. TCP: The PromiseA registered courier with a phone line. Before sending anything, the courier phones the receiver:3 min5. The Three-Way HandshakeSYN flood: an attacker sends huge numbers of SYNs and never completes the handshake, filling the4 min6. How TCP Keeps Its PromiseSequence number — the number of the first byte in each segment (bytes are numbered, not packets).4 min7. Flow Control and Congestion ControlFlow control protects the receiver. Every ACK carries a receive window: "I have room for this3 min8. Closing and Connection StatesFIN ("finish") — the polite close: "I have no more data to send." Each direction closes separately,3 min9. Head-of-Line Blocking and QUICA single-lane road. The truck at the front breaks down. Every car behind it stops — even cars going to2 min10. NAT: Many Private Devices, One Public AddressNAT tables have timeouts. Idle entries are removed, and the connection silently dies — the5 min11. FirewallsA firewall allows or blocks traffic using rules based on source/destination IP address (or CIDR3 min12. What Connections Cost: Round Trips, Keep-Alive and PoolsLatency — how long one trip takes. Bandwidth = how much data per second the link can carry. A5 min
Extras
The Whole StoryThe whole module retold as one story — no new facts, a fast revision of Networking 2: TCP, UDP and Ports.RevisionInterview QuestionsReal interview questions on Networking 2: TCP, UDP and Ports, answered the way you would say them out loud.Interview prepQuick ReferenceGlossary and cheat sheet for Networking 2: TCP, UDP and Ports — the page to reread before an interview.Reference