CACS303 Computer Networking

Computer NetworkingUnit 113 min read

Computer Networks: Layers, Protocols & Real-World Architecture

Unit 1 of Computer Networking introduces the foundational concepts of computer networks, explaining why layered architecture is essential, how the OSI and TCP/IP models organize communication, and how protocols enable data exchange across layers. This note covers definitions, functions of each layer, real-world example

Why Study Computer Networks?

A computer network is a collection of interconnected devices (computers, servers, routers, switches) that communicate and share resources (data, files, internet access). Networks enable modern services like online banking (e.g., Nepal Rastra Bank’s core banking system), e-commerce (e.g., Daraz’s order processing), and social media (e.g., WhatsApp’s end-to-end encryption).

Key Needs for Networks

  1. Resource Sharing: Printers, files, and internet access.
  2. Communication: Email, video calls (e.g., Zoom in TU classes).
  3. Cost Efficiency: Reduces hardware/software duplication.
  4. Scalability: Easy to add new devices (e.g., NTC expanding fiber networks).
  5. Reliability: Backup systems (e.g., Nepal Electricity Authority’s grid redundancy).

Network Architecture: How Devices Connect

Networks are designed using architectures—structures that define how devices interact. The two main types are:

1. Peer-to-Peer (P2P) Architecture

  • Definition: Devices (peers) share resources directly without a central server.
  • Example: File sharing (e.g., BitTorrent for downloading movies).
  • Pros: No single point of failure, low cost.
  • Cons: Limited scalability, security risks (e.g., malware spread in P2P networks).
Peer APeer BPeer C
P2P network topology (BitTorrent-style sharing)

2. Client-Server Architecture

  • Definition: One central server manages resources; clients (users/devices) request services.
  • Example:
    • eSewa: Your phone (client) connects to eSewa’s server to pay bills.
    • Ncell’s 4G network: Your phone (client) connects to Ncell’s base stations (servers).
  • Pros: Centralized control, easier security, scalable.
  • Cons: Server overload risk, single point of failure.
Client DevicesWeb ServerDatabase Server
Client-server model (eSewa payment system example)

Layered Architecture: The OSI and TCP/IP Models

Networks use layered models to simplify design and communication. The two most important models are:

1. OSI (Open Systems Interconnection) Model

A 7-layer theoretical model (rarely implemented directly but useful for understanding). Each layer has a specific function:

Application (Layer 7)DataPresentation (Layer 6)DataSession (Layer 5)DataTransport (Layer 4)SegmentNetwork (Layer 3)PacketData Link (Layer 2)FramePhysical (Layer 1)Bits
OSI Model with data unit names at each layer (highlighted: Network and Transport layers)
Layer Function Protocols/Examples Real-World Use
Application (7) User interfaces, services (HTTP, FTP, SMTP). HTTP, DNS, SSH Loading a webpage (e.g., Daraz.com).
Presentation (6) Data translation (encryption, compression). SSL/TLS, JPEG, MPEG Secure banking (e.g., Nabil Bank’s HTTPS).
Session (5) Manages connections (start/end sessions). NetBIOS, RPC WhatsApp call setup.
Transport (4) End-to-end communication (TCP/UDP). TCP, UDP Streaming (e.g., YouTube video playback).
Network (3) Routing and addressing (IP). IP, ICMP, Router Ncell routing your call to a tower.
Data Link (2) Framing, MAC addressing, error detection. Ethernet, PPP, Switch Switch connecting laptops in a TU lab.
Physical (1) Raw bit transmission (cables, signals). Fiber, Wi-Fi, Hub Fiber optic cables in NTC’s backbone.
ApplicationHTTP, FTP, SMTPPresentation/SessionSSL/TLS, JPEGTransportTCP, UDPNetworkIP, ICMP, RouterData LinkEthernet, MAC, SwitchPhysicalFiber, Wi-Fi, Hub
OSI layers with protocols/devices (Nepali examples: Ncell router, NTC fiber, TU lab switch)

