Routelearn.net
Course menu

Unit 3: Network ModelsLesson 3.1 (1 of 3 in this unit)13 of 84 in the Network Fundamentals course

The OSI Model

Learn how networking is split into seven layers, what each layer does, which protocols and devices work at each one, and how the layers work together when a laptop opens a website.

Beginner · 20 min read · Before this: What Is a Computer Network?

The OSI (Open Systems Interconnection) model is a seven-layer reference model that divides network communication into the Physical, Data Link, Network, Transport, Session, Presentation and Application layers, each providing services to the layer above it.

In simple terms: The OSI model breaks the job of sending data into seven smaller jobs, one per layer. It gives everyone a shared way to say where a protocol, a device or a problem fits.

Opening a website involves several separate jobs: requesting the page, protecting the connection, delivering the data, choosing a route and transmitting signals. Layers organise those jobs, and each layer uses the service of the layer below it. By the end of this lesson, you should be able to answer four questions:

  • What does each of the seven layers do, and what is its unit of data (PDU)?
  • Which protocols and devices work at each layer?
  • Where do MAC addresses, IP addresses and ports fit?
  • What happens, layer by layer, when a laptop opens a website?

💡 In simple terms: sending data is like sending a parcel. The contents, the packaging, the delivery address and the van each do a different job, and none of them needs to know how the others work.

Why a layered model?

In the 1970s, every computer maker had its own networking system, and systems from different makers could not talk to each other. The OSI (Open Systems Interconnection) model was published by the ISO in 1984 as a common, vendor-neutral way to describe networking. Splitting the work into layers solves several problems:

Mix and match. Wi-Fi can replace Ethernet at layers 1 and 2 without changing your browser at layer 7.
Vendors can work together. A switch from one company and a NIC from another agree on layer 2 standards.
Easier to learn. You can study one layer at a time without knowing everything at once.
Easier to troubleshoot. “The link light is on, but I have no IP address” points you to layer 3, not layer 1.

OSI is a reference model: a way to describe and discuss networking. The protocols that actually run the internet come from the TCP/IP suite.

Learn more: The TCP/IP Model

The seven layers at a glance

OSI is numbered from Physical (1) at the bottom to Application (7) at the top. Data goes down the layers on the sender and up the layers on the receiver.

  1. 7ApplicationData

    Gives programs a way onto the network: the requests and replies they send.

    e.g. HTTP, HTTPS, DNS, DHCP, SSH, SMTP

  2. 6PresentationData

    Agrees how data is written: character sets, compression and encryption.

    e.g. UTF-8, JPEG, MP4, TLS encryption

  3. 5SessionData

    Opens, keeps track of and closes conversations between programs.

    e.g. RPC, NetBIOS, SOCKS

  4. 4TransportSegment (TCP) / Datagram (UDP)

    Gets data to the right program (port) on the other device; TCP adds reliability.

    e.g. TCP, UDP

  5. 3NetworkPacket

    Logical (IP) addresses, and choosing a path from one network to another.

    e.g. IPv4, IPv6, ICMP, OSPF

  6. 2Data LinkFrame

    Moves frames across one local link using MAC addresses, and checks for errors.

    e.g. Ethernet (802.3), Wi-Fi (802.11), PPP

  7. 1PhysicalBits

    Turns bits into signals and back: voltage on copper, light in fibre, radio waves.

    e.g. Copper (1000BASE-T), fibre, Wi-Fi radio, connectors

The seven OSI layers, from 7 (closest to the user) down to 1 (the wire).

A PDU (protocol data unit) is the name for a unit of data at a given layer. Using the right name tells people which layer you mean: a frame is layer 2, a packet is layer 3.

💡 Memory trick from layer 7 down: "All People Seem To Need Data Processing". From layer 1 up: "Please Do Not Throw Sausage Pizza Away".

The layers are functional categories. Real protocols don't always fit neatly into one layer, especially at layers 5 to 7.

Each layer in detail

Each card shows the layer's job, its PDU, example protocols, the devices that work at that layer, and what it does when you open a web page.

7Layer 7: Application

Gives applications access to network services: asking for a web page, looking up a name, sending an email.

