Tutorial 2: Routing Algorithms and Graph-Theoretic Foundations Expanded

Table of Contents

  1. Learning Objectives
  2. Overview
  3. Detailed Technical Content
  4. Quiz
  5. Exercises
  6. Homework
  7. Summary

Learning Objectives

Overview

Routing algorithms form the core of the control plane. At a fundamental level, a network can be abstracted as a graph where vertices represent routers (or networks) and edges represent links, each assigned a cost (weight). The routing problem reduces to finding the least-cost path between any source-destination pair. This tutorial provides a rigorous foundation in graph theory as applied to networking, including the formal definition of the least-cost path, the choice of routing metrics, and the classification of routing approaches (static vs dynamic). We explore the trade-offs involved in routing optimization, including the multi-constraint path problem, and discuss the scalability challenges that motivate hierarchical routing. Finally, we introduce the two classic algorithms—Dijkstra and Bellman-Ford—that underpin link-state and distance-vector protocols, setting the stage for detailed study in later tutorials.

Detailed Technical and Theoretical Content

1. Graph Model of a Network

A network is mathematically represented as a weighted graph G = (V, E, w), where:

In many networks, links are undirected (symmetric costs), but some may be directed (e.g., asymmetric routing policies or wireless links with different transmission powers). The graph may also be dynamic, with edges appearing or disappearing over time.

The cost w(u,v) reflects a quantitative measure such as delay, bandwidth (inverse), monetary cost, or a composite metric. The goal of routing is to find a path P = (v₀, v₁, ..., vₖ) between a source s and a destination t that minimises the total cost: ∑_{i=0}^{k-1} w(v_i, v_{i+1}).

2. The Least-Cost Path Problem

Given a graph with positive edge weights, the single-source shortest path (SSSP) problem is to find the least-cost paths from a source node to all other nodes. This is the core computation performed by routing algorithms. The complexity of SSSP depends on the graph size and the chosen algorithm.

For routing, we typically need the all-pairs shortest paths in small networks, but in practice, each router only computes paths to all destinations (distributed). The Bellman-Ford and Dijkstra algorithms are the two primary approaches, each with different assumptions and performance characteristics.

3. Routing Metrics and Cost Functions

Metrics can be simple or complex:

A key issue is that a single metric cannot capture all objectives (e.g., minimizing delay and maximizing bandwidth simultaneously). This leads to multi-constraint routing, which is NP-hard in general, prompting heuristics (e.g., using additive metrics and QoS routing).

4. Static versus Dynamic Routing

Most modern networks use dynamic routing protocols (OSPF, BGP) but may incorporate static routes for specific purposes (e.g., default route).

5. Routing Optimization and Multi-Constraint Paths

In many scenarios, a path must satisfy multiple constraints (e.g., delay ≤ 50 ms, bandwidth ≥ 10 Mbps). This is the multi-constrained path (MCP) problem, which is known to be NP-hard when there are more than two additive constraints (or one additive and one multiplicative). Heuristics like the k-shortest paths or constrained shortest path first (CSPF) are often used. In practice, routing protocols usually optimize a single additive metric, while policies handle constraints.

6. Scalability Challenges and Hierarchical Approaches

As networks grow, maintaining a global shortest path tree becomes infeasible due to:

To address this, networks are organized hierarchically into Autonomous Systems (ASes). Within an AS, an IGP (e.g., OSPF) handles internal routing; between ASes, an EGP (e.g., BGP) manages reachability with policy. This reduces the size of the routing table and limits the scope of updates.

7. Advanced: Distributed vs Centralised Computation

In a distributed system, each router computes its own shortest paths using only information exchanged with neighbours. This leads to asynchronous algorithms like Bellman-Ford (distance-vector) and OSPF (link-state). In centralised computation, a single node (controller) collects all topology information and computes paths for all routers, installing forwarding rules (SDN). Centralised can achieve global optimality and easier policy enforcement, but at the cost of a single point of failure and potential bottleneck.

8. Algorithms in Practice: Dijkstra and Bellman-Ford Preview

We give a brief overview of the two classic algorithms:

We will cover these in detail in later tutorials.

Figure 1: Example weighted graph

    (A)---2---(B)
     |         |
     4         1
     |         |
    (C)---3---(D)
    

Costs are shown on edges. Least-cost path from A to D is A-B-D (cost 3).


Quiz

Answer each question; check your understanding by revealing the answer.

Question 1: In a network graph, what do vertices and edges represent?

Show AnswerVertices represent routers (or network nodes); edges represent links between them.

Question 2: What is the least-cost path problem?

Show AnswerFinding a path between two nodes that minimises the total sum of edge weights.

Question 3: Name three common routing metrics.

