4.3.14 · D4Computer Networks

Exercises — Static routing vs dynamic routing

3,130 words14 min readBack to topic

The small network below is what several questions refer to — study it once, then use it as you solve.

Figure — Static routing vs dynamic routing

L1 — Recognition

Q1.1 In static routing, who writes each row of the routing table, and does that row change on its own if a link dies?

Q1.2 Give the prefix (in slash notation) of a default route, and say in one line when the router uses it.

Q1.3 Name the three families of dynamic routing protocols and one example protocol for each.

Recall Solution L1

Q1.1 A human network administrator types each route by hand. The row does not change automatically — it stays frozen until the admin edits it (see Routing table).

Q1.2 The default route is 0.0.0.0/0. Because /0 means "zero network bits fixed", it matches every destination, so by longest-prefix match it is chosen only when no more-specific route matches — a catch-all toward the Default gateway. See Longest prefix match.

Q1.3 Distance-vector (example: RIP), Link-state (example: OSPF), and Path-vector (example: BGP). See the "three protocol families" box above — distance-vector shares only a number, link-state shares the whole map, path-vector shares the full path list.


L2 — Application

Q2.1 On router R1 in the figure, write the Cisco-style static route so R1 can reach PC-B's network 192.168.2.0/24 (mask 255.255.255.0) via R2's link IP 10.0.0.2.

Q2.2 PC-A can ping PC-B, but the reply never comes back (ping times out). Only R1 was configured. What single command on R2 fixes it? R1's link IP is 10.0.0.1.

Q2.3 A stub router has exactly one exit toward the ISP at 10.0.0.2. Write the one static default route that sends all unknown traffic there.

Recall Solution L2

All three use the figure's PC-A — R1 — R2 — PC-B layout.

Q2.1

ip route 192.168.2.0 255.255.255.0 10.0.0.2

Why: R1 has no built-in knowledge that PC-B's network exists. We hand it the destination network, its mask (255.255.255.0 = /24, see the notation box), and the next-hop IP (R2's near-side interface).

Q2.2 The reply packet travels the opposite direction, so R2 needs its own route back to PC-A's network 192.168.1.0/24:

ip route 192.168.1.0 255.255.255.0 10.0.0.1

Why: routing is per-direction. Configuring only R1 teaches the forward path; the return path is a separate route on R2.

Q2.3

ip route 0.0.0.0 0.0.0.0 10.0.0.2

Why: 0.0.0.0/0 is the shortest prefix, so it wins only when nothing more specific matches — the perfect single-exit catch-all.


L3 — Analysis

Q3.1 (Bellman–Ford by hand) Node X has neighbours A (link cost ) and B (link cost ). They advertise their best costs to destination Z: , . Compute and the chosen next hop.

Q3.2 (trap-check) Suppose B now improves and advertises . Recompute and the next hop. Did the answer change?

Q3.3 (equal-cost tie) Now instead let A's link rise to while everything else stays as in Q3.1 (, , ). Compute the total via each neighbour. What special situation arises, and what do real protocols do about it?

Q3.4 (edge case: count-to-infinity) In Q3.1, X reaches Z via A at cost 4, and A relies on the direct link A–Z. Suppose the A–Z link fails. Distance-vector routers only exchange numbers, not full paths. Explain, step by step, how X and A can fool each other into a routing loop, why the cost keeps climbing (the count-to-infinity problem), and one standard fix.

Q3.5 (overhead reasoning) A perfectly stable 3-router company network never changes for years. List two concrete resources dynamic routing would waste here, define what a "security attack surface" means in one line, and state which style wins with a why.

Recall Solution L3

The core equation (built in the parent note) is which says: any path from to must first hop to some neighbour (cost ), then continue optimally from (cost ); pick the smallest total. This is Bellman–Ford, the engine of RIP.

Q3.1

  • via A:
  • via B:

Why A and not B? B's own path is cheaper, but the link to B is expensive. Total path cost is what matters — always combine link + advertised, then minimise.

The figure below draws exactly this decision. X sits on the left; the thick orange arrow to A is the cheap link () and the thin ink arrow to B is the expensive link (). The dotted teal arrows on the right are the advertised costs and that A and B phone in. Read each route as "solid link cost + dotted advertised cost": the top path totals (marked WINNER in orange), the bottom totals . The picture makes the trap visible — the neighbour with the cheaper advertised number (B, dotted ) sits behind the expensive solid link, so it loses.

Figure — Static routing vs dynamic routing

Q3.2

  • via A:
  • via B:

Why: the min compares totals, not the advertised numbers alone. B's advertised cost changed to , but that still sits on top of the expensive link (), giving , which loses to A's . This is exactly why a "cheaper neighbour" does not automatically win — improving a distant cost cannot help if the first hop to that neighbour is too expensive.

Q3.3

  • via A:
  • via B:

Both neighbours give the identical total — an equal-cost tie. Here alone does not name a single winner, so a router must break the tie. Two standard behaviours: (1) a deterministic tie-breaker (e.g. keep the currently installed route, or prefer the lower router-ID / lower next-hop IP) so the choice is stable; or (2) equal-cost multipath (ECMP) — install both next hops and split traffic across them, used by OSPF. Either way the cost is unambiguously ; only the chosen next hop needs a rule.

