advanced25 min studyLesson 194 in Engineering

Compute paths from topology or neighbor estimates

Compare link-state and distance-vector reasoning, calculate weighted paths, and separate convergence assumptions from transient forwarding behavior.

On this page

What you’ll understand

  • Calculate a lowest-cost path from explicit link weights.
  • Explain the information exchanged by link-state and distance-vector approaches.
  • Identify why stale information can produce loops during change.

Routing requires devices to agree on useful next hops while each device receives information at different times. Two important approaches expose different information: link-state routing distributes descriptions of topology, while distance-vector routing distributes neighbors' estimates of distance to destinations. Both can produce good paths under their assumptions. Neither makes propagation instantaneous or guarantees that every forwarding table remains mutually consistent during a failure. Start with a small graph so the mechanism is inspectable.

Link-state routing builds a shared graph

In a simplified single-area link-state view, routers advertise local connectivity and costs. Flooding spreads newer information so each router can construct a topology database and compute shortest paths from itself. OSPF uses this family of mechanisms, with areas and route types adding structure beyond our small graph. A link cost is an administrative metric, not inherently a measured millisecond delay. A path minimizing summed cost can therefore differ from the path with the fewest hops or smallest measured latency.

Given nonnegative link weights, shortest-path computation compares complete accumulated costs rather than greedily choosing the cheapest immediate link. If A reaches B at cost two, B reaches D at three, and A reaches D directly at nine, the path through B costs five and beats the direct edge. Each router installs its own next hop toward the resulting path. Equal-cost alternatives can exist, but the way packets use them depends on forwarding behavior and configuration.

C(P)=∑e∈Pce,P∗∈arg min⁡P:s⇝dC(P)C(P)=\sum_{e\in P}c_e,\qquad P^*\in\operatorname*{arg\,min}_{P:s\leadsto d}C(P)
c_e is a nonnegative administrative link cost and C(P) is the path's cost in the same dimensionless metric units. This static graph model assumes the relevant topology is known and omits policy, area hierarchy, and failures during computation.↔ Scroll wide equations horizontally.

Distance vectors exchange estimates

A distance-vector router can estimate its distance to a destination by adding the cost to a neighbor to that neighbor's advertised distance. The minimum over eligible neighbors gives the update. This is a distributed version of Bellman-Ford reasoning. A router need not receive the complete topology to make the calculation, but its neighbors' estimates may be stale or depend indirectly on itself. That dependence explains why a removed route can appear to remain reachable through a chain of mistaken beliefs.

RIP illustrates a concrete distance-vector protocol with hop-count metrics, a finite unreachable value, and mechanisms such as split horizon and triggered updates. These details matter: an abstract recurrence alone is not a complete protocol. Count-to-infinity is the gradual escalation of mutually dependent incorrect estimates after a failure. Split horizon and poison reverse address important cases, yet should not be described as universal instantaneous loop elimination for every topology and timing. Examine the actual protocol and failure sequence.

Dx(d)←min⁡v∈N(x)(c(x,v)+Dv(d))D_x(d)\leftarrow\min_{v\in N(x)}\bigl(c(x,v)+D_v(d)\bigr)
D_x(d) is router x's estimated distance to d; N(x) is its eligible neighbor set. Costs share one metric unit. The recurrence describes distance-vector reasoning with supplied neighbor estimates, not an assertion that asynchronous updates converge instantly.↔ Scroll wide equations horizontally.

Convergence is a process with observable stages

After a failure, detection, advertisement, propagation, computation, and forwarding installation occur at different devices. A stable final shortest-path solution does not imply safe intermediate forwarding. Distinguish a control-plane database that has learned a change from hardware that has installed it. Also separate an administrative metric change from a physical link failure: detection and information distribution differ. A useful test records packet loss and actual next hops throughout the transition, not only the final route table.

The optimization lab provides a limited analogy for iterative adjustment: change step size η and initial value x₀ in the scalar recurrence xₙ=(1−η)ⁿx₀. With a nonzero x₀, predict alternating contraction for η=1.5 and growth for η above two, then step through it. This is gradient descent on a quadratic, not Bellman-Ford, OSPF, or a routing convergence proof. The lesson is to demand a mechanism-specific stability argument; a graph that appears to settle under one update rule cannot certify a different distributed protocol.

Choose a weighted route

A static graph has A–B cost 2, B–D cost 3, A–C cost 1, C–D cost 8, and A–D cost 9. Which of these three candidate paths minimizes A's cost to D?

  1. Add the costs along A–B–D: 2 + 3 = 5. Add the costs along A–C–D: 1 + 8 = 9. The direct A–D edge also costs 9.

  2. Select A–B–D with cost 5 and next hop B. Choosing C just because its first edge costs only one would be a greedy mistake: the remaining edge costs eight.

  3. If B–D fails, recompute using the changed graph. The two remaining listed candidates tie at cost nine, but routers may learn and install that change at different times.

The result

The best listed path has metric cost five through B. This is a result for the stated static weighted graph, not a measured latency or a convergence-time guarantee.

Explore the model

Interactive lab

Interactive lab · optimization

An update rule needs its own stability argument

Vary η and a nonzero x₀ for gradient descent on x²/2, then predict contraction, alternation, or divergence; x₀=0 instead stays at zero. The scalar recurrence is an analogy for checking iteration assumptions; it does not run a routing protocol or demonstrate microloop freedom.

An update rule needs its own stability argumentGradient descent on f(x) = x²/2: xₙ = (1 − η)ⁿx₀. Playback advances two discrete iterations per second. Values outside |x| ≤ 4 are explicitly reported. Current readings: Position x0: 2; Objective x²/2: 2; Iteration behavior: Stable step. All parameters are adjustable with the labeled controls below.−4−202402.174.356.528.7Parameter xf(x) = x²/2n = 0
ObjectiveDiscrete iterate
Position x0
2
Objective x²/2
2
Iteration behavior
Stable step
n = 0 · t = 0 s

Gradient descent on f(x) = x²/2: xₙ = (1 − η)ⁿx₀. Playback advances two discrete iterations per second. Values outside |x| ≤ 4 are explicitly reported. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forConvergence claims depend on the exact update rule and information assumptions, not on the mere presence of repeated updates.

Check your understanding

What information primarily distinguishes a link-state approach from a distance-vector approach?

Try it yourself

Router X hears distance seven to D from neighbor A at link cost two, and distance five from neighbor B at link cost five. Compute X's distance-vector choice, then explain the risk if A's advertisement is stale.

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Add each local link cost to that neighbor's advertised estimate before comparing the totals.

Compare with the solution

Via A the estimate is 2 + 7 = 9; via B it is 5 + 5 = 10, so the recurrence selects A at estimated distance nine. If A's seven relies on a failed path or indirectly on X, the estimate may not correspond to a usable route and can contribute to a loop. Protocol freshness, withdrawal, and loop-mitigation mechanisms must address that distributed-state problem.

Take it with you

  • Shortest cost means the minimum of summed configured metrics under a graph model.
  • Link-state and distance-vector approaches expose different information to routers.
  • A correct final path does not guarantee consistent forwarding during updates.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.