Computer Networks / Lecture / Lecture 8
Lecture · Computer Networks

The 7 Layers of the OSI Model: Concepts and Functions

You typed “Hello!” in Telegram and pressed send. In less than a second the message reached your friend’s phone. Along the way it passed through the hands of seven different “workers”: each put on or took off its own envelope. These workers are the 7 layers of the OSI model. In the lesson you will learn what each layer does, watch step by step in an animation how a message turns into a “matryoshka” (encapsulation), and practise looking for a network problem layer by layer.

:ik-kitob: Lecture 8 ⏱ 2 academic hours (80 minutes) 🚇 Packet simulators ⚡ A seven-layer envelope
08

Lesson goals and plan

By the end of the lesson you will…

  • list the 7 layers of the OSI model in order and explain the job of each
  • know the name of each layer’s data unit (PDU) — bit, frame, packet, segment, data
  • place protocols and devices (Ethernet, IP, TCP, HTTP, hub, switch, router) on the matching layer
  • distinguish vertical (service) and horizontal (protocol) communication between layers
  • describe the processes of encapsulation and decapsulation at the level of headers
  • analyse a network fault layer by layer “from the bottom up”

Plan (according to the syllabus)

  1. The physical, data link, network, transport, session, presentation and application layers of the OSI model and their functions
  2. Interaction between layers, and the processes of encapsulation and decapsulation

I am a packet. Each layer puts its own “clothing” on me: transport — a jacket with a port number, network — a coat with an IP address, data link — a raincoat with a MAC address. At the receiver they are taken off in reverse order. In the animation you will see this with your own eyes!

Why do the phones, routers and servers of different companies “understand” each other?

Your phone is a Samsung, your router a TP-Link, and the Telegram server is on another continent, on another company’s equipment. They never “agreed” with one another. Yet the message arrives. The secret is in a common set of rules: the work in a network is divided into layers, and each layer does its job according to a standard. In 1984 ISO (the International Organization for Standardization) announced this idea as the OSI (Open Systems Interconnection) reference model. Today every network engineer describes a problem as “this is a Layer 2 problem” or “something is broken at Layer 3”.

Key terms

First recall the term yourself, then click the card to check.

The physical, data link, network, transport, session, presentation and application layers of the OSI model and their functions

Splitting a complex job into pieces is the golden rule of engineering. Think of the post: you write a letter, put it in an envelope and write the address; the postman does not read what is inside, he only looks at the address; the lorry driver does not even know the address — he just carries the sack from city A to city B. Everyone knows their own job and does not meddle in anyone else’s. The OSI model is just like that.

Definition

The OSI reference model is a conceptual model that divides the process of communication in a network into 7 logical layers. Each layer does a specific job, connects only with neighbouring layers through an “interface”, and “talks” to its peer on the other device by means of a protocol.

7 · Application 6 · Presentation 5 · Session 4 · Transport 3 · Network 2 · Data Link 1 · Physical data segment packet frame bit HTTP, DNS, SMTP, FTP encoding, encryption, compression opening/closing a session TCP, UDP · ports IP, ICMP · router Ethernet, Wi-Fi · switch cable, signal · hub
Fig. 8.1. The OSI model: 7 layers, their PDU names and typical protocols/devices
A memory aid

From the bottom up (P-D-N-T-S-P-A): “Physical Data-link Network Transport Session Presentation Application”. A popular English version: “Please Do Not Throw Sausage Pizza Away”.

The layers one by one: from the bottom up

Job: to turn bits (0 and 1) into a physical signal and carry it over the medium. Voltage levels, light pulses, radio frequency, connector shape, number of pins, cable length, speed (bit/s) — all are defined at this layer.

Examples: UTP cable, optical fiber, RJ-45 (Lecture 7), 1000BASE-T, Wi-Fi radio, hub and repeater — they do not know addresses; they simply amplify the incoming signal and spread it to everyone.

PDU: bit.

Job: reliable delivery from node to node within one network segment (one “room”). It assembles bits into a frame, writes the sender’s and receiver’s MAC addresses into the frame, adds an FCS (CRC) at the end to detect errors, and controls access to the shared medium (MAC — Media Access Control).

IEEE splits it into two sublayers: LLC (Logical Link Control) — the interface upward, and MAC — medium access and addressing.

Examples: Ethernet (IEEE 802.3), Wi-Fi (802.11), PPP, switch, network card. PDU: frame.

Job: delivery from source to destination across different networks — logical addressing (IP address) and routing (choosing the best path). If the data link layer works “inside one room”, the network layer works “between cities”.

Examples: IPv4, IPv6, ICMP (ping), router. PDU: packet. You will study this layer in depth in Lecture 11 and Practical classes 10–15.

Job: end-to-end delivery between two programs (processes). Splitting large data into pieces (segmentation), identifying the program by port numbers, and, when needed, acknowledgement, retransmission, restoring order and flow control.

Examples: TCP (reliable, connection-oriented), UDP (fast, connectionless). PDU: segment (TCP) or datagram (UDP). Details — in Lecture 12.

