Sub topic 11
Where the mapping blurs: ARP, ICMP, TLS, and the five-layer hybrid
This chapter assumes you know the four TCP/IP layers (link, internet, transport, application) and the seven OSI layers. It also assumes you understand encapsulation and the basic job of each layer. Here you will look at the protocols that do not sit cleanly in one layer, and at why that is acceptable.
Why the mapping is only approximate
The OSI model was written as a design reference before most of today's protocols existed. The TCP/IP model was written afterward, to describe protocols that already worked. The two were never drawn up together, so the boundaries do not match exactly.
The clean version of the mapping looks like this:
| TCP/IP layer | OSI layers |
|---|---|
| Application | 7 Application, 6 Presentation, 5 Session |
| Transport | 4 Transport |
| Internet | 3 Network |
| Link | 2 Data link, 1 Physical |
This table is a useful default. It fails in three kinds of places:
- Protocols that serve one layer but depend on another (ARP, ICMP).
- Protocols that do the work of several OSI layers at once (TLS).
- Layers that one model has and the other leaves out (the OSI presentation and session layers, and the physical layer).
A layer is a role, not a law. When a protocol straddles two roles, the useful question is "what does it do for its neighbors?" The question "which box is it in?" is less useful.
ARP: between layer 2 and layer 3
The Address Resolution Protocol (ARP) maps an IPv4 address to a MAC address on the local network. A host that wants to send an IP packet to 192.168.1.1 must put a destination MAC address in the Ethernet frame. ARP finds it.
ARP is hard to place for these reasons:
- It exists to serve IP, which is layer 3.
- It does not travel inside an IP packet. An ARP message is carried directly in an Ethernet frame, with EtherType
0x0806. IP uses0x0800. - It uses link-layer addresses and only works within one broadcast domain. Routers do not forward ARP requests.
Most textbooks put ARP at layer 2 because of how it is carried. Others put it at "layer 2.5" because it connects layer 3 addresses to layer 2 addresses. In the TCP/IP model it belongs to the link layer, since it never leaves the local link.
You can see ARP at work on Linux:
ip neigh showEach line shows an IP address, the interface, and the MAC address that ARP learned. If the state is FAILED or INCOMPLETE, the host sent a request and nobody answered.
IPv6 has no ARP. Its Neighbor Discovery Protocol (NDP) does the same job, and it uses ICMPv6 messages carried inside IPv6 packets. So the same function lives at a different place depending on the IP version, which shows that the placement is a historical detail and not a fixed rule.
ICMP: a layer 3 protocol that rides on IP
The Internet Control Message Protocol (ICMP) reports errors and answers diagnostic queries. Examples are "destination unreachable", "time exceeded", and the echo request and reply behind ping.
ICMP is hard to place because it points two ways:
- It is carried inside an IP packet, with IP protocol number 1. That looks like a protocol sitting above IP, as TCP and UDP do.
- It exists only to support IP. Routers and hosts generate it as part of the work of forwarding packets, and it has no application data of its own.
The standard answer is that ICMP is a layer 3 protocol. It is an integral part of the internet layer even though it is encapsulated in IP. In the TCP/IP model it belongs to the internet layer. Some diagrams draw it slightly above IP to show the encapsulation. Both drawings are in use, so you should recognize both.
ICMP messages also contain part of the packet that caused the error. A "port unreachable" message includes the original IP header and the first bytes of the original datagram. The sender uses this to match the error to a socket, so ICMP depends on transport layer information.
traceroute uses this behavior across layers. It sends packets with a small TTL (a field in the IP header) and reads the ICMP "time exceeded" replies:
traceroute -n 192.0.2.10Each hop that returns a reply identifies a router on the path. Firewalls that drop ICMP make hops show up as * * *.
TLS: several OSI layers in one protocol
Transport Layer Security (TLS) encrypts and authenticates a connection. It is the hardest common protocol to place, and the answer depends on which model you ask.
Consider what TLS does:
- It runs on top of TCP and uses TCP as a reliable byte stream.
- Applications such as HTTP run on top of TLS.
- It negotiates parameters and keeps state for the connection (session-like behavior).
- It encodes and encrypts data (presentation-like behavior).
- Its name contains "Transport", but it does not move segments between hosts.
| View | Placement of TLS |
|---|---|
| Strict OSI | Layer 6 (presentation), with parts at layer 5 (session) |
| TCP/IP | Application layer, because it is a protocol that runs above transport |
| Informal | "Layer 4.5", between transport and application |
The practical point is that TLS is implemented in application space. A library such as OpenSSL runs inside the program, and the kernel's TCP stack knows nothing about it. TCP sees TLS records as opaque bytes. This supports the TCP/IP placement.
The mapping is imprecise here because OSI separates session management, data representation, and application logic into three layers. Real protocols mostly combine them. TLS is one example, and HTTP is another: HTTP has its own connection reuse (session-like) and content encoding (presentation-like) features.
Related protocols have a similar problem:
- QUIC runs on top of UDP, but it provides reliability, congestion control, and encryption. It does transport-layer work from the application's point of view, yet it is built as a library over UDP.
- VPN protocols such as WireGuard carry IP packets inside UDP packets. A packet at layer 3 is the payload of layer 4, which inverts the usual order.
- Tunnels in general (GRE, IP-in-IP) put one layer inside another of the same kind.
The five-layer hybrid
Many textbooks and courses use a five-layer model. It keeps the four TCP/IP layers but splits the link layer in two:
| Layer | Name | Example |
|---|---|---|
| 5 | Application | HTTP, DNS, TLS |
| 4 | Transport | TCP, UDP |
| 3 | Network (internet) | IP, ICMP |
| 2 | Data link | Ethernet, Wi-Fi (MAC), ARP |
| 1 | Physical | Cables, radio, signaling |
This hybrid has become popular for these reasons:
- It keeps the number-based vocabulary of OSI for lower layers. Engineers say "layer 2 switch" and "layer 3 router" and "layer 4 load balancer" regardless of the model they learned.
- It separates the physical medium from frame formats and addressing. This matters because hardware faults and framing faults need different fixes.
- It drops OSI layers 5 and 6, which real protocols rarely implement as separate software.
The hybrid is not an official standard. Do not expect every source to agree on it. When you read an exam question or a vendor document, check which model it uses before you count layers.
Layer numbers in everyday use
Common phrases depend on the OSI numbering, and they are only loosely accurate:
- A "layer 2 switch" forwards by MAC address.
- A "layer 3 switch" or router forwards by IP address.
- A "layer 4 load balancer" decides using IP addresses and TCP or UDP ports.
- A "layer 7 load balancer" or "application gateway" reads HTTP headers, paths, or cookies. The "7" here means "application", not a strict OSI claim.
These terms describe which header the device inspects. A device that reads TLS Server Name Indication to route traffic is hard to describe by number. Most people call it layer 7 anyway.
Edge cases and common mistakes
- Treating the table as a rule. If a protocol seems to fit two boxes, describe what it does and what it relies on. This is more accurate than forcing a label.
- Saying ICMP is a transport protocol. It has no ports and does not carry application data, so it does not do the job of the transport layer, even though it has an IP protocol number like TCP and UDP.
- Saying ARP uses IP. ARP does not use IP. If it did, a host would need a MAC address to send the request that finds a MAC address.
- Assuming TLS is part of TCP. The two are separate. A TCP connection can exist without TLS. TLS can also run over other reliable transports.
- Assuming a strict one-to-one pairing of OSI and TCP/IP layers. OSI layers 5 and 6 have no counterpart in TCP/IP. They are folded into the application layer.
- Forgetting that the physical layer is outside TCP/IP. The four-layer model starts at the link layer and does not define cables or signals.
Checking your understanding
Exercise
A colleague says "ARP is a layer 3 protocol because it deals with IP addresses." Give two facts that argue for placing ARP at layer 2 (the link layer) instead, and explain what makes the placement debatable.
Show answer
First, ARP messages are carried directly in Ethernet frames (EtherType 0x0806), not inside IP packets. Second, ARP only works within a single broadcast domain, and routers do not forward it, so it never leaves the local link. It is debatable because ARP exists to translate layer 3 addresses (IPv4) into layer 2 addresses (MAC), so it serves layer 3 while operating at layer 2. Some sources call it "layer 2.5" for this reason.
Exercise
TLS runs on top of TCP and below HTTP. Name the placement of TLS in the strict OSI model and in the TCP/IP model, and give one implementation fact that supports the TCP/IP placement.
Show answer
In OSI, TLS is usually placed at layer 6 (presentation), with some session behavior from layer 5. In TCP/IP, it belongs to the application layer. Supporting fact: TLS is implemented in user space by a library such as OpenSSL inside the application, and the operating system's TCP stack treats TLS records as ordinary payload bytes.
Exercise
You run ip neigh show and see 192.168.1.1 dev eth0 FAILED. Which layer in the five-layer hybrid is the most likely location of the problem, and which layer-3 test would you try next to separate a local-link fault from a routing fault?
Show answer
The most likely location is layer 2 (data link), because the host sent ARP requests for the gateway and received no reply. To separate the cases, ping another host on the same subnet, if one exists. If that works, the problem is specific to the gateway. If nothing on the subnet answers, check the link and the interface first. A routing fault would not produce a FAILED ARP entry for an on-link neighbor, because ARP happens before any routing beyond the local subnet.