Computer ScienceCollege

The OSI Model

The Open Systems Interconnection (OSI) model splits network communication into seven layers, each with one clear job, from sending raw bits down a cable (Layer 1) to giving applications network services such as web browsing and email (Layer 7). It gives engineers and students a shared vocabulary for where a protocol, a device or a fault sits.

This guide covers what each layer does, the PDU, protocols and devices at each layer, encapsulation and de-encapsulation, how OSI compares with the TCP/IP model, mnemonics, worked troubleshooting examples, and a 10-question practice quiz.

1Introduction

The OSI reference model was published by the International Organization for Standardization (ISO) in 1984 as ISO 7498. Its goal was to let equipment and software from different vendors work together by agreeing on what each part of the communication process is responsible for.

The key idea is layering. Each layer provides a service to the layer above it and uses the service of the layer below it. A layer only needs to understand its own protocol and the interface to its neighbours. That is why you can swap Wi-Fi for Ethernet (Layers 1 and 2) without changing your browser (Layer 7).

Why Layering Matters

Modularity

Each layer can change independently. IPv6 replaced IPv4 at Layer 3 without changing TCP or HTTP.

Interoperability

Vendors build to standard interfaces, so a phone from one company can talk to a server from another.

Troubleshooting

Technicians test layer by layer (is the cable connected? is there an IP address? does DNS resolve?) to isolate faults quickly.

2Key Definitions

Protocol

A set of rules for formatting and exchanging messages, such as TCP or HTTP

PDU (protocol data unit)

The unit of data at a layer: bits, frame, packet, segment or data

Encapsulation

Each layer wrapping the data from the layer above with its own header (and trailer at Layer 2)

De-encapsulation

The receiver removing headers layer by layer as data moves up the stack

MAC address

A 48-bit hardware address used for delivery on the local link (Layer 2)

IP address

A logical address used to reach hosts across networks (Layer 3)

Port number

A 16-bit number identifying an application process on a host (Layer 4), e.g. 443 for HTTPS

Peer-to-peer communication

Each layer conceptually talks to the same layer on the other host through its header

MTU

Maximum transmission unit: the largest payload a link can carry in one frame (1,500 bytes on standard Ethernet)

TCP/IP model

The four-layer model the internet actually uses: Link, Internet, Transport, Application

3The Seven Layers at a Glance

Layers 5 to 7 are often called the upper (host) layers because they run in software on the end devices. Layers 1 to 4 are the lower (media/transport) layers that move data across the network.

#LayerMain jobPDUExample protocolsDevices
7ApplicationNetwork services for applicationsDataHTTP, DNS, SMTP, FTP, SSH, DHCPHosts, proxies, L7 load balancers
6PresentationFormat, encode, compress, encryptDataTLS (often placed here), UTF-8, JPEG, MPEGHosts
5SessionOpen, manage and close sessionsDataRPC, NetBIOS, PPTPHosts
4TransportProcess-to-process delivery, ports, reliabilitySegment (TCP) / Datagram (UDP)TCP, UDPHosts, firewalls
3NetworkLogical addressing and routing between networksPacketIPv4, IPv6, ICMP, OSPF, IPsecRouters, Layer 3 switches
2Data LinkNode-to-node delivery on one link, MAC addressing, error detectionFrameEthernet (802.3), Wi-Fi (802.11), PPP, VLAN taggingSwitches, bridges, NICs, access points
1PhysicalTransmit raw bits as signalsBitsEthernet cabling standards, DSL, fibre, radioCables, hubs, repeaters, modems

4Layer by Layer

Layer 1: Physical

Turns bits into signals and back: voltage levels on copper, light pulses on fibre, radio waves for Wi-Fi. It defines connectors, cable types, data rates and bit timing. It has no idea what the bits mean. Hubs and repeaters work here: they simply regenerate and repeat signals out of every port.

Layer 2: Data Link

Moves frames between two devices on the same link. It adds source and destination MAC addresses, controls access to the shared medium, and detects (but generally does not correct) transmission errors with a Frame Check Sequence (CRC). IEEE splits it into two sublayers: LLC (Logical Link Control) and MAC (Media Access Control). Switches learn which MAC address is on which port and forward frames only where they need to go.

