How the Internet and TCP/IP Work
Learn the layered model, packets, IP, TCP, UDP and the three-way handshake, with a focus on what attackers and defenders see.
Beginner · about 6 hours · difficulty 2/5
You cannot defend a network you do not understand. Every scan, alert and firewall rule is written in the language of TCP/IP.
Layers
The TCP/IP model has four layers: link (Ethernet, Wi-Fi, MAC addresses), internet (IP addresses and routing), transport (TCP and UDP ports) and application (HTTP, DNS, SSH). The seven-layer OSI model is common interview vocabulary; know that "layer 3" means IP and "layer 7" means the application.
TCP vs UDP
- TCP is connection-oriented. The three-way handshake (SYN, SYN-ACK, ACK) sets up a session, then data is ordered and retransmitted. Port scanners abuse this handshake to see which ports are open.
- UDP sends datagrams with no handshake. DNS, VoIP and many games use it. It is easy to spoof, which enables amplification DDoS attacks.
Other pieces you will meet
- ARP maps IPs to MAC addresses on a local network and can be spoofed for man-in-the-middle attacks.
- ICMP carries ping and error messages.
- NAT lets many private devices share one public IP; routers and firewalls sit at these boundaries.
Pitfalls
- Memorizing the OSI model without being able to explain what actually happens when you open a website.
- Assuming a closed port and a filtered port look the same; they do not, and that difference matters when scanning.
Good enough to move on: you can explain, step by step, what packets flow when a browser opens an HTTPS site, from ARP and DNS to the TCP handshake.
Key concepts
- TCP/IP and OSI layers
- IP addressing and routing
- TCP three-way handshake
- UDP and spoofing
- ARP and MAC addresses
- ICMP
- NAT and private ranges
Mini project
Draw the full sequence of packets (ARP, DNS, TCP, TLS, HTTP) for loading a website on your home network, then confirm it with a packet capture later in this section.
Check yourself
What does a port scanner learn from receiving a SYN-ACK versus an RST in reply to a SYN?
Free resources
- Cloudflare Learning: Networking (Cloudflare)
- Computer Networking: A Top-Down Approach resources (Kurose and Ross)
- TryHackMe Networking rooms (TryHackMe)