2. TCP/IP Model (Practical Model)

A 4-layer model used in real networks (simplified OSI). Each layer corresponds to 1-3 OSI layers:

Application (OSI 7,6,5)HTTP, DNS, SMTPTransport (OSI 4)TCP, UDPInternet (OSI 3)IP, ICMPNetwork Access (OSI 2,1)Ethernet, Wi-Fi, PPP
TCP/IP model mapping to OSI layers with Nepali-relevant protocols
TCP/IP Layer OSI Layers Function Protocols
Application 7, 6, 5 User services (HTTP, email). HTTP, FTP, DNS, SMTP
Transport 4 End-to-end communication (reliable/unreliable). TCP, UDP
Internet 3 Logical addressing and routing. IP, ICMP, Router
Network Access 2, 1 Physical transmission (frames, signals). Ethernet, Wi-Fi, PPP

Why Use Layered Architecture?

Advantages

  1. Modularity: Each layer can be updated independently (e.g., Ncell upgrading to 5G without changing apps).
  2. Standardization: Protocols are universally understood (e.g., HTTP works on all browsers).
  3. Interoperability: Devices from different vendors can communicate (e.g., iPhone + Android on WhatsApp).
  4. Error Isolation: A fault in one layer doesn’t crash the whole system (e.g., Wi-Fi drops but internet still works via 4G).
  5. Security: Layers like Presentation (encryption) and Network (firewalls) add protection.

Disadvantages

  1. Overhead: Extra layers add processing delay (e.g., TCP’s 3-way handshake slows down connections).
  2. Complexity: Debugging across layers is harder (e.g., troubleshooting a slow YouTube load).

How Data Travels Across Layers: Encapsulation/Decapsulation

Data moves down the layers at the sender and up at the receiver, with each layer adding its own header (or header + trailer).

Example: Sending an Email (SMTP)

  1. Application Layer: Your email client (e.g., Gmail) formats the message.
  2. Presentation Layer: Encrypts the data (if HTTPS).
  3. Session Layer: Manages the connection with the server.
  4. Transport Layer: Adds TCP header (port numbers, sequence numbers).
  5. Network Layer: Adds IP header (source/destination IP).
  6. Data Link Layer: Adds Ethernet frame (MAC addresses).
  7. Physical Layer: Sends raw bits over fiber/cable/Wi-Fi.
08162431Version4 bitsIHL4 bitsType of Service8 bitsTotal Length16 bits
IPv4 header structure (first 8 bytes)

At the receiver, the process reverses (decapsulation).

sequenceDiagram
    participant Sender as Your Device
    participant Router as Ncell Router
    participant Receiver as Gmail Server
    Sender->>Router: Email (Encapsulated: TCP + IP + Ethernet)
    Router-->>Receiver: Email (Decapsulated: IP + TCP)
    Receiver->>Sender: ACK (Reverse Path)

Real-World Applications of Layered Networks

1. eSewa Transaction (End-to-End Example)

When you pay a bill via eSewa:

  • Application Layer: Your phone app sends a payment request (HTTP).
  • Transport Layer: TCP ensures the request reaches eSewa’s server.
  • Network Layer: IP routes the request through NTC’s fiber network to eSewa’s data center.
  • Data Link Layer: Ethernet/Wi-Fi frames carry the data to your router.
  • Physical Layer: Signals travel via mobile towers (Ncell) or fiber cables (NTC).

2. WhatsApp Call (VoIP)

  • Application Layer: WhatsApp app encodes voice.
  • Transport Layer: UDP (for real-time calls, tolerates some packet loss).
  • Network Layer: IP routes packets via internet backbone (Google’s servers).
  • Physical Layer: Packets travel over Wi-Fi or mobile data (Ncell).

