network

OSI (Open Systems Interconnection) Model

  • By DK
  • May 30, 2025 - 30 min
OSI (Open Systems Interconnection) Model

OSI Model Layers


Application Layer - All

Presentation Layer - People

Session Layer - Seem

Transport Layer - To

Network Layer - Need

Data Link Layer - Data

Physical Layer - Processing


🔽 At the Receiver Side:

OSI LayerRole at Receiver Side
1. PhysicalReceives raw bits from the medium
2. Data LinkChecks and processes frames, verifies MAC addresses
3. NetworkProcesses IP packets, routes data to correct device
4. TransportReassembles segments, delivers data to correct app port
5. SessionMaintains session state, controls dialogues
6. PresentationDecrypts, decompresses, formats data
7. ApplicationPasses data to the application (e.g., YouTube app)

Summary:

  • Sender: Data flows top-down from Application to Physical layer.
  • Receiver: Data flows bottom-up from Physical to Application layer.

Application Layer


Description:

The application layer acts as the interface between end-user applications and the network, providing the necessary services and protocols for communication.

Open System Inter-Connection -

  • Introduced in 1983
  • adopted by ISO (International Standard Organization) in 1984

Protocols:

It utilizes various application-layer protocols, including:

HTTP/HTTPS: Web browsing (HyperText Transfer Protocol)

FTP/SFTP: File transfer (File Transfer Protocol / Secure FTP)

SMTP: Sending emails (Simple Mail Transfer Protocol)

IMAP/POP3: Retrieving emails DNS Resolving domain names to IP addresses

DHCP: Assigning IP addresses dynamically

Telnet: Remote terminal access (insecure) SSH Secure remote terminal access

SNMP: Network management and monitoring NTP Time synchronization (Network Time Protocol)

LDAP: Directory services (Lightweight Directory Access Protocol)

RDP: Remote desktop access


Presentation Layer


The Presentation Layer is responsible for translating, encrypting, and compressing data between the application and the network.

Main Functions:

FunctionDescription
TranslationConverts data formats (e.g., from EBCDIC to ASCII) so that different systems can understand each other.
Encryption/DecryptionSecures data during transmission (e.g., SSL/TLS encryption).
Compression/DecompressionReduces data size to speed up transmission (e.g., JPEG, MP3, MPEG).

💡 Examples of Presentation Layer Use:

  • SSL/TLS – Encrypts HTTPS traffic
  • MIME – Encodes email attachments
  • JPEG, MP3, MPEG – Compressed media formats
  • ASCII, UTF-8 – Character encoding standards

Common Encodings the Presentation Layer Might Handle

EncodingUse
ASCIIBasic English characters only
UTF-8Most common Unicode encoding, web standard
UTF-16Unicode, often used in Windows
EBCDICLegacy IBM systems
Base64For sending binary files via text (like email attachments)

1️⃣ Data Reformatting

Purpose: Convert data formats between systems. 🔹Example:

  • Converting Date format from DD/MM/YYYY to MM-DD-YYYY .
2️⃣ Translating

Purpose: Convert between different character encodings. 🔹Example:

  • Converting from Unicode to ASCII (e.g., “₹”“?” if not supported in ASCII)
3️⃣ Encryption

Purpose: Secure the data before transmission. 🔹Example:

  • Using SSL/TLS to encrypt HTTP traffic → turns into HTTPS
  • Encrypting a message with AES before sending
4️⃣ Compression

Purpose: Reduce data size for faster transmission. 🔹Example:

  • Compressing an image with JPEG
  • Compressing a file with Gzip before sending over the network

Session Layer


The Session Layer is responsible for starting, managing, and ending sessions between two devices or applications.

Key Responsibilities:

FeatureDescription

🔄

Session Management

Opens, maintains, and closes communication sessions between systems.

⏸️

Synchronization

Adds

checkpoints

in long transmissions so if failure happens, the session can resume from last checkpoint instead of starting over.

🔐

Dialog Control

Manages

who speaks when

— handles

full-duplex (both can talk) or half-duplex (take turns)

communication.

Explanation with examples:

