Learn Networking in 10 DaysDay 1: Network Fundamentals & the OSI Model

Day 1: Network Fundamentals & the OSI Model

What You'll Learn Today

  • What a computer network is and why networks exist
  • Types of networks: PAN, LAN, MAN, and WAN
  • The OSI 7-layer model and the role of each layer
  • How data encapsulation works across layers
  • How the TCP/IP model compares to the OSI model

What Is a Computer Network?

A computer network is a collection of interconnected devices that can exchange data. The devices β€” computers, servers, phones, printers, IoT sensors β€” communicate over wired or wireless media using agreed-upon rules called protocols.

Networks exist to share resources (files, printers, internet access), enable communication (email, video calls), and provide centralized management (authentication, backups).

flowchart LR
    subgraph Network["Simple Computer Network"]
        A["πŸ’» Laptop"]
        B["πŸ–₯️ Server"]
        C["πŸ–¨οΈ Printer"]
        D["πŸ“± Phone"]
    end
    A --- B
    A --- C
    B --- D
    style Network fill:#3b82f6,color:#fff

At its core, every network relies on three elements:

Element Description Example
Nodes Devices that send or receive data Computers, routers, switches
Links Physical or wireless connections between nodes Ethernet cables, Wi-Fi signals
Protocols Rules governing how data is formatted and transmitted HTTP, TCP, IP

Types of Networks

Networks are classified primarily by their geographic scope.

flowchart LR
    subgraph PAN["PAN\n< 10 m"]
        P1["Bluetooth\nheadset"]
    end
    subgraph LAN["LAN\n< 1 km"]
        L1["Office\nnetwork"]
    end
    subgraph MAN["MAN\n< 50 km"]
        M1["City-wide\nnetwork"]
    end
    subgraph WAN["WAN\nGlobal"]
        W1["The\nInternet"]
    end
    PAN --> LAN --> MAN --> WAN
    style PAN fill:#8b5cf6,color:#fff
    style LAN fill:#3b82f6,color:#fff
    style MAN fill:#22c55e,color:#fff
    style WAN fill:#f59e0b,color:#fff
Type Full Name Range Speed Example
PAN Personal Area Network ~10 meters Low–Medium Bluetooth devices, USB tethering
LAN Local Area Network Up to ~1 km High (1–10 Gbps) Office or home network
MAN Metropolitan Area Network Up to ~50 km Medium–High City-wide cable TV network
WAN Wide Area Network Unlimited Varies The Internet, corporate MPLS

PAN (Personal Area Network)

A PAN connects devices within your immediate personal space. Bluetooth pairing your phone to headphones creates a PAN. These networks are small, low-power, and short-range.

LAN (Local Area Network)

A LAN covers a building or campus. Most office networks and home Wi-Fi setups are LANs. They use Ethernet (IEEE 802.3) or Wi-Fi (IEEE 802.11) and offer high bandwidth with low latency.

MAN (Metropolitan Area Network)

A MAN spans a city or large campus. Internet service providers often operate MANs to connect multiple LANs across a metropolitan area. Cable TV networks are a classic example.

WAN (Wide Area Network)

A WAN connects LANs across cities, countries, or continents. The Internet is the largest WAN. Organizations also build private WANs using leased lines or MPLS to connect branch offices.


The OSI 7-Layer Model

The Open Systems Interconnection (OSI) model, published by ISO in 1984, is a conceptual framework that standardizes network communication into seven layers. Each layer has a specific responsibility and communicates with the layers directly above and below it.

flowchart TB
    subgraph OSI["OSI Model"]
        L7["Layer 7 β€” Application\nHTTP, FTP, SMTP, DNS"]
        L6["Layer 6 β€” Presentation\nSSL/TLS, JPEG, ASCII"]
        L5["Layer 5 β€” Session\nNetBIOS, RPC"]
        L4["Layer 4 β€” Transport\nTCP, UDP"]
        L3["Layer 3 β€” Network\nIP, ICMP, OSPF"]
        L2["Layer 2 β€” Data Link\nEthernet, Wi-Fi, ARP"]
        L1["Layer 1 β€” Physical\nCables, Hubs, Signals"]
    end
    L7 --> L6 --> L5 --> L4 --> L3 --> L2 --> L1
    style L7 fill:#ef4444,color:#fff
    style L6 fill:#f59e0b,color:#fff
    style L5 fill:#f59e0b,color:#fff
    style L4 fill:#22c55e,color:#fff
    style L3 fill:#3b82f6,color:#fff
    style L2 fill:#8b5cf6,color:#fff
    style L1 fill:#8b5cf6,color:#fff