PDU
Data
Protocols
HTTP, HTTPS, DNS, DHCP, SMTP, IMAP, FTP, SSH
Devices
Hosts (PCs, servers); firewalls and proxies that inspect applications
Real example
Your browser sends the HTTP request “GET /index.html” to the web server.

6Layer 6: Presentation

Makes sure both sides understand the data: character encoding, data formats, compression and encryption.

PDU
Data
Protocols
Formats such as UTF-8, JPEG, MPEG; TLS encryption is often placed here
Devices
Hosts
Real example
The page is encoded as UTF-8 text and encrypted with TLS before it leaves the server.

5Layer 5: Session

Opens, manages and closes conversations (sessions) between applications, and can resume them after a break.

PDU
Data
Protocols
Session functions of RPC, NetBIOS, SMB, TLS session resumption
Devices
Hosts
Real example
Your login to a web app stays open while you click between pages, and is ended when you log out.

4Layer 4: Transport

Delivers data between the right applications on two hosts, using port numbers. TCP adds reliability and ordering.

PDU
Segment (TCP) or datagram (UDP)
Protocols
TCP, UDP (and QUIC, built on UDP)
Devices
Hosts; firewalls and NAT routers read ports
Real example
Your PC sends from port 51524 to the server’s port 443, and resends any segment that gets lost.

3Layer 3: Network

Moves packets between different networks using logical (IP) addresses, choosing a route hop by hop.

PDU
Packet
Protocols
IPv4, IPv6, ICMP; routing protocols such as OSPF and BGP
Devices
Routers, Layer 3 switches, firewalls
Real example
Your packet carries source 192.168.1.20 and destination 203.0.113.20, and each router picks the next hop.

2Layer 2: Data Link

Delivers frames across one local link using MAC addresses, and detects damaged frames.

PDU
Frame
Protocols
Ethernet (802.3), Wi-Fi (802.11), PPP; ARP (finds the MAC address for an IP address)
Devices
Switches, wireless access points, network interface cards (NICs)
Real example
Your laptop puts the packet in a frame addressed to the home router’s MAC address 02:00:00:00:00:01.

1Layer 1: Physical

Turns bits into signals and back: voltages on copper, light in fibre, radio waves in the air. Defines cables, connectors and speeds.

PDU
Bits
Protocols
Ethernet physical standards (1000BASE-T, 10GBASE-SR), Wi-Fi radio, DSL, fibre
Devices
Cables, connectors, hubs, repeaters, transceivers, modems
Real example
The frame leaves your laptop as bits carried on Wi-Fi radio waves and reaches the router’s antenna.

Layer 7: what “Application” really means

Application-layer protocols define the service being requested: HTTP requests a page, DNS asks for an address, DHCP requests IP settings and SSH provides secure remote access. The browser itself is an application that uses these protocols; it is not “in” layer 7.

Learn more: HTTP: How the Web TalksDNSDHCP

Layers 6 and 5: real but blurry

The Presentation and Session layers deal with how information is represented or protected, and how a conversation is managed. In TCP/IP, applications and supporting protocols do these jobs, so don't expect a separate layer 5 or layer 6 header in every packet. TLS, for example, protects many connections, but calling it “only layer 6” oversimplifies its role.

Learn more: HTTPS and TLS

Layer 4: TCP and UDP

The transport layer delivers data between applications on two hosts:

TCPUDP
StyleConnection-oriented byte streamConnectionless datagrams
Delivery & orderReliable and in orderNot guaranteed by UDP itself
Lost dataRetransmittedNo built-in retransmission
PortsYesYes

Applications can add their own reliability on top of UDP, so “uses UDP” doesn't always mean “unreliable”.

Learn more: What the Transport Layer Does

Layers 3, 2 and 1: getting there

Layer 3, Network: IP addresses identify interfaces across networks, and routers use the destination IP and their routing table to choose where a packet goes next. Layer 2, Data Link: on an Ethernet LAN, frames carry source and destination MAC addresses, and switches use their MAC address table to forward them. Layer 1, Physical: the frame is sent as signals over copper, fibre or radio. A damaged cable or the wrong optical transceiver stops everything before the higher layers get a chance to work.