Q3.4 (count-to-infinity) This is the classic distance-vector edge case.

  1. Start: A reaches Z directly at cost, say, ; X reaches Z via A at . Both tables are correct.
  2. The A–Z link fails. A now has no direct route, so it should say "Z = unreachable ()".
  3. But before A can tell anyone, X's last update still advertises "I can reach Z at cost 4". A hears this and thinks "great, I'll reach Z via X at ". A does not realise X's own route to Z went through A itself — because distance-vector shares only the number 4, never the path, A cannot see the loop.
  4. Now A points to X, X points to A: a routing loop. A packet for Z bounces A→X→A→X forever.
  5. Each round of gossip they add one more link cost, so the advertised distance keeps counting up crawling toward "infinity". This is the count-to-infinity problem, and it is why RIP has slow convergence. Fixes: (a) define a small "infinity" — RIP caps the metric at 16 hops = unreachable, so the climb stops fast; (b) split horizon — never advertise a route back to the neighbour you learned it from (X would not tell A "I reach Z at 4" since it learned that from A); (c) route poisoning / poison reverse — actively advertise the dead route as infinite. Note this whole failure mode is impossible for OSPF link-state (everyone has the full map) and for BGP path-vector (the full path list reveals the loop).

Q3.5 Dynamic routing here would waste (1) bandwidth on periodic update messages that carry no new information, and (2) CPU/memory rerunning the algorithm on a topology that never moves. A security attack surface = the set of ways an outsider could interfere — here, a malicious neighbour could phone in fake routes and hijack traffic, a door that static routing simply does not open. Why static wins: every euro of adaptivity buys you nothing when nothing ever changes — you pay constant bandwidth, CPU and a fake-route risk to "adapt" to failures that never happen, so the simple, secure, zero-overhead hand-written table is strictly the better fit here.


L4 — Synthesis

Q4.1 (design a full static path) Extend the figure: add router R3 and network 192.168.3.0/24 in a line PC-A — R1 — R2 — R3 — PC-C, with links R1–R2 = 10.0.0.0/30 and R2–R3 = 10.0.1.0/30. R2's IP toward R3 is 10.0.1.1; R3's IP toward R2 is 10.0.1.2. Write the static route(s) R1 needs so PC-A can reach PC-C, and explain why R1 needs a route even though PC-C is two hops away.

Q4.2 (choose the tool) A regional ISP connects to 40 other autonomous networks whose links go up and down daily, and where each side is run by a different company you don't fully trust. Which routing style, which protocol family (from the three defined above), and which specific protocol from the connections list fits — and why?

Recall Solution L4

Q4.1 R1 must have a route for every destination PC-A actually sends packets to. PC-A's packets to PC-C carry destination 192.168.3.0/24 — that is the only network R1 lacks. (PC-A never sends packets to the inter-router link 10.0.1.0/30; that link only carries transit traffic between R2 and R3, so R1 needs no route for it.) So a single line suffices, pointing at the one next hop R2 = 10.0.0.2:

ip route 192.168.3.0 255.255.255.0 10.0.0.2

Why does R1 need a route for a network two hops away? A router only ever decides the next hop, not the whole path. R1 hands the packet to R2; R2 then repeats the decision toward R3. But R1 still cannot forward a packet whose destination it has no row for — so 192.168.3.0/24 must appear in R1's table, pointing at R2. (A single ip route 0.0.0.0 0.0.0.0 10.0.0.2 default route would also cover it, since R1 has only one exit.)

Q4.2 Use dynamic routing, the path-vector family (defined in the families box), specifically BGP — the protocol that glues different autonomous systems (independently run networks) together. Why: the topology changes daily (needs auto-adaptation and convergence), it spans many organisations (too big for hand-written static tables), and BGP is built for policy and limited trust between untrusted neighbours — exactly the "different company" concern. Path-vector's full-path advertisements let each side apply policy and reject loops. Intra-company link-state (OSPF running Dijkstra) or distance-vector (RIP) would run inside each network, but the between-networks glue is path-vector BGP.


L5 — Mastery

Q5.1 (convergence trade-off with numbers) Two designs carry the same traffic. Design S is static: after any link failure an admin must be paged and edit routes, taking on average 20 minutes of full outage. Design D is dynamic: it self-heals with a measured convergence time of 45 seconds per failure, but sends update messages costing 2% of link bandwidth continuously. Links fail on average twice a month.

(a) Compute the monthly outage minutes for each design. (b) State in one sentence the decision rule this comparison teaches.

Q5.2 (full trace + defend) Reuse Q3.1's numbers (, , , ). The link X–A now fails. In RIP, A can no longer be a next hop. Recompute and the new next hop, and name the general property of dynamic routing you just demonstrated.

Recall Solution L5

Q5.1 (a) Failures per month .

  • Static: outage minutes per month.
  • Dynamic: convergence s min, so outage minutes per month.

(b) Decision rule: dynamic slashes outage ( min) but pays a constant bandwidth tax — worth it when failures are frequent or downtime is costly; wasteful when the network is tiny and stable. Match the tool to the failure rate and the cost of an outage, not to which sounds "smarter".

Q5.2 With X–A failed, only neighbour B remains usable:

  • via A: unavailable (link down)
  • via B:

Why: removing A deletes its term from the min, so the router re-minimises over the surviving neighbours — only B is left, giving . The significance: the cost rose from to , but the table updated itself with no human editing it. This is the defining property of dynamic routing: self-healing / automatic convergence after a topology change — precisely what static routing cannot do.


Recall One-line self-check before you leave

Static vs dynamic is only about who fills the routing table and when — a human by hand (frozen) vs a protocol automatically (adapting). Everything else (metrics, Bellman–Ford, the three families, count-to-infinity, convergence) hangs off that one distinction.