Discussion 3
1
CS 168, Summer 2025 @ UC Berkeley
Slides credit: Sylvia Ratnasamy, Rob Shakir, Peyrin Kao, Iuniana Oprescu
Routing I 🫂
Logistics
Distance-Vector Algorithm Sketch
Distance-Vector Correctness
Distance-Vector Enhancements
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.
One-line algorithm: If you hear about a path to a destination, tell all your neighbors!
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
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
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
Careful viewers 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.
Rule 2: Updates from Next-Hop
Distance-Vector Correctness
Distance-Vector Enhancements
Updates From the Current Next-Hop
Recall our routing challenges: Topology can change.
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.
The Distance-Vector Algorithm So Far
For each destination:
Rule 3: Resending and Expiring
Distance-Vector Correctness
Distance-Vector Enhancements
The Distance-Vector Algorithm So Far
For each destination:
Handling Failures
Recall our routing challenges: Links and routers can fail.
Solution: Each route has a finite time to live (TTL).
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 4: Poison Expired Routes
Distance-Vector Correctness
Distance-Vector Enhancements
Poison for Fast Route Expiry
Key problem: When something fails, nobody's reporting it.
Solution: Poison ☠️.
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 5A/5B:�Split Horizon / Poison Reverse
Distance-Vector Correctness
Distance-Vector Enhancements
Split Horizon / Poison Reverse – The Problem
The problem: When I give someone a path, they advertise it back to me.
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 (infinity).
R1
R1
R1
R1
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 6: Count to Infinity
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 – Solution
Solution: Enforce a maximum cost.
Result:
The Distance-Vector Algorithm So Far
For each destination:
Eventful Updates
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:
Worksheet
Question 1: Distance Vector
Question 1: Distance Vector
Question 1: Distance Vector
Question 1: Distance Vector
Question 1: Distance Vector
Question 1: Distance Vector
Question 1: Distance Vector
Question 1: Distance Vector
Worksheet
Question 2: Split Horizon and Poison
Question 2: Split Horizon and Poison
Worksheet
Question 3: Count to Infinity
Question 3: Count to Infinity
Question 3: Count to Infinity
Question 3: Count to Infinity
Question 3: Count to Infinity
Questions?
Feedback Form: https://tinyurl.com/cs168-su25-disc-feedback