Show AnswerHop count, bandwidth-based cost, delay.

Question 4: What is the primary disadvantage of static routing?

Show AnswerIt does not automatically adapt to topology changes, requiring manual reconfiguration.

Question 5: What is the time complexity of Dijkstra's algorithm with a binary heap?

Show AnswerO(|E| log |V|).

Question 6: Which algorithm can handle negative edge weights, assuming no negative cycles?

Show AnswerBellman-Ford.

Question 7: Explain the concept of route aggregation and how it helps scalability.

Show AnswerRoute aggregation combines multiple subnets into a single prefix advertisement, reducing the size of routing tables and the number of updates.

Question 8: What is a multi-constrained path?

Show AnswerA path that must satisfy more than one constraint (e.g., delay and bandwidth).

Question 9: Why is the multi-constrained path problem NP-hard?

Show AnswerBecause when there are two or more additive constraints, it becomes a variant of the NP-hard QoS routing problem.

Question 10: What is the difference between distributed and centralised routing?

Show AnswerDistributed: each router computes its own paths; centralised: a single controller computes all paths.

Question 11: What is an Autonomous System (AS)?

Show AnswerA group of networks under a single administrative domain with a common routing policy.

Question 12: What is the typical cost function used in OSPF?

Show AnswerCost = reference bandwidth / link bandwidth (often reference = 100 Mbps).

Question 13: Can hop count be considered a good metric for large networks? Why or why not?

Show AnswerNo, because it ignores link capacity and may lead to inefficient paths; also limited to 15 hops in RIP.

Question 14: What is the purpose of link-state advertisements (LSAs) in OSPF?

Show AnswerTo flood information about a router's local links to all routers in the area.

Question 15: How does hierarchical routing reduce the size of routing tables?

Show AnswerBy aggregating routes at area boundaries and only advertising summaries.

Question 16: What is the main advantage of dynamic routing over static routing?

Show AnswerAdaptability to network changes without manual intervention.

Question 17: What is the Bellman-Ford equation for distance-vector routing?

Show AnswerD_x(y) = min_v { c(x,v) + D_v(y) }, where v is a neighbour of x.

Question 18: Is Dijkstra's algorithm guaranteed to find the shortest path if some weights are negative? Explain.

Show AnswerNo, Dijkstra assumes non-negative weights; negative weights can cause incorrect results.

Question 19: What is the difference between a directed and undirected graph in networking?

Show AnswerDirected edges imply asymmetric costs or unidirectional links; undirected implies symmetric costs.

Question 20: Why is it beneficial to model a network as a graph?

Show AnswerIt allows the application of well-known graph algorithms for path computation and analysis.

Question 21: What is the impact of using a very large metric for a link?

Show AnswerIt makes the link less preferred; traffic will avoid it unless all other paths are worse.

Question 22: Explain the trade-off between optimality and stability in routing.

Show AnswerOptimality seeks the best path according to metrics, but changing routes too often (instability) can cause oscillations and overhead; protocols may use hold-down timers to sacrifice optimality for stability.

Exercises

Work through these problems to apply the concepts. Sample solutions are hidden.

Exercise 1: Given the graph below, compute the least-cost path from A to all other nodes using Dijkstra's algorithm (show steps).

    (A)---1---(B)
     |         |
     4         2
     |         |
    (C)---3---(D)
Show Solution

Exercise 2: Explain why hop count can lead to suboptimal routing in networks with heterogeneous link speeds.

Show Solution Hop count treats each link equally, ignoring that a low-speed link may be slower than a high-speed link even if it has fewer hops. A path with more hops but higher bandwidth may be better, but hop-count metric would choose the shorter hop path.

Exercise 3: Convert the OSPF cost formula (cost = 10^8 / bandwidth) into a metric where bandwidth is in Mbps. Calculate the cost for links of 10 Mbps, 100 Mbps, and 1 Gbps.

Show Solution

Exercise 4: A router receives three routing updates for the same destination prefix: via OSPF (cost 5), via RIP (hop count 3), and via a static route. The administrative distances are: OSPF=110, RIP=120, static=1. Which route is installed in the FIB? Why?

Show Solution The static route (AD=1) is preferred because the lowest AD wins, regardless of the metric.

Exercise 5: Describe a scenario where static routing might be preferred over dynamic routing.

Show Solution In a small branch office with a single connection to the headquarters, static default route is simple and secure, and no dynamic updates are needed.

Exercise 6: Explain the concept of "equal-cost multipath" (ECMP) and how it can improve network performance.

Show Solution ECMP allows a router to forward packets along multiple paths that have the same metric, distributing traffic and increasing throughput.

Exercise 7: Given a network with 5 nodes and link costs, use the Bellman-Ford algorithm to compute distances from a source. Provide the initial and final distance vectors for each node.

