Elective Distributed Networking

Distributed NetworkingUnit 415 min read

Internetworking: Protocols, Devices, Routing & Topologies

Unit 4 of Distributed Networking covers how networks interconnect via protocols (TCP/IP, ICMP), hardware (routers, switches), routing algorithms (distance-vector, link-state), and topologies (mesh, star, bus). It explains packet forwarding, NAT, and real-world examples like eSewa’s secure transactions or Ncell’s mobile

Core Concepts

What is Internetworking?

Internetworking is the practice of connecting multiple autonomous networks (e.g., LANs, WANs) to form a larger, unified network (like the Internet). It relies on:

  • Protocols (rules for communication)
  • Devices (routers, bridges, gateways)
  • Routing (deciding paths for data)
  • Topologies (physical/logical layouts)

Why does it matter? Without internetworking, your WhatsApp message couldn’t travel from Pokhara to Kathmandu—or your Daraz order from a server in the US to a warehouse in Nepal.


1. Protocols: The Rules of the Road

Protocols define how data is formatted, addressed, transmitted, and received. The TCP/IP suite is the backbone of internetworking.

TCP/IP Protocol Stack (Layers)

The OSI model (7 layers) is theoretical, but TCP/IP (4 layers) is practical. Here’s how they map:

Application (HTTP, DNS, FTP)DataTransport (TCP, UDP)SegmentInternet (IP, ICMP, ARP)PacketNetwork Access (Ethernet,Wi-Fi)Frame
TCP/IP 4-layer model with data encapsulation at each layer (eSewa payment example)
Application (HTTP, FTP, DNS)DataTransport (TCP, UDP)SegmentInternet (IP, ICMP, ARP)PacketNetwork Access (Ethernet,Wi-Fi)Frame
TCP/IP 4-layer model with data encapsulation (eSewa payment example)

Key Protocols:

Layer Protocol Role
Application HTTP/HTTPS Web traffic (e.g., Daraz, eSewa)
Transport TCP Reliable, connection-oriented (e.g., file downloads)
UDP Fast, connectionless (e.g., video calls, DNS)
Internet IP (IPv4/IPv6) Addressing and routing (e.g., 192.168.1.1 to 8.8.8.8)
ICMP Error reporting (e.g., "ping" command)
Network Access Ethernet/Wi-Fi Local network communication (frames)

How TCP/IP Works: A Packet’s Journey

  1. Application Layer: Your browser (HTTP) requests daraz.com.np.
  2. Transport Layer: TCP splits data into segments (with sequence numbers for reliability).
  3. Internet Layer: IP adds source/destination IP addresses and creates a packet.
  4. Network Access Layer: Ethernet/Wi-Fi encapsulates the packet into a frame (adds MAC addresses).
  5. Transmission: The frame travels through switches/routers to reach the destination.
sequenceDiagram
    participant Phone as User's Phone (192.168.1.10)
    participant Router as Home Router (192.168.1.1)
    participant ISP as NTC Backbone
    participant Server as eSewa Server (203.123.45.67)
    Phone->>Router: HTTP Request (TCP Segment)
    Router->>ISP: IP Packet (192.168.1.10 → 203.123.45.67)
    ISP->>Server: Forwarded Packet (BGP routing)
    Server-->>ISP: TCP ACK
    ISP-->>Router: IP Packet
    Router-->>Phone: HTTP Response (TCP Segment)
    Note over Phone,Server: **Layers collapsed for clarity**
    Note over ISP,Server: **BGP routing in ISP backbone**
08162431Source Port (16)16 bitsDestination Port (16)16 bitsSequence Number (32)32 bitsAcknowledgment Number (32)32 bitsData Offset (4)4 bitsReserved(6)6 bitsFlags (6)6 bitsWindow Size (16)16 bits
TCP Segment Header (eSewa payment request from 192.168.1.10:54321 to 203.123.45.67:443)

Worked Example: eSewa Payment When you pay a bill via eSewa:

  • Your phone (192.168.1.10) sends a TCP segment to eSewa’s server (203.123.45.67).
  • The router (192.168.1.1) forwards the IP packet to NTC’s backbone.
  • NTC’s routers use BGP (Border Gateway Protocol) to route it globally.
  • The server replies with a TCP ACK (acknowledgment) to confirm payment.

2. Internetworking Devices

Devices connect networks and forward data based on rules.

1111RouterSwitchHubComputer AComputer BServer
Router connects networks; switch connects devices within a network

A. Routers

  • Function: Connect different networks (e.g., your home LAN to Ncell’s mobile network).
  • How they work:
    • Use IP addresses to decide where to send packets.
    • Maintain a routing table (e.g., 203.123.45.0/24 → Router2).
    • Can perform NAT (Network Address Translation) to share one public IP among many devices.

