šŸ“˜ Visual Posts About Contact
Explore šŸ“‹ Cheat Sheets āœļø Practice šŸŽ® Games šŸŽ¬ Simulations šŸƒ Flashcards šŸŽÆ Interactive Layers šŸ“– Storytelling
šŸ’œ Support my site

Master the OSI Model

7 Layers Explained Practical Examples 2026 Standards

Understand how networks actually work. Learn the 7-layer framework that powers every network device, from switches to web browsers, with practical examples and hands-on exercises.

Start Learning ↓
Layer 7: Application HTTP, FTP, SMTP Layer 6: Presentation SSL/TLS, JPEG Layer 5: Session NetBIOS, RPC Layer 4: Transport TCP, UDP Layer 3: Network IP, ICMP, Routers Layer 2: Data Link MAC, Switches Layer 1: Physical Cables, Hubs, Bits DATA FLOW

01 What is the OSI Model?

The OSI (Open Systems Interconnection) Model is a 7-layer framework that standardizes network communication. Created by ISO in 1984, it enables different systems (Windows, Linux, macOS, network hardware) to communicate regardless of underlying architecture.

🧠 Layer Mnemonic (Bottom to Top)

"Please Do Not Throw Sausage Pizza Away"

Physical → Data Link → Network → Transport → Session → Presentation → Application

Why Learn the OSI Model?

  • Troubleshooting: Isolate network issues layer by layer (cable problem vs routing issue)
  • Network Design: Understand where to implement security, QoS, and load balancing
  • Certifications: Required for CompTIA Network+, CCNA, and most networking certifications
  • Professional Communication: Common language for IT professionals worldwide

OSI vs TCP/IP

While the OSI Model has 7 layers, the internet actually runs on TCP/IP, a simpler 4-layer model:

OSI

7-Layer Model

Purpose: Teaching and reference framework

Layers: Application, Presentation, Session, Transport, Network, Data Link, Physical

TCP/IP

4-Layer Model

Purpose: Actual internet implementation

Layers: Application, Transport, Internet, Network Access

šŸ’” Key Point

OSI Layers 5-7 (Session, Presentation, Application) collapse into TCP/IP's single Application Layer. OSI provides more granular troubleshooting even though TCP/IP is what's actually implemented.

āœ“ Checkpoint: Can you...

  • Name all 7 OSI layers in order?
  • Explain the difference between OSI and TCP/IP?
  • Describe one practical use of the OSI Model?

02 The 7 Layers: Quick Overview

Before diving deep into each layer, let's get a bird's-eye view of what each layer does, what protocols it uses, and what data unit it works with.

LAYER NAME DATA UNIT KEY PROTOCOLS DEVICES 7 Application User Interface Data HTTP, FTP, SMTP DNS, DHCP, SSH Browsers, Email 6 Presentation Data Translation Data SSL/TLS, JPEG MPEG, ASCII Gateways 5 Session Connection Mgmt Data NetBIOS, RPC PPTP, SIP Gateways 4 Transport End-to-End Segment TCP, UDP SCTP, DCCP Firewalls 3 Network Routing Packet IP, ICMP OSPF, BGP Routers, L3 SW 2 Data Link MAC Addressing Frame Ethernet, PPP ARP, STP Switches, Bridges 1 Physical Transmission Media Bits Ethernet PHY USB, Bluetooth Cables, Hubs, NIC

šŸ’” Pro Tip: Data Unit Names

Each layer works with a different "unit" of data:

  • • Layers 5-7: Data (raw application data)
  • • Layer 4: Segment (TCP) or Datagram (UDP)
  • • Layer 3: Packet
  • • Layer 2: Frame
  • • Layer 1: Bits (1s and 0s)

āœ“ Checkpoint: Can you...

  • Name the data unit at each layer?
  • Identify at least one protocol for each layer?
  • Explain which devices operate at Layers 1, 2, and 3?

03 Layer 7: Application Layer

7
Application Layer
Provides network services directly to end-user applications. Handles protocols for web, email, file transfer, and name resolution.
HTTP/HTTPS FTP/SFTP SMTP/IMAP DNS DHCP SSH

What It Does

The Application Layer provides network services to applications. This is NOT the applications themselves (Chrome, Outlook), but the protocols they use to communicate over the network.

āš ļø Important Distinction

Layer 7 ≠ Applications. Chrome is an application. HTTP is the Layer 7 protocol Chrome uses to fetch web pages.

Key Protocols

HTTP

Web Protocol

Ports: 80 (HTTP), 443 (HTTPS)

Function: Transfers web content

2026: HTTP/3 uses QUIC (UDP)

DNS

Name Resolution

Port: 53 (UDP/TCP)

Function: Domain → IP translation

Example: google.com → 142.250.185.46

SMTP

Email Sending

Ports: 25, 587 (TLS)

Function: Sends email

Pair with: IMAP/POP3 for receiving

DHCP

IP Assignment

Ports: 67 (server), 68 (client)

Function: Auto IP configuration

Process: Discover → Offer → Request → Ack

SSH

Secure Remote Access

Port: 22

Function: Encrypted terminal access

Replaces: Telnet (unencrypted)

FTP

File Transfer

Ports: 20 (data), 21 (control)

Function: Upload/download files

Secure: SFTP (port 22) or FTPS

Deep Dive: HTTP/3 and QUIC (2026 Standard)

