Contents
Explainers

The OSI Model and TCP/IP Layers Explained

Why networks are built in layers, what each of the seven OSI layers does, how the four-layer TCP/IP model the internet actually uses maps onto it, and how a packet gets wrapped and unwrapped on its way.

Last updated:

Networking is split into layers, where each layer does one job and only talks to the layers directly above and below it. The two models you’ll hear about are the seven-layer OSI model (a reference framework) and the four-layer TCP/IP model (what the internet actually runs on). On the way out, each layer wraps the data in its own “envelope” (a header); on the way in, the layers peel those envelopes off again in reverse. Once layers click, phrases like “layer 3 switch”, “layer 7 proxy” or “a VPN works at layer 3” start to make sense.

Illustration: a letter goes into an envelope, the envelope into a box, the box onto a truck; on the other side the steps run in reverse
  1. ① Application: the letterThe content itself — HTTP and other app data
  2. ② Transport: the envelopeAdds the TCP header — which program gets it (port)
  3. ③ Network: the boxAdds the IP header — which machine it goes to (IP address)
  4. ④ Link & physical: the truckAdds the frame header and goes out as signals
  5. ⑤ Receiver: unwrap in reverseUnpacks layer by layer until the letter is read

Why layers?

Think about sending a parcel:

  • You write the letter and don’t care how it travels;
  • The courier picks it up and sticks on a shipping label, without reading the letter;
  • The sorting centre only reads the destination city and decides where it goes next;
  • The truck driver just drives to the next depot.

Each role sticks to its own job and hands off through agreed formats — the envelope, the label. Network layers work the same way, and that pays off in three ways:

  1. Layers can be swapped independently: moving from Ethernet to Wi-Fi only changes the bottom two layers; your browser doesn’t notice;
  2. Problems are easier to pin down: you can check layer by layer — a loose cable (physical), a wrong IP (network), or a broken website (application);
  3. Work can be divided: web developers don’t need to understand fibre optics, and router makers don’t need to know HTML.

The seven OSI layers

The OSI model, from the International Organization for Standardization, has seven layers, numbered from the bottom up:

LayerNameWhat it doesCommon protocols / standardsUnit of data
7ApplicationNetwork services for programs: web, email, name lookupsHTTP, DNS, SMTP, FTPData
6PresentationData formats, encoding, compression and encryptionTLS encryption, UTF-8, JPEGData
5SessionOpens, maintains and closes a “session”Session management, RPCData
4TransportEnd-to-end delivery: ports pick the program; reliable or low-latencyTCP, UDPSegment
3NetworkIP addresses for addressing across networks and choosing a path (routing)IP, ICMPPacket
2Data linkDelivers data to the next device on the same local network using MAC addressesEthernet, Wi-Fi (802.11)Frame
1PhysicalTurns 0s and 1s into electrical, light or radio signalsCopper cable, fibre, radioBit

A classic mnemonic, bottom to top: Please Do Not Throw Sausage Pizza Away.

TCP/IP: the four layers the internet actually uses

OSI is detailed, but what actually runs on the internet is the TCP/IP suite, which folds the seven layers into four:

TCP/IP layerOSI equivalentKey protocols
ApplicationApplication + presentation + session (5–7)HTTP, DNS, TLS
TransportTransport (4)TCP, UDP
InternetNetwork (3)IP, ICMP
Link (network access)Data link + physical (1–2)Ethernet, Wi-Fi

In practice people mix the two: they describe how protocols behave with the four-layer model, but say which layer a device or technology works at using OSI’s numbers.

Encapsulation: one envelope per layer

When data goes out, each layer it passes through adds its own header in front with the information that layer needs. The link layer also adds a trailer at the end for error checking:

Application HTTP data Data Transport TCP hdr HTTP data Segment: adds ports Network IP hdr TCP hdr HTTP data Packet: adds IPs Link Frame hdr IP hdr TCP hdr HTTP data Trailer Frame: MACs
The lower the layer, the more envelopes wrap the data — the actual content (the HTTP data) always stays in the middle.
HeaderWhat’s in itWho reads it
TCP headerSource port, destination port, sequence and acknowledgement numbersThe operating systems at each end
IP headerSource IP, destination IP, time to live (TTL)Every router along the way
Frame header / trailerSource MAC, destination MAC; the trailer holds a checksumThe next device on the same local network