Layer 3: Network

Gets packets from the source host to the destination host across many networks. It provides logical addressing (IP addresses), routing (choosing a path using routing tables built by protocols such as OSPF), and fragmentation when a packet is too big for a link. The TTL (IPv4) or Hop Limit (IPv6) field stops packets looping forever. ICMP reports errors and powers ping and traceroute.

Layer 4: Transport

Delivers data between processes on two hosts, identified by port numbers. TCP is connection-oriented: three-way handshake (SYN, SYN-ACK, ACK), sequence numbers, acknowledgements, retransmission, flow control (sliding window) and congestion control. UDP is connectionless and has no delivery guarantees, which suits DNS lookups, voice and video calls, and online games where speed matters more than perfect delivery.

Layer 5: Session

Sets up, manages and tears down sessions (dialogues) between applications. It handles dialogue control (who talks when) and checkpointing, so a long transfer can resume from the last checkpoint after a failure. In TCP/IP these duties are mostly handled by the application itself.

Layer 6: Presentation

Makes sure data sent by one system can be read by another: character encoding (ASCII, UTF-8), data formats (JPEG, MPEG), serialisation, compression and encryption. It is sometimes called the “translator” of the network.

Layer 7: Application

The layer users' software talks to: protocols that provide network services such as HTTP (web), DNS (name resolution), SMTP/IMAP (email), FTP (file transfer), SSH (remote login) and DHCP (automatic IP configuration). Note that the browser itself is not Layer 7; the protocols it uses are.

Well-Known Ports Worth Memorising

FTP 20/21 · SSH 22 · SMTP 25 · DNS 53 · HTTP 80 · HTTPS 443. Ports are a Layer 4 concept even though they identify Layer 7 services.

5Encapsulation & De-encapsulation

When you send data, it travels down the stack on your device. Each layer treats everything from above as its payload and adds its own header, a bit like putting a letter in an envelope, then that envelope in a bigger one. At the receiver the data travels up the stack, and each layer reads and strips the header meant for it.

Layers 7–5: application data (e.g. an HTTP request)

Layer 4: TCP header + data = segment (ports, sequence number, checksum)

Layer 3: IP header + segment = packet (source and destination IP, TTL)

Layer 2: Ethernet header + packet + FCS trailer = frame (MAC addresses, error check)

Layer 1: the frame is sent as bits

Interactive: OSI Encapsulation Step-Through

Follow one web request down the sender's seven layers, across the wire as bits, and back up the receiver's stack. Each layer adds (or removes) its own header.

Sender (your laptop)

7Application
6Presentation
5Session
4Transport
3Network
2Data Link
1Physical

Receiver (web server)

7Application
6Presentation
5Session
4Transport
3Network
2Data Link
1Physical

Step 1 / 14 · Encapsulation: travelling down the stack

Layer 7 PDU: Data

Data

The browser creates an HTTP request: GET /index.html. Application-layer protocols (HTTP, DNS, SMTP) define what the message says.

What Changes Hop by Hop?

As a packet crosses routers on its way to a distant server, each router removes the old frame, reads the IP header to choose the next hop, and builds a new frame for the next link. So the MAC addresses change at every hop, while the source and destination IP addresses stay the same end to end (unless NAT rewrites them, as most home routers do for outgoing traffic).

6OSI vs TCP/IP

The TCP/IP model (described in RFC 1122) has four layers and grew out of the protocols that run the internet. OSI was designed as a general model first. The layers line up like this:

OSI layersTCP/IP layerExamples
7 Application, 6 Presentation, 5 SessionApplicationHTTP, DNS, SMTP, TLS
4 TransportTransportTCP, UDP
3 NetworkInternetIP, ICMP
2 Data Link, 1 PhysicalLink (Network Access)Ethernet, Wi-Fi

OSI

  • 7 layers; a reference model
  • Clear split between service, interface and protocol
  • Model designed before its protocols
  • Used for teaching and describing devices

