The OSI Model

Seven layers that describe how data moves from one application to another across a network.

What Is the OSI Model?

The Open Systems Interconnection (OSI) model is a reference framework published by ISO. It splits network communication into seven layers. Each layer has one job, serves the layer above it, and relies on the layer below it.

Real networks run on the TCP/IP suite rather than OSI protocols. Engineers still use OSI terms every day, though: "that's a Layer 2 problem," "a Layer 4 load balancer," "a Layer 7 firewall."

Memory trick (Layer 7 down to 1): All People Seem To Need Data Processing: Application, Presentation, Session, Transport, Network, Data Link, Physical.
Layer 1 up to 7: Please Do Not Throw Sausage Pizza Away.

The 7 Layers

7 · Application Data
6 · Presentation Data
5 · Session Data
4 · Transport Segment / Datagram
3 · Network Packet
2 · Data Link Frame
1 · Physical Bits
#LayerJobExamplesDevices
7ApplicationNetwork services for applicationsHTTP, HTTPS, DNS, SMTP, SSH, FTP, DHCP, SNMPL7 firewall, proxy
6PresentationFormatting, encryption, compressionTLS, JPEG, ASCII, UTF-8—
5SessionOpens, manages and closes sessionsNetBIOS, RPC, SQL sessions—
4TransportEnd-to-end delivery, ports, reliabilityTCP, UDPStateful firewall, L4 load balancer
3NetworkLogical addressing and routingIPv4, IPv6, ICMP, OSPF, BGPRouter, L3 switch
2Data LinkMAC addressing, framing, error detectionEthernet, 802.1Q, ARP*, STP, Wi-Fi (802.11)Switch, bridge, NIC
1PhysicalBits on the wireCopper, fiber, radio, RJ45, SFPCable, hub, repeater, transceiver

*ARP sits between Layers 2 and 3. It maps IP addresses to MAC addresses. Most people file it under Layer 2.

Layer by Layer

Layer 1: Physical

Moves raw bits as electrical signals, light, or radio waves. Covers cable types, connectors, voltages, speed and duplex.

Layer 2: Data Link

Delivers frames between devices on the same local network using 48-bit MAC addresses, for example 00:1A:2B:3C:4D:5E. Ethernet adds a frame check sequence (FCS) so corrupted frames get dropped.

Layer 3: Network

Moves packets between networks using IP addresses. Routers read the destination IP and pick a path from their routing table.

Layer 4: Transport

Delivers data between applications using port numbers.

TCPUDP
ConnectionConnection-oriented (3-way handshake: SYN, SYN-ACK, ACK)Connectionless
ReliabilityAcknowledgements, retransmission, orderingBest effort
Flow controlYes (windowing)No
Used byHTTP/S (80/443), SSH (22), SMTP (25)DNS (53), DHCP (67/68), SNMP (161), VoIP

Layer 5: Session

Sets up, keeps track of, and tears down sessions between applications, including checkpoints and recovery. Modern protocols usually handle this inside the application.

Layer 6: Presentation

Makes sure the receiver can read the data: character encoding, compression, and encryption. TLS encryption is often described as a Layer 6 job.

Layer 7: Application

The protocols applications use to talk over the network. When you load https://networking.joeit.net, your browser uses DNS to find the IP and HTTPS to fetch the page.

Encapsulation

As data goes down the stack on the sender, each layer adds its own header. This is called encapsulation. The receiver strips the headers as the data goes back up (de-encapsulation).

Application data:                              [ DATA ]
L4 adds TCP header (ports):           [ TCP | DATA ]                 = Segment
L3 adds IP header (IPs):         [ IP | TCP | DATA ]                 = Packet
L2 adds Ethernet header/trailer: [ ETH | IP | TCP | DATA | FCS ]     = Frame
L1 sends it as:                  10110010 01101... = Bits

Key point: At each router hop, the Layer 2 frame is rebuilt with new source and destination MAC addresses. The Layer 3 source and destination IPs stay the same (unless NAT is used).

OSI vs TCP/IP

OSITCP/IP model
7 Application, 6 Presentation, 5 SessionApplication
4 TransportTransport
3 NetworkInternet
2 Data Link, 1 PhysicalNetwork Access (Link)

Troubleshooting with the OSI Model

Three common approaches:

L1  show interfaces status          ! is the link up? errors?
L2  show mac address-table          ! is the MAC learned in the right VLAN?
L3  ping 8.8.8.8 / show ip route    ! do we have a route and a reply?
L4  telnet host 443 / nc -zv host 443   ! is the port open?
L7  curl -I https://host            ! does the app respond?

Check Yourself

1. What is the PDU at Layer 3?A packet.
2. A switch makes forwarding decisions using which address?The destination MAC address (Layer 2).
3. Which layer uses port numbers?Layer 4, Transport (TCP/UDP).
4. A user can ping a server but the website won't load. Which layers should you check next?Layer 4 (is TCP 80/443 open or blocked by a firewall?) and Layer 7 (is the web service running?).
5. As a packet crosses a router, which addresses change?The source and destination MAC addresses change. The IP addresses stay the same unless NAT is in use.
← Home Next: Routing & Switching →