The 4-layer TCP/IP model
The TCP/IP model is the standard way to think about how networking software is structured. Splitting work into layers makes the system manageable: each layer has one job and talks only to the layers above and below.
The four layers
From top (closest to the user) to bottom (closest to the wire):
- Application layer — what the user-facing program produces.
- Transport layer — reliable end-to-end delivery between processes.
- Internet (Network) layer — addressing and routing across networks.
- Link (Network access) layer — physical wires, radios, frames, MAC addresses.
Each layer adds its own header to the data as it travels down the stack on the sender, and removes that header on the way up the stack at the receiver.
Layer 1: Application layer
Where user-facing protocols live: HTTP, HTTPS, FTP, SMTP, IMAP, POP3, DNS, SSH.
- Generates the actual content (a web page request, an email).
- Hands the data to the transport layer.
Layer 2: Transport layer
Provides end-to-end connection between processes on different hosts.
- TCP for reliable, in-order delivery (HTTP, FTP, SMTP).
- UDP for fast, connectionless delivery (DNS queries, streaming).
- Adds port number to direct data to the right process (e.g. port 80 = HTTP, 443 = HTTPS, 25 = SMTP).
Layer 3: Internet (Network) layer
Routes packets across networks.
- IP is the dominant protocol — adds source and destination IP addresses to each packet.
- Routers operate at this layer, choosing the next hop toward the destination.
Layer 4: Link (Network access) layer
The lowest layer — physical and immediate-network details.
- Ethernet, Wi-Fi — frame formats, MAC addresses for hop-by-hop delivery on a local link.
- Hardware drivers, NICs (network interface cards).
Encapsulation — adding headers
When you send a web request, each layer wraps the data:
Application: "GET / HTTP/1.1\nHost: example.com\n..."
↓ (HTTP request)
Transport: [TCP header | HTTP request]
↓
Internet: [IP header | TCP header | HTTP request]
↓
Link: [Ethernet header | IP header | TCP header | HTTP request | Ethernet trailer]
↓
Wire / Air
At the receiver, each layer reads (and removes) its own header before passing up.
Why layer at all?
- Modularity — replace one layer (Wi-Fi instead of Ethernet) without changing others.
- Abstraction — application programmers don't worry about radio frequencies; routing engineers don't worry about email format.
- Standardisation — different vendors implement different layers and they still interoperate.
Mapping protocols to layers
| Layer | Protocols |
|---|---|
| Application | HTTP, HTTPS, FTP, SMTP, IMAP, POP3, DNS, SSH |
| Transport | TCP, UDP |
| Internet | IP (v4 and v6), ICMP |
| Link | Ethernet, Wi-Fi (802.11), Bluetooth |
✦Worked example— Worked example — sending an email
You send an email from your laptop to your friend's mailbox:
- Application — your email client speaks SMTP to your mail server.
- Transport — TCP chunks the SMTP exchange into reliable packets, port 25 (or 587).
- Internet — IP addresses each packet (your laptop's IP → mail server's IP) and routes it.
- Link — Wi-Fi frames carry packets to your home router, then Ethernet carries them onward.
At the mail server, each layer unwraps until SMTP arrives at the application.
Hardware that operates at each layer
- Hub — link layer (forwards bits to all ports — obsolete).
- Switch — link layer (forwards frames based on MAC address).
- Router — internet layer (routes packets based on IP address).
- Firewall / proxy — typically internet/transport, sometimes application.
⚠Common mistakes— Pitfalls
- Confusing TCP/IP with OSI. OSI has 7 layers; TCP/IP has 4. Both teach the same idea — layering.
- Putting protocols on the wrong layer. SMTP is application; IP is internet. Memorise the table.
- Saying "the application layer is the application". It's the layer that handles application protocols, not the running app itself.
- Saying packets contain headers from one layer. They contain headers from every layer above the link.
- Calling Wi-Fi a transport-layer protocol. It's link layer.
➜Try this— Quick check
Match each to its layer:
- TCP → transport.
- HTTP → application.
- IP → internet.
- Ethernet → link.
- DNS → application.
- UDP → transport.
AI-generated · claude-opus-4-7 · v3-deep-computer-science