Master the OSI Model
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 ā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:
7-Layer Model
Purpose: Teaching and reference framework
Layers: Application, Presentation, Session, Transport, Network, Data Link, Physical
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.
š” 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
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
Web Protocol
Ports: 80 (HTTP), 443 (HTTPS)
Function: Transfers web content
2026: HTTP/3 uses QUIC (UDP)
Name Resolution
Port: 53 (UDP/TCP)
Function: Domain ā IP translation
Example: google.com ā 142.250.185.46
Email Sending
Ports: 25, 587 (TLS)
Function: Sends email
Pair with: IMAP/POP3 for receiving
IP Assignment
Ports: 67 (server), 68 (client)
Function: Auto IP configuration
Process: Discover ā Offer ā Request ā Ack
Secure Remote Access
Port: 22
Function: Encrypted terminal access
Replaces: Telnet (unencrypted)
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
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):
- Client Hello: Browser sends supported cipher suites and a random number.
- Server Hello: Server picks a cipher suite, sends certificate + public key + random number.
- Key Exchange: Both sides generate a shared secret using Diffie-Hellman.
- 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
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
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.
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.
Point-to-Point Tunneling Protocol
Purpose: Creates VPN tunnels. 2026 Status: Deprecated due to security vulnerabilities. Use IPsec, OpenVPN, or WireGuard instead.
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.
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
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
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
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:
- SYN (Synchronize): Client sends SYN flag with initial sequence number (ISN). "I want to connect, my sequence starts at 1000."
- 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."
- 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.
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:
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
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
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
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
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
Interior gateway protocol. Uses Dijkstra's algorithm. Fast convergence. Link-state routing.
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.
Connectivity Test
How it works: Sends ICMP Echo Request, receives Echo Reply
Use case: Test if host is reachable and measure round-trip time
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):
- Check for most specific match (longest prefix)
- 192.168.1.50 ā Matches 192.168.1.0/24 (send locally)
- 10.5.1.1 ā Matches 10.0.0.0/8 (send to 192.168.1.1)
- 8.8.8.8 ā No specific match ā Use default route 0.0.0.0/0
- Decrement TTL by 1 at each hop
- 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
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
- ARP Request (Broadcast): "Who has IP 192.168.1.10? Tell 192.168.1.5"
- ARP Reply (Unicast): "192.168.1.10 is at MAC 00:1A:2B:3C:4D:5E"
- Cache: Device stores this in ARP cache for future use
Data Link Layer Protocols
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).
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.
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
Layer 1 Device (Dumb)
- Broadcasts to ALL ports
- Causes collisions (half-duplex)
- Creates single collision domain
- Obsolete in 2026
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:
- Frame arrives on Port 1 with source MAC 00:1A:2B:3C:4D:5E
- Switch adds entry: "Port 1 = MAC 00:1A:2B:3C:4D:5E"
- Next time, frames to that MAC go only to Port 1
- 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
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
Twisted Pair (Ethernet)
Types: Cat5e, Cat6, Cat6a, Cat7
Speed: Up to 10 Gbps (Cat6a)
Distance: ~100 meters max
Use: Office/home networks
Fiber Optic
Types: Single-mode, Multi-mode
Speed: Up to 400 Gbps+
Distance: 100+ kilometers
Use: Data centers, ISP backbones
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.
The Step-by-Step Process
Sending Data (Encapsulation)
- Layer 7 (Application): User creates data (email, web page)
- Layer 6 (Presentation): Encrypts/compresses data
- Layer 5 (Session): Adds session management info
- Layer 4 (Transport): Adds TCP/UDP header with port numbers ā SEGMENT
- Layer 3 (Network): Adds IP header with source/destination IP ā PACKET
- Layer 2 (Data Link): Adds Ethernet header/trailer with MAC addresses ā FRAME
- 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:
- Layer 1: Receives bits, converts to frame
- Layer 2: Checks MAC address, strips Ethernet header ā packet
- Layer 3: Checks IP address, strips IP header ā segment
- Layer 4: Checks port number, strips TCP/UDP header ā data
- 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)
- Layer 1: Router receives electrical/optical signals on interface (e.g., eth0)
- 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
- 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)
- Layer 3: IP packet ready (TTL decremented, checksum updated)
- 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
- Layer 1: Transmits frame as signals on outgoing interface
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
- Browser sends HTTP GET request for "/" resource
- DNS resolution happens first (example.com ā 93.184.216.34)
- TLS 1.3 handshake encrypts the connection
- Data is compressed if supported (gzip/Brotli)
- HTTPS session established and maintained
- Cookies/session tokens managed
- TCP connection to port 443 (HTTPS)
- Three-way handshake (SYN ā SYN-ACK ā ACK)
- Segments transmitted with sequence numbers
- 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
- Ethernet frame created with your MAC ā router's MAC
- ARP resolves router IP to MAC address
- Switch forwards frame to correct port
- 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 -ashows MAC addresses? -
Layer 3 Check:
ping 8.8.8.8(Google DNS) works?tracerouteshows hops? -
Layer 4 Check:
telnet example.com 80connects? Firewall blocking ports? -
Layer 7 Check:
nslookup google.comresolves? 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 butping 8.8.8.8fails
Problem 2: Protocol Matching
Question: Match each protocol to its correct OSI layer:
- HTTPS
- TCP
- Ethernet
- IP
- TLS
View Solution
Answers:
- HTTPS: Layer 7 (Application)
- TCP: Layer 4 (Transport)
- Ethernet: Layer 2 (Data Link)
- IP: Layer 3 (Network)
- 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.comfails 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:
- TCP header added with port 587
- Email composed in application
- Bits transmitted over Wi-Fi
- IP header added with destination server IP
- Ethernet frame created with MAC addresses
- TLS encrypts the connection
View Solution
Correct Order:
- 2. Email composed in application (Layer 7)
- 6. TLS encrypts the connection (Layer 6)
- 1. TCP header added with port 587 (Layer 4)
- 4. IP header added with destination server IP (Layer 3)
- 5. Ethernet frame created with MAC addresses (Layer 2)
- 3. Bits transmitted over Wi-Fi (Layer 1)
Key Insight: Encapsulation flows top to bottom (Application ā Physical).