ArcLibrary

OSI 7-Layer Model

The textbook standard for network layering — seven layers, each with one job; theoretically clean, engineering reality differs.

OSILayeringBasics
核心 · Key Idea

In one line: The OSI 7-layer model splits networking from "light signals" to "application semantics" into seven layers — physical / link / network / transport / session / presentation / application. Each layer uses only the one below. It's a theoretical model; in practice most vendors run a TCP/IP 5-layer stack.

One-line per layer#

LayerNameJobExamples
7ApplicationBusiness semanticsHTTP / SMTP / DNS / SSH
6PresentationEncoding / encryption / compressionTLS (partly) / JPEG / ASCII
5SessionEstablish / maintain sessionsRPC sessions, SQL sessions
4TransportEnd-to-end reliable or fastTCP / UDP
3NetworkInter-subnet routingIP / ICMP / OSPF
2Data LinkSame-link transportEthernet / Wi-Fi / PPP
1PhysicalBits → signalsCopper / fibre / radio

Analogy#

打个比方 · Analogy

Sending a letter:

  • Physical = postal trucks / roads;
  • Link = local courier;
  • Network = inter-city postal routing;
  • Transport = "guaranteed signature" (TCP) vs "lose-it-don't-care" (UDP);
  • Session = "this is our ongoing conversation";
  • Presentation = translation / encryption;
  • Application = the contents of the letter.

Why 5 and 6 are "blurry in practice"#

Presentation and session layers have basically no standalone protocols in TCP/IP. Their functions:

  • Presentation → handled by application protocols themselves (HTTP Content-Encoding / Content-Type, TLS encryption).
  • Session → handled jointly by app + transport (HTTP cookies, TLS session resume).

So engineering's TCP/IP model has only 5 layers (sometimes merged to 4).

Key concepts#

EncapsulationEncapsulation
Each layer adds its header on the way down.
De-encapsulationDe-encapsulation
Each layer peels its header on the way up.
PDUProtocol Data Unit
Each layer's name for its unit: bit / frame / packet / segment / message.
Peer-to-peerPeer-to-peer
Endpoints talk logically at the same layer; lower layers are just couriers.

Troubleshooting with the OSI model#

Layered debugging = bottom-up, eliminate each layer before moving up.

Practical notes#

  • The OSI 7 layers describe; they don't dictate implementation.
  • In practice use TCP/IP: physical / link / network / transport / application.
  • "L4 / L7" are everyday terms: load balancers schedule by L4 (ports) or L7 (HTTP) — commonly asked in interviews.
  • Wireshark / tcpdump expand by layer — OSI is the best frame of reference for capture analysis.

Easy confusions#

OSI 7 layers
Teaching model, theoretically clean.
Presentation / session aren't separately implemented.
TCP/IP 5 layers
Engineering model.
What the real internet runs on.

Further reading#