The TCP/IP Model
The Internet was not built from the OSI model. It grew from the ARPANET's TCP/IP protocol suite, described in RFC 1122 (1989), which uses a simpler model with four layers. Many textbooks use a five-layer hybrid that splits the bottom layer in two.
Mapping the models
| TCP/IP layer | OSI layers | Main protocols |
|---|---|---|
| Application | 5, 6, 7 | HTTP, DNS, SMTP, SSH, TLS, DHCP |
| Transport | 4 | TCP, UDP, QUIC |
| Internet | 3 | IP (v4/v6), ICMP |
| Link (network access) | 1, 2 | Ethernet, Wi-Fi, PPP, ARP |
osi = ["Physical", "Data link", "Network", "Transport", "Session", "Presentation", "Application"]
tcpip = {
"Link": ["Physical", "Data link"],
"Internet": ["Network"],
"Transport": ["Transport"],
"Application": ["Session", "Presentation", "Application"],
}
for layer, covers in reversed(list(tcpip.items())):
nums = [osi.index(c) + 1 for c in covers]
print(f"{layer:<12} = OSI {', '.join(map(str, nums)):<8} ({' + '.join(covers)})")Application = OSI 5, 6, 7 (Session + Presentation + Application)
Transport = OSI 4 (Transport)
Internet = OSI 3 (Network)
Link = OSI 1, 2 (Physical + Data link)
The hourglass
The TCP/IP stack is often drawn as an hourglass. At the top there are thousands of applications; at the bottom, dozens of link technologies (Ethernet, Wi-Fi, 5G, fibre, satellite). In the narrow waist there is essentially one protocol: IP. Anything that can carry IP packets can join the Internet, and anything that speaks IP can use every network. This is why the Internet could adopt Wi-Fi and smartphones without redesigning HTTP.
stack = {
"Application": ["HTTP", "DNS", "SMTP", "SSH", "DHCP", "NTP"],
"Transport": ["TCP", "UDP", "QUIC"],
"Internet": ["IP"],
"Link": ["Ethernet", "Wi-Fi", "LTE/5G", "DOCSIS", "PPP"],
}
for layer, protocols in stack.items():
line = " ".join(protocols)
print(f"{layer:>11} | {line:^40} |")Application | HTTP DNS SMTP SSH DHCP NTP |
Transport | TCP UDP QUIC |
Internet | IP |
Link | Ethernet Wi-Fi LTE/5G DOCSIS PPP |
Which transport does each application use?
Applications pick a transport protocol depending on what they need. TCP gives a reliable, ordered byte stream; UDP gives fast, independent messages with no guarantees. Some well-known choices:
apps = [
("HTTP/1.1, HTTP/2", "TCP", 80, "pages must arrive complete and in order"),
("HTTP/3", "UDP", 443, "runs QUIC, which adds its own reliability"),
("DNS query", "UDP", 53, "one small question, one small answer"),
("SSH", "TCP", 22, "an interactive session must not lose keystrokes"),
("DHCP", "UDP", 67, "the client has no IP address yet"),
("Video call media", "UDP", None, "late data is useless, so don't wait for resends"),
]
for name, transport, port, why in apps:
port_text = str(port) if port else "dynamic"
print(f"{name:<17} {transport} port {port_text:<8} {why}")HTTP/1.1, HTTP/2 TCP port 80 pages must arrive complete and in order
HTTP/3 UDP port 443 runs QUIC, which adds its own reliability
DNS query UDP port 53 one small question, one small answer
SSH TCP port 22 an interactive session must not lose keystrokes
DHCP UDP port 67 the client has no IP address yet
Video call media UDP port dynamic late data is useless, so don't wait for resends
Where each layer runs
An important practical difference: who implements each layer.
| Layer | Implemented in |
|---|---|
| Application | your program (browser, server, library) |
| Transport | the operating system kernel (TCP/UDP), or user space for QUIC |
| Internet | the operating system kernel, and routers |
| Link | the network card's hardware and driver |
Your program talks to the transport layer through the socket API (you will use it in the socket programming lesson). Everything below is handled by the operating system.
End-to-end principle
The TCP/IP design follows the end-to-end principle: keep the network core simple (routers just forward IP packets as best they can) and put intelligence, such as reliability and encryption, in the end hosts. Routers don't know about TCP connections or HTTP requests. That made the Internet cheap to build and easy to extend, but it is also why IP itself is called a best-effort service: packets can be lost, duplicated or reordered, and higher layers must cope.
Tip: In interviews and documentation you'll hear both vocabularies. "Layer 3" always means the OSI network layer (IP). "Layer 7" means the application. Nobody says "TCP/IP layer 2" for transport, so stick with OSI numbers when you use numbers.
Test yourself
Which OSI layers does the TCP/IP Application layer cover?
- Only layer 7
- Layers 5, 6 and 7
- Layers 4 to 7
- Layers 6 and 7
What protocol forms the 'narrow waist' of the Internet hourglass?
- TCP
- Ethernet
- IP
- HTTP
Why does DNS usually use UDP?
- UDP is encrypted
- A query and answer are single small messages, so a connection setup would waste time
- TCP cannot carry text
- Routers block TCP