Skip to main content

Network Fundamentals and OSI Model

The OSI Model Deep Dive

0:00
LearnStep 1/3

Unpacking the Stack: OSI vs. Reality

For senior engineers, the Open Systems Interconnection (OSI) model isn't just a textbook diagram; it's a mental framework for isolation. When a microservice times out or a packet drops, knowing exactly which layer is responsible is the difference between a 5-minute fix and a 5-hour outage.

The 7 Layers & PDUs

Data moves down the stack (Encapsulation) and up the stack (Decapsulation). At each layer, a Protocol Data Unit (PDU) is formed.

LayerNamePDUFunction & Examples
7ApplicationDataHigh-level APIs. HTTP, DNS, SSH, gRPC.
6PresentationDataEncoding/Encryption. SSL/TLS (often grouped here), JSON serialization.
5SessionDataSession state. RPC mapping, NetBIOS.
4TransportSegment/DatagramEnd-to-end reliability/flow control. TCP, UDP, Ports.
3NetworkPacketRouting/Addressing. IP (IPv4/IPv6), ICMP, IPSec.
2Data LinkFrameNode-to-node transfer. Ethernet, MAC addresses, VLANs, ARP.
1PhysicalBitThe wire/signal. Fiber, Copper, WiFi radio waves.

Encapsulation in Action

When your application sends an HTTP GET request:

  1. L7: Construction of the HTTP payload.
  2. L4: TCP header added (Source Port: 54321, Dest Port: 80). PDU: Segment.
  3. L3: IP header added (Source IP: 192.168.1.5, Dest IP: 93.184.216.34). PDU: Packet.
  4. L2: Ethernet header (Source MAC, Gateway MAC) and FCS trailer added. PDU: Frame.
  5. L1: Frame serialized into electrical pulses on the wire.

Troubleshooting with tcpdump

We can verify this encapsulation by inspecting PDUs directly.

bash

OSI vs. TCP/IP

While OSI has 7 layers, the internet runs on the TCP/IP stack, which typically condenses the top three layers (App, Presentation, Session) into the Application Layer and combines Data Link and Physical into the Network Access Layer (or Link Layer). However, the distinction remains vital for debugging: SSL handshake errors are L6/L7, while ARP issues are strictly L2.