How TCP/IP and OSI Models Differ
Why the Internet runs on 4 TCP/IP layers, not 7 OSI layers. A real packet passing through each layer, with commands you can run to verify.
What happens when you open a website
You type thomas-labs.com into your browser, press Enter, and the page appears. On a day when the company network is slow, you can’t open it and don’t know who to ask: is DNS broken, is the cable disconnected, or is the server down? Those three things lie at different points along the packet’s path. Without a way to divide the work, you’d have to search from start to finish.
Layering is that division: each layer handles one job and only talks to the layer directly above and below it.
There are two common ways to divide. The OSI model has 7 layers. The TCP/IP model has 4 layers. This post puts them side by side and shows why the software you run every day is organized according to TCP/IP.
Seven layers and four layers
OSI (Open Systems Interconnection) is a reference model published by ISO, dividing network communication into 7 layers: Physical, Data Link, Network, Transport, Session, Presentation, Application. It was born as a standard design for vendors to write networking software that could talk to each other.
TCP/IP is the protocol suite that ARPANET and then the Internet actually used, grouped into 4 layers: Network Access (also called Link), Internet, Transport, Application.
The diagram below shows which layers merge into which.
graph LR
subgraph OSI["OSI: 7 layers"]
A7["Application"]
A6["Presentation"]
A5["Session"]
A4["Transport"]
A3["Network"]
A2["Data Link"]
A1["Physical"]
end
subgraph TCPIP["TCP/IP: 4 layers"]
B4["Application"]
B3["Transport"]
B2["Internet"]
B1["Network Access"]
end
A7 --> B4
A6 --> B4
A5 --> B4
A4 --> B3
A3 --> B2
A2 --> B1
A1 --> B1
The top three OSI layers merge into Application. The bottom two merge into Network Access.
Why merge? Because the boundary between Session and Presentation hardly exists in real software. HTTP handles data formatting itself (headers, charset) and handles sessions itself (cookies, keep-alive) inside it. No software sits separately at the Session layer. A layer with no one working there isn’t worth keeping.
A real packet passing through each layer
Run this command in your terminal:
$ curl -sI https://thomas-labs.com/ | head -1
HTTP/2 200
Before the line HTTP/2 200 appears, three things have happened: your machine asks DNS what IP thomas-labs.com is, opens a TCP connection to that IP on port 443, then sends an HTTP request over that connection. Each thing belongs to a different layer.
See the DNS step with dig:
$ dig thomas-labs.com +short
185.199.111.153
185.199.109.153
185.199.108.153
185.199.110.153
These four addresses are GitHub Pages servers, where thomas-labs.com is hosted. I ran the command above and got exactly those four lines. When you run it again you might see a different order, because DNS returns a group of servers and your machine uses one.
dig sends a DNS query over UDP to port 53 of the name server. UDP is a Transport layer protocol with no handshake, no guarantee of delivery: suitable for short queries, if lost, ask again. DNS and HTTP are Application layer protocols. IP is the Internet layer protocol handling addressing and routing. Ethernet or Wi-Fi is the Network Access layer handling sending bits over wire or air.
Each layer wraps the same data in an extra shell. The diagram below shows the wrapping order as the packet leaves your machine.
sequenceDiagram participant App as Application (HTTP) participant Trans as Transport (TCP) participant Net as Internet (IP) participant Link as Network Access (Ethernet) App->>Trans: GET / HTTP/2 (with headers) Trans->>Net: TCP segment (port 443) Net->>Link: IP packet (source IP, dest IP) Link->>Link: Ethernet frame (source MAC, dest MAC)
With each wrap, the lower layer doesn’t need to understand the upper layer’s content. The network card only needs MAC addresses to forward the frame to the next machine. The router only needs to read the IP address in the packet. Thanks to that, you can swap Wi-Fi for fiber and HTTP above doesn’t know a thing.
The diagram below arranges those headers in the exact order they appear in the final packet, read from left to right.
graph LR L["Ethernet header<br/>source MAC, dest MAC"] --> I["IP header<br/>source IP, dest IP"] I --> T["TCP header<br/>source port, dest port"] T --> D["HTTP data<br/>GET / HTTP/2"]
Why the Internet chose TCP/IP
TCP/IP came first, worked, and was built into operating systems. OSI came later as a design slowly realized.
TCP/IP design assumes the network will fail: packets lost, links broken, machines dead. It pushes most of the complexity to the two ends (sender and receiver), so the middle (routers) only does one simple job: forward packets. You see the trace in that TCP retransmits when packets are lost, while IP promises nothing. Routers need no connection state.
OSI remains the shared vocabulary. When someone says “layer 2 error” or “layer 7 attack”, they’re using OSI to point to where the problem is. But real software is organized according to TCP/IP.
Comparison table
| TCP/IP | Corresponding OSI | What it does | Protocols you meet daily |
|---|---|---|---|
| Application | Application, Presentation, Session | Speak the application language | HTTP, HTTPS, DNS, SSH |
| Transport | Transport | Multiplex between processes, fix errors | TCP, UDP |
| Internet | Network | Address and route | IP, ICMP |
| Network Access | Data Link, Physical | Send bits over wire or air | Ethernet, Wi-Fi |
One easy confusion: DNS port 53 and HTTPS port 443 are at the Transport layer, not Application. Port numbers are how TCP and UDP distinguish multiple programs on the same machine. Domain names and request syntax are Application matters.
When you read error logs
curl: (6) Could not resolve host is a DNS error. curl: (7) Failed to connect is TCP failing to open, meaning Transport or Internet. ping runs over ICMP, the Internet layer; being able to ping doesn’t mean DNS or HTTPS works. Knowing which layer the packet is at narrows down where to look, instead of searching from the start.
OSI gives you the vocabulary to say where the problem is; TCP/IP is the map of running software. A layer only deserves to exist when something actually works there.