Post

The Seven-Layer OSI Model

The Seven-Layer OSI Model

๐ŸŒ The Seven-Layer OSI Model

๐Ÿ“Œ Overview:

The OSI model is a foundational concept for understanding network communication and troubleshooting. Itโ€™s like a roadmap for how data travels across a networkโ€”from an app or browser all the way down to the hardware and back.

๐Ÿชœ OSI Model โ€“ 7 Layers (Top to Bottom):

  1. ๐ŸŸฃ Application (Layer 7)
    • Interface for end users.
    • Examples: Browsers (HTTP/HTTPS), Email clients (SMTP, IMAP).
  2. ๐ŸŸฃ Presentation (Layer 6)
    • Handles data formatting, encryption, and compression.
    • Example: SSL/TLS (for encryption).
  3. ๐ŸŸฃ Session (Layer 5)
    • Manages start, maintenance, and end of sessions between applications.
    • Think: login sessions, API calls.
  4. ๐ŸŸก Transport (Layer 4)
    • Ensures data is delivered reliably (TCP) or quickly (UDP).
    • Breaks data into segments.
    • Examples: TCP (reliable), UDP (faster, no guarantees).
  5. ๐ŸŸก Network (Layer 3)
    • Handles logical addressing and routing.
    • Examples: IP, ICMP, ARP.
  6. ๐ŸŸข Data Link (Layer 2)
    • Manages physical addressing (MAC), switching, and framing.
    • Examples: Ethernet, Wi-Fi.
  7. ๐ŸŸข Physical (Layer 1)
    • Deals with cables, signals, bits, and connectors.
    • Examples: RJ-45, fiber optics, electrical signals.

๐Ÿง  Mnemonics Used:

  • Top to bottom: All People Seem To Need Data Processing
  • Bottom to top: Please Do Not Throw Sausage Pizza Away

๐ŸŽฏ OSI Model = A Troubleshooting Tool

When facing a network issue, Iโ€™d start from the bottom layer upward:

  • Is the cable fine? (Layer 1)
  • Is MAC address or ARP resolved? (Layer 2/3)
  • Is IP assigned? Is ping working? (Layer 3)
  • Are TCP/UDP ports open? (Layer 4)
  • Is the app running properly? Is browser configured right? (Layer 7)

๐Ÿ”„ Protocol Mapping (As per Figure 1-18)

LayerExample Protocols
ApplicationHTTP, FTP, SMTP
TransportTCP, UDP
NetworkIP, ARP, ICMP
Data LinkEthernet, Wi-Fi
PhysicalHardware, cables

image.png

๐Ÿ“ฆ Real-World Analogy:

Just like the postal service:

  • You write a letter (application),
  • put it in an envelope (presentation),
  • go to the post office (session),
  • itโ€™s loaded onto a truck (transport),
  • follows a city route (network),
  • gets local delivery (data link),
  • and travels physically by road (physical).

image.png

๐ŸŸฃ Layer 7: Application Layer โ€“ OSI Model ๐Ÿง 

๐Ÿ“Œ Quick Recap:

Many people mistakenly think this layer is the apps like Chrome, Outlook, or Zoomโ€”but nope!

โ†’ Application Layer = Interface between apps running on different devices.

๐Ÿงฉ What Actually Happens:

  • This layer sets up communication between user-facing apps on different machinesโ€”but doesnโ€™t contain the actual app code.
  • It includes protocols that let applications communicate.

๐Ÿงช Examples of Protocols:

ProtocolUse
HTTP/HTTPSWeb browsing
SMTP, POP3, IMAP4Email
DNSDomain name resolution
FTPFile transfer
Telnet, SSHRemote login
RDPRemote desktop
SNMPNetwork monitoring

โš™๏ธ Two Types of Apps at This Layer:

  1. ๐Ÿง‘ User-facing apps โ†’ like web browsers, email clients
  2. ๐Ÿ› ๏ธ System utilities โ†’ like SNMP for network alerts

๐Ÿ“ฆ Payload = Actual data + control info

  • Itโ€™s not just contentโ€”it includes source/destination and other metadata.

๐Ÿ–ฅ๏ธ Hosts = The two devices exchanging data


๐ŸŸฃ Layer 6: Presentation Layer โ€“ OSI Model ๐Ÿง 

๐Ÿ“Œ Overview:

This is like the โ€œmakeoverโ€ layerโ€”it prepares data to be readable, compressed, and secured:

๐Ÿงฉ Key Functions:

  1. ๐ŸŽจ Formatting โ†’ Ensures data format is understandable on both ends
  2. ๐Ÿ“ฆ Compression โ†’ Reduces data size before transmission
  3. ๐Ÿ” Encryption โ†’ Secures data (e.g., TLS, S/MIME)

๐Ÿ›  Real-World Examples:

  • Email encryption via S/MIME or TLS
  • File transfers using ZIP compression
  • SSL/TLS (sometimes overlaps Layer 5/6)

๐ŸŸฃ Layer 5: Session Layer โ€“ OSI Model ๐Ÿง 

๐Ÿ“Œ Main Role:

  • Sets up, manages, and ends communication sessions
  • Handles re-sync if session drops (e.g., Zoom reconnects after disconnect)