Which devices work at which layer?

A device is usually described by the highest layer it reads to make its forwarding decision. Watch how far “up” each device looks:

LaptopL1–L7Switchreads L2Routerreads L3Firewallreads L3–L7Web serverL1–L7
  1. 1. Switch: layer 2. It reads only the destination MAC address in the frame and forwards the frame out of the right port.
  2. 2. Router: layer 3. It removes the frame, reads the destination IP address, chooses the next hop and builds a new frame.
  3. 3. Firewall: layers 3 to 7. It checks the IP addresses and the TCP port. A modern firewall may also inspect the application data.
  4. 4. Hosts: all seven. The web server unwraps every layer to reach the HTTP request itself.
LayerDevices
1 PhysicalCables, connectors, hubs, repeaters, media converters, modems
2 Data LinkSwitches, access points, NICs
3 NetworkRouters, Layer 3 switches
4 to 7Firewalls, load balancers, proxies, and every host

Real devices often work at several layers at once. A home router, for example, is a switch (L2), a router (L3) and a firewall with NAT (L3/L4) in one box.

Learn more: Comparing Network Devices

MAC address, IP address and port: different jobs

IdentifierLayerWhat it identifies
MAC address2The sender or next recipient on one local link
IP address3A network interface across an IP network
TCP/UDP port4An application endpoint or service

An HTTPS connection might look like this:

FieldExample
Client IP192.168.1.20
Server IP203.0.113.20
Client source port51524 (temporary)
Server destination port443
TransportTCP

The reply reverses the ports: source port 443, destination port 51524. (203.0.113.20 is a documentation address, not a live server.)

Common protocols and ports

Port numbers belong to the transport protocols (TCP and UDP), not to the OSI layers in general.

ServiceTransportPort
HTTPTCP80
HTTPS (HTTP/1.1, HTTP/2)TCP443
HTTPS (HTTP/3)QUIC over UDP443
DNSUDP and TCP53
SSHTCP22
DHCPv4 server / clientUDP67 / 68

These are common defaults, not proof of which application sent a packet, because services can run on other ports. ICMP (used by ping) has no ports at all: it is carried directly inside IP.

Learn more: Common Ports to Know

Encapsulation: wrapping data for delivery

On the way down the sender's stack, each protocol adds its own control information, usually a header. This is called encapsulation. On the way up, the receiver removes each header again. This is de-encapsulation (also called decapsulation). Each layer reads only its own header, as if it were talking directly to the same layer on the other device.

Step 1 of 17

You type a message. The chat app hands it to the network stack.

Your laptopSee you at 6!Encapsulation ↓Chat serverSee you at 6!De-encapsulation ↑7Application6Presentation5Session4Transport3Network2Data Link1Physical7Application6Presentation5Session4Transport3Network2Data Link1PhysicalHTTPDataHTTPDataHTTPDataformatted (e.g. encrypted)HTTPDataformatted (e.g. encrypted)HTTPDatasession trackedHTTPDatasession trackedTCPHTTPDataTCPHTTPDataIPTCPHTTPDataIPTCPHTTPDataEthIPTCPHTTPDataFCSEthIPTCPHTTPDataFCS0110 1001 1100…0110 1001 1100…Networks and routers
Each layer adds its own header on the way down and removes it on the way up. Ethernet is the only one here that also adds a trailer: the FCS, an error check at the end of the frame.

The short version, with the name of the data unit at each stage:

Data: The application produces data, such as an HTTPS request.

  1. Data · application
  2. Segment · transport
  3. Packet · network
  4. Frame · data link

Data: The application produces data, such as an HTTPS request. Segment: TCP adds a header with the source and destination ports. Packet: IP adds a header with the source and destination IP addresses. Frame: Ethernet adds MAC addresses in front and an error check (FCS) at the end.

On the way out each layer wraps the one above it; the receiver unwraps them in reverse (decapsulation).
StageUnitWhat's added
ApplicationDataThe request or response content
TCPSegment (UDP: datagram)Ports, sequence numbers and other TCP fields
IPPacketSource and destination IP addresses
EthernetFrameMAC addresses, EtherType and an error-check trailer
PhysicalBitsLink-specific signalling