Evolution:

  • HTTP/1.1: One request per TCP connection
  • HTTP/2 (2015): Multiplexing over single TCP connection, but head-of-line blocking remains
  • HTTP/3 (2022+): Uses QUIC protocol built on UDP, eliminating head-of-line blocking

QUIC Benefits:

  • Faster connection establishment (0-RTT reconnection)
  • Independent stream processing (packet loss doesn't block other streams)
  • Built-in encryption (TLS 1.3)
  • Better mobile performance (connection migration)

2026 Adoption: 30%+ of top websites use HTTP/3 (Google, Facebook, Cloudflare)

āœ“ Checkpoint: Can you...

  • Name 5 Application Layer protocols and their ports?
  • Explain why HTTP/3 is faster than HTTP/2?
  • Describe what DNS does?
  • Distinguish between the Application Layer and applications?

04 Layer 6: Presentation Layer

6
Presentation Layer
Translates data between application and network formats. Handles encryption, compression, and data formatting.
SSL/TLS JPEG/GIF/PNG MPEG/AVI ASCII/EBCDIC Encryption

What It Does

The Presentation Layer is the translator. It converts data from application format into a format that can be sent over the network. Think of it as the "data formatter" that ensures both sides understand each other.

Three Main Functions

  • 1. Data Translation: Converts character sets (ASCII ↔ EBCDIC), formats (JSON → XML), or encoding schemes.
  • 2. Encryption/Decryption: Uses SSL/TLS to encrypt data before transmission (HTTPS uses this).
  • 3. Compression: Reduces file size (like ZIP files) to save bandwidth.

Real-World Analogy

Imagine international diplomacy:

You're sending a secret message to a foreign ally. The Presentation Layer is the translator + encryption specialist. They translate your English message to French, encrypt it so spies can't read it, and compress it so it fits in a small diplomatic pouch.

šŸ’” SSL/TLS in 2026

TLS 1.3 is the current standard (as of 2018, mandatory in 2026). TLS 1.0 and 1.1 are deprecated due to security vulnerabilities. TLS 1.3 provides:

  • Faster handshake (1-RTT instead of 2-RTT)
  • Removal of weak ciphers (RC4, SHA-1)
  • Perfect forward secrecy (even if key is compromised, past sessions stay secure)
Deep Dive: How SSL/TLS Handshake Works

The TLS 1.3 Handshake (Simplified):

  1. Client Hello: Browser sends supported cipher suites and a random number.
  2. Server Hello: Server picks a cipher suite, sends certificate + public key + random number.
  3. Key Exchange: Both sides generate a shared secret using Diffie-Hellman.
  4. Encrypted Communication: All further data is encrypted with the shared secret.

2026 Enhancement: Post-quantum cryptography (PQC) algorithms are being tested to protect against quantum computer attacks.

āœ“ Checkpoint: Can you...

  • Name the three main functions of the Presentation Layer?
  • Explain what SSL/TLS does?
  • Give an example of data compression at this layer?

05 Layer 5: Session Layer

5
Session Layer
Establishes, maintains, and terminates connections (sessions) between applications.
NetBIOS RPC PPTP SIP RTP

What It Does

The Session Layer manages conversations between computers. It opens, maintains, and closes connections (sessions), ensuring data is properly synchronized between devices.

Real-World Analogy

Imagine a phone call:

The Session Layer is the call management system. It:

  • → Establishes the session: Dials the number and connects the call
  • → Maintains the session: Keeps the line open while you talk
  • → Synchronizes: Ensures both sides take turns speaking
  • → Terminates the session: Hangs up when the call ends

Key Concepts

Session Management

Checkpointing: If a large file transfer is interrupted, the session can resume from the last checkpoint instead of starting over.

Dialog Control: Determines if communication is:

  • • Simplex: One-way only (TV broadcast)
  • • Half-Duplex: Two-way, but only one at a time (walkie-talkie)
  • • Full-Duplex: Two-way simultaneously (phone call)

āš ļø Session vs Transport Layer

Common confusion: Session Layer manages application-level conversations (like "login sessions"), while Transport Layer manages the actual connection between devices. Think: Session = application logic, Transport = network plumbing.

Session Layer Protocols

NetBIOS

Network Basic Input/Output System

Purpose: Session management for Windows networks (legacy). Provides name resolution, session establishment, and data transfer services. Now largely replaced by DNS and SMB over TCP/IP.

RPC

Remote Procedure Call

Purpose: Allows programs to execute procedures on remote computers as if they were local. Used in distributed systems (NFS, Windows services). Examples: gRPC, Java RMI.

PPTP

Point-to-Point Tunneling Protocol

Purpose: Creates VPN tunnels. 2026 Status: Deprecated due to security vulnerabilities. Use IPsec, OpenVPN, or WireGuard instead.

SIP

Session Initiation Protocol

Purpose: Establishes, modifies, and terminates multimedia sessions (VoIP calls, video conferencing). Works with RTP for actual media delivery. Used by Zoom, Microsoft Teams.

RTP

Real-time Transport Protocol

Purpose: Delivers audio and video over IP networks. Provides timing information and sequence numbering for media streams. Works with RTCP for quality monitoring.

šŸ’” Session Layer in Modern Networks

In the TCP/IP model, Session Layer functions are often handled by applications themselves (like HTTP cookies for web sessions) or integrated into other layers. This is why Session Layer is sometimes considered the "least important" OSI layer in practical networking - its functions still exist but are distributed across other layers.

āœ“ Checkpoint: Can you...

  • Explain what a "session" is in networking?
  • Describe the difference between simplex, half-duplex, and full-duplex?
  • Give an example of checkpointing?
  • Explain what SIP does in VoIP calls?
  • Describe why PPTP is no longer recommended?

06 Layer 4: Transport Layer

4
Transport Layer
Ensures reliable end-to-end data delivery. Handles segmentation, flow control, error detection, and port-based application identification.
TCP UDP SCTP DCCP

What It Does

The Transport Layer manages end-to-end communication between applications. It breaks data into segments, ensures they arrive in order, handles retransmission of lost packets, and uses port numbers to multiplex multiple connections.

TCP vs UDP: The Critical Difference

TCP

Transmission Control Protocol

Connection-Oriented • Reliable • Ordered Delivery

  • Three-way handshake: SYN → SYN-ACK → ACK
  • Guaranteed delivery: ACKs and retransmissions
  • Flow control: Sliding window mechanism
  • Congestion control: Slow start, congestion avoidance
  • Use cases: HTTP/HTTPS, SSH, FTP, email
UDP

User Datagram Protocol

Connectionless • Fast • No Guarantees

  • No handshake: Fire-and-forget messaging
  • No reliability: No ACKs, no retransmission
  • Low overhead: 8-byte header vs TCP's 20+ bytes
  • Stateless: No connection tracking
  • Use cases: DNS, DHCP, VoIP, live streaming, gaming, QUIC

šŸ’” When to Use Which Protocol?

TCP: When you need every byte to arrive correctly (file transfers, web pages, databases). UDP: When speed matters more than perfection (live video, voice calls, real-time games, DNS lookups).

Port Numbers: Application Addressing

While IP addresses identify devices, port numbers identify specific applications or services on those devices. This allows multiple services to run on one IP address.

Port Number Ranges

  • 0-1023: Well-Known Ports (System)
    Requires root/admin privileges. HTTP=80, HTTPS=443, SSH=22, DNS=53, SMTP=25
  • 1024-49151: Registered Ports (User)
    Assigned by IANA for specific services. MySQL=3306, PostgreSQL=5432, RDP=3389
  • 49152-65535: Dynamic/Ephemeral Ports
    Randomly assigned by OS for outgoing connections (source ports)

TCP Three-Way Handshake

Connection Establishment Process:

  1. SYN (Synchronize): Client sends SYN flag with initial sequence number (ISN). "I want to connect, my sequence starts at 1000."
  2. SYN-ACK: Server responds with SYN+ACK, acknowledging client's ISN and sending its own. "Got it! My sequence starts at 5000. I acknowledge your 1000."
  3. ACK (Acknowledge): Client sends ACK to confirm. "Perfect! I acknowledge your 5000. Connection established."

Why synchronize sequence numbers? To prevent duplicate packets from old connections being accepted and to ensure both sides can reassemble data in correct order.

TCP Three-Way Handshake CLIENT SERVER 1. SYN (seq = 100) "I want to connect" 2. SYN-ACK (seq = 300, ack = 101) "Got it! Here's my seq" 3. ACK (ack = 301) āœ“ CONNECTION ESTABLISHED - Data Transfer Begins
Deep Dive: TCP Flow Control and Congestion Control

Flow Control (Receiver Protection):

  • Sliding Window: Receiver advertises how much buffer space it has
  • Window Size: Prevents sender from overwhelming receiver
  • Zero Window: Receiver can pause transmission when buffer is full

Congestion Control (Network Protection):

  • Slow Start: Begin with small congestion window, double it each RTT
  • Congestion Avoidance: Linear increase after reaching threshold
  • Fast Retransmit/Recovery: Quick recovery from packet loss
  • 2026 Algorithms: BBR (Bottleneck Bandwidth and RTT) used by Google, improves throughput on lossy networks

Other Transport Layer Protocols

While TCP and UDP dominate, other specialized protocols exist for specific use cases:

SCTP

Stream Control Transmission Protocol

Purpose: Combines best of TCP and UDP

Features:

  • Multi-streaming (multiple independent streams in one connection)
  • Multi-homing (connection survives IP address changes)
  • Message-oriented (preserves message boundaries)

Use cases: Telecom signaling (SS7 over IP), WebRTC data channels

DCCP

Datagram Congestion Control Protocol

Purpose: UDP with congestion control

Features:

  • Unreliable delivery (like UDP)
  • Congestion control (like TCP)
  • Prevents sender from overwhelming network

Use cases: Streaming media where some loss is acceptable but fairness matters

šŸ’” Why Aren't SCTP/DCCP More Popular?

Network compatibility: Many firewalls and NATs only understand TCP/UDP. SCTP/DCCP packets are often blocked. This creates a "chicken and egg" problem - applications don't use them because networks block them, and networks don't support them because no applications use them. In 2026, they remain niche protocols for specialized environments.

āœ“ Checkpoint: Can you...

  • Explain the key differences between TCP and UDP?
  • Describe the three-way handshake process?
  • Name the three port ranges and their purposes?
  • Explain when you would choose UDP over TCP?
  • Describe what flow control does?
  • Explain what makes SCTP unique compared to TCP?

07 Layer 3: Network Layer

3
Network Layer
Routes packets across networks using logical IP addressing. Determines the best path from source to destination through multiple hops.
IPv4/IPv6 ICMP OSPF BGP Routers

What It Does

The Network Layer handles logical addressing (IP addresses) and routing (path selection). It enables communication between devices on different networks by forwarding packets hop-by-hop from source to destination.

šŸ’” Layer 3 vs Layer 2

Layer 2 (Data Link): Delivers frames between devices on the same network using MAC addresses. Layer 3 (Network): Routes packets between different networks using IP addresses.

IP Addressing: The Foundation

IPv4

Internet Protocol version 4

Format: 32-bit (4 octets, dotted decimal)

Example: 192.168.1.1

Total Addresses: ~4.3 billion (232)

Status (2026): Exhausted globally; NAT extends usability

IPv6

Internet Protocol version 6

Format: 128-bit (8 hextets, colon-separated)

Example: 2001:0db8:85a3::8a2e:0370:7334

Total Addresses: 340 undecillion (2128)

Status (2026): 45%+ global adoption, mandatory for new deployments

Subnetting and CIDR

Networks are divided into subnets using CIDR notation (Classless Inter-Domain Routing) to efficiently allocate IP addresses.

Example: 192.168.1.0/24

  • Network Address: 192.168.1.0
  • Subnet Mask: 255.255.255.0 (or /24)
  • Usable Range: 192.168.1.1 - 192.168.1.254 (254 hosts)
  • Broadcast: 192.168.1.255
  • /24 Meaning: First 24 bits are network, last 8 bits are host (28 - 2 = 254 usable)

Routing: How Packets Find Their Way

Routers use routing tables to determine the next hop for each packet. Routing can be static (manually configured) or dynamic (learned via routing protocols).

Dynamic Routing Protocols

OSPF (Open Shortest Path First)

Interior gateway protocol. Uses Dijkstra's algorithm. Fast convergence. Link-state routing.

BGP (Border Gateway Protocol)

Exterior gateway protocol. Routes between ISPs and autonomous systems. The backbone of the internet.

ICMP: Network Diagnostics

Internet Control Message Protocol provides error reporting and diagnostic capabilities. No data transfer—just control messages.

ping

Connectivity Test

How it works: Sends ICMP Echo Request, receives Echo Reply

Use case: Test if host is reachable and measure round-trip time

traceroute

Path Discovery

How it works: Uses TTL to discover each hop along the path

Use case: Identify where packets are being dropped or delayed

Deep Dive: How Routing Decisions Are Made

Routing Table Example:

Destination        Gateway         Interface    Metric
192.168.1.0/24     0.0.0.0         eth0         0      (Directly connected)
10.0.0.0/8         192.168.1.1     eth0         1      (Via router)
0.0.0.0/0          192.168.1.1     eth0         10     (Default route)

Decision Process (Longest Prefix Match):

  1. Check for most specific match (longest prefix)
  2. 192.168.1.50 → Matches 192.168.1.0/24 (send locally)
  3. 10.5.1.1 → Matches 10.0.0.0/8 (send to 192.168.1.1)
  4. 8.8.8.8 → No specific match → Use default route 0.0.0.0/0
  5. Decrement TTL by 1 at each hop
  6. If TTL reaches 0 → Drop packet, send ICMP "Time Exceeded"

TTL Purpose: Prevents routing loops. Default is typically 64 or 128.

āœ“ Checkpoint: Can you...

  • Explain the difference between IPv4 and IPv6?
  • Calculate the usable host range for 192.168.10.0/26?
  • Describe what a router does?
  • Explain the difference between OSPF and BGP?
  • Describe how ping and traceroute work?

08 Layer 2: Data Link Layer

2
Data Link Layer
Provides node-to-node data transfer using MAC addresses. Handles error detection and frame formatting.
Ethernet Wi-Fi (802.11) PPP ARP Switches

What It Does

The Data Link Layer is the local delivery service. It takes packets from Layer 3 and delivers them to the correct device on the same network using MAC addresses.

Two Sublayers

  • LLC (Logical Link Control): Interfaces with Network Layer, handles flow control and error checking.
  • MAC (Media Access Control): Interfaces with Physical Layer, handles addressing and media access.

Real-World Analogy

Imagine an apartment building:

Layer 3 (Network) gets mail to the right building using the street address (IP). Layer 2 (Data Link) delivers it to the right apartment using the apartment number (MAC address).

MAC Addresses Explained

MAC Address (Media Access Control)

Format: 48-bit (6 bytes) in hexadecimal

Example: 00:1A:2B:3C:4D:5E

Structure:

  • First 3 bytes (OUI): Manufacturer ID (00:1A:2B = Vendor)
  • Last 3 bytes: Device-specific identifier

Key Fact: MAC addresses are theoretically permanent (burned into NIC), but can be spoofed in software.

ARP - The Translator

Address Resolution Protocol (ARP) translates IP addresses to MAC addresses on the local network.

How ARP Works

  1. ARP Request (Broadcast): "Who has IP 192.168.1.10? Tell 192.168.1.5"
  2. ARP Reply (Unicast): "192.168.1.10 is at MAC 00:1A:2B:3C:4D:5E"
  3. Cache: Device stores this in ARP cache for future use
ARP: Broadcast Request, Unicast Reply SWITCH PC-A 192.168.1.5 AA:BB:CC:DD:EE:01 PC-B (TARGET) 192.168.1.10 AA:BB:CC:DD:EE:02 PC-C 192.168.1.20 AA:BB:CC:DD:EE:03 PC-D 192.168.1.30 AA:BB:CC:DD:EE:04 1. ARP REQUEST (BROADCAST) "Who has 192.168.1.10?" 2. ARP REPLY (UNICAST - only to sender) "I'm 192.168.1.10 at AA:BB:CC:DD:EE:02" Note: PC-C and PC-D receive broadcast but don't reply (wrong IP)

Data Link Layer Protocols

Ethernet

IEEE 802.3

Purpose: Wired LAN standard. Uses CSMA/CD (Carrier Sense Multiple Access with Collision Detection). Frame size: 64-1518 bytes. Speeds: 10 Mbps to 400 Gbps (2026).

Wi-Fi

IEEE 802.11

Purpose: Wireless LAN standard. Uses CSMA/CA (Collision Avoidance). 2026 Standard: Wi-Fi 7 (802.11be) - up to 46 Gbps, 320 MHz channels.

PPP

Point-to-Point Protocol

Purpose: Direct connection between two nodes (no switches). Used in DSL, dial-up, VPNs. Supports authentication (PAP, CHAP), compression, error detection. Common in WAN links.

Switches vs Hubs

HUB

Layer 1 Device (Dumb)

  • Broadcasts to ALL ports
  • Causes collisions (half-duplex)
  • Creates single collision domain
  • Obsolete in 2026
SWITCH

Layer 2 Device (Smart)

  • Learns MAC addresses
  • Forwards only to correct port
  • Full-duplex communication
  • Reduces collisions (separate collision domains)
Deep Dive: How Switches Learn MAC Addresses

MAC Address Table (CAM Table):

Port    MAC Address           Learned
1       00:1A:2B:3C:4D:5E     Dynamic
2       00:1A:2B:3C:4D:5F     Dynamic
3       00:1A:2B:3C:4D:60     Static

Learning Process:

  1. Frame arrives on Port 1 with source MAC 00:1A:2B:3C:4D:5E
  2. Switch adds entry: "Port 1 = MAC 00:1A:2B:3C:4D:5E"
  3. Next time, frames to that MAC go only to Port 1
  4. Unknown MACs? Flood to all ports except source (like a hub)

Security Risk: MAC flooding attacks can overflow the CAM table, forcing the switch to act like a hub (enabling sniffing).

āœ“ Checkpoint: Can you...

  • Explain what a MAC address is?
  • Describe how ARP works?
  • Explain the difference between a hub and a switch?
  • Identify the two sublayers of Layer 2?
  • Explain when PPP is used instead of Ethernet?

09 Layer 1: Physical Layer

1
Physical Layer
Transmits raw bits over physical medium. Deals with cables, voltages, frequencies, and electrical signals.
Cat5e/Cat6/Fiber Wi-Fi Radio Hubs/Repeaters USB/Bluetooth

What It Does

The Physical Layer is the actual hardware. It converts digital bits (1s and 0s) into electrical signals, light pulses, or radio waves, and transmits them over physical media.

Real-World Analogy

Imagine a telegraph system:

The Physical Layer is the copper wire and electrical pulses. It doesn't care about the message—it just transmits dots and dashes (bits) as electrical signals.

Transmission Media

Copper

Twisted Pair (Ethernet)

Types: Cat5e, Cat6, Cat6a, Cat7

Speed: Up to 10 Gbps (Cat6a)

Distance: ~100 meters max

Use: Office/home networks

Fiber

Fiber Optic

Types: Single-mode, Multi-mode

Speed: Up to 400 Gbps+

Distance: 100+ kilometers

Use: Data centers, ISP backbones

Wireless

Wi-Fi / Radio

Standard: 802.11ax (Wi-Fi 6/6E), 802.11be (Wi-Fi 7)

Speed: Up to 9.6 Gbps (Wi-Fi 6)

Frequency: 2.4 GHz, 5 GHz, 6 GHz

Use: Mobile devices, IoT

šŸ’” 2026 Wi-Fi Standard: Wi-Fi 7 (802.11be)

Wi-Fi 7 began rolling out in 2024-2025 and offers up to 46 Gbps theoretical speeds, 320 MHz channels, and Multi-Link Operation (MLO) for simultaneous connections on multiple bands.

Key Concepts

Encoding Methods

How bits are represented as signals:

  • Manchester Encoding: Used in classic Ethernet. High-to-low = 1, Low-to-high = 0.
  • 4B/5B: Converts 4-bit data into 5-bit codes (prevents long strings of 0s).
  • PAM5 (used in Gigabit Ethernet): 5 voltage levels instead of 2.

Devices at Layer 1

  • Hubs: Broadcast signals to all ports (obsolete).
  • Repeaters: Amplify/regenerate signals to extend distance.
  • Network Interface Cards (NICs): Convert digital data to physical signals.
  • Cables: Physical medium (copper, fiber, coax).
Deep Dive: How Ethernet Cable Pins Work (T568A vs T568B)

Standard Ethernet Cable (Cat5e/Cat6) Wiring:

  • Pin 1-2: TX+ and TX- (Transmit)
  • Pin 3-6: RX+ and RX- (Receive)
  • Pin 4-5, 7-8: Used in Gigabit Ethernet (all 4 pairs)

T568A vs T568B: Different wire color orders. T568B is most common in North America. Both work identically if used consistently on both ends.

Crossover Cable: One end T568A, other end T568B. Used to directly connect two computers (rarely needed now—Auto-MDIX does this automatically).

āœ“ Checkpoint: Can you...

  • Name three types of transmission media?
  • Explain what encoding is?
  • Describe the difference between copper and fiber?
  • Name devices that operate at Layer 1?

10 Data Encapsulation: The Journey Through Layers

Encapsulation is how each layer wraps data with its own header (and sometimes trailer) as it moves down the OSI stack. Think of it like nesting Russian dolls—each layer adds its own envelope.

SENDER (Encapsulation) Application Data L6 Hdr Data L5 Hdr Data TCP Hdr SEGMENT IP Hdr PACKET Eth Hdr FRAME Trailer BITS (01001101...) Network Transmission RECEIVER (De-encapsulation) BITS → Frame Strip Eth Hdr/Trailer → PACKET Strip IP Hdr → SEGMENT Strip TCP Hdr → DATA Process Session Info Decrypt/Decompress Application Data āœ“

The Step-by-Step Process

Sending Data (Encapsulation)

  1. Layer 7 (Application): User creates data (email, web page)
  2. Layer 6 (Presentation): Encrypts/compresses data
  3. Layer 5 (Session): Adds session management info
  4. Layer 4 (Transport): Adds TCP/UDP header with port numbers → SEGMENT
  5. Layer 3 (Network): Adds IP header with source/destination IP → PACKET
  6. Layer 2 (Data Link): Adds Ethernet header/trailer with MAC addresses → FRAME
  7. Layer 1 (Physical): Converts to electrical/light/radio signals → BITS

Receiving Data (De-encapsulation)

The receiver does the exact opposite—stripping off each layer's header as it moves UP the stack:

  1. Layer 1: Receives bits, converts to frame
  2. Layer 2: Checks MAC address, strips Ethernet header → packet
  3. Layer 3: Checks IP address, strips IP header → segment
  4. Layer 4: Checks port number, strips TCP/UDP header → data
  5. Layers 5-7: Process session/presentation/application data

🧠 Remember Encapsulation

"All People Seem To Need Data Processing"

Application → Presentation → Session → Transport (Segment) → Network (Packet) → Data Link (Frame) → Physical (Bits)

āœ“ Checkpoint: Can you...

  • Explain what encapsulation is?
  • Name the data unit at each layer?
  • Describe de-encapsulation?
  • Explain why each layer adds a header?

Partial Encapsulation/Decapsulation at Routers

This is a critical concept that many beginners miss: Routers do NOT perform complete decapsulation. They only decapsulate to Layer 3, make routing decisions, then re-encapsulate with new Layer 2 information.

šŸ’” Key Concept

When a packet travels through a router, the router strips the Layer 2 frame, reads the Layer 3 packet, then creates a NEW Layer 2 frame for the next network segment. This is called partial encapsulation/decapsulation.

Why Routers Work This Way

Layer 2 is Local

MAC addresses only work on the same physical network. When moving to a different network, you need new Layer 2 addressing for that specific segment.

Layer 3 is End-to-End

IP addresses stay constant from source to destination. This allows packets to cross multiple networks while maintaining their origin and final destination.

What Happens at Each Router Hop

Step 1: Incoming Interface (Decapsulation)
  1. Layer 1: Router receives electrical/optical signals on interface (e.g., eth0)
  2. Layer 2: Router decapsulates Ethernet frame:
    • Checks destination MAC (must match router's interface MAC)
    • Verifies FCS (Frame Check Sequence) - drops if corrupted
    • Strips Ethernet header and trailer
    • Extracts the IP packet
  3. Layer 3: Router processes IP packet:
    • Reads destination IP address
    • Consults routing table to find next hop or outgoing interface
    • Decrements TTL by 1 (prevents routing loops)
    • Recalculates IP header checksum
Step 2: Routing Decision
  • Router looks up destination IP in routing table
  • Determines next-hop IP address OR directly connected network
  • If next-hop MAC address unknown, router sends ARP request to find it
Step 3: Outgoing Interface (Re-encapsulation)
  1. Layer 3: IP packet ready (TTL decremented, checksum updated)
  2. Layer 2: Router creates NEW Ethernet frame:
    • Source MAC = Router's outgoing interface MAC (e.g., eth1 MAC)
    • Destination MAC = Next hop's MAC address
    • Adds new Ethernet header and FCS trailer
  3. Layer 1: Transmits frame as signals on outgoing interface
Router Partial Encapsulation Process INCOMING FRAME Eth Hdr IP Header TCP Data FCS Src MAC: PC-A | Dst MAC: Router IP: 192.168.1.10 → 10.0.0.50, TTL=64 STEP 1: DE-ENCAPSULATION Strip Layer 2 (Frame) Remove Ethernet header + FCS trailer IP Hdr TCP Data ← PACKET (Layer 3 PDU) STEP 2: LAYER 3 PROCESSING Read IP Header • Check destination IP: 10.0.0.50 • Decrement TTL: 64 → 63 Route • Routing table • Next: Router2 ARP Get Router2 MAC STEP 3: RE-ENCAPSULATION Create NEW Layer 2 • Src MAC: Router eth1 (outgoing) • Dst MAC: Router2 MAC (next hop) NEW Eth IP TCP Data FCS OUTGOING FRAME NEW Hdr IP Header TCP Data NEW FCS Src MAC: Router | Dst MAC: Router2 āœ“ NEW IP: 192.168.1.10 → 10.0.0.50, TTL=63 āœ“ SAME CHANGED: • Source MAC • Destination MAC • FCS (recalculated) • TTL (decremented) • IP Checksum UNCHANGED: • Source IP • Destination IP • Source Port • Destination Port • Application Data

Visual Example: Packet Through 2 Routers

šŸ–„ļø PC-A (192.168.1.10) sends to PC-B (10.0.0.50)

AT SENDER (PC-A):

[MAC: PC-A → Router1] [IP: 192.168.1.10 → 10.0.0.50, TTL=64] [TCP] [Data]

↓ ROUTER 1 Receives Frame

• Layer 2: Checks MAC (matches Router1's eth0) → STRIPS [MAC: PC-A → Router1]

• Layer 3: Reads destination IP: 10.0.0.50

• Routing Table: "To reach 10.0.0.0/24, send to Router2 (172.16.0.2)"

• Decrements TTL: 64 → 63

• ARP: "What's Router2's MAC?" → 00:22:33:44:55:66

• Layer 2: CREATES NEW [MAC: Router1 → Router2]

LEAVING ROUTER 1:

[MAC: Router1 → Router2] [IP: 192.168.1.10 → 10.0.0.50, TTL=63] [TCP] [Data]

Notice: IP addresses unchanged, MAC addresses NEW, TTL decremented

↓ ROUTER 2 Receives Frame

• Layer 2: Checks MAC (matches Router2's eth0) → STRIPS [MAC: Router1 → Router2]

• Layer 3: Reads destination IP: 10.0.0.50

• Routing Table: "10.0.0.50 is directly connected on eth1"

• Decrements TTL: 63 → 62

• ARP: "What's PC-B's MAC?" → AA:BB:CC:DD:EE:FF

• Layer 2: CREATES NEW [MAC: Router2 → PC-B]

ARRIVING AT PC-B:

[MAC: Router2 → PC-B] [IP: 192.168.1.10 → 10.0.0.50, TTL=62] [TCP] [Data]

PC-B performs FULL decapsulation (strips all headers up to Layer 7)

What Changes vs What Stays the Same

Layer Field At Each Router Hop
Layer 2 Source MAC CHANGED → Router's outgoing interface MAC
Layer 2 Destination MAC CHANGED → Next hop's MAC
Layer 2 FCS (Trailer) RECALCULATED → New checksum
Layer 3 TTL DECREMENTED by 1
Layer 3 IP Header Checksum RECALCULATED (due to TTL change)
Layer 3 Source IP UNCHANGED (end-to-end)
Layer 3 Destination IP UNCHANGED (end-to-end)
Layer 4 Source Port UNCHANGED
Layer 4 Destination Port UNCHANGED
Layer 4+ All TCP/UDP/Data UNCHANGED

āš ļø Common Exam Question

Q: "If a packet passes through 5 routers, how many different Layer 2 frames will be created?"

A: 6 frames. The original sender creates 1, then each of the 5 routers creates a new frame = 6 total Layer 2 frames. But there's only 1 Layer 3 packet throughout the journey (with decreasing TTL).

Switches vs Routers: The Critical Difference

Layer 2 Switch

Forwarding Behavior:

  • Operates at Layer 2 only
  • Reads destination MAC address
  • Does NOT modify the frame
  • Forwards frame unchanged
  • Does NOT touch IP header or TTL
  • Works within single network/VLAN

Layer 3 Router

Forwarding Behavior:

  • Operates at Layer 3
  • Reads destination IP address
  • Strips Layer 2 frame completely
  • Creates NEW Layer 2 frame
  • Decrements TTL, recalculates checksum
  • Routes between different networks

āœ“ Checkpoint: Can you...

  • Explain why routers strip and rebuild Layer 2 headers?
  • Identify which parts of a packet change at each router hop?
  • Describe what happens to TTL as a packet crosses routers?
  • Explain why source/destination IP addresses stay the same but MAC addresses change?
  • Calculate how many Layer 2 frames are created if a packet crosses 3 routers?
  • Explain the difference between how switches and routers handle frames?

11 Real-World Examples

Let's trace actual network activities through the OSI Model to see how everything works together.

Example 1: Loading a Web Page (HTTPS)

Scenario: You type "https://example.com" in your browser

Layer 7 (Application):
  • Browser sends HTTP GET request for "/" resource
  • DNS resolution happens first (example.com → 93.184.216.34)
Layer 6 (Presentation):
  • TLS 1.3 handshake encrypts the connection
  • Data is compressed if supported (gzip/Brotli)
Layer 5 (Session):
  • HTTPS session established and maintained
  • Cookies/session tokens managed
Layer 4 (Transport):
  • TCP connection to port 443 (HTTPS)
  • Three-way handshake (SYN → SYN-ACK → ACK)
  • Segments transmitted with sequence numbers
Layer 3 (Network):
  • IP packet created: Source IP (your device) → Destination IP (93.184.216.34)
  • Routers determine best path hop-by-hop
  • TTL decrements at each router
Layer 2 (Data Link):
  • Ethernet frame created with your MAC → router's MAC
  • ARP resolves router IP to MAC address
  • Switch forwards frame to correct port
Layer 1 (Physical):
  • Bits transmitted over Ethernet cable / Wi-Fi
  • Electrical signals (cable) or radio waves (Wi-Fi)

Example 2: Troubleshooting Network Issues

Scenario: "The Internet is Down!"

Using the OSI Model to isolate the problem:

  • Layer 1 Check: Are cables plugged in? Link lights on? ethtool eth0
  • Layer 2 Check: Can you ping the gateway by IP? arp -a shows MAC addresses?
  • Layer 3 Check: ping 8.8.8.8 (Google DNS) works? traceroute shows hops?
  • Layer 4 Check: telnet example.com 80 connects? Firewall blocking ports?
  • Layer 7 Check: nslookup google.com resolves? Browser settings correct?

šŸ’” The OSI Troubleshooting Philosophy

Start at Layer 1 and work up. There's no point debugging DNS (Layer 7) if your cable is unplugged (Layer 1). Always verify the foundation first.

12 Practice Problems

Problem 1: Layer Identification

Question: A network administrator notices that devices can communicate on the local network but cannot reach the internet. Which OSI layer is most likely causing the problem?

View Solution

Answer: Layer 3 (Network Layer)

Explanation:

  • Devices can communicate locally = Layers 1 and 2 are working (cables, switches, MAC addressing)
  • Cannot reach internet = routing problem (Layer 3)
  • Likely issues: Default gateway misconfigured, router down, or ISP routing problem
  • Diagnostic: ping [gateway IP] works but ping 8.8.8.8 fails

Problem 2: Protocol Matching

Question: Match each protocol to its correct OSI layer:

  1. HTTPS
  2. TCP
  3. Ethernet
  4. IP
  5. TLS
View Solution

Answers:

  1. HTTPS: Layer 7 (Application)
  2. TCP: Layer 4 (Transport)
  3. Ethernet: Layer 2 (Data Link)
  4. IP: Layer 3 (Network)
  5. TLS: Layer 6 (Presentation) - handles encryption

Problem 3: Data Unit Identification

Question: When data leaves the Transport Layer and enters the Network Layer, what is it called? What information is added?

View Solution

Answer:

  • Data Unit Name: Packet (Layer 3 calls it a packet)
  • What's Added: IP header containing:
    • Source IP address
    • Destination IP address
    • TTL (Time To Live)
    • Protocol (TCP=6, UDP=17)
    • Header checksum
  • Previous Layer: Transport Layer called it a "segment" (TCP) or "datagram" (UDP)

Problem 4: Real-World Scenario

Question: You can successfully ping a web server by IP address (e.g., 142.250.185.46) but cannot access it by domain name (google.com). Which layer is the problem at, and what protocol is likely failing?

View Solution

Answer: Layer 7 (Application Layer) - DNS Failure

Explanation:

  • Ping by IP works = Layers 1-3 are functional (Physical, Data Link, Network)
  • Cannot resolve domain name = DNS (Layer 7) is broken
  • Likely Causes: DNS server misconfigured, DNS server down, firewall blocking port 53
  • Diagnostic: nslookup google.com fails or times out
  • Fix: Change DNS servers to 8.8.8.8 (Google) or 1.1.1.1 (Cloudflare)

Problem 5: Encapsulation Order

Question: Place the following steps in the correct order for sending an email:

  1. TCP header added with port 587
  2. Email composed in application
  3. Bits transmitted over Wi-Fi
  4. IP header added with destination server IP
  5. Ethernet frame created with MAC addresses
  6. TLS encrypts the connection
View Solution

Correct Order:

  1. 2. Email composed in application (Layer 7)
  2. 6. TLS encrypts the connection (Layer 6)
  3. 1. TCP header added with port 587 (Layer 4)
  4. 4. IP header added with destination server IP (Layer 3)
  5. 5. Ethernet frame created with MAC addresses (Layer 2)
  6. 3. Bits transmitted over Wi-Fi (Layer 1)

Key Insight: Encapsulation flows top to bottom (Application → Physical).

13 Knowledge Check

1. Which layer is responsible for logical addressing (IP addresses)?

Layer 4 (Transport)āŒ
Layer 3 (Network)āœ…
Layer 2 (Data Link)āŒ

2. What is the data unit at Layer 2?

SegmentāŒ
PacketāŒ
Frameāœ…

3. Which protocol operates at the Transport Layer?

HTTPāŒ
TCPāœ…
IPāŒ

4. What does TLS do in the OSI Model?

Encrypts data at the Presentation Layerāœ…
Routes packets at the Network LayerāŒ
Manages MAC addresses at the Data Link LayerāŒ

5. A switch operates primarily at which layer?

Layer 1 (Physical)āŒ
Layer 2 (Data Link)āœ…
Layer 3 (Network)āŒ

6. What is the main difference between TCP and UDP?

TCP is reliable; UDP is unreliableāœ…
TCP uses port numbers; UDP does notāŒ
TCP is Layer 3; UDP is Layer 4āŒ

7. Which layer converts data into electrical signals?

Layer 1 (Physical)āœ…
Layer 2 (Data Link)āŒ
Layer 3 (Network)āŒ

8. In 2026, which IP version is increasingly adopted for new networks?

IPv4āŒ
IPv6āœ…
IPv5āŒ