Layer 1: Physical

The Physical layer deals with the raw transmission of bits over a physical medium. It defines voltages, pin layouts, cable specifications, and signal timing.

  • Devices: Hubs, repeaters, cables, connectors
  • Examples: Cat5e/Cat6 Ethernet cables, fiber optic, radio waves (Wi-Fi)
  • PDU: Bits

Layer 2: Data Link

The Data Link layer provides node-to-node data transfer within the same network segment. It handles framing, MAC addressing, and error detection.

  • Devices: Switches, bridges, NICs
  • Protocols: Ethernet (IEEE 802.3), Wi-Fi (IEEE 802.11), PPP
  • PDU: Frames

Layer 3: Network

The Network layer handles logical addressing and routing β€” moving packets from source to destination across multiple networks.

  • Devices: Routers, Layer 3 switches
  • Protocols: IP, ICMP, OSPF, BGP
  • PDU: Packets

Layer 4: Transport

The Transport layer provides end-to-end communication between applications. It manages segmentation, flow control, error recovery, and port numbers.

  • Protocols: TCP (reliable), UDP (fast, connectionless)
  • PDU: Segments (TCP) / Datagrams (UDP)

Layer 5: Session

The Session layer manages sessions β€” ongoing exchanges between two nodes. It handles setup, maintenance, and teardown of connections.

  • Protocols: NetBIOS, RPC, PPTP
  • PDU: Data

Layer 6: Presentation

The Presentation layer handles data translation, encryption, and compression. It ensures the application layer receives data in a usable format.

  • Functions: Encryption (SSL/TLS), data formatting (JPEG, ASCII, MPEG)
  • PDU: Data

Layer 7: Application

The Application layer is the interface between the network and the end user's software. It provides network services directly to applications.

  • Protocols: HTTP, FTP, SMTP, DNS, SSH
  • PDU: Data
Layer Name Key Function Devices/Protocols PDU
7 Application User interface to network HTTP, DNS, FTP Data
6 Presentation Data format, encryption SSL/TLS, JPEG Data
5 Session Session management NetBIOS, RPC Data
4 Transport End-to-end delivery TCP, UDP Segment/Datagram
3 Network Routing, logical addressing IP, ICMP, OSPF Packet
2 Data Link Framing, MAC addressing Ethernet, Wi-Fi Frame
1 Physical Bit transmission Cables, hubs Bits

Mnemonic: "All People Seem To Need Data Processing" (top-down) or "Please Do Not Throw Sausage Pizza Away" (bottom-up).


Data Encapsulation

When data travels from an application down through the OSI layers, each layer wraps the data with its own header (and sometimes a trailer). This process is called encapsulation. The receiving side reverses the process β€” de-encapsulation.

flowchart TB
    subgraph Encapsulation["Data Encapsulation"]
        D["Application Data"]
        S["Transport Header + Data = Segment"]
        P["Network Header + Segment = Packet"]
        F["Data Link Header + Packet + Trailer = Frame"]
        B["Physical: Bits on the wire"]
    end
    D --> S --> P --> F --> B
    style D fill:#ef4444,color:#fff
    style S fill:#22c55e,color:#fff
    style P fill:#3b82f6,color:#fff
    style F fill:#8b5cf6,color:#fff
    style B fill:#f59e0b,color:#fff
Layer PDU Name What Is Added
Application / Presentation / Session Data Application-level formatting
Transport Segment (TCP) or Datagram (UDP) Source/destination port, sequence numbers
Network Packet Source/destination IP address, TTL
Data Link Frame Source/destination MAC address, FCS (error check)
Physical Bits Electrical/optical signals

Each layer only communicates with its peer layer on the remote device. A router reading a packet does not care about the application data β€” it reads the Layer 3 header to make routing decisions, then forwards the packet.


TCP/IP Model vs. OSI Model

