// learn Β· networking Β· 8 min

The OSI & TCP/IP layers, animated.

Two famous models describe how data turns into bits on the wire. Watch a packet get wrapped layer by layer at the sender, ride the wire, then unwrap layer by layer at the receiver β€” and see how OSI's 7 layers and TCP/IP's 4 layers describe the same thing.

OSI seven-layer model and TCP/IP four-layer model animated tutorial. Encapsulation walkthrough from application data through Ethernet frame, then decapsulation at the receiver. Covers headers for TCP, IP, and Ethernet plus port, IP-address, and MAC-address concepts.
// osi & tcp/ip layers

A packet wrapped layer by layer at the sender, transmitted, then unwrapped layer by layer at the receiver. Watch the headers stack and peel off.

// before you start
you should know
  • Β·Rough sense of what an IP address is
  • Β·Have heard of TCP and UDP, even vaguely
  • Β·Helpful: the URL flow lesson β€” it shows TCP and IP in context
by the end you'll

Name every OSI layer in order. Explain what header each layer adds, and why IP and MAC addresses serve different purposes.

pace: 8 minutes

// 7 OSI layers, top to bottom: 7 Application, 6 Presentation, 5 Session, 4 Transport, 3 Network, 2 Data Link, 1 Physical. TCP/IP groups layers 5–7 as "Application" and layers 1–2 as "Link".

osi & tcp/ip β€” step 1 / 6 Β· the layers
SENDER7ApplicationHTTP, DNS, SSHApp6PresentationTLS, encodingApp5Sessionsockets, RPCApp4TransportTCP, UDP, portsTransport3NetworkIP, routingInternet2Data LinkEthernet, MACLink1Physicalcables, signalsLinkRECEIVER7ApplicationHTTP, DNS, SSHApp6PresentationTLS, encodingApp5Sessionsockets, RPCApp4TransportTCP, UDP, portsTransport3NetworkIP, routingInternet2Data LinkEthernet, MACLink1Physicalcables, signalsLink(no packet yet)β–’β–’β–’ PHYSICAL WIRE β–’β–’β–’

Two models, same packet

Two famous models describe the same thing: how data turns into bits on the wire. OSI splits it into 7 layers (1 = Physical at the bottom, 7 = Application at the top). TCP/IP groups them into 4 (Link, Internet, Transport, Application). Same packet, different labels.

// key insight

Each layer only talks to the layers next to it. The Transport layer knows nothing about the cable or the Wi-Fi chip. The Network layer knows nothing about your TCP sequence numbers. That isolation is why you can replace one part of the stack β€” swap Ethernet for Wi-Fi, swap TCP for QUIC, swap HTTP for SSH β€” without rewriting the rest.

// exam-ready Β· what each layer adds and how to inspect it
$L7 Application
$L6 Presentation
$L5 Session
$L4 Transport
$L3 Network
$L2 Data Link
$L1 Physical
$TCP/IP : Link
$TCP/IP : Internet
$TCP/IP : Transport
$TCP/IP : Application
$tcpdump -i any -nn
$ss -tlnp
$ip route
$ip neighbor
$ip -s link
// check yourself
4 quick questions
Q1

Which OSI layer adds the source and destination IP addresses?

Q2

Why does a packet need BOTH an IP address and a MAC address?

Q3

Which best describes the difference between TCP and UDP?

Q4

At which OSI layers do switches and routers operate?

These aren't graded β€” they're just for active recall, which is what actually makes the lesson stick.

πŸ§…
// now poke at the layers

Network tools

ping (L3), traceroute (L3), DNS lookup (L7), MTU check (L2/L3), and more. Each one operates at a specific layer β€” try them while picturing where in the stack you are.

open β†’
// more in networking

keep going β€” these pair well with what you just learned.

see all networking β†’
all lessonstry the network tools