Here's what the finished Ethernet frame looks like:

Preamble7 BSync pattern
SFD1 BStart of frame
Destination MAC6 BWho it's for
Source MAC6 BWho sent it
EtherType2 Be.g. 0x0800 = IPv4
Payload46–1500 BIP packet (+ padding)
FCS4 BError check (CRC)
On the wire only (8 B)
Ethernet header: 14 B
Frame: 64–1518 bytes (destination MAC → FCS)
Ethernet II frame. The preamble and SFD are transmitted before the frame but aren't counted in its size. Payloads under 46 bytes are padded; 802.1Q VLAN tags add 4 bytes.

This is simplified: HTTPS also adds TLS protection, and a large message is split across many packets. The encapsulation lesson follows every header as it is added and removed, with real addresses, and shows what changes at a router.

Learn more: Encapsulation and De-encapsulation

OSI compared with TCP/IP

TCP/IP is the protocol suite the internet actually runs on. Its common model has four layers. You can switch the diagram to the five-layer view that many courses use:

OSI ↔ TCP/IP (4-layer view)
7ApplicationHTTP, DNS, DHCP, SSH
6PresentationEncoding, compression, encryption
5SessionSetting up and ending sessions
4TransportTCP, UDP · ports
3NetworkIPv4, IPv6, ICMP · routers
2Data LinkEthernet, Wi-Fi · MAC · switches
1PhysicalCables, fibre, radio · bits
Application
Transport
Internet
Link / Network Access
The mapping is a teaching approximation, not an exact equivalence. Always check which model a diagram uses.
OSI layersTCP/IP layerExamples
7, 6, 5ApplicationHTTP, DNS, DHCP, SSH, plus security and session functions
4TransportTCP, UDP
3InternetIPv4, IPv6, ICMP
2, 1Link / Network AccessEthernet, Wi-Fi, physical transmission

Use OSI numbers to talk about problems, and TCP/IP to understand what actually runs.

Learn more: The TCP/IP Model

A laptop opens a website

Assume the laptop already has working IP settings and the site uses HTTPS over TCP. Select any step to see which layers are involved.

Step 1 of 9 · DNS query
Laptop
DNS server
Gateway
Web server

1. DNS query · Application · UDP 53

What's the address of example.com?

Tap this step's arrow for the details.

Logical view: DNS traffic to a remote resolver also passes through the gateway. HTTP/3 replaces the TCP and TLS steps with QUIC over UDP, which builds in TLS.

Name resolution → next hop → transport → security and the application.

In order, the important steps are:

  1. Name resolution: get the server's IP address, unless it is already cached.
  2. Next-hop choice: is the destination local, or does it need the gateway?
  3. Local delivery: find the next hop's MAC address with ARP if needed.
  4. Transport setup: open the TCP connection.
  5. Security and application: negotiate TLS and send the HTTP request.

A later lesson follows the same request packet by packet.

Learn more: What Happens When You Open a Website?

When a layer fails

Each layer depends on the one below it, so a failure at a low layer breaks everything above it. A failure at a high layer leaves the lower layers working:

LayerExample symptomCheck
PhysicalNo link lightCable, power, fibre, transceiver, interface status
Data linkLink up, but local devices unreachableWi-Fi association, switch port, MAC learning, interface errors
NetworkOther networks unreachableIP address, mask, gateway, routes
TransportHost reachable, service isn'tIs the service listening? Is the port filtered?
ApplicationConnects, but the request failsDNS, certificates, authentication, application logs

Troubleshooting with the layers

Many engineers check from the bottom up: they prove that each layer works before moving to the next one. Useful commands on a Windows PC:

LayerCommandWhat it proves
1–2ipconfig /all, netsh wlan show interfacesThe adapter is connected and has a MAC address
2–3arp -aThe PC has learned the gateway's MAC address
3ping 192.168.1.1, tracert 203.0.113.20IP packets reach the gateway and beyond
4Test-NetConnection host -Port 443A TCP connection to the service opens
7nslookup example.com, the browserDNS answers and the application responds

