Computer Networks / Practical class / Practical class 14
Practical class · Computer Networks

Dynamic Routing: RIP, OSPF and BGP Protocols

This is practical class 2 on dynamic routing (complex cases and faults). In practical class 13 you saw how the protocols work on a “good day”. Today is a “bad day”: a link goes down and RIP routers count up to 16, OSPF neighbors fail to “recognize” each other, and a single BGP policy changes the direction of all Internet traffic. You will see each problem in the simulator and model it in Python.

:ik-kitob: Practical class 14 ⏱ 2 academic hours (80 minutes) 🚇 Packet simulators ⚡ Protocols on a bad day
14

Lesson goals and plan

By the end of the lesson you will…

  • you can explain the “count to infinity” problem and show how split horizon, poison reverse and hold-down overcome it
  • you can identify the OSPF reference bandwidth problem and recalculate costs
  • you can use Dijkstra to calculate which routes change after a link failure (re-convergence)
  • you can find why an OSPF adjacency fails to form (area, timers, subnet, MTU, authentication, router ID)
  • you can apply the BGP best-path selection rules (LOCAL_PREF, AS_PATH, ORIGIN, MED…) and show the effect of a policy in the simulator
  • you can make the final choice among routes learned from several protocols (AD + LPM)

Plan (according to the syllabus)

  1. Dynamic Routing: RIP, OSPF and BGP Protocols

Today we “learn by breaking things”. In every experiment, predict first: what goes down, who finds out and when, and which path is the new one? The basics are in practical class 13 (session 1) — if you do not remember Bellman–Ford or Dijkstra, go back to the simulators there.

Can one wrong announcement leave the whole world without YouTube?

Yes — and it has happened. In 2008 an ISP in one country, trying to block YouTube locally, announced part of YouTube’s prefix via BGP as “its own”; the announcement leaked to neighboring providers and, thanks to the longest-prefix rule, YouTube traffic in a large part of the world flowed in the wrong direction for about two hours. Dynamic protocols repair the network by themselves — but they spread wrong information just as fast. Today we simulate exactly these “bad days”.

Key terms

Theory reminder

From practical class 13: RIP — Bellman–Ford and the hop metric, OSPF — LSDB and Dijkstra, BGP — AS_PATH and policy. There the network was always “healthy” and everyone started from an empty state. In real life, the interesting things begin after a change: how long does convergence take, and where do packets go in the meantime?

Table 14.1. How protocols “find out” after a failure
RIPOSPFBGP
Detecting the failureUpdates stop arriving (invalid timer 180 s) or the interface goes downHellos stop arriving (dead interval, usually 40 s) or the interface goes downKeepalives stop arriving (hold time, usually 180 s) or the session drops
Reporting itNew distances to neighbors (triggered update)A new LSA is flooded across the whole areaA WITHDRAW message and announcements of alternative paths
RecalculationBellman–Ford, messages spread hop by hopSPF runs again on every routerThe best path is re-selected in every AS
Main riskCount to infinity, temporary loopsAdjacency not forming, wrong costWrong announcements (route leak, hijack), policy mistakes

Dynamic Routing: RIP, OSPF and BGP Protocols

Session 2

This is the second of the two sessions with the same name in the course syllabus. In practical class 13 (session 1) you studied the idea of the three protocols and the Bellman–Ford and Dijkstra algorithms. Today: count to infinity in RIP and the countermeasures, OSPF cost and adjacency faults, re-convergence after a failure, and BGP policy between ASes.

Scenario 1. RIP: count to infinity

Chain: A — B — C — D. The network has converged: A is 3 hops from D, B is 2, C is 1. Now the C–D link goes down.

C can no longer reach D directly. But B still advertises “D is 2 hops away” — C does not know this path goes through itself and thinks, “so it is 3 hops via B”. B hears “3” from C and updates itself to 4… They keep feeding each other false “rumors”, raising the metric up to 16. Meanwhile, packets sent to D circle between B and C.

:ik-takror: Count-to-infinity simulator

