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
- Resource Sharing: Printers, files, and internet access.
- Communication: Email, video calls (e.g., Zoom in TU classes).
- Cost Efficiency: Reduces hardware/software duplication.
- Scalability: Easy to add new devices (e.g., NTC expanding fiber networks).
- 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).
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.
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:
| 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. |
2. TCP/IP Model (Practical Model)
A 4-layer model used in real networks (simplified OSI). Each layer corresponds to 1-3 OSI layers:
| 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
- Modularity: Each layer can be updated independently (e.g., Ncell upgrading to 5G without changing apps).
- Standardization: Protocols are universally understood (e.g., HTTP works on all browsers).
- Interoperability: Devices from different vendors can communicate (e.g., iPhone + Android on WhatsApp).
- Error Isolation: A fault in one layer doesn’t crash the whole system (e.g., Wi-Fi drops but internet still works via 4G).
- Security: Layers like Presentation (encryption) and Network (firewalls) add protection.
Disadvantages
- Overhead: Extra layers add processing delay (e.g., TCP’s 3-way handshake slows down connections).
- 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)
- Application Layer: Your email client (e.g., Gmail) formats the message.
- Presentation Layer: Encrypts the data (if HTTPS).
- Session Layer: Manages the connection with the server.
- Transport Layer: Adds TCP header (port numbers, sequence numbers).
- Network Layer: Adds IP header (source/destination IP).
- Data Link Layer: Adds Ethernet frame (MAC addresses).
- Physical Layer: Sends raw bits over fiber/cable/Wi-Fi.
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.
Worked Example: Tracing a Google Search
Let’s trace how a search for "TU exam notes" works:
- You type in Chrome (Application Layer) → HTTP request.
- TCP (Transport Layer) adds port numbers (e.g., port 80 for HTTP).
- IP (Network Layer) adds:
- Source IP:
192.168.1.5(your home router). - Destination IP:
142.250.190.46(Google’s server).
- Source IP:
- 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).
- Source MAC:
- Physical Layer: Signal travels via Wi-Fi (2.4GHz) to your router.
- Router forwards to ISP (NTC) → internet backbone → Google’s server.
- Google sends back HTML (Application Layer) → Your browser renders the page.
Exam Tip: How This Unit is Tested
- 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.)
- Expect questions like:
- 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.
- 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.)
- 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.
- Given
- Not in this unit, but future units (e.g., subnetting) will test:
- 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)
Short Answer:
- What is the difference between OSI and TCP/IP models?
- Name two protocols used in the Transport Layer and their functions.
Scenario-Based:
- "When you load a webpage on your phone using Ncell’s 4G, which layers are involved? Describe the role of each."
Diagram:
- Draw the TCP/IP model and label each layer’s function.
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…