DEV Community

Cover image for Networking 101: Part 2
Himanshu Bhatt
Himanshu Bhatt

Posted on

Networking 101: Part 2

Understanding Networking Models: OSI vs. TCP/IP

Networking models provide a structured way to understand how data travels from one device to another. They break down a complex process into simple, manageable steps. Whether you're new to networking or looking to brush up on the basics, this blog will guide you from the very beginning (0) to an advanced understanding—all explained in simple language.

In this post, we'll cover:

  • Why layered models are important
  • A detailed look at the OSI model (7 layers)
  • An introduction to the TCP/IP model (4 layers)
  • How the two models map to each other
  • Key protocols used in each layer
  • How Data Flows: From Your Laptop to YouTube
  • How these models help with troubleshooting and system design

1. Why Layered Models?

Imagine building a house: you start with a foundation, then add walls, wiring, and finally the roof. Each step relies on the previous one. Similarly, networking models break the process of sending data into layers, where each layer handles a specific part of the job. This makes it easier to design, troubleshoot, and update networks without redoing the entire system.

Key benefits of layered models:

  • Modularity: Each layer has its own responsibility.
  • Simplified Troubleshooting: You can pinpoint problems to a specific layer.
  • Interoperability: Different devices and software can work together because they adhere to common standards.

2. The OSI Model (7 Layers)

The OSI (Open Systems Interconnection) model is a conceptual framework that divides network communication into 7 layers. Each layer adds its own header (a kind of packaging) to the data and passes it on to the next layer. Here’s a breakdown from the bottom (physical) to the top (application):

Layer 1: Physical (Bits 🔌)

  • Function: Transmits raw bits (0s and 1s) over physical media.
  • What It Uses: Cables, fiber optics, radio waves (Wi-Fi), and hardware devices like hubs and repeaters.
  • Data Unit: Bits
  • Analogy: Think of it as the plumbing pipes that carry water.

Layer 2: Data Link (Frames 🖇️)

  • Function: Provides reliable node-to-node communication by framing raw bits into meaningful units called frames and using physical addresses (MAC addresses).
  • What It Uses: Ethernet, switches.
  • Data Unit: Frames (which include a header with MAC addresses and error-checking information)
  • Analogy: Like a postal worker reading an envelope with a street address to deliver a letter correctly.

Layer 3: Network (Packets 🌍)

  • Function: Routes data between different networks using logical addresses (IP addresses).
  • What It Uses: Routers, and protocols like IP (Internet Protocol) and ICMP.
  • Data Unit: Packets (frames with an added IP header)
  • Analogy: Like a GPS system that finds the best route for your letter to travel across cities.

Layer 4: Transport (Segments 🚚)

  • Function: Ensures complete data transfer between devices, managing error recovery, flow control, and data segmentation.
  • What It Uses: Protocols such as TCP (for reliable connections) and UDP (for fast, connectionless communication).
  • Data Unit: Segments (TCP) or Datagrams (UDP)
  • Analogy: Imagine a courier who not only delivers parts of a package in the correct order but also checks that nothing is missing.

Layer 5: Session (Handshakes 🤝)

  • Function: Manages sessions or connections between applications. It sets up, maintains, and terminates communication sessions.
  • What It Uses: Protocols like NetBIOS and RPC.
  • Data Unit: Session messages
  • Analogy: Like a telephone operator who connects calls and makes sure conversations start and end smoothly.

Layer 6: Presentation (Translation 🔄)

  • Function: Translates data into a format that the Application layer can understand. It handles encryption, decryption, compression, and data translation.
  • What It Uses: Protocols such as SSL/TLS (for encryption), ASCII (for text), JPEG (for images).
  • Data Unit: Formatted data
  • Analogy: Like a translator who converts a foreign language into your native language.

Layer 7: Application (Apps 📱)

  • Function: Provides network services directly to applications and users. It is where all user interaction happens.
  • What It Uses: Protocols such as HTTP, SMTP, FTP, and DNS.
  • Data Unit: Messages
  • Analogy: Like the final product you see—a web page, an email, or a file download.

3. The TCP/IP Model (4 Layers)

The TCP/IP model is the practical model used on the internet. It combines some of the OSI layers for simplicity. Here are its 4 layers:

TCP/IP Layer Corresponding OSI Layers Key Protocols
Application Application, Presentation, Session HTTP, SMTP, FTP, DNS, etc.
Transport Transport TCP, UDP
Internet Network IP, ICMP
Link Data Link, Physical Ethernet, ARP, Wi-Fi, etc.