Job: to open, maintain and close a communication session between two programs; the order of the dialogue (who speaks when); and, in a long transfer, to set “checkpoints” — if it breaks, to continue from the last point rather than from the start.

Examples: NetBIOS sessions, RPC, session management in a video conference. In the modern Internet an application usually does these jobs itself.

Job: to bring data into a common form that both sides understand — the “interpreter”. Character encoding (ASCII, UTF-8), compression (JPEG, MP3, ZIP), encryption and decryption.

Examples: the Uzbek letter “o‘” in UTF-8, JPEG pictures, MP4 video formats; TLS encryption is often explained as a job of this layer.

Job: to provide network services to user programs. Note: the application layer is not the browser itself but the protocols the browser uses.

Examples: HTTP/HTTPS (web), DNS (name → IP), SMTP/IMAP (mail), FTP (files), DHCP (getting an address). PDU: data (a message).

Table 8.1. The OSI layers: a quick reference
№LayerKey questionAddress / identifierPDUDevice
7ApplicationWhich service is needed?URL, domain namedata—
6PresentationIn what form?—data—
5SessionHow is the dialogue managed?session identifierdata—
4TransportWhich program, did it arrive reliably?portsegment / datagram(firewall)
3NetworkWhich network, by which path?IP addresspacketrouter
2LinkTo whom in this segment?MAC addressframeswitch, network card
1PhysicalHow do bits become a signal?—bithub, cable, repeater
Did you know?

OSI is a reference model: it describes “how it should be”. In practice the Internet runs on the TCP/IP stack, in which the upper three layers (5–7) are merged into a single application layer. We will compare the two models in the next lecture, Lecture 9. Even so, engineers use exactly the OSI numbers when they say “L2 switch”, “L3 switch”, “L7 load balancer”.

Which layer is the problem on? A diagnostic exercise

When an experienced technician hears the complaint “the Internet does not work”, they check from the bottom up: is the cable connected (1)? Is the switch port light on (2)? Is there an IP address, does the ping to the gateway go through (3)? Is the port open (4)? … Read each situation and choose the layer where the problem most probably is.

:ik-qidiruv: Network doctor

Choose an answer.

Interaction between layers, and the processes of encapsulation and decapsulation

Imagine a matryoshka doll: the smallest is your message, a bigger one wraps it, then a still bigger one… On the sender’s side the data is “wrapped” in just this way, and on the receiver’s side it is “unwrapped” in reverse order.

Two directions of communication: vertical and horizontal

↕ Vertical: service (interface)

Inside one device, layer N uses the service of layer (N−1) and provides a service to layer (N+1). The boundary between them is the service access point (SAP). For example, the browser tells TCP “deliver this data reliably to port 443” — it does not care how TCP does it.

↔ Horizontal: protocol (peers)

The same layers on different devices “talk” to each other through a protocol. A header added by the sender’s TCP part is read only by the receiver’s TCP part. This communication is virtual: in reality the data goes down, travels over the cable, and goes up again.

Sender (A)Receiver (B) 7 Application 4 Transport 3 Network 1–2 Data Link/Physical 7 Application 4 Transport 3 Network 1–2 Data Link/Physical HTTP (virtual) TCP (virtual) IP (virtual) the real path — cable / radio
Fig. 8.2. Dashed lines — virtual (protocol) communication between peer layers; the red path — the real movement of the data

Encapsulation: each layer adds its own “envelope”

  1. 7–5. Data

    The program prepares the message (an HTTP request); it is encoded and, if needed, encrypted (6), and sent within a session (5). For now it is just data.

  2. 4. Segment

    The transport layer splits the data into pieces and adds a TCP header (≥ 20 bytes) to each: source and destination port, sequence number, acknowledgement number, checksum.

  3. 3. Packet

    The network layer adds an IP header (≥ 20 bytes in IPv4) in front of the segment: source and destination IP, TTL (time to live), protocol number (TCP = 6).

  4. 2. Frame

    The data link layer puts the packet between an Ethernet header (14 bytes: destination MAC, source MAC, type) and an FCS trailer (4 bytes). It is the only layer that also adds something at the end.

  5. 1. Bits

    The physical layer turns the frame into a stream of bits and a signal, and sends it onto the medium.

Now let us watch it live. Type your message and press Next step (or switch on automatic play). The left column is the sender, the right column the receiver. On the “tape” in the middle, watch how the PDU grows and then shrinks.

:ik-quti: Animation of encapsulation and decapsulation

Please note

The destination MAC address in the Ethernet header is not that of the final server but of the next hop (usually your router). The MAC address changes in every “room”, while the IP address hardly changes along the way. This is the most important practical sign of the difference between Layer 2 and Layer 3.

How big is the overhead?

Every header is “packaging”, not useful data. In Ethernet the IP packet in one frame usually does not exceed 1500 bytes (the MTU). Subtract the IP (20) and TCP (20) headers and at most 1460 bytes of useful payload remain. For small messages the share of the packaging is very large — like sending a single button in a big box.