3. Daraz Order Processing

  • Application Layer: Your order (HTTP) → Daraz’s server.
  • Transport Layer: TCP ensures all order details arrive.
  • Network Layer: IP routes to Daraz’s warehouse server.
  • Data Link Layer: Switches direct traffic within Daraz’s data center.

Let’s trace how a search for "TU exam notes" works:

  1. You type in Chrome (Application Layer) → HTTP request.
  2. TCP (Transport Layer) adds port numbers (e.g., port 80 for HTTP).
  3. IP (Network Layer) adds:
    • Source IP: 192.168.1.5 (your home router).
    • Destination IP: 142.250.190.46 (Google’s server).
  4. Ethernet (Data Link Layer) adds:
    • Source MAC: AA:BB:CC:11:22:33 (your laptop).
    • Destination MAC: FF:FF:FF:FF:FF:FF (broadcast to router).
  5. Physical Layer: Signal travels via Wi-Fi (2.4GHz) to your router.
  6. Router forwards to ISP (NTC) → internet backbone → Google’s server.
  7. Google sends back HTML (Application Layer) → Your browser renders the page.
Internet BackboneHTTP ResponseYour LaptopHome Router (Ncell)NTC ISPGoogle Server
Google search path with Nepali ISP examples (Ncell/NTC)

Exam Tip: How This Unit is Tested

  1. Definitions (2-3 marks):
    • Expect questions like:
      • "Define subnetting." (Answer: Dividing a network into smaller networks.)
      • "Why is layered architecture needed?" (Answer: Modularity, standardization, interoperability.)
  2. Layer Functions (4-5 marks):
    • Match layers to functions (e.g., "Which layer handles MAC addressing?" → Data Link Layer).
    • Draw and label the OSI/TCP/IP models.
  3. Real-World Scenarios (5-7 marks):
    • "Explain how eSewa uses layered architecture." (Trace from app → server → payment gateway.)
    • "Why does WhatsApp use UDP instead of TCP?" (Answer: Real-time, low latency.)
  4. Calculations (3-5 marks):
    • Not in this unit, but future units (e.g., subnetting) will test:
      • Given 192.168.1.0/24, calculate subnets for /26.
  5. Diagrams (3-5 marks):
    • Draw OSI/TCP/IP layers with labels.
    • Show encapsulation/decapsulation for a scenario (e.g., email).

Common Mistakes to Avoid

  • Mixing OSI and TCP/IP: Remember TCP/IP has 4 layers, OSI has 7.
  • Forgetting Physical Layer: Often overlooked, but critical for real-world networks (e.g., fiber vs. Wi-Fi).
  • Vague Answers: Always tie examples to Nepali companies (e.g., Ncell, NTC, eSewa) for full marks.
  • Ignoring Protocols: Know which protocol belongs to which layer (e.g., IP is Network Layer, TCP is Transport).

Summary Table: Key Concepts

Concept Definition Example
Computer Network Interconnected devices sharing resources. Ncell’s 4G network.
P2P Architecture Decentralized, direct sharing. BitTorrent.
Client-Server Centralized control (server manages clients). eSewa app.
OSI Model 7-layer theoretical model. Used in textbooks.
TCP/IP Model 4-layer practical model. Used in real networks (e.g., internet).
Encapsulation Adding headers at each layer (sender). Email → TCP → IP → Ethernet.
Decapsulation Removing headers at each layer (receiver). Reverse of encapsulation.

Practice Questions (Self-Check)

  1. Short Answer:

    • What is the difference between OSI and TCP/IP models?
    • Name two protocols used in the Transport Layer and their functions.
  2. Scenario-Based:

    • "When you load a webpage on your phone using Ncell’s 4G, which layers are involved? Describe the role of each."
  3. Diagram:

    • Draw the TCP/IP model and label each layer’s function.
  4. Real-World Link:

    • "How does Khalti’s payment system use layered architecture? Trace the path of a payment request from your phone to Khalti’s server."

Based on the TU BCA syllabus for Computer Networking (CACS303), unit 1.

Discussion

Loading…