TCP/IP

  • 4 layers; describes the working internet
  • Session and Presentation folded into Application
  • Protocols came first, model described them
  • What real networks implement

Many textbooks also use a five-layer hybrid (Physical, Data Link, Network, Transport, Application), which splits TCP/IP's Link layer back into Physical and Data Link. If a question says “TCP/IP model”, check which version your course uses.

7Worked Examples

Classification

Place Each Item in Its OSI Layer

Cat 6 cable, hub, repeater → Layer 1 (they carry or repeat signals only)

Switch, MAC address, Ethernet frame → Layer 2

Router, IP address, ICMP (ping) → Layer 3

TCP, UDP, port 443 → Layer 4

HTTP, DNS, SMTP → Layer 7

Key insight: ask what the item looks at. A device that reads MAC addresses is Layer 2; one that reads IP addresses is Layer 3.

Calculation

Header Overhead for 1,000 Bytes of Data

An application sends 1,000 bytes over TCP/IPv4/Ethernet with minimum-size headers. How big is the frame, and what fraction is useful data?

Segment: 1,000 + 20 (TCP header) = 1,020 bytes

Packet: 1,020 + 20 (IPv4 header) = 1,040 bytes

Frame: 1,040 + 14 (Ethernet header) + 4 (FCS) = 1,058 bytes

Efficiency: 1,000 / 1,058 ≈ 94.5%

Key insight: the 1,040-byte packet fits within Ethernet's 1,500-byte MTU, so no fragmentation is needed. (On the wire there are also an 8-byte preamble and an inter-frame gap, which some courses include.)

Troubleshooting

Bottom-Up Diagnosis of “The Internet Is Down”

Layer 1: Is the link light on, or is Wi-Fi connected? No link → cable, port or radio problem.

Layer 2: Is the device associated with the right network or VLAN?

Layer 3: Does it have a valid IP address and gateway? Can it ping the gateway, then a public IP?

Layer 4: Is a firewall blocking the port (e.g. 443)?

Layer 7: Pinging an IP works but names fail → DNS problem.

Key insight: each successful test proves every layer below it is working, which is how technicians narrow a fault quickly.

Trace

What Happens When You Load a Web Page

1. DNS (Layer 7, usually over UDP port 53) turns the domain name into an IP address.

2. TCP (Layer 4) opens a connection to port 443 with a three-way handshake.

3. TLS sets up encryption (Layer 6 in OSI terms).

4. The browser sends an HTTP GET request (Layer 7).

5. IP (Layer 3) routes each packet; ARP finds the gateway's MAC so Ethernet or Wi-Fi (Layer 2) can deliver the first hop; Layer 1 sends the bits.

8Mnemonics & Memory Aids

Bottom Up (1 → 7)

“Please Do Not Throw Sausage Pizza Away” — Physical, Data Link, Network, Transport, Session, Presentation, Application.

Top Down (7 → 1)

“All People Seem To Need Data Processing” — Application, Presentation, Session, Transport, Network, Data Link, Physical.

PDUs (4 → 1)

“Some People Fear Bees” — Segment, Packet, Frame, Bits.

Devices

“Hubs hear bits (1), switches see MACs (2), routers read IPs (3).”

Encapsulation Direction

“Down the stack you dress it up; up the stack you undress it.”

9Common Mistakes

Swapping Layers 2 and 3

Saying switches route by IP or routers forward by MAC

A (basic) switch forwards frames by MAC address at Layer 2. A router forwards packets by IP address at Layer 3. Layer 3 switches exist, but they are doing routing.

Mixing Up PDU Names

Calling a Layer 2 unit a packet

Bits (1), frames (2), packets (3), segments or datagrams (4). Exams often test the exact term.

Listing Layers in the Wrong Direction

Numbering Application as Layer 1

Physical is Layer 1 at the bottom; Application is Layer 7 at the top. Read the question to see which direction it wants.

Calling Applications “Layer 7”

Saying Chrome or Outlook is the Application layer