1. Create and Manage Sessions

  • What it means: When two systems start talking (like a user logging in to a web app), the session layer sets up a "session" — a continuous exchange of data. It manages the session state throughout the interaction, maintaining synchronization and context.
  • Example:
    • When you log in to an online banking app, the session layer helps establish your session so the bank server knows it’s you throughout your activity.
    • In video calls (Zoom, Teams), the session layer creates a session for your meeting, managing connection parameters so both ends stay connected.

2. Add Checkpoints after some pages or process

  • What it means: Checkpoints act as "save points" in communication, so if the session breaks, data transmission can resume from the last checkpoint instead of starting over.
  • Example:
    • In a file transfer protocol (FTP), large files are transferred in chunks. If the connection drops, the session layer uses checkpoints to resume the transfer from the last successful chunk, not from scratch.
    • In online exams or multi-step forms, checkpoints allow saving progress so you don’t lose data if the session times out or you navigate away accidentally.

3. Terminate Session

  • What it means: Once the communication or task is complete, the session layer terminates the session cleanly, releasing resources and ensuring both sides agree the session ended.
  • Example:
    • When you log out of an app, the session is terminated so no further communication happens until you log in again.
    • After finishing a video call, the session closes the connection properly to free resources on both client and server.

Transport Layer


The Transport Layer is responsible for end-to-end communication between devices. It ensures reliable data transfer, error recovery, and flow control so that data sent from a source reaches the destination accurately and in order.

QnA:

Q - If one system (like your phone or computer) is using YouTube and WhatsApp at the same time, how does the Transport Layer know which data is for YouTube and which is for WhatsApp?

A - The Transport Layer (TCP/UDP) uses port numbers to identify which app or process each piece of data belongs to.

🧠 Here's how it works:

When you open YouTube and WhatsApp Web at the same time:

1. Your device assigns a unique source port to each app:

AppSource Port (random)Destination Port
YouTube51512443 (HTTPS)
WhatsApp51513443 (HTTPS)

💡 Both are using HTTPS (port 443), but each uses a different source port on your device.


2. When a response comes back, the Transport Layer checks:

  • Destination port in the packet
  • Matches it to the correct app/process that started the request

📦 Example Packet Flow:

FieldYouTube PacketWhatsApp Packet
Source IPYour IPYour IP
Source Port
Destination IPYouTube Server IPWhatsApp Server IP
Destination Port

At the receiving side (your device), the Transport Layer sees:

  • “This response is for port 51512 → Deliver it to YouTube app”
  • “This response is for port 51513 → Deliver it to WhatsApp app”

🎯 So in simple terms:

The Transport Layer uses unique port numbers to keep track of which app made which request. That way, even if multiple apps use the same internet connection, their data doesn't get mixed up.


🔹 The Source Port is usually generated randomly by the Transport Layer (specifically the OS) — not manually chosen by the app.


🔄 Here's How It Works:


✅ When you make a request (e.g., open YouTube):
  1. The app (like a browser) tells the OS: “I want to connect to YouTube on port 443.”
  2. The Transport Layer (in OS) assigns a random unused source port, e.g., 51324 .
  3. So the packet has:
    • Source port: 51324 (random)
    • Destination port: 443 (YouTube server)
  4. When the response comes back from YouTube, it knows to send it to port 51324 on your device.
  5. Your OS looks at port 51324 and knows: “Ah! That belongs to your browser → forward it there.”

✅ Summary Table:

FeatureTCPUDP
ConnectionConnection-orientedConnectionless
ReliabilityHigh (guaranteed delivery)Low (no guarantee)
Order of deliveryMaintainedNot guaranteed
SpeedSlower (due to reliability)Faster (less overhead)
Use casesWeb, email, file transferStreaming, gaming, Voice and video calls (VoIP)

🔽 At the Sender Side (Transport Layer):

  • Breaks the large data into segments (chunks)
  • Adds headers to each segment (like sequence numbers)
  • Sends them to the network (via Layer 3 - Network Layer)

🔽 At the Receiver Side (Transport Layer):

  • Receives the incoming segments
  • Uses sequence numbers to:
    • Reorder them correctly (if they arrive out of order)
    • Detect missing segments and request retransmission (if using TCP)
  • Reassembles all segments into the original complete data
  • Sends it up to the application (like browser, video player, etc.)

