1
CS 168, Spring 2026 @ UC Berkeley
Slides credit: Sylvia Ratnasamy, Rob Shakir, Peyrin Kao, Iuniana Oprescu
Distance-Vector Protocols
Lecture 6 (Routing 2)
Some Announcements
Recall: Routing Principles
Routing allows us to find paths through the network.
The Internet uses destination-based forwarding.
We need a valid directed delivery tree with no dead ends and no loops!
R1
R7
R5
C
R6
D
R2
R3
R4
R8
B
A
R3's Table (Conceptual) | |
Destination | Next Hop |
A | R2 |
B | R4 |
C | R7 |
D | R4 |
Static or direct routes can be hard coded!
Distance-Vector Algorithm Sketch
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Distance-Vector Algorithm Sketch
One-line algorithm: If you hear about a path to a destination, tell all your neighbors.
R2
A
R3
R1
R5
R4
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15
A is 1 away from me. I should tell my neighbors.
A this way
Distance-Vector Algorithm Sketch
One-line algorithm: If you hear about a path to a destination, tell all your neighbors.
R2
A
R3
R1
R5
R4
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15
A this way
A is 1 away from me.
A is 1 away from me.
Distance-Vector Algorithm Sketch
One-line algorithm: If you hear about a path to a destination, tell all your neighbors.
R2
A
R3
R1
R5
R4
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15
A this way
We just found a way to reach A. We should tell our neighbors.
A this way
A this way
Distance-Vector Algorithm Sketch
One-line algorithm: If you hear about a path to a destination, tell all your neighbors.
R2
A
R3
R1
R5
R4
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15
A this way
A is 2 away from me.
A is 2 away.
A is 2 away.
A is 2 away.
A this way
A this way
Distance-Vector Algorithm Sketch
One-line algorithm: If you hear about a path to a destination, tell all your neighbors.
R2
A
R3
R1
R5
R4
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15
A this way
We just found a way to reach A. We should tell our neighbors.
A this way
A this way
A this way
A this way
A this way
A this way
Distance-Vector Algorithm Sketch
One-line algorithm: If you hear about a path to a destination, tell all your neighbors.
R2
A
R3
R1
R5
R4
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15
A this way
A this way
A this way
A this way
A this way
A this way
A this way
A is 3 away.
A is 3 away.
A is 3 away.
A is 3 away.
A is 3 away.
A is 3 away.
A is 3 away.
A is 3 away.
Distance-Vector Algorithm Sketch
One-line algorithm: If you hear about a path to a destination, tell all your neighbors.
R2
A
R3
R1
R5
R4
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15
A this way
A this way
A this way
A this way
A this way
A this way
A this way
A this way
A this way
A this way
A this way
A this way
A this way
A this way
A this way
We did it! Everybody knows the next-hop to A now.
Distance-Vector Algorithm Sketch – Routing vs. Forwarding
R2
A
R3
R1
R5
R4
R6
R7
R8
R9
R10
R11
R12
R13
R14
R15
Routing announcements ("I can reach A") propagated outward, away from A.
When forwarding packets toward A, packets travel inward, toward A.
Distance-Vector Algorithm Sketch – Multiple Destinations
What if there are multiple destinations?
We'll focus on a single destination for simplicity.
Rule 1: Bellman-Ford Updates
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Multiple Paths Advertised
What if you hear about multiple paths to a single destination?
R5
R3
R4
R2
R1
A
A is 3 away from me.
A is 2 away from me.
I prefer what R4 is offering.
A this way
Multiple Paths Advertised
What if you hear about multiple paths to a single destination?
R5
R3
R4
R2
R1
A
Multiple Paths Advertised
You might not hear about both paths simultaneously.
R5
R3
R4
R2
R1
A
A is 3 away from me.
R5's Table | ||
To: | Via: | Cost: |
A | R3 | 4 |
Multiple Paths Advertised
You might not hear about both paths simultaneously.
R5
R3
R4
R2
R1
A
R5's Table | ||
To: | Via: | Cost: |
A | R3�R4 | 4�3 |
A is 2 away from me.
I like this new path better. I'll abandon the old one.
The Distance-Vector Algorithm So Far
For each destination:
Unequal Costs
Not all link costs are 1.
R3
R1
R2
1
10
A is 5 away from me.
R3's Table | ||
To: | Via: | Cost: |
A | R1 | 1+5 = 6 |
Unequal Costs
Not all link costs are 1.
R3
R1
R2
1
10
R3's Table | ||
To: | Via: | Cost: |
A | R1 | 1+5 = 6 |
A is 3 away from me.
This path actually costs 10+3=13. I'll keep using the cost 6 path and reject this.
The Distance-Vector Algorithm So Far
For each destination:
Distributed Bellman-Ford Algorithm
Some of you might have noticed this operation looks familiar.
Bellman-Ford is another relaxation-based shortest path algorithm.
Distance-vector algorithms are a distributed, asynchronous version of Bellman-Ford.
Bellman-Ford Algorithm
The centralized Bellman-Ford algorithm for a single destination:
def bellman_ford(dst, routers, links):
� distance = {}; nexthop = {}
� for r in routers:� distance[r] = INFINITY� nexthop[r] = None� distance[dst] = 0� � for _ in range(len(routers)-1):� for (r1, r2, linkcost) in links:
� if distance[r1] + linkcost < distance[r2]:� distance[r2] = distance[r1] + linkcost� nexthop[r2] = r1
� return distance, nexthop
Everyone starts infinity away from the destination, except for the destination itself (0 away).
The relaxation operation.
Bellman-Ford loops through nodes and relaxes repeatedly.
In distance-vector, each router relaxes in parallel, with both directions as links between routers.
Bellman-Ford Demo
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
The Distance-Vector Algorithm So Far
For each destination:
Terminology note:
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
| | |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
| | |
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
| | |
Static routing: Someone hard-codes R1's table to say it can reach A.
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
| | |
I found a way to reach A!
Time to tell all my neighbors.
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
| | |
I'm R1, and A is 1 away from me.
New advertisement!
I don't have a way to reach A yet, so I'll accept.
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 1+1=2 |
1 (link cost to R1), plus�1 (advertised cost).
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R3's Table | ||
To: | Via: | Cost: |
| | |
Time to tell everyone about my shiny new path to A.
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R3's Table | ||
To: | Via: | Cost: |
| | |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
I'm R2, and A is 2 away from me.
I'm R2, and A is 2 away from me.
Notice: R2's announcement doesn't include the next-hop.�Nobody else cares how R2 reaches A, just that R2 can reach A.
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R3's Table | ||
To: | Via: | Cost: |
| | |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
I'm R2, and A is 2 away from me.
I'm R2, and A is 2 away from me.
New advertisement?!
This new path costs 1+2=3.
I already have a cost 1 path.
No thanks.
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R3's Table | ||
To: | Via: | Cost: |
| | |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
I'm R2, and A is 2 away from me.
New advertisement?!?
I don't have a path to A yet, so I'll accept.
I'm R2, and A is 2 away from me.
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 1+2=3 |
1 (link cost to R2), plus�1 (advertised cost).
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
Time to advertise my exciting new path to A.
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
I'm R3, and A is 3 away from me.
New advertisement?!??!?!!!?
This new path costs 1+3=4.
I already have a cost 2 path.
No thanks.
Bellman-Ford Demo
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
We did it! Everybody has a way to reach A now.
A this way
A this way
A this way
Rule 2: Updates from Next-Hop
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Updates From the Current Next-Hop
Recall our routing challenges: Topology can change.
R3
R1
R2
R3's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 1+3 = 4 |
I'm R2, and A is 3 away from me.
A wasn't in my table. Accept!
Updates From the Current Next-Hop
Recall our routing challenges: Topology can change.
R3
R1
R2
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 4 |
I'm R1, and A is 8 away from me.
1+8=9 is worse than 4.
Reject!
Updates From the Current Next-Hop
Recall our routing challenges: Topology can change.
R3
R1
R2
I'm R2, and A is 8 away from me.
R2 is the next-hop. Accept!
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 4 |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 1+8=9 |
Hi, it's R2 again. I know I said A is 3 away from me earlier, but that's changed. Now A is 8 away.
What R2 is really saying:
The Distance-Vector Algorithm So Far
For each destination:
Convergence
If the network never changes:
If a change happens (e.g. a link goes down):
The network topology is constantly changing, so routers run the protocol indefinitely.
Rule 3: Resending
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Ensuring Reliability
Recall our routing challenges: Packets can get dropped.
Solution: Resend advertisements every X seconds.
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
| | |
I'm R1, and A is 1 away from me.
Huh? Did someone say something?
Dropped!
The Distance-Vector Algorithm So Far
For each destination:
Rule 4: Expiring
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Handling Failures
Recall our routing challenges: Links and routers can fail.
Solution: Each route has a finite time to live (TTL).
R3
R2
Didn't have a path to A. Accept!
R3's Table | |||
To: | Via: | Cost: | TTL: |
| | | |
I'm R2, and A is 5 away from me.
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | 6 | 11 |
t = 0
Need another confirmation of this route in the next 11 seconds.
A
Handling Failures
Recall our routing challenges: Links and routers can fail.
Solution: Each route has a finite time to live (TTL).
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | 6 | 10 |
t = 1
t = 2
9
t = 3
8
t = 4
7
R3
R2
A
Handling Failures
Recall our routing challenges: Links and routers can fail.
Solution: Each route has a finite time to live (TTL).
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | 6 | 11 |
t = 5
We got a confirmation!�Reset TTL back to 11.
I'm still R2, and A is still 5 away from me.
R3
R2
A
Handling Failures
Recall our routing challenges: Links and routers can fail.
Solution: Each route has a finite time to live (TTL).
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | 6 | 10 |
t = 6
9
t = 7
8
t = 8
7
t = 9
Link goes down!
6
t = 10
5
t = 11
4
t = 12
3
t = 13
2
t = 14
1
t = 15
R3
R2
A
Handling Failures
Recall our routing challenges: Links and routers can fail.
Solution: Each route has a finite time to live (TTL).
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | 6 | 0 |
t = 16
Timeout! Delete expired entry.
Link goes down!
R3
R2
A
Timers
Routers maintain multiple timers:
The Distance-Vector Algorithm So Far
For each destination:
This is a mostly-functional protocol now.�Let's add some optimizations for faster convergence.
Rule 5: Poison Expired Routes
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Route Expiry is Slow
Waiting for routes to expire is slow. Let's watch the demo again.
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | 2 | 13 |
t = 3
12
R3
R2
R1
A
Assume that by t=3, R3 knows a route to A.
t = 4
11
t = 5
Route Expiry is Slow
Waiting for routes to expire is slow. Let's watch the demo again.
R3's Table | |||
To: | Via: | Cost: | TTL: |
R2 | A | 2 | 10 |
t = 6
Pause right here.
Link goes down!
No thanks, I already have a cost 2 path.
I'm R1, and A is 1 away from me.
R3
R2
R1
A
Route Expiry is Slow
Waiting for routes to expire is slow. Let's watch the demo again.
R3's Table | |||
To: | Via: | Cost: | TTL: |
R2 | A | 2 | 9 |
8
7
6
t = 7
t = 8
t = 9
t = 10
R3
R2
R1
A
Route Expiry is Slow
Waiting for routes to expire is slow. Let's watch the demo again.
R3's Table | |||
To: | Via: | Cost: | TTL: |
R2 | A | 2 | 5 |
t = 11
Again, R3 is forced to reject this new path, because it's still waiting for the busted path to time out.
No thanks, I already have a cost 2 path.
I'm R1, and A is 1 away from me.
R3
R2
R1
A
Route Expiry is Slow
Waiting for routes to expire is slow. Let's watch the demo again.
R3's Table | |||
To: | Via: | Cost: | TTL: |
R2 | A | 2 | 4 |
3
2
1
t = 12
t = 13
t = 14
t = 15
R3
R2
R1
A
Route Expiry is Slow
Waiting for routes to expire is slow. Let's watch the demo again.
R3's Table | |||
To: | Via: | Cost: | TTL: |
R2 | A | 2 | 0 |
t = 16
Timeout! Delete expired entry.
R3
R2
R1
A
Sure, I'll accept, my old path just expired.
I'm R1, and A is 1 away from me.
Can we alert R3 of the failure sooner, so it can delete the old busted path earlier (and start accepting new paths)?
Poison for Fast Route Expiry
Waiting for routes to expire is slow.
Solution: Poison.
Poison for Fast Route Expiry
Poison lets us detect busted routes faster. Let's watch the demo again.
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | 2 | 13 |
t = 3
12
R3
R2
R1
A
Assume that by t=3, R3 knows a route to A.
t = 4
11
t = 5
Poison for Fast Route Expiry
Poison lets us detect busted routes faster. Let's watch the demo again.
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | 2 | 10 |
t = 6
R3 updates the table to indicate the path is busted. TTL recharges, just like any other update.
Link goes down!
Looks like the path via R2 is busted.
R3
R2
R1
A
I'm R2, and A is�∞ away from me.
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | ∞ | 16 |
Poison for Fast Route Expiry
Poison lets us detect busted routes faster. Let's watch the demo again.
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R2 | ∞ | 16 |
R3's Table | |||
To: | Via: | Cost: | TTL: |
A | R1 | 2 | 16 |
t = 6
R3 was able to accept the new route way earlier!
t=6 with poison, t=16 without poison.
Link goes down!
Sure, I'll accept, that's better than infinity.
I'm R1, and A is 1 away from me.
R3
R2
R1
A
Accepting and Advertising Poison
Where does poison come from?
When one of those occurs:
Accepting and Advertising Poison
When you get a poison advertisement from the current next-hop:
When you update the table with a poison route:
Don't forward packets along a poisoned route.
To: | Via: | Cost: |
A | R1 | ∞ |
Don't forward to R1.
The Distance-Vector Algorithm So Far
For each destination:
Rule 6A:�Split Horizon
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Split Horizon – The Problem
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
We ran the algorithm for some time, and we converged to this steady-state.
All subsequent advertisements will be rejected.
Split Horizon – The Problem
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
I'm R3, and A is 3 away from me.
Rejected. I have cost 2, and you're offering cost 1+3=4.
Split Horizon – The Problem
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
A link goes down, and R2's entry expires (no more updates from R1).
What happens now?
Split Horizon – The Problem
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
I'm R3, and A is 3 away from me.
My table's empty, so that sounds good to me.
R2's Table | ||
To: | Via: | Cost: |
A | R3 | 4 |
Split Horizon – The Problem
R2's Table | ||
To: | Via: | Cost: |
A | R3 | 4 |
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
A this way
A this way
We made a routing loop!
Split Horizon – The Problem
Problem ("me" = R2):
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
I'm R3, and A is 3 away from me.
My table's empty, so that sounds good to me.
R2's Table | ||
To: | Via: | Cost: |
A | R3 | 4 |
Split Horizon – The Problem
The split horizon problem: When I give someone a path, they advertise it back to me.
Solution: Don't advertise a path back to the person who gave it to you.
The Distance-Vector Algorithm So Far
For each destination:
Rule 6B:�Poison Reverse
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Poison Reverse
Split horizon: If R1 gives me a route, don't advertise it to R1.
Poison reverse: If R1 gives me a route, advertise poison back to R1.
Poison reverse is an alternative way to avoid routing loops.
Poison Reverse vs. Split Horizon
R2
I can reach A.
Split Horizon:
I can reach A.
Poison Reverse:
R2
R2
I can reach A.
R2
I can reach A.
I cannot reach A.
Don't advertise anything back to R1.
Explicitly advertise poison back to R1.
R1
R1
R1
R1
Poison Reverse
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
Let's watch the demo again, but with poison reverse this time.
As before, we first reach steady state.
Poison Reverse
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 2 |
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
A link goes down, and R2's entry expires (no more updates from R1).
What happens now?
Poison Reverse
R2's table now explicitly says: Do not send packets to R3.
R1
A
R2
R3
R1's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R2's Table | ||
To: | Via: | Cost: |
| | |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
I'm R3, and A is ∞ away from me.
My table's empty, so that sounds good to me.
R2's Table | ||
To: | Via: | Cost: |
A | R3 | ∞ |
Poison Reverse vs. Split Horizon
Suppose we end up with a routing loop somehow.
Split horizon: No poison is sent.
R2's Table | ||
To: | Via: | Cost: |
A | R3 | 4 |
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
I got this route from R3, so don't send it to R3.
I got this route from R2, so don't send it to R2.
Poison Reverse vs. Split Horizon
Suppose we end up with a routing loop somehow.
Poison reverse: R3 explicitly sends poison back to R2.
R2's Table | ||
To: | Via: | Cost: |
A | R3 | 4 |
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 3 |
I'm R3, and A is ∞ away from me.
R3 is my next-hop, so I accept.
R2's Table | ||
To: | Via: | Cost: |
A | R3 | ∞ |
I got this route from R2, so send poison to R2.
The Distance-Vector Algorithm So Far
For each destination:
Rule 7: Count to Infinity
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Count to Infinity – The Problem
Split horizon (or poison reverse) helps us avoid length-2 loops.
But we can still get routing loops with 3 or more routers.
Count to Infinity – The Problem
Suppose the tables reach steady-state.
A
R3's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 2 |
R2's Table | ||
To: | Via: | Cost: |
A | R3 | 2 |
R1
R2
R3
Count to Infinity – The Problem
Link goes down! A now unreachable.
R3 updates table and sends poison.
Poison reaches R2, but not R1!
I'm R3, and A is�∞ away from me.
R1
R2
R3
A
R3's Table | ||
To: | Via: | Cost: |
A | Direct | 1 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 2 |
R2's Table | ||
To: | Via: | Cost: |
A | R3 | 2 |
R3's Table | ||
To: | Via: | Cost: |
A | Direct | ∞ |
I'm R3, and A is�∞ away from me.
Dropped!
R2's Table | ||
To: | Via: | Cost: |
A | R3 | ∞ |
Count to Infinity – The Problem
At this point, R3 and R2 know A is unreachable.
But R1 still thinks there's a path to A!
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | Direct | ∞ |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 2 |
R2's Table | ||
To: | Via: | Cost: |
A | R3 | ∞ |
Count to Infinity – The Problem
R1 announces it can reach A.
Split horizon: R1's path came from R3, so don't tell R3.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | Direct | ∞ |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 2 |
R2's Table | ||
To: | Via: | Cost: |
A | R3 | ∞ |
I'm R1, and A is�2 away from me.
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 3 |
Count to Infinity – The Problem
R2 announces it can reach A.
Split horizon: R2's path came from R1, so don't tell R1.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | Direct | ∞ |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 2 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 3 |
I'm R2, and A is�3 away from me.
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 4 |
Count to Infinity – The Problem
R3 announces it can reach A.
Split horizon: R3's path came from R2, so don't tell R2.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 4 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 2 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 3 |
I'm R3, and A is�4 away from me.
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 5 |
Count to Infinity – The Problem
We keep advertising in a cycle, and costs keep increasing!
Split horizon can't save us.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 4 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 5 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 3 |
I'm R1, and A is�5 away from me.
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 6 |
Count to Infinity – The Problem
We keep advertising in a cycle, and costs keep increasing!
Split horizon can't save us.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 4 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 5 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 6 |
I'm R2, and A is�6 away from me.
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 7 |
Count to Infinity – The Problem
We keep advertising in a cycle, and costs keep increasing!
Split horizon can't save us.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 7 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 5 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 6 |
I'm R3, and A is�7 away from me.
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 8 |
Count to Infinity – The Problem
We keep advertising in a cycle, and costs keep increasing!
Split horizon can't save us.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 7 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 8 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 6 |
I'm R1, and A is�8 away from me.
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 9 |
Count to Infinity – The Problem
We keep advertising in a cycle, and costs keep increasing!
Split horizon can't save us.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 7 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 8 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 9 |
I'm R2, and A is�9 away from me.
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 10 |
Count to Infinity – The Problem
We keep advertising in a cycle, and costs keep increasing!
Split horizon can't save us.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 10 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 8 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 9 |
I'm R3, and A is�10 away from me.
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 11 |
Count to Infinity – The Problem
The problem, restated:
Split horizon won't save us.
R1
R2
R3
2
5
8
3
6
9
10
7
4
Count to Infinity – Solution
Solution: Enforce a maximum cost.
Result:
Count to Infinity – Solution
All numbers ≥ 16 are considered infinity.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 10 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 11 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 9 |
I'm R1, and A is�11 away from me.
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 12 |
Count to Infinity – Solution
All numbers ≥ 16 are considered infinity.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 10 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 11 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 12 |
I'm R2, and A is�12 away from me.
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 13 |
Count to Infinity – Solution
All numbers ≥ 16 are considered infinity.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 13 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 11 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 12 |
I'm R3, and A is�13 away from me.
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 14 |
Count to Infinity – Solution
All numbers ≥ 16 are considered infinity.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 13 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 14 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 12 |
I'm R1, and A is�14 away from me.
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 15 |
Count to Infinity – Solution
All numbers ≥ 16 are considered infinity.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 13 |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 14 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 15 |
R3's Table | ||
To: | Via: | Cost: |
A | R2 | 16 ∞ |
I'm R2, and A is�15 away from me.
Count to Infinity – Solution
All numbers ≥ 16 are considered infinity.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | ∞ |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | 14 |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 15 |
I'm R3, and A is�∞ away from me.
R1's Table | ||
To: | Via: | Cost: |
A | R3 | ∞ |
Count to Infinity – Solution
All numbers ≥ 16 are considered infinity.
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | ∞ |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | ∞ |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | 15 |
I'm R1, and A is�∞ away from me.
R2's Table | ||
To: | Via: | Cost: |
A | R1 | ∞ |
Count to Infinity – Solution
We've reached steady state!
A
R1
R2
R3
R3's Table | ||
To: | Via: | Cost: |
A | R2 | ∞ |
R1's Table | ||
To: | Via: | Cost: |
A | R3 | ∞ |
R2's Table | ||
To: | Via: | Cost: |
A | R1 | ∞ |
The Distance-Vector Algorithm So Far
For each destination:
Eventful Updates
Lecture 6, CS 168, Spring 2026
Distance-Vector Correctness
Distance-Vector Enhancements
Eventful Updates
When do we send advertisements?
Triggered updates are an optimization.
Our Completed Distance-Vector Algorithm
For each destination:
Summary: Distance-Vector Rules
1. Bellman-Ford Updates: Accept if advertised cost + link cost to neighbor < best-known cost.
2. Updates From Next-Hop: Accept if advertisement is from next hop.
3. Resending: Advertise periodically.
4. Expiring: Expire an entry if TTL runs out.
5. Poison Expired Routes: Send poison if an entry expires.
6A. Split Horizon: Don't advertise path back to the person who gave it to you.
6B. Poison Reverse: Send poison back to the person who gave you the path.
7. Count To Infinity: Any cost ≥ 16 is advertised as ∞.
This is now a pretty good routing protocol!