Show Solution Will vary; provide a step-by-step example similar to textbook exercises.

Exercise 8: What is the impact of increasing the update interval in a distance-vector protocol like RIP?

Show Solution Longer intervals reduce bandwidth usage but slow convergence, increasing the risk of routing loops.

Exercise 9: Discuss the trade-offs between using a single additive metric versus multiple metrics for routing decisions.

Show Solution Single metric simplifies computation and avoids NP-hardness, but may not capture all requirements; multiple metrics enable richer policies but are computationally harder.

Exercise 10: Compare the scalability of Dijkstra's algorithm (link-state) with Bellman-Ford (distance-vector) in terms of communication overhead and computation.

Show Solution Link-state floods topology information to all routers → O(n) messages per change, but each router computes its own paths. Distance-vector exchanges vectors with neighbours → O(1) per update, but may require many iterations and suffer from slow convergence.

Homework Assignments

These require deeper thinking and research. Write comprehensive answers.

Homework 1: Prove that Dijkstra's algorithm correctly computes shortest paths in a graph with non-negative edge weights. (You may use induction.)

Show Answer Outline Use induction on the set of visited nodes; each step picks the unvisited node with smallest tentative distance, which is proven to be final because any alternative path would go through another unvisited node with larger distance.

Homework 2: Discuss the challenges of using dynamic metrics (e.g., based on congestion) in routing protocols. How can oscillations be avoided?

Show Answer Outline Dynamic metrics can cause route flapping; solutions include damping, using only load averages, and employing hysteresis.

Homework 3: Design a small network (6 nodes) and assign costs. Then, compare the shortest paths computed by Dijkstra and Bellman-Ford assuming no negative cycles. Show that they produce the same result.

Show Answer Outline Provide graph, run both algorithms step-by-step, show final distances and paths.

Homework 4: Research the concept of "route poisoning" and how it helps prevent routing loops in distance-vector protocols.

Show Answer Outline Route poisoning sets the metric to infinity (e.g., 16 in RIP) for a failed route and advertises it to neighbours to quickly eliminate the route.

Homework 5: Explain the relationship between routing metrics and Quality of Service (QoS). How can routing support QoS guarantees?

Show Answer Outline Metrics like delay and bandwidth can be used to select paths that meet QoS requirements; however, QoS routing is complex and often uses admission control.

Homework 6: Compare the use of OSPF areas and BGP route reflectors for scalability. What are the similarities and differences?

Show Answer Outline Both reduce the scope of updates; OSPF areas limit flooding, BGP route reflectors reduce iBGP mesh. OSPF is for intra-AS, BGP is for inter-AS.

Homework 7: Explore the NP-hardness of the multi-constrained path problem. Give a reduction from a known NP-hard problem (e.g., knapsack).

Show Answer Outline Show that the problem contains the partition problem as a special case when considering two additive constraints.

Homework 8: A network operator wants to minimize latency but also avoid congested links. Propose a composite metric and discuss its advantages and limitations.

Show Answer Outline Composite metric = α * delay + β * (1/available_bandwidth). Can be tuned, but may be hard to set weights and may cause instability.

Homework 9: Analyse the effect of link failures on the convergence time of a distance-vector protocol. What parameters influence the time to reach a consistent state?

Show Answer Outline Influenced by update intervals, hold-down timers, network diameter, and count-to-infinity time.

Homework 10: Research and compare the shortest path algorithms used in OSPF (Dijkstra) and IS-IS (also Dijkstra). Are there any differences in their implementations?

Show Answer Outline Both use Dijkstra; differences lie in protocol encapsulation (OSPF runs over IP, IS-IS over Layer 2) and area design (IS-IS uses Level 1/2).

Homework 11: Explain the concept of "route summarisation" and provide an example of how it reduces routing table size.

Show Answer Outline Summarisation replaces multiple specific prefixes with a single less specific one. Example: 192.168.1.0/24, 192.168.2.0/24 → 192.168.0.0/22.

Homework 12: Discuss the implications of using negative edge weights in routing. Why are they generally avoided in practice?

Show Answer Outline Negative weights can cause negative cycles, making shortest paths undefined; they also complicate algorithms. In networking, costs are always non-negative.

Summary

This tutorial provided a rigorous introduction to the graph-theoretic foundation of routing. We defined the network as a weighted graph, formulated the least-cost path problem, and examined the role of routing metrics. We contrasted static and dynamic routing and discussed the challenges of scalability and multi-constraint optimization. The preview of Dijkstra and Bellman-Ford algorithms set the stage for detailed exploration in later tutorials. Understanding these fundamentals is essential for mastering the control-plane protocols that operate in real networks.


End of Tutorial 2 .