๐ŸŽฏ Key Points:

  • Manages sessions, syncs, and recovers failed sessions
  • Used in video calls, API communications
  • Usually handled by the OS and app APIs

๐ŸŸก Layer 4: Transport Layer โ€“ OSI Model ๐Ÿšš

๐Ÿ“Œ Main Function:

  • Transports application data across networks

๐Ÿ“ฆ Two Main Protocols:

  1. โœ… TCP (reliable): Resends lost data, used in browsers, email
  2. ๐Ÿš€ UDP (faster): No guarantee of delivery, used in streaming, gaming

๐Ÿ”„ Encapsulation:

  • TCP = Segments
  • UDP = Datagrams
  • Headers contain delivery info
  • Ports identify which app to send to

๐Ÿ“ฎ Analogy:

  • Letter = Payload
  • Envelope = Segment/Datagram
  • Name = Port
  • Address = IP (Layer 3 handles it)

๐ŸŸก Layer 3: Network Layer โ€“ OSI Model ๐ŸŒ

๐Ÿ“Œ Main Function:

  • Sends packets from one network to another until destination is reached
  • Handles routing; routers work here

๐Ÿ“ฆ Protocols:

  • IP: Adds address info โ†’ creates packets
  • ICMP: Diagnostics (used by ping)
  • ARP: Maps IP to MAC
  • Handles fragmentation if needed

๐Ÿค Analogy:

  • Delivery truck system = Network layer
  • Envelope address = IP
  • Route = Decided by routers

๐Ÿ“Œ Basic Function:

  • Transfers data within the local network
  • Converts data into frames, includes MAC addresses

๐Ÿ›  Examples:

  • Ethernet (wired), Wi-Fi (wireless)

๐Ÿ“ฆ Frame Includes:

  • Header โ†’ Source/Destination MAC
  • Trailer โ†’ Error check info (e.g., CRC)

๐Ÿ“ก Switch Types:

  • Layer 2: Simple MAC-based forwarding
  • Layer 3: Adds routing

๐ŸŸข Layer 1: Physical Layer โ€“ OSI Model โšก

๐Ÿ“Œ Basic Role:

  • Converts bits (1s and 0s) into physical signals (electricity, light, or radio waves)

๐Ÿ›ฐ๏ธ Transmission Media:

  • Air โ†’ Wi-Fi, Bluetooth
  • Copper โ†’ Voltage (Ethernet)
  • Fiber โ†’ Light pulses

๐Ÿ”„ Think of It As:

  • Roads or airways for data
  • Physical properties like speed & voltage = Layer 1โ€™s job

๐Ÿงฉ PDU (Protocol Data Unit) โ€“ Layer-wise Breakdown

๐Ÿ“Œ What is it?

PDU = A structured block of data at each OSI layer

โ†’ Like how a train might change names at every station but itโ€™s still the same train

๐Ÿ“Š PDU Names by Layer:

OSI LayerPDU NameTechnical Name
Layer 7 โ€“ ApplicationPayload / DataL7PDU
Layer 6 โ€“ PresentationPayload / DataL6PDU
Layer 5 โ€“ SessionPayload / DataL5PDU
Layer 4 โ€“ TransportSegment (TCP) / Datagram (UDP)L4PDU
Layer 3 โ€“ NetworkPacketL3PDU
Layer 2 โ€“ Data LinkFrameL2PDU
Layer 1 โ€“ PhysicalBits / TransmissionL1PDU

๐ŸŒ Summary: How OSI Layers Work Together

๐Ÿงญ Concept:

When a browser sends a request to a web server, the data passes through all 7 layers.

Each layer adds a header, like putting a letter in layered envelopes.

When data arrives, headers are removed in reverse orderโ€”this is decapsulation.


image.png

๐Ÿชœ Step-by-Step Example:

DeviceAction
Browser (Sender)Creates HTTP request (payload โ€œPโ€) using Applicationโ€“Session layers
Transport Layer (TCP)Adds header โ†’ becomes a segment
Network Layer (IP)Adds IP header โ†’ becomes a packet
Data Link Layer (NIC)Adds header & trailer โ†’ becomes a frame
Physical Layer (NIC)Converts everything into bits, sends over wire
SwitchReads frame, checks MAC, forwards to correct port
RouterRemoves frame info, reads packet, routes it, creates a new frame
Receiver NICGets frame, removes header/trailer, passes packet to Network Layer
Network LayerStrips header, passes segment to TCP
TCPStrips header, passes payload to HTTP
Web ServerProcesses HTTP request โœ…

๐Ÿ” Key Concepts:

  • Encapsulation = Each layer adds a header
  • Decapsulation = Receiver removes headers
  • Frame = Data Link unit
  • Packet = Network unit
  • Segment = Transport unit

๐Ÿ”บ Important Notes:

  • Switch โ†’ Works at Layer 2
  • Router โ†’ Works at Layer 3
  • TCP/IP Model โ†’ Simplifies OSI:
    • Application (App + Presentation + Session)
    • Transport
    • Internet
    • Link (Data Link + Physical)

๐Ÿ“Œ In short:

For data to travel from browser to server, all layers must work together.

Switches and routers decide the path, and the server finally receives the message.

This post is licensed under CC BY 4.0 by the author.