PowerShell's Test-NetConnection tests DNS (layer 7), IP (layer 3) and TCP (layer 4) in one command:

Example output from Windows PowerShell, written for this lesson (documentation addresses)
PS C:\> Test-NetConnection example.com -Port 443

ComputerName     : example.com
RemoteAddress    : 203.0.113.20
RemotePort       : 443
InterfaceAlias   : Wi-Fi
SourceAddress    : 192.168.1.20
TcpTestSucceeded : True
What to look for: a value in RemoteAddress means DNS (layer 7) turned the name into an IP address. SourceAddress shows the PC's own IP address (layer 3). TcpTestSucceeded : True means a TCP connection to port 443 opened (layer 4); False would point to a closed or filtered port. If the website still fails, look at TLS or the application itself.

A successful ping tests only layers 1 to 3: it doesn't prove that HTTPS on port 443 works.

Learn more: Bottom-Up, Top-Down, Divide and ConquerA Troubleshooting Method

Common mistakes

  • Thinking every packet has seven headers. Real traffic uses TCP/IP, and layers 5 and 6 rarely have a header of their own.
  • Calling everything a “packet”. A frame is layer 2, a packet is layer 3 and a segment is layer 4. Using the right word shows which layer you mean.
  • Saying a switch works at layer 3. A normal switch forwards frames using MAC addresses (layer 2). Only a Layer 3 (multilayer) switch can also route.
  • Placing ports at layer 3. Ports belong to TCP and UDP at layer 4; IP addresses are layer 3.
  • Treating the browser as “the application layer”. The browser is an application that uses layer 7 protocols such as HTTP and DNS.
  • Forcing every protocol into one layer. ARP sits between layers 2 and 3, and TLS spans layers 5 to 7. The model is a guide, not a strict rule.
✅ Key takeaways
  • OSI has seven layers: Physical, Data Link, Network, Transport, Session, Presentation and Application.
  • PDUs: bits (1), frame (2), packet (3), segment or datagram (4), data (5–7).
  • Switches work at layer 2, routers at layer 3, firewalls at layers 3 to 7; hosts use all seven.
  • MAC addresses, IP addresses and ports do different jobs at layers 2, 3 and 4.
  • The sender wraps data in headers; the receiver removes them in reverse order.
  • OSI is the shared vocabulary; TCP/IP (taught with four or five layers) is what actually runs.
  • Layer models are a guide; not every protocol fits exactly one layer.

Knowledge check: which layer?

Predict · scenario 1

A laptop's Ethernet port shows no link light at all. At which layer should you start looking?

Predict · scenario 2

A PC can ping the web server's IP, but the website won't load in the browser.

Predict · scenario 3

A router receives data from one network and must forward it to another. What is the layer 3 PDU it works with, and which addresses does it read?

Predict · scenario 4

A frame arrives on one port and must be forwarded out of the correct port inside the same LAN, using the destination MAC address. Which device does this?

Predict · scenario 5

Users can reach websites by IP address but not by name. Which layer and service is the most likely cause?

Where to go next

Continue with The TCP/IP model to see the four layers that really run the internet, then Encapsulation and de-encapsulation to watch each header being added and removed. For layer 2 details, read Ethernet fundamentals and MAC addresses.

FAQ

Do I need to memorise both models?
Yes. Engineers use the OSI layer numbers as shared vocabulary when troubleshooting, for example "that's a layer 2 issue". The TCP/IP model describes the protocols that actually run. Learn both, and learn how their layers map to each other.
Is TCP/IP four layers or five?
The original model has four layers: Application, Transport, Internet and Link. Many courses, including CCNA material, split Link into Data Link and Physical, which gives five. Neither is wrong; check which version a diagram or exam question uses.
Why do two models even exist?
OSI came from a standards body (the ISO) that designed a vendor-neutral reference model. TCP/IP grew out of the protocols that people actually built and deployed. TCP/IP won in practice, and OSI became the shared vocabulary.
What is a "layer 8" problem?
It is engineers' humour for user error. The joke is that the problem sits above layer 7, with the person using the device, so it isn't in the network at all.