First “Break the C–D link”, then rounds.
  1. Plain RIP

    The metrics “jump” up by 2: B and C take turns believing each other’s old value. It takes 15 rounds to reach 16 — about 7–8 minutes in real RIP! That is exactly why the limit of 16 was chosen so small.

  2. Split horizon

    B learned D from C — so it does not tell C about D. C has no other source → immediately 16. Within three rounds everyone knows.

  3. Poison reverse

    Instead of staying silent, B tells C “D — 16”. In real RIP this removes the wrong path without waiting for the timer. In our simplified model the result of both is the same.

  4. Hold-down and triggered update

    Hold-down: for a route that has worsened, for 180 s do not believe suspicious messages from other neighbors. Triggered update: send the message immediately without waiting for 30 s. Be careful: in looped topologies (a ring of 3 or more routers) split horizon alone is not enough.

Scenario 2. OSPF: the cost trap and re-convergence

A campus network has an old 100 Mbit/s link and new 10 Gbit/s fiber. By default the reference is 100 Mbit/s: both links get cost = 1! OSPF treats them as equal and may send traffic over the slow link too. The fix — the same on all routers:

Cisco IOSR1(config)# router ospf 1
R1(config-router)# auto-cost reference-bandwidth 100000   # Mbit/s: 100 Gbit/s
# now: 100M → 1000, 1G → 100, 10G → 10, 100G → 1
R1# show ip ospf interface brief                          # check the Cost column
Warning

If you change the reference on only one router, the routers “rate” the same link differently — producing asymmetric and unexpected paths. This setting must be the same across the whole OSPF domain.

How does OSPF work when a link fails? The router that notices the failure floods a new LSA; every router in the area updates its LSDB and recalculates SPF. Which routes change can be found with “Dijkstra twice” (task 3). For example, in the practical class 13 backbone, if the F–T link fails, A’s path to T changes from A → F → T (cost 2) to A → N → T (cost 20) — the slow 10M link (cost 100) is still not chosen.

If an OSPF adjacency does not form: checklist

Table 14.2. What must match for two OSPF routers to become neighbors
ParameterIf it does not matchCommand to check
Area number (area ID)Hellos are not acceptedshow ip ospf interface
Hello and Dead intervalsThe neighbor is not visible at allshow ip ospf interface
Subnet and maskHellos are not acceptedshow ip interface brief
Authentication (type and key)The neighbor is not visibledebug ip ospf adj
MTUThe neighbor is visible, but gets “stuck” in the EXSTART/EXCHANGE stateshow ip ospf neighbor
Router ID must not be duplicatedThe adjacency breaks, a warning appears in the logshow ip ospf

Scenario 3. BGP: policy steers traffic

You are the provider AS 100 (Vodiy-Net). The content provider AS 500 announces its prefix (203.0.113.0/24). In the simulator, each AS selects the best path with a simplified BGP rule: (1) highest LOCAL_PREF, (2) shortest AS_PATH, (3) on a tie — the neighbor with the lower number. An AS that sees its own number in AS_PATH rejects the announcement. Turn the policies on and off and watch where AS 100’s traffic goes.

:ik-globus: BGP: path selection between autonomous systems

Independent tasks

6 tasks: each is a model of a real fault or decision. Without an input() prompt.

Common mistakes

ErrorSignFix
Split horizon is disabled (or a looped topology)After a failure the metrics slowly grow, a temporary loopSplit horizon/poison reverse, triggered update; in a larger network — OSPF
The OSPF reference was changed on only one routerAsymmetric, unexpected pathsThe same auto-cost reference-bandwidth across the whole domain
Hello/Dead timers or area do not matchshow ip ospf neighbor is emptyMake them the same on both sides
MTU mismatchThe neighbor gets stuck in EXSTART/EXCHANGEMake the MTUs equal
Confusing LOCAL_PREF and prependingTraffic does not shift in the expected directionLOCAL_PREF is for outgoing, prepending is for incoming traffic
The same prefix from two protocols: thinking “the smaller metric wins”An unexpected protocol’s route in the tableMetrics of different protocols cannot be compared — AD first

Boss level

Boss level: BGP — a path vector with policy

