Network Layer · Computer Networks

Delivery, Forwarding and Unicast Routing Protocols

Watch lectures

Delivery, Forwarding, and Unicast Routing Protocols


1. Direct vs. Indirect Packet Delivery

Packet handling at the network layer is classified into two distinct delivery modes:

 Direct Delivery:
 [ Host A ] =============================> [ Host B ]
            (Both on Subnet 192.168.1.0/24)
            (Resolved via ARP; direct Layer 2 frame transmission)

 Indirect Delivery:
 [ Host A ] ──> [ Router R1 ] ──> [ Router R2 ] ──> [ Host C ]
 Subnet A                                           Subnet C
 |<--- Indirect 1 ------>|<--- Indirect 2 ---->|<--- Direct --->|
  1. Direct Delivery:
    • Occurs when the destination host is on the same physical network as the deliverer (either the source host or the final router).
    • The sender computes Dest IP AND Subnet Mask. If it matches its own Network ID, the destination MAC is resolved via ARP and the packet is delivered directly.
  2. Indirect Delivery:
    • Occurs when the destination host resides on a different network.
    • The packet is delivered to the Default Gateway (Router). The packet traverses intermediate routers hop-by-hop (indirect deliveries) until reaching the final router on the destination subnet, which performs the final direct delivery.

2. Router Forwarding & Longest Prefix Match

Routers maintain forwarding tables to direct incoming packets to appropriate outbound interfaces.

Forwarding Techniques:

  • Next-Hop Method: Stores only the IP address of the next router (RnextR_{\text{next}}) rather than the complete end-to-end path.
  • Network-Specific Routing: Stores one route entry per destination network rather than per host.
  • Default Route (0.0.0.0/0): Captures all packets with no explicit entry in the table.

The Longest Prefix Match Rule:

When multiple routes in a CIDR routing table match the destination IP address, the router forwards the packet using the route with the Longest Prefix (Highest mask length /n/n), because it represents the most specific route.

 Routing Table:
 1.  192.168.0.0 /16  ──> Interface eth0
 2.  192.168.1.0 /24  ──> Interface eth1
 3.  0.0.0.0     /0   ──> Interface eth2 (Default)

 Packet with Destination IP 192.168.1.55 matches both /16 and /24.
 Rule: /24 has a longer prefix than /16 (24 > 16) ===> Forward to eth1!

3. Unicast Routing Protocols Architecture

Unicast routing protocols discover network topology and compute loop-free optimal paths dynamically.

                            ROUTING PROTOCOLS
                                    |
         +--------------------------+--------------------------+
         |                                                     |
  INTERIOR GATEWAY PROTOCOLS (IGP)              EXTERIOR GATEWAY PROTOCOLS (EGP)
  (Routing WITHIN an Autonomous System)         (Routing BETWEEN Autonomous Systems)
         |                                                     |
  +------+------+                                              |
  |             |                                              |
Distance      Link-State                                  Path-Vector
 Vector         (OSPF)                                       (BGP)
 (RIP)
  • Autonomous System (AS): A collection of routers and subnets under single administrative authority presenting a unified routing policy.

4. Distance Vector Routing: RIP

Distance Vector Routing uses the Bellman-Ford Algorithm:

  • Philosophical Principle: "Each router tells its immediate neighbors about the entire world."
  • Routing Information Protocol (RIP):
    • Metric: Hop Count (traversed routers). Max hops = 15; 16 = infinity (unreachable).
    • Updates: Transmits full routing tables periodically every 30 seconds over UDP Port 520.
    • Count-to-Infinity Problem: Link failure can cause looping metric increments up to 16.
    • Remedies: Split Horizon (never advertise routes back out the interface they were learned), Poison Reverse (advertise failed route with metric 16), and Hold-down Timers.

5. Link-State Routing: OSPF

Link-State Routing uses Dijkstra's Shortest Path First (SPF) Algorithm:

  • Philosophical Principle: "Each router tells the entire world about its immediate neighbors."
  • Open Shortest Path First (OSPF):
    • Link State Advertisements (LSAs): Routers flood link status packets throughout the area.
    • Link State Database (LSDB): Every router builds an identical mathematical topological graph of the network and computes the shortest-path tree using Dijkstra's algorithm.
    • Metric: Cost, inversely proportional to bandwidth:
Cost=108 bpsBandwidth\text{Cost} = \frac{10^8\text{ bps}}{\text{Bandwidth}}
  • Hierarchical Design: Divides networks into Areas, connected via Area 0 (Backbone Area) through Area Border Routers (ABRs).
    • Designated Router (DR): Multi-access networks elect a DR and BDR to reduce adjacency overhead.

6. Path-Vector Routing: BGP

Path-Vector Routing powers the core inter-domain Internet through BGP-4 (Border Gateway Protocol Version 4):

  • EGP Protocol: Operates across independent Autonomous Systems over TCP Port 179.
  • AS-Path Attribute: BGP advertises reachable network prefixes along with the full sequence of ASNs (Autonomous System Numbers) traversed:
Path for Net X=[AS 400,AS 200,AS 100]\text{Path for Net X} = [ \text{AS 400}, \text{AS 200}, \text{AS 100} ]
  • Loop Prevention: If a router sees its own ASN in an incoming path advertisement, it discards the route, eliminating loops.
  • Policy Routing: Routes are chosen based on commercial, political, and peering rules rather than simple shortest distance.

7. Comprehensive Unicast Routing Protocol Comparison

Feature RIP (v2) OSPF (v2/v3) BGP (BGP-4)
Category Distance Vector (IGP) Link-State (IGP) Path Vector (EGP)
Algorithm Bellman-Ford Dijkstra (SPF) Path Vector Policy
Routing Metric Hop Count (Max 15) Cost (∝1Bandwidth\propto \frac{1}{\text{Bandwidth}}) AS-Path & Policy Attributes
Underlying Transport UDP Port 520 IP Protocol 89 TCP Port 179
Convergence Speed Slow Very Fast Moderate
Loop Prevention Split Horizon & Poison Reverse SPF Tree & Area Hierarchy AS-Path attribute inspection
Scope Small, legacy LANs Enterprise campus backbones Global Internet Core

8. Key Exam Questions & Takeaways

  1. Explain the Longest Prefix Match rule with an example.
    • If an incoming IP matches both a /16 route and a /24 route, the router selects the /24 route because it represents a more specific destination network.
  2. Why does RIP define 16 as infinity?
    • To bound the execution time of the Count-to-Infinity problem and ensure routing loops terminate.
  3. What transport protocol and port does BGP use, and why?
    • BGP uses TCP Port 179. Because BGP handles critical inter-domain Internet routing, using TCP guarantees reliable, connection-oriented message delivery without requiring internal retransmission or windowing logic.
Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.

← All Computer Networks modules