Network Layer


What it does at sender side:

  1. Receives segments from Transport Layer
    • The Transport Layer passes chunks of data (segments) with port info to Network Layer.
  2. Encapsulates segments into packets
    • It adds an IP header with:
      • Source IP address (your device's IP)
      • Destination IP address (target server’s IP)
  3. Determines the best path to destination
    • Uses routing information to decide where to send the packet next.
    • May consult routing tables or use protocols like OSPF, BGP (mostly routers do this, but sender sets initial destination IP).
  4. Handles fragmentation if needed
    • If the packet is too large for the next network segment (exceeds MTU), it splits it into smaller packets.
  5. Passes packets down to Data Link Layer
    • After preparing the packet, it sends it to the Data Link Layer for framing and physical transmission.

Key points:

  • MTU (Maximum Transmission Unit) is the maximum size of a single packet/frame that can be sent on the network link, measured in bytes, typically ~1500 bytes for Ethernet.
  • The MTU is not measured in MB or large chunks like 50 MB or 10 MB. It’s about small packet size limits on a network.

Suppose we have 100 MB of data. The Transport Layer breaks this data into 10 MB segments. Here’s what happens next:

How fragmentation works with this example:

  • The Transport Layer splits the file into 10 segments of ~10 MB each.
  • The Network Layer gets these 10 segments (each ~10 MB).
  • Because each 10 MB segment is way larger than the MTU (~1500 bytes), the Network Layer fragments each 10 MB segment into many smaller packets, each ≤ MTU size.
  • So instead of your example grouping packets like "1- 10+10+10+... = 50 MB", the fragmentation splits each 10 MB segment into thousands of small packets, each about 1500 bytes.

Visual:

10 MB segment from Transport Layer → Network Layer fragments into many small packets (~1500 bytes each):
Packet 1: ~1500 bytes (fragment 1 of segment 1)
Packet 2: ~1500 bytes (fragment 2 of segment 1)
...
Packet ~6667: ~1500 bytes (fragment last of segment 1)
This happens for each 10 MB segment individually.

On receiver side:

  • The receiver's Network Layer collects all fragments of a segment, reassembles them back into the full 10 MB segment.
  • Then passes that full segment to Transport Layer, which then reassembles all 10 segments into the full 100 MB file.

TL;DR:

  • MTU is small (~1500 bytes), so Network Layer breaks each big segment into many small packets.
  • It does NOT combine multiple segments into big packets like 50 MB chunks.

Network Layer (Sender Side) - Summary

  1. Fragment segments into packets based on the MTU (Maximum Transmission Unit) — each packet will be at most MTU size (usually ~1500 bytes).
  2. Wrap each packet with IP header, including:
    • Source IP address (sender)
    • Destination IP address (fixed until the packet reaches its final destination)
  3. Send each IP packet to the Data Link Layer for framing and transmission over the physical network.


1. Receives packets from Network Layer

  • The Data Link Layer takes each IP packet prepared by the Network Layer.

2. Creates frames

  • It adds a Data Link header and trailer around the packet, forming a frame.
  • The header includes:
    • Source MAC address (physical address of sender’s network interface)
    • Destination MAC address (next hop’s physical address — usually a router or the destination device if on the same LAN)

3. Error detection

  • Adds error-checking info (like a Frame Check Sequence (FCS) or CRC) to the trailer.
  • This helps detect corrupted frames at the receiver.

4. Controls access to the physical medium

  • Uses protocols (like Ethernet’s CSMA/CD) to control when the device can send data on the network medium.
  • Ensures no collisions or manages retransmissions.

5. Passes frames to the Physical Layer

  • Converts frames into bits/signals for transmission over the physical medium (cables, wireless, etc.).

Example in brief:

StepDescription
InputIP packet from Network Layer
OutputFrame with MAC addresses, error-checking, ready to send on physical medium

"Frame Depends" what this means ?

  • The Data Link Layer formats data into frames, but the exact frame structure depends on the network technology (hardware/protocol).
  • For example:
    • Ethernet:
      • Uses Ethernet frames with MAC addresses, CRC, and a specific header/trailer format.
    • Wi-Fi (IEEE 802.11):
      • Frames include wireless-specific fields like wireless control information, MAC addresses, and error checking.
    • PPP (Point-to-Point Protocol):
      • Frames are different, designed for direct links like serial connections.
    • ATM or Frame Relay:
      • Use their own frame formats, different from Ethernet.
  • The core function (framing + addressing + error detection) is the same,
  • But frame details and signaling depend on the hardware and protocol used on that network segment.

Result

Receives packets from Network Layer and encapsulates them into frames by adding:

  • MAC addresses (source and next hop’s physical address)
  • Error-checking info (like CRC) The frame structure depends on the network hardware and protocol (Ethernet, Wi-Fi, etc.).

Frames are sent hop-by-hop, from one system (device/router) to the next, not directly to the final destination.

At each hop, the MAC addresses change to reflect the current sender and receiver on that network segment.

If the sender transmits faster than the receiver can handle, the Data Link Layer controls flow to prevent data loss.

If errors occur in a frame, it is detected via error checking and retransmitted if necessary.

When the communication medium is shared (like Ethernet LAN), the Media Access Control (MAC) protocol manages who can send data and when, avoiding collisions.



Physical Layer


Main Role:

  • Transmits raw bits (0s and 1s) over a physical medium (like cables, wireless signals, fiber optics).

Key Functions:

  1. Bit Transmission
    • Converts frames from the Data Link Layer into electrical, optical, or radio signals.
    • Sends these signals bit by bit through the physical medium.
  2. Defines Physical Specifications
    • Specifies cables, connectors, voltages, frequencies, and signal timing.
    • Examples: Ethernet cables (Cat5/6), fiber optics, wireless radio frequencies.
  3. Synchronization
    • Ensures sender and receiver clocks are synchronized to accurately interpret the bit stream.
  4. Data Rate Control
    • Controls the speed at which bits are sent (bit rate).
  5. Physical Topology
    • Defines the physical layout of devices on the network (star, bus, ring, mesh).

Important Points:

  • The Physical Layer does not understand data meaning — it only sends and receives raw bits.
  • It’s responsible for hardware-level transmission and reception.
  • It interacts directly with the network medium (cables, wireless).

Example:

  • When you send a message over Wi-Fi or Ethernet:
    • Physical Layer converts the frames into radio waves or electrical signals.
    • In fiber optic cables, data is converted into light pulses for transmission.
    • These signals travel over air or cables to the next device.

Summary Table:

FunctionDescription
Bit-level transmissionSends raw bits as electrical/optical/radio signals
Physical media specsDefines cables, connectors, voltage levels
SynchronizationMatches sender/receiver timing
Data rateControls bit transmission speed
Physical topologyNetwork device layout

Result

  • Transmits raw bits (0s and 1s) over the physical medium (cables, fiber optics, wireless).
  • Determines the duration of each bit — how long a bit lasts on the medium (called the bit timing or bit period).
  • Controls the data rate — how many bits are sent per second (bit rate).
  • Decides the direction of data flow — whether communication is:
    • Simplex (one direction only),
    • Half-duplex (both directions but one at a time),
    • Full-duplex (both directions simultaneously).

Additional points to keep in mind:

  • The Physical Layer defines electrical or optical signal properties (voltage levels, light pulses, radio waves).
  • It handles physical connections (cables, connectors).


OSI Model — Data Flow from Sender to Receiver

OSI LayerSender Side (What Happens)Receiver Side (What Happens)Main Responsibility Summary
Application (7)User apps create data (HTTP, FTP, email, etc.)Passes data up to user applicationsInterface for user and apps; prepares data
Presentation (6)Formats, encrypts, compresses dataDecrypts, decompresses, converts data formatData translation, encryption, compression
Session (5)Manages sessions, controls dialogs (start, maintain, end)Manages session reestablishment, synchronizationSession management and control
Transport (4)Splits data into segments; adds ports; manages flow, errorReassembles segments; error checking; flow controlReliable/connectionless delivery; segmentation
Network (3)Encapsulates segments into packets; adds source & dest IPReassembles packets; routes based on IP addressesLogical addressing and routing
Data Link (2)Frames packets with MAC addresses, error checks; controls media accessChecks for errors, sends ACKs, passes frames to Network LayerPhysical addressing; error detection; media control
Physical (1)Converts frames into bits/signals; sends over physical mediumReceives bits/signals; converts back to framesRaw bit transmission and reception

📤 OSI Model Explained During a File Upload (Video Example)

This document breaks down how each layer of the OSI Model works when you upload a file (e.g., a video) from your computer to a web server or cloud platform.


🧠 OSI Model during Video Upload


7. Application Layer

👤 Who/What: Your browser or app (e.g., Chrome, YouTube app)
📦 Role: User interaction, choosing the file to upload.

  • You click “Upload.”
  • The app opens a file dialog.
  • You select a video.
  • It uses protocols like HTTP/HTTPS to send the request.

🎯 The Application Layer talks directly to the user and initiates file transfer via the appropriate protocol.


6. Presentation Layer

🎨 Who/What: App logic, browser encoder
📦 Role: Data formatting, encoding, encryption (if any)

  • Your file is encoded into a format suitable for transfer (e.g., Base64 or binary chunks).
  • If HTTPS is used, it’s encrypted here.

🎯 This layer ensures data is in the right format and secures it if needed.


5. Session Layer

🔁 Who/What: TCP session control
📦 Role: Maintains session between your device and the server.

  • Opens and manages a session.
  • Keeps the connection alive during the upload.
  • Handles things like retrying after a disconnect (in some advanced apps).

🎯 This layer manages the upload session — so if you pause/resume or if it’s interrupted and restarted, this helps keep context.


4. Transport Layer

📤 Who/What: TCP (Transmission Control Protocol)
📦 Role: Breaks file into segments, ensures reliable transfer.

  • The video file is broken into small segments.
  • Uses TCP to ensure all segments arrive in order.
  • Handles retransmission of lost packets.

🎯 Think of this layer as the reliable delivery guy: breaks the file into chunks and makes sure each one reaches the destination.


3. Network Layer

🗺️ Who/What: IP (Internet Protocol)
📦 Role: Adds source/destination IP addresses and routes data.

  • Segments from Transport Layer are put into packets.
  • Each packet gets a source (your IP) and destination (server IP).
  • Finds the best route through routers to the server.

🎯 Routes your data across the internet like a GPS system.


🧱 Who/What: Network interface card (NIC), switch
📦 Role: Converts packets into frames, adds MAC addresses.

  • Adds your MAC address and the next router’s MAC.
  • Handles error detection on the link (e.g., Ethernet frame checks).
  • Transmits frames within the local network (e.g., from your laptop to your Wi-Fi router).

🎯 Responsible for communication over your local network (LAN).


1. Physical Layer

🔌 Who/What: Wi-Fi or Ethernet cable
📦 Role: Sends bits (0s and 1s) physically over the medium.

  • Transmits raw binary data as electrical signals (Ethernet) or radio waves (Wi-Fi).
  • These bits are received by the router, which then repeats the process toward the destination.

🎯 The actual “hardware” level of sending your data — think wires, fiber optics, airwaves.


⛓️ Summary Table

OSI LayerExample During UploadResponsibility
7. ApplicationClick upload in appUser interaction & protocols
6. PresentationEncode, encrypt fileFormat, compress, encrypt
5. SessionKeep connection aliveStart, manage, resume session
4. TransportBreak file into segmentsReliable transfer (TCP)
3. NetworkIP addressing & routingRoute packets to server
2. Data LinkMAC address & framesSend over local network
1. PhysicalSend signals via Wi-FiActual transmission medium

⚙️ Real-world Example

  • You start uploading.
  • Application Layer starts the upload.
  • Presentation Layer encodes the video.
  • Session Layer keeps the session active.
  • Transport Layer (TCP) breaks the video into reliable chunks.
  • Network Layer (IP) routes it through the internet.
  • Data Link Layer sends it over your Wi-Fi.
  • Physical Layer transmits the bits.

Nexxtapp1
nexxtapp articles - business and startups
nexxtapp articles - business and startups
nexxtapp articles - business and startups
nexxtapp articles - business and startups
nexxtapp articles - business and startups
nexxtapp articles - business and startups

2025 - Powered by NexxtApp.