Sub topic 9
Putting the Two Models Side by Side
This chapter assumes you can name the seven OSI layers and the four TCP/IP layers, and that you know what encapsulation is. It does not repeat how each layer works. It shows how the two models line up, why they line up the way they do, and how to use the mapping without being misled by it.
Why two models exist
The OSI reference model was written as a design framework before most of today's protocols were finished. Its seven layers describe the functions a network needs. The TCP/IP model was written afterward to describe protocols already running on the internet. It has four layers, and each layer is defined by the protocols that live in it.
This difference in origin explains most of the mismatches. OSI asks "what jobs must be done?" TCP/IP asks "what do these protocols do?" When you map one to the other, you are matching a functional taxonomy against a protocol-driven one.
The mapping table
Here is the standard mapping, with example protocols.
| TCP/IP layer | OSI layer(s) | Example protocols and technologies |
|---|---|---|
| Application | 7 Application, 6 Presentation, 5 Session | HTTP, DNS, SMTP, TLS, SSH |
| Transport | 4 Transport | TCP, UDP |
| Internet | 3 Network | IPv4, IPv6, ICMP |
| Link | 2 Data Link, 1 Physical | Ethernet, Wi-Fi, ARP |
Three of the four TCP/IP layers map cleanly to one or two OSI layers. The pairing at the top and the bottom is where the two models differ in granularity.
Layer by layer
Link layer = OSI layers 1 and 2
The TCP/IP link layer covers everything needed to move a frame across one network segment. In OSI terms that is the Physical layer (signals, cables, radio) and the Data Link layer (framing, MAC addressing, local delivery).
TCP/IP does not subdivide this. The model's authors treated "whatever gets a packet across the local link" as a black box. That is why you will see the link layer described as "network access" or "network interface" in some texts. It is also why Ethernet, a standard that spans both OSI layers 1 and 2, fits in one box.
Internet layer = OSI layer 3
This is the cleanest match. Both models place logical addressing and routing here. IP is the defining protocol. A router makes its forwarding decision using only information at this layer.
Transport layer = OSI layer 4
Another clean match. Both models place end-to-end delivery between processes here, using ports to tell applications apart. TCP and UDP live at this layer in both models.
Application layer = OSI layers 5, 6, and 7
TCP/IP merges three OSI layers into one. OSI separates them like this:
- Session (5): setting up, managing, and ending dialogs between applications.
- Presentation (6): data representation, such as character encoding, serialization, and encryption.
- Application (7): the protocols that applications use directly.
In TCP/IP, none of these three jobs gets its own layer. The application itself, or a library it uses, handles them. A web browser using HTTPS handles encoding (presentation), maintains cookies and connection state (session), and speaks HTTP (application). All of this happens in one program and one layer of the model.
Why TCP/IP collapses the top and bottom
The reasoning is practical. On the internet, applications are written against the transport layer's interface, which is the socket API. Everything above the socket is the application's business. There is no standard interface between a "session layer" and a "presentation layer" in real software, so a separate layer would describe a boundary that does not exist in code.
The bottom is similar. IP is designed to run over any link technology. The internet layer does not care whether the frame below it travels over copper, fiber, or radio. So the model does not need to distinguish between the physical signal and the frame format.
Using the two vocabularies
Engineers usually mix the vocabularies. They describe protocols with the TCP/IP model but use OSI layer numbers as shorthand. Common examples:
- "Layer 2 switch": a device that forwards frames using MAC addresses.
- "Layer 3 switch" or "router": a device that forwards packets using IP addresses.
- "Layer 4 load balancer": a device that balances by IP address and port, without reading application content.
- "Layer 7 load balancer": a device that reads application data, such as HTTP headers or URLs, to decide where to send a request.
Notice that these numbers come from OSI, but the things they describe are TCP/IP protocols. Nobody says "layer 5 firewall" or "layer 6 load balancer" in practice, because the session and presentation layers have no separate implementation to point at.
Worked example: an HTTPS request
Follow one request and label each header with both models.
| What is in the data | TCP/IP layer | OSI layer |
|---|---|---|
| HTTP request line and headers | Application | 7 |
| TLS record carrying the HTTP data | Application | 6 (approximately) |
| TCP header with source and destination ports | Transport | 4 |
| IP header with source and destination addresses | Internet | 3 |
| Ethernet header with MAC addresses | Link | 2 |
| Electrical or radio signal | Link | 1 |
The TLS row is the awkward one. TLS encrypts and frames data, which sounds like Presentation. But it also negotiates sessions and runs on top of TCP, which sounds like Session or Transport. Different textbooks place it differently. The next chapter covers this in more detail. For this chapter, remember that the table gives an approximate label, not a fact.
A quick check with code
You can see the mapping in a program. The following Python script builds a packet with Scapy, stacking one header per layer, and then prints the layer names it found.
from scapy.all import Ether, IP, TCP
pkt = Ether() / IP(dst="192.0.2.10") / TCP(dport=80, flags="S")
layers = {
"Ether": ("Link", "OSI 2"),
"IP": ("Internet", "OSI 3"),
"TCP": ("Transport", "OSI 4"),
}
layer = pkt
while layer:
name = layer.name
for key, (tcpip, osi) in layers.items():
if layer.__class__.__name__ == key:
print(f"{key:6} -> TCP/IP {tcpip}, {osi}")
layer = layer.payload if layer.payload else None
if layer.__class__.__name__ == "NoPayload":
breakThe output lists Ether, IP, and TCP in order. Scapy has no header for physical signals, because software never sees them. The packet has no application data, so there is nothing to label at the top.
Common mistakes
- Treating the mapping as exact. It is a convention. Several protocols do not fit in a single box, and sources disagree about where to put them.
- Using OSI layer numbers for TCP/IP layers. "Layer 4" always means the OSI transport layer, which corresponds to the TCP/IP transport layer. "Layer 3" means the Network layer, which is the TCP/IP internet layer. TCP/IP layers themselves are usually named rather than numbered.
- Looking for session or presentation code in a TCP/IP stack. You will not find separate modules. Those functions are spread across applications and libraries.
- Assuming a layer boundary means a separate piece of software. Layers are a way to describe responsibilities. The operating system's network stack implements the transport, internet, and link layers. The application layer is the program and its libraries.
- Assuming that a device only handles one layer. A router uses layers 1 to 3. A switch uses layers 1 and 2. A firewall may inspect layers 3 to 7. Each device reads headers up to a certain depth and ignores the rest.
Decision criteria: which model to use
- Use the TCP/IP model when you are describing how real internet software and protocols fit together, or when reading an RFC.
- Use OSI numbers when you need shorthand for where a device or fault sits, such as "a layer 2 problem" or "a layer 7 firewall."
- Use both when training or documenting, and state which one you mean.
Exercise
A load balancer distributes traffic by reading the URL path in each HTTP request. Which OSI layer number do engineers usually call it, and which TCP/IP layer does that correspond to?
Show answer
It is called a layer 7 load balancer. OSI layer 7 is the Application layer, and in TCP/IP that is the Application layer, which also absorbs OSI layers 5 and 6.
Exercise
Why does the TCP/IP model have no separate session or presentation layer?
Show answer
TCP/IP describes real protocols, and applications are written directly against the socket interface of the transport layer. There is no standard boundary in real software between session, presentation, and application functions, so the model keeps them in one application layer.
Exercise
Ethernet is one standard. Which TCP/IP layer contains it, and which OSI layers does it span?
Show answer
It sits in the TCP/IP link layer, which covers OSI layer 1 (Physical) and layer 2 (Data Link).