System Design

OSI Model vs TCP/IP Model | System Design Essentials

Welcome back to the System Design Essentials series! Before we can design distributed systems that communicate across the globe, we absolutely must understand how that communication physically happens.

In this guide, we are diving deep into the foundation of computer networking: the OSI Model and the TCP/IP Model. These conceptual frameworks map out exactly how data travels from an application on your laptop, through the internet, and directly into a server halfway across the world.

The OSI Model (Open Systems Interconnection)

The OSI model is a theoretical, 7-layer framework developed by the ISO. While it isn't strictly what the modern internet runs on today, it is the universal language engineers use to troubleshoot and design network architectures.

Think of it like an assembly line. When you send an email, the data starts at the top layer and moves down, getting wrapped in protective "envelopes" (headers) at each step. When the receiving server gets it, the data moves bottom-up, unwrapping the envelopes until it reaches the email application.

The 7 Layers of OSI (Top to Bottom)

  1. Layer 7 - Application: The layer closest to the end-user. This is where your web browsers and email clients live. (Protocols: HTTP, HTTPS, FTP, SMTP)
  2. Layer 6 - Presentation: Responsible for formatting, encrypting, and translating the data so the application layer can understand it. (Protocols: SSL, TLS, JPEG)
  3. Layer 5 - Session: Establishes, maintains, and terminates the communication session between two devices.
  4. Layer 4 - Transport: The crucial layer that breaks data into "segments" and ensures it gets to the destination reliably. (Protocols: TCP, UDP)
  5. Layer 3 - Network: Responsible for routing the data across multiple different networks using IP addresses. It breaks segments into "packets." (Protocols: IPv4, IPv6, ICMP)
  6. Layer 2 - Data Link: Responsible for node-to-node delivery on the same local network using MAC addresses. It breaks packets into "frames." (Protocols: Ethernet, Wi-Fi, ARP)
  7. Layer 1 - Physical: The raw, physical hardware. Cables, radio waves, electrical signals, and fiber optics transmitting bits (1s and 0s).

The TCP/IP Model (Transmission Control Protocol / Internet Protocol)

While the OSI model is great for theory, the TCP/IP model is the actual, practical framework that the internet was built upon. Developed by the Department of Defense (DoD), it condensed the 7 OSI layers into 4 highly functional layers.

The 4 Layers of TCP/IP

  1. Application Layer: Combines the OSI Application, Presentation, and Session layers into one massive layer. It handles all high-level protocols like HTTP, DNS, and SSH.
  2. Transport Layer: Directly maps to the OSI Transport layer. It controls the flow of data using TCP (reliable) or UDP (fast).
  3. Internet Layer: Directly maps to the OSI Network layer. It handles the logical routing of packets across the web using IP addresses.
  4. Network Access Layer: Combines the OSI Data Link and Physical layers. It handles the actual hardware transmission of the data.

Why Does This Matter in System Design?

As a software engineer, why do you need to know this?

In a system design interview, you will frequently need to make networking decisions.

  • If you are building a video streaming service (like Netflix or Twitch), do you use TCP or UDP? (Hint: You use UDP at Layer 4 because speed is more important than perfect reliability).
  • If your system is under a DDoS attack, is it an L7 (Application Layer) attack like HTTP flooding, or an L3 (Network Layer) attack like an ICMP flood? You cannot mitigate an attack if you don't know what layer it is targeting.
  • When configuring a Load Balancer, do you need an L4 Load Balancer (fast, looks only at IP/Ports) or an L7 Load Balancer (slower, looks at internal HTTP headers to make smart routing decisions)?

Conclusion

Understanding the difference between OSI and TCP/IP, and intimately knowing layers 3, 4, and 7, is a non-negotiable prerequisite for anyone looking to build, scale, or secure a distributed architecture.

Watch the video above for a complete whiteboard breakdown on exactly how these models function under the hood!