Layer 1: Link (Network Interface)

  • Function: Handles the physical transmission of data (combines OSI’s Physical and Data Link layers).
  • What It Uses: Cables, switches, Wi-Fi hardware.
  • Analogy: The pipes and local wiring that connect devices within a building.

Layer 2: Internet

  • Function: Routes packets across different networks using logical addresses.
  • What It Uses: Routers and the IP protocol.
  • Analogy: Like a mail sorting center that figures out which postal route to send your letter on.

Layer 3: Transport

  • Function: Provides reliable or fast data transfer between endpoints.
  • What It Uses: TCP (ensures reliability) and UDP (offers speed when reliability isn’t critical).
  • Analogy: Like a delivery service that confirms receipt of every package or simply drops off the package quickly.

Layer 4: Application

  • Function: Combines the responsibilities of the OSI’s Session, Presentation, and Application layers.
  • What It Uses: Various protocols that provide network services (e.g., HTTP for web pages, DNS for name resolution).
  • Analogy: The interface you interact with, like browsing a website or sending an email.

4. Mapping OSI to TCP/IP

Here’s a quick reference for how the OSI model maps to the TCP/IP model:

OSI Model Layers TCP/IP Model Layers
Physical & Data Link Link (Network Interface)
Network Internet
Transport Transport
Session, Presentation, Application Application

This mapping shows that while the OSI model is more detailed, the TCP/IP model is simpler and reflects the actual protocols used on the internet.


5. Key Protocols at Each Layer

Understanding common protocols will help you grasp how data is processed at each layer:

  • Data Link / Link Layer:
    • Ethernet: Manages local area network communication.
    • ARP (Address Resolution Protocol): Maps IP addresses to MAC addresses.
  • Network / Internet Layer:
    • IP (Internet Protocol): Routes packets using IP addresses.
    • ICMP (Internet Control Message Protocol): Used for error messages and diagnostics (e.g., ping).
  • Transport Layer:
    • TCP (Transmission Control Protocol): Provides reliable, connection-oriented communication.
    • UDP (User Datagram Protocol): Provides fast, connectionless communication.
  • Application Layer:
    • HTTP, SMTP, FTP, DNS: Support services like web browsing, email, file transfer, and domain name resolution.

6. How Data Flows: From Your Laptop to YouTube 🚀

Step 1: Encapsulation (Sending Data)

  • Application Layer: You type "youtube.com" → your browser performs a DNS lookup to resolve the domain to an IP address → an HTTP request is created.

  • Transport Layer: TCP adds a header with port 80 (for HTTP) or port 443 (for HTTPS).

  • Network Layer: IP adds source/destination IPs (e.g., your IP → YouTube’s IP).

  • Data Link Layer: Ethernet adds your MAC address and your router’s MAC address.

  • Physical Layer: Converts frames to electrical or optical signals for transmission over the network.

Step 2: Across the Internet 🌐

  • Routers read IP headers to forward packets to the appropriate destination based on the IP address.

  • Switches use MAC addresses to move frames locally within the same network.

Step 3: Decapsulation (Receiving Data)

  • Physical Layer: YouTube’s server receives bits over the medium (electrical or optical signals).

  • Data Link Layer: Strips off the MAC addresses from the frames.

  • Network Layer: Checks if the destination IP address matches the server’s IP.

  • Transport Layer: TCP reassembles the data segments in order, ensuring no packets are lost or out of order.

  • Application Layer: YouTube’s server sends back the video data as an HTTP (or HTTPS) response, which your browser processes and displays.


7. How These Models Help in Troubleshooting and Design 🛠️

  • Troubleshooting:

    • Physical Issues: Check cables and hardware if data isn’t being transmitted.
    • Data Link Issues: Verify MAC addresses and switch configurations.
    • Network Issues: Use tools like ping and traceroute to test IP connectivity.
    • Transport/Application Issues: Investigate port blocks or firewall rules if data isn’t reaching the right application.
  • Designing Systems:

    • Modularity: You can upgrade or change one layer (like moving from IPv4 to IPv6) without reconfiguring the entire network.
    • Interoperability: Devices from different manufacturers can work together if they follow these standard models.
    • Scalability: Layered designs allow for adding new protocols (e.g., HTTP/3) without overhauling lower layers.

Conclusion 🎯

The OSI and TCP/IP models are essential blueprints that help us understand how data moves from one device to another. By breaking the process into layers—from the physical cables to the applications we interact with—we can design, troubleshoot, and improve networks more effectively.

Whether you’re a novice or an experienced engineer, mastering these models will give you the tools to build and maintain reliable, secure, and scalable systems. In our next post, we’ll explore IP addressing, subnetting, and CIDR notation in simple, step-by-step detail.

Happy learning and keep exploring the layers of networking!


Top comments (0)