A packet’s full trip through the layers

Put the sender, one router along the way and the receiver side by side, and you can see exactly what each layer does and when:

Sender (your PC) Router Receiver (server) SENDER: WRAP, TOP TO BOTTOM Application: HTTP request 1 Transport: add TCP header 2 Network: add IP header 3 Link: add frame header 4 Physical: send as signals 5 ROUTER: UNWRAP ONLY TO LAYER 3 Strip frame, read IP 6 Route, add new frame 7 Forward to next hop 8 RECEIVER: UNWRAP, BOTTOM TO TOP Link: check MAC, strip 9 Network: check IP, strip 10 Transport: port → program 11 Application: read request 12
The sender adds a header at each layer on the way down, a router only unwraps as far as the network layer, and the receiver strips headers on the way up.
StepWhereWhat happens
① HTTP requestSender · applicationThe browser writes the request — “please send the home page”
② Add TCP headerSender · transportAdds source and destination ports (e.g. 443) plus sequence numbers for ordering and retransmission
③ Add IP headerSender · networkAdds its own IP and the site’s IP — this decides which machine the packet is for
④ Add frame headerSender · linkAdds its own MAC and the MAC of the next hop (usually your home router)
⑤ Send signalsSender · physicalThe network card sends the whole frame as electrical or radio signals
⑥ Strip frame, read IPRouterRemoves the frame header and reads only the destination in the IP header — it never looks at TCP or HTTP
⑦ Route, add new frameRouterPicks the next hop, wraps the packet in a new frame (new source and destination MACs), and decrements the TTL
⑧ ForwardRouter → next stopThis repeats at every router until the packet reaches the destination network
⑨ Check MAC, stripReceiver · linkConfirms the frame is addressed to it, verifies the checksum, removes header and trailer
⑩ Check IP, stripReceiver · networkConfirms the destination IP is its own and removes the IP header
⑪ Port → programReceiver · transportHands the data to the program on port 443, reassembles it in order, and sends acknowledgements
⑫ Read the requestReceiver · applicationThe web server has the complete request and starts preparing the page

Look at steps ⑥ and ⑦: a router only unwraps as far as the network layer. All it cares about is where the packet is going — it has no need to read the page inside. That’s layering doing its job.

Devices and technologies by layer

LayerTypical devicesNotes
PhysicalCables, fibre, modems, hubsCarry signals without understanding them
Data linkSwitches, network cards, Wi-Fi access pointsRead MAC addresses and forward within a local network
NetworkRouters, layer 3 switchesRead IP addresses and forward between networks
Transport and upFirewalls, load balancers, proxy serversCan see ports or even application content, and allow, distribute or forward by rule

You can place proxies and VPNs, coming up later in this series, on the same table: most proxies work at the application or session layer, while a typical VPN wraps whole IP packets at the network layer.

FAQ

OSI or TCP/IP — which one is "right"?

The internet actually runs on the TCP/IP protocol suite, so use the four-layer model to understand how things really work. OSI's seven layers are a finer-grained reference, and people still use its numbers to say where something operates — "layer 3 switch", "layer 7 load balancer".

Which layer is TLS in?

Sources disagree. TLS sits above TCP and below HTTP, so the TCP/IP model usually lumps it into the application layer; by OSI's division of labour its encryption work belongs to the presentation layer, and some put it in the session layer. Knowing where it sits — between TCP and HTTP — matters more than the number.

What do "layer 2" and "layer 3" devices mean?

How far up the stack a device looks. A layer 2 device (an ordinary switch) only reads MAC addresses and forwards within one local network; a layer 3 device (a router) reads IP addresses and can forward between networks.

Don't have Pangolin yet?

Available for iPhone / iPad, Mac, Windows and Android. New accounts get a free 7-day Pro trial.

Download the app
← All posts