Layer 7 is the protocols (HTTP, SMTP) that applications use, not the programs themselves.

Thinking MAC Addresses Travel End to End

Expecting the destination MAC to be the remote server

The destination MAC is the next hop, usually your default gateway. MAC addresses are rewritten at every router; IP addresses are not (apart from NAT).

Assuming OSI Is What Runs the Internet

Treating the OSI model as an implementation

The internet uses TCP/IP. OSI is a reference model for describing and comparing protocols.

Frequently Asked Questions

What are the 7 layers of the OSI model in order?
From bottom to top: 1 Physical, 2 Data Link, 3 Network, 4 Transport, 5 Session, 6 Presentation, 7 Application. A common bottom-up mnemonic is "Please Do Not Throw Sausage Pizza Away"; top-down, "All People Seem To Need Data Processing".
Is the OSI model actually used on the internet?
The internet runs on the TCP/IP protocol suite, not on the OSI protocols that were designed alongside the model. The OSI model survives as a reference and teaching framework: engineers still say "a Layer 2 switch", "a Layer 7 load balancer" or "it is a Layer 1 problem", using OSI numbering to describe where something works.
What is the difference between a switch and a router?
A switch works at Layer 2. It forwards frames inside one local network using MAC addresses and a MAC address table it learns automatically. A router works at Layer 3. It connects different networks and forwards packets using IP addresses and a routing table. Your home "router" is usually a router, a switch and a wireless access point in one box.
What is encapsulation in networking?
Encapsulation is the process of each layer wrapping the data from the layer above with its own header (and at Layer 2, a trailer). Application data becomes a TCP segment, then an IP packet, then an Ethernet frame, then bits on the wire. The receiver reverses this, called de-encapsulation, with each layer reading and removing its own header before passing the rest up.
Which layer does TLS/HTTPS belong to?
It depends on the model and the exam. In the OSI mapping, encryption is a Presentation-layer (Layer 6) function, so TLS is often listed there. In the TCP/IP model there is no Presentation layer, so TLS is treated as part of the Application layer, running on top of TCP. HTTPS is simply HTTP (Layer 7) carried over TLS. State which model you are using.
Where does ARP fit in the OSI model?
ARP (Address Resolution Protocol) maps a known IPv4 address to the MAC address needed to deliver a frame on the local link. Because it links Layer 3 addresses to Layer 2 addresses, textbooks place it at Layer 2, at Layer 3, or "between" them (sometimes called Layer 2.5). Its messages are carried directly in Ethernet frames, not inside IP packets.

Practice Quiz

Test your understanding of the OSI model — layers, protocols, devices and encapsulation — select the correct answer for each question.

1.Which is the correct order of the OSI layers from Layer 1 to Layer 7?

2.At which OSI layer does a router make forwarding decisions?

3.What is the name of the protocol data unit (PDU) at the Data Link layer?

4.Which layer is responsible for end-to-end delivery between processes, using port numbers, and optionally providing reliability and flow control?

5.MAC addresses are used at which layer?

6.Encryption, compression and character-set translation are traditionally assigned to which OSI layer?

7.During encapsulation on the sending host, what does the Data Link layer add to a packet?

8.In the four-layer TCP/IP model, which OSI layers are combined into the Application layer?

9.A user can ping a server by IP address but cannot open its website by name. Which is the most likely cause?

10.Which pairing of protocol and OSI layer is correct?

Study Tips

  • Learn one row at a time: for each layer, know its number, name, job, PDU, two protocols and one device. That covers most exam questions.
  • Draw the encapsulation stack: sketch the frame as [Eth header | IP header | TCP header | data | FCS] until you can do it from memory.
  • Practise mapping: take any protocol or device you meet and ask “which layer, and why?”
  • Know both models: be ready to draw OSI next to TCP/IP and show which layers merge.

Related Topics

Turn this topic into your own study guide

Upload your class notes, slides or textbook chapter and Remy builds a study guide, flashcards and practice tests on exactly what your course covers — then answers your questions as you go.

Study this with Remy — free

Teachers: print this page as a handout or share the link with your class — it’s free.