# 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. Free notes, key concepts,...

Canonical: https://www.internhack.in/roadmaps/tracks/cybersecurity/internet-basics
Last updated: 2026-11-28

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](https://www.cloudflare.com/learning/network-layer/what-is-the-network-layer/) (Cloudflare)
- [Computer Networking: A Top-Down Approach resources](https://gaia.cs.umass.edu/kurose_ross/online_lectures.htm) (Kurose and Ross)
- [TryHackMe Networking rooms](https://tryhackme.com/) (TryHackMe)

Previous: [Active Directory Fundamentals](https://www.internhack.in/roadmaps/tracks/cybersecurity/active-directory-basics) · Next: [Subnetting, Ports and Common Services](https://www.internhack.in/roadmaps/tracks/cybersecurity/subnetting-ports)

## More in Networking for Security

- [How the Internet and TCP/IP Work](https://www.internhack.in/roadmaps/tracks/cybersecurity/internet-basics)
- [Subnetting, Ports and Common Services](https://www.internhack.in/roadmaps/tracks/cybersecurity/subnetting-ports)
- [DNS and How It Gets Abused](https://www.internhack.in/roadmaps/tracks/cybersecurity/dns)
- [HTTP for Security Work](https://www.internhack.in/roadmaps/tracks/cybersecurity/http)
- [TLS and Encryption in Transit](https://www.internhack.in/roadmaps/tracks/cybersecurity/tls)
- [Packet Analysis with Wireshark](https://www.internhack.in/roadmaps/tracks/cybersecurity/wireshark)

## Related

- [Roadmaps](https://www.internhack.in/roadmaps)
- [Cybersecurity Roadmap](https://www.internhack.in/roadmaps/tracks/cybersecurity)