Common mistakes

MisconceptionIn reality
Numbering the layers from top to bottom (application — 1)Numbering goes from the bottom: physical — 1, application — 7.
“The application layer is Chrome, Telegram”The application layer is the protocols that programs use (HTTP, DNS...).
“A router forwards a frame by MAC address”A router forwards by IP (Layer 3); by MAC — a switch.
“The destination MAC in a frame is the MAC address of the final server”Only within one segment: usually it is the MAC address of the next router (the gateway).
“Each layer only adds a header”The data link layer also adds a trailer (FCS).
Using segment, packet and frame as synonymsA segment is the PDU of Layer 4, a packet of Layer 3, a frame of Layer 2. The correct term is an accurate diagnosis.

Reinforcement

// REMEMBER IN 1 MINUTE

  1. From the bottom: Physical, Data Link, Network, Transport, Session, Presentation, Application (P-D-N-T-S-P-A).
  2. PDU: bit → frame → packet → segment → data.
  3. Identifiers: MAC (2), IP (3), port (4). Devices: hub (1), switch (2), router (3).
  4. Vertical communication is service (inside one device), horizontal is protocol (peer layers).
  5. On sending, headers are added (encapsulation); on receiving, they are removed (decapsulation).
:ik-xat:The postA letter (7) → an envelope and address (3) → a mail sack (2) → a lorry (1). Everyone knows their own layer.
:ik-telefon:A Telegram messageText in UTF-8 (6), encrypted with TLS, TCP/UDP (4), IP (3), a Wi-Fi frame (2), a radio wave (1).
:ik-asbob:Tech support“Did you check the cable?” — Layer 1. “Did you get an IP?” — Layer 3. Engineers work in just this order.

Final test

Review questions

What is the OSI model and why was it created?

ISO’s 7-layer reference model (1984). It splits network tasks into standard pieces so that systems from different manufacturers can work together; it gives a common language for teaching and for troubleshooting.

What are the advantages of dividing into layers?

Complexity is reduced; each layer can be developed and replaced separately (for example, Ethernet instead of Wi-Fi — the upper layers do not change); standardisation and diagnostics become easier.

State the difference between the physical and data link layers.

Physical — turns bits into a signal and carries it (cable, connector, voltage). Data link — assembles bits into frames, delivers within one segment using MAC addresses and detects errors with the FCS.

How do the network and transport layers differ?

Network — device to device (IP, routing); transport — program to program (ports, reliability, segmentation).

What are the jobs of the session and presentation layers?

Session — opening/maintaining/closing a dialogue, checkpoints. Presentation — encoding, compression, encryption.

Give the PDU name of each layer.

1 — bit, 2 — frame, 3 — packet, 4 — segment (TCP) / datagram (UDP), 5–7 — data.

Describe the process of encapsulation.

As data goes down, a TCP header (segment), an IP header (packet), and an Ethernet header and FCS (frame) are added; then the bits are sent as a signal.

What does each layer check in decapsulation?

2 — the FCS and the destination MAC; 3 — the destination IP and the protocol field; 4 — the port and sequence number (TCP sends an ACK); then 6 — decryption/decoding; 7 — passing to the program.

What are vertical and horizontal communication?

Vertical — the service (interface) between neighbouring layers in one device. Horizontal — the protocol (virtual) communication between the same layers in different devices.

Why is the frame renewed at every router, while the IP address is not?

A MAC address has meaning only within one segment; each segment has new “neighbours”. The IP address is end-to-end — it is kept along the whole way.

Independent work

Independent study topic in the course syllabus: “The OSI and TCP/IP models and the interaction of network layers.” (6 hours). In this lesson you do the OSI part of the topic, and in Lecture 9 the TCP/IP part.

  1. For the process in your variant, build a 7-layer table: which protocol/standard works at each layer, which header (address, port) is added, and the PDU name.
  2. Draw the encapsulation diagram (in matryoshka form), showing the approximate size of each header.
  3. Install Wireshark (optional), open one packet, mark the headers by OSI layers and attach a screenshot.
Assessment criteria (individual assignment)
CriterionPoints
The 7-layer table is complete and correct (protocols, PDUs)2
The encapsulation diagram is clear, with headers and sizes shown1
It is correctly explained at which layer the addresses (MAC, IP, port) belong1
Practical analysis (Wireshark or another tool) / sources1

Summary

7 layersPhysical, Data Link, Network, Transport, Session, Presentation, Application — from the bottom up.
Each layer — one questionSignal? To whom in the segment? To which network? To which program? Session? Format? Service?
PDUBit, frame, packet, segment, data.
AddressesMAC — 2, IP — 3, port — 4.
DevicesHub — 1, switch — 2, router — 3.
Two kinds of communicationVertical — service, horizontal — protocol (virtual).
EncapsulationGoing down, headers are added; the data link layer also adds the FCS.
DecapsulationGoing up, each layer checks its own header and removes it.

Your lesson results

Your results are saved in this browser. Read all the sections and complete the exercises and assignments.

My personal notes