The TCP/IP model (also called the Internet model) is the practical model that the Internet actually uses. It has four layers that map to the OSI model.

flowchart TB
    subgraph OSI["OSI Model (7 Layers)"]
        O7["Application"]
        O6["Presentation"]
        O5["Session"]
        O4["Transport"]
        O3["Network"]
        O2["Data Link"]
        O1["Physical"]
    end
    subgraph TCPIP["TCP/IP Model (4 Layers)"]
        T4["Application"]
        T3["Transport"]
        T2["Internet"]
        T1["Network Access"]
    end
    O7 -.-> T4
    O6 -.-> T4
    O5 -.-> T4
    O4 -.-> T3
    O3 -.-> T2
    O2 -.-> T1
    O1 -.-> T1
    style OSI fill:#3b82f6,color:#fff
    style TCPIP fill:#22c55e,color:#fff
OSI Layer(s) TCP/IP Layer Protocols
7, 6, 5 β€” Application, Presentation, Session Application HTTP, FTP, DNS, SMTP, SSH
4 β€” Transport Transport TCP, UDP
3 β€” Network Internet IP, ICMP, ARP
2, 1 β€” Data Link, Physical Network Access Ethernet, Wi-Fi, PPP

Key differences:

  • The OSI model is a theoretical reference; TCP/IP is a practical implementation.
  • OSI has 7 layers; TCP/IP consolidates them into 4.
  • OSI separates Presentation and Session; TCP/IP rolls them into the Application layer.
  • Most real-world troubleshooting uses the TCP/IP model, but the OSI model is invaluable for understanding concepts and certification exams.

Summary

Summary Table

Concept Key Point
Computer network Interconnected devices sharing resources via protocols
Network types PAN < LAN < MAN < WAN by geographic scope
OSI model 7-layer conceptual framework for network communication
Encapsulation Each layer wraps data with its own header/trailer
TCP/IP model 4-layer practical model that powers the Internet
PDU Data unit changes name at each layer (data β†’ segment β†’ packet β†’ frame β†’ bits)

Key Takeaways

  1. Networks exist to share resources and enable communication between devices.
  2. The OSI model divides networking into 7 layers, each with a clear responsibility.
  3. Data encapsulation adds headers at each layer as data moves down the stack.
  4. The TCP/IP model is the practical counterpart to the OSI model, using 4 layers.
  5. Understanding layered models is essential for diagnosing where network problems occur.

Practice Problems

Beginner

  1. Name the 7 layers of the OSI model from bottom to top. For each layer, give one example protocol or device.
  2. A user reports they cannot load a website. At which OSI layer does HTTP operate? At which layer would you check if the Ethernet cable is plugged in?
  3. What is the PDU name at each of these layers: Transport, Network, Data Link?

Intermediate

  1. Explain the difference between a hub (Layer 1) and a switch (Layer 2). Why does a switch improve network performance?
  2. A packet travels from your laptop to a web server across the Internet. Describe the encapsulation process from the Application layer down to the Physical layer.
  3. Compare the OSI and TCP/IP models. Why does the TCP/IP model combine Layers 5, 6, and 7 into a single Application layer?

Advanced

  1. You run ping 8.8.8.8 and it succeeds, but ping google.com fails. Using the OSI model, identify which layer is likely causing the problem and explain why.
  2. A company has offices in Tokyo and New York connected by a leased line. Classify the network within each office and the connection between them by network type (LAN, WAN, etc.). Describe which OSI layers are most relevant at each segment.
  3. Design a diagram showing how a web request (HTTP) gets encapsulated at each OSI layer, transmitted across two routers, and de-encapsulated at the destination server. Identify what each intermediate router examines.

References

  • Kurose, J. & Ross, K. β€” Computer Networking: A Top-Down Approach, 8th Edition
  • Tanenbaum, A. & Wetherall, D. β€” Computer Networks, 6th Edition
  • ISO 7498-1 β€” OSI Basic Reference Model
  • RFC 1122 β€” Requirements for Internet Hosts

Next Up

In Day 2, we dive into LAN & WAN technologies β€” Ethernet, MAC addresses, switches vs. hubs, VLANs, and WAN technologies like MPLS. You will learn how data actually moves within and between networks.