Worked Example: Ncell’s Mobile Data When you browse on Ncell:

  1. Your phone (192.168.8.5) sends a packet to google.com (8.8.8.8).
  2. The mobile router (4G/LTE tower) checks its routing table:
    • 8.8.8.8/32 → Send to Ncell’s core network.
  3. Ncell’s routers use OSPF (Open Shortest Path First) to forward it to NTC.
  4. NTC routes it to Google’s servers.

B. Switches vs. Hubs

Device Layer Function Example
Switch Data Link (L2) Forwards frames based on MAC addresses Linksys switch in a home network
Hub Physical (L1) Broadcasts all data to every port Obsolete (avoid in modern networks)
Router Network (L3) Forwards packets based on IP addresses MikroTik router in an office

3. Routing Algorithms: Finding the Best Path

Routers use algorithms to decide the best path for packets. Two main types:

A. Distance-Vector Routing (e.g., RIP)

  • How it works:
    • Routers share their routing tables with neighbors periodically.
    • Example: If Router A knows Destination X is 2 hops away via Router B, it updates its table.
  • Pros: Simple, low overhead.
  • Cons: Slow to adapt to changes (e.g., link failures).
  • Real Example: RIP (Routing Information Protocol) is used in small networks like a university campus.
  • How it works:
    • Each router broadcasts its entire network topology (links and costs).
    • Uses Dijkstra’s algorithm to compute the shortest path.
  • Pros: Fast convergence, handles large networks well.
  • Cons: High CPU/memory usage.
  • Real Example: OSPF runs in NTC’s backbone to route traffic between ISPs.
23142R1R2R3R4
Link-state routing example: OSPF shortest path (cost=6) from R1 to R4

Comparison Table:

Feature Distance-Vector (RIP) Link-State (OSPF)
Update Method Periodic (every 30 sec) Triggered (on changes)
Complexity Low High
Scalability Poor (max 15 hops) Excellent (thousands of nodes)
Convergence Slow Fast
Example Use Small office networks ISP backbones (NTC, Ncell)

Worked Example: Kathmandu Traffic Routes (Analogy)

Imagine Kathmandu’s roads as a network:

  • Distance-Vector: Like asking your neighbor, "How do I get to Thamel?" They say, "Go via Durbar Marg (2 km)." But if Durbar Marg is blocked, you’re stuck until they update.
  • Link-State: Like Google Maps. Every junction (router) sends its full map to a central server, which recalculates the best route instantly if a road (link) is closed.
21342Durbar MargThamelKathmandu Durbar SquareSanauliBoudhanath
Kathmandu road analogy: Distance-vector routing (RIP) path to Boudhanath (cost=7)

4. Network Topologies: How Devices Are Connected

Topology defines how devices are physically or logically arranged.

A. Physical Topologies

Type Description Example Pros Cons
Bus All devices share a single cable. Old Ethernet (10BASE2) Simple, cheap Single point of failure
Star All devices connect to a central hub/switch. Home Wi-Fi router Easy to manage, scalable Central hub is a bottleneck
Ring Devices connected in a closed loop. Token Ring networks Predictable latency Failure in one node breaks the ring
Mesh Every device connected to every other. Military networks, blockchain Highly reliable, redundant paths Expensive, complex

B. Logical Topologies

  • How data flows (independent of physical layout).
  • Example: A star topology can behave like a mesh if switches dynamically reroute traffic (e.g., in a data center).

Real Example: Daraz’s Warehouse Network

  • Physical: Star topology (all racks connect to a central switch).
  • Logical: Mesh-like redundancy (if one switch fails, others reroute orders).

5. Routing Protocols in Depth

A. Interior Gateway Protocols (IGPs)

Used within an autonomous system (e.g., Ncell’s network):

  • RIP (Distance-Vector): Max 15 hops, metric = hop count.
  • OSPF (Link-State): Uses cost (based on bandwidth), hierarchical (areas).

B. Exterior Gateway Protocols (EGPs)

Used between autonomous systems (e.g., NTC ↔ Ncell):

  • BGP (Border Gateway Protocol):
    • Path-vector protocol (chooses paths based on policy, not just distance).
    • Used by all ISPs (including Google, Facebook).
    • Example: NTC might prefer to route traffic to Google via a faster (but more expensive) link.

Mermaid Sequence Diagram: BGP Route Advertisement