Recreate the simulator’s BGP “brain” in Python. +90 XP

Input: line 1 — m; the next m lines “AS1 AS2” (neighbors). Then the source AS (the prefix owner). Then k; the next k lines are policies: “LP A B V” — A sets LOCAL_PREF = V on paths received from neighbor AS B (default 100); “PREPEND A B K” — when A announces to B, it repeats its own number an extra K times.

Rules: in rounds (everyone simultaneously, from the neighbors’ best paths of the previous round) — until changes stop (at most 50). B’s announcement from a neighbor: [B]×(1+K) + B’s path. If your own number is in AS_PATH — reject. Selection: higher LOCAL_PREF → shorter AS_PATH → lower neighbor number. Output: for every AS other than the source, in ascending order, “AS x: AS_PATH” or “AS x: yo‘l yo‘q”.

Reinforcement

Review questions

How does count to infinity arise?

Neighboring routers trust each other’s stale information about a failed network and take turns raising the distance; the temporary loop lasts until the metric reaches “infinity” (16 in RIP).

What is the difference between split horizon, poison reverse, hold-down and triggered update?

Split horizon — do not advertise back to the side it was learned from; poison reverse — advertise to that side with 16; hold-down — for a worsened route, do not believe new messages for a while; triggered update — report immediately on a change.

Why must the OSPF reference bandwidth be changed?

Because the default is 100 Mbit/s, every link faster than 100M gets cost = 1 and OSPF cannot tell them apart. The reference is raised to the same value across the whole domain.

Which parameters must match for an OSPF adjacency?

Area number, Hello and Dead intervals, subnet and mask, authentication, MTU (for a full adjacency); router IDs must not be duplicated.

How does OSPF re-converge when a link fails?

The router that notices the failure (by the interface or the dead interval) floods a new LSA; all routers in the area update the LSDB, recalculate SPF and update their tables.

How does BGP choose the best path (simplified)?

Highest LOCAL_PREF → shortest AS_PATH → lowest ORIGIN (i < e < ?) → lowest MED → eBGP preferred over iBGP → lowest router ID (on Cisco there are also weight and other steps before these).

What traffic do LOCAL_PREF and AS-path prepending affect?

LOCAL_PREF — through which neighbor traffic leaves your own AS (outgoing); prepending — by which path other ASes reach you (incoming traffic).

How does a router choose among routes learned from several protocols?

For the same prefix the source with the smallest AD goes into the table; when a packet is forwarded, the longest matching prefix in the table is selected. Metrics of different protocols are not compared directly.

Independent work

The independent-study topic in the course syllabus: “Comparative analysis of the RIP, OSPF, EIGRP and BGP protocols.” (6 hours). The part related to this class — fault and policy analysis:

  1. Draw the scenario for your variant and write down the expected behavior step by step (which router learns what, and when).
  2. Run the matching Python programs from the lesson with your variant’s data and explain the result.
  3. Model the scenario in Packet Tracer (RIP/OSPF) or on paper (BGP); attach the results of the required show commands.
  4. Write measures to prevent or fix the problem.
Assessment criteria (individual assignment)
CriterionPoints
The scenario and expected behavior are analyzed correctly2
The Python programs or manual calculations are correct and explained1
The simulator/paper model and the show results1
The prevention and fix measures are justified1

Summary

Count to infinityThe weak point of DV; the limit of 16, split horizon, poison reverse, hold-down.
OSPF costRaise the reference equally across the whole domain, otherwise fast links look equal.
Re-convergenceNew LSA → everyone recalculates SPF; only the affected routes change.
AdjacencyArea, timers, subnet, authentication, MTU, unique RID.
BGP selectionLOCAL_PREF → AS_PATH → ORIGIN → MED → eBGP → RID.
PolicyLOCAL_PREF — outgoing, prepending — incoming traffic.
Many protocolsOne prefix — AD decides; for a packet — LPM.
The whole pathPractical classes 11–12 (static) → 13–14 (dynamic) → practical class 15: routing table analysis.

Your lesson results

Your results are saved in this browser. Read all the sections and complete the exercises and assignments.

My personal notes