sequenceDiagram
    participant NTC as NTC Router
    participant Google as Google Router
    NTC->>Google: OPEN (Hello, let's exchange routes)
    Google-->>NTC: KEEPALIVE (Ack)
    NTC->>Google: UPDATE (Advertise: 203.123.45.0/24 via AS6453)
    Google->>NTC: UPDATE (Advertise: 8.8.8.0/24 via AS15169)
    Note over NTC,Google: Both routers now have each other's routes in their BGP tables.

6. NAT (Network Address Translation)

Problem: IPv4 addresses are exhausted (only ~4.3 billion), but devices need unique IPs. Solution: NAT lets multiple devices share one public IP.

How NAT Works

  1. Your phone (192.168.1.10) sends a packet to google.com.
  2. The home router replaces:
    • Source IP: 192.168.1.10 → 203.123.45.1 (public IP).
    • Source Port: 54321 → 12345 (randomized).
  3. Google replies to 203.123.45.1:12345.
  4. The router forwards it to your phone using its NAT table.

NAT Table Example:

Public IP:Port Private IP:Port Protocol
203.123.45.1:12345 192.168.1.10:54321 TCP
203.123.45.1:12346 192.168.1.11:8080 UDP

Real Example: Your Home Internet

  • Without NAT: Every device (phone, laptop, TV) would need a public IP.
  • With NAT: All devices hide behind 203.123.45.1 (assigned by NTC).

7. Subnetting and CIDR

Why? To efficiently allocate IP addresses and reduce routing table size.

Subnetting Basics

  • Classful vs. Classless:
    • Old: 192.168.1.0/24 (Class C, 256 hosts).
    • New: CIDR (Classless Inter-Domain Routing) lets you borrow bits (e.g., /25 = 128 hosts).
  • Formula:
    • Number of hosts = (subtract 2 for network and broadcast addresses).

Worked Example: NTC’s Subnetting NTC has 10.0.0.0/8. To divide it into 16 subnets:

  • New prefix: /12 (since subnets).
  • Each subnet: 10.x.0.0/12 (e.g., 10.0.0.0/12, 10.1.0.0/12, etc.).
  • Hosts per subnet: .

In the Real World

  1. eSewa Payments

    • Idea Used: TCP/IP + NAT + Routing
    • How: When you pay a bill, your phone’s packet travels through:
      • Home router (NAT translates 192.168.1.10 → 203.123.45.1).
      • NTC’s backbone (routers use BGP to forward it to eSewa’s servers in the US).
      • eSewa’s load balancer (distributes requests across multiple servers using OSPF for internal routing).
  2. Pathao Ride Booking

    • Idea Used: Client-Server Model + Routing Protocols
    • How:
      • Your phone (client) sends a UDP request (fast, no connection setup) to Pathao’s server.
      • Pathao’s CDN (Content Delivery Network) uses anycast routing to direct you to the nearest server (e.g., Kathmandu vs. Pokhara).
      • The server replies with driver locations via TCP (reliable for payment processing).
  3. NEPSE Stock Trading

    • Idea Used: Link-State Routing + Redundancy
    • How:
      • NEPSE’s servers use OSPF to ensure low-latency trading between Kathmandu and Lalitpur data centers.
      • If one link fails (e.g., fiber cut), OSPF reconverges in <1 second to reroute orders.
      • Traders see real-time prices via WebSockets (Application Layer), which use TCP under the hood.

Exam Tip

What to Expect in TU/PU Exams

  1. Definitions & Concepts (20%)

    • Expect questions like:
      • "Differentiate between RIP and OSPF with examples."
      • "What is NAT? Draw a NAT table for a scenario with 3 devices."
    • Tip: Memorize the TCP/IP layers and routing protocol comparisons.
  2. Scenario-Based Questions (30%)

    • Example:

      "A network uses the IP range 172.16.0.0/16. Subnet it into 8 equal parts. Show the new subnets and usable host ranges."

    • Tip: Practice subnetting and routing table calculations (use the formula ).
  3. Diagrams & Troubleshooting (25%)

    • Example:

      "Draw a star topology with 4 devices and label the roles of a switch and router." "Why does a ping fail between two subnets? List 3 possible causes."

    • Tip: Always label diagrams with IPs, MACs, and device roles (e.g., "Router R1: 192.168.1.1").
  4. Real-World Applications (25%)

    • Example:

      "How does WhatsApp use internetworking to send messages globally? Explain the role of NAT and routing protocols."

    • Tip: Relate to eSewa, Pathao, or Ncell in your answers. Use terms like:
      • "NAT translates private IPs to public IPs (like your home router)."
      • "BGP routes traffic between ISPs (like NTC and Ncell)."

Common Pitfalls to Avoid

  • Confusing MAC vs. IP addresses: MAC is for local network (Layer 2), IP is for global routing (Layer 3).
  • Ignoring subnet masks: Always include them in answers (e.g., 192.168.1.0/24).
  • Overcomplicating routing: For exams, stick to RIP (distance-vector) and OSPF (link-state) unless asked about BGP.
  • Forgetting NAT: Many questions involve home/office networks—always assume NAT is in place.

Quick Revision Checklist

Before the exam, ensure you can:

  1. Draw the TCP/IP 4-layer model and label protocols at each layer.
  2. Explain how a router forwards a packet using its routing table.
  3. Calculate subnets and usable hosts for any CIDR block.
  4. Compare RIP vs. OSPF in a table.
  5. Describe NAT with a NAT table example.
  6. Name 3 real-world uses of internetworking (e.g., eSewa, Pathao, NEPSE).

Based on the TU BSc CSIT syllabus for Distributed Networking, unit 4.

Discussion

Loading…