1
CS 168, Summer 2025 @ UC Berkeley
Slides credit: Sylvia Ratnasamy, Rob Shakir, Peyrin Kao, Iuniana Oprescu
Link-State Protocols, IP Addressing
Lecture 6 (Routing 3)
4.1
4.2
4.3
4.4
4.5
4.6
Link-State Protocols
Lecture 6, CS 168, Summer 2025
Link-State Protocols
IP Addressing
Routing Protocols – Roadmap
Routing protocols can be classified by:
Today, we'll look at link-state protocols.
| Intra-domain (Interior Gateway Protocol) | Inter-domain�(Exterior Gateway Protocol) |
Distance-vector | RIP | – |
Link-state | IS-IS, OSPF | – |
Path-vector | – | BGP |
Link-State Protocols: Definition
Link-state protocols:
Distance-vector:
Link-state:
How do routers learn this?
What algorithm do we run?
Global Data
Suppose R3 has learned the full network graph.
R3 can run a graph algorithm to compute paths.
R3
R2
R1
R5
R4
1
1
1
7
2
1
10
A
B
1
R3's Table | |
Destination | Next Hop |
A | R2 |
... | ... |
How do routers learn this?
What algorithm do we run?
Computing Paths
Lecture 6, CS 168, Summer 2025
Link-State Protocols
IP Addressing
Link-State Algorithms
What graph algorithm do we run to compute paths?
Any single source shortest-path algorithm will work.
Some possible choices:
Ensuring Consistency
Each router can only influence its next hop.
No guarantee that routers compute the same paths!
We have to ensure that every router is using a "compatible" approach.
R3
R2
R1
R5
R4
A
B
R3
R2
R1
R5
R4
A
B
R2 forwards to R3.
R3 forwards to R2.
Ensuring Consistency
Requirements for routers to produce valid, compatible decisions:
Routers don't necessarily need to use the same shortest-path algorithm, as long as they follow these rules.
Learning Graph Topology
Lecture 6, CS 168, Summer 2025
Link-State Protocols
IP Addressing
Steps of Learning Network Graph
Link-state protocols:
How do routers learn this?
Steps of Learning Network Graph (1/2) – Learn Neighbors
How do we discover who is adjacent to us and their identity? Say hello!
R1
R2
R3
Hello, I'm R2.
Hello, I'm R2.
Hello, I'm R1.
Hello, I'm R3.
My neighbor is R2.
My neighbor is R2.
My neighbors are R1 and R3.
Steps of Learning Network Graph (2/2) – Propagate Neighbor Information
How do we learn about the rest of the network, beyond our neighbors?
R1
R1 and R2 are neighbors. Tell everyone!
R1 and R2 are neighbors. Tell everyone!
R2
R1 and R2 are neighbors. Tell everyone!
R3
Avoiding Infinite Flooding
Flooding: When you receive an update, send it to everybody.
We have to be careful of the same update being sent repeatedly.
R1
R2
R5 and R9 are neighbors.
R5 and R9 are neighbors.
R5 and R9 are neighbors.
R5 and R9 are neighbors.
R5 and R9 are neighbors.
Avoiding Infinite Flooding
Amplification: When there's a loop, copies of the same message get multiplied.
R1
R2
R3
Avoiding Infinite Flooding
Amplification: When there's a loop, copies of the same message get multiplied.
R1
R2
R3
R1
R3
R1
R2
R2
R3
R1
R2
R2
R3
R1
R3
R1
R2
R1
R3
R1
R2
R2
R3
R2
R3
R2
R3
R1
R3
This edge means, R1 sends the message to R2.
Then, R2 sends it to R1, and so on.
R1
R3
Avoiding Infinite Flooding
Problem: Naive solution (send to all neighbors) causes amplification.
Solution:
To identify packets you've seen before, add a timestamp.
✓ Seen it.
✓ Seen it.
✓ Seen it.
R1
R2
R3
Ensuring Reliability
The network is still best-effort. Updates could get dropped.
Solution: Periodically re-send the update.
Ensuring Convergence
The network could change. What happens if a link goes down?
While waiting for convergence, the routing state might be invalid.
Link is down, but R1 doesn't know!
R1 forwards to R3.
R3 knows about the link failure!
R3 forwards to R1.
R2
R1
R3
A
R2
R1
A
R3
Link-State vs. Distance-Vector
Link-state is relatively simple. All the complexity is in the details!
Why might we want to use link-state over distance-vector?
Real networks often use a combination of path/distance-vector and link-state.
Hierarchical Addressing
Lecture 6, CS 168, Summer 2025
Link-State Protocols
IP Addressing
Scaling Routing
Can we really scale routing and forwarding to every host on the Internet?
The secret to scaling routing is how we do addressing.
R3's Table | |
Destination | Port |
A | 0 |
B | 1 |
C | 1 |
D | 2 |
... | ... |
One entry for every possible destination.
The trick: Use more informative names than A, B, C, D for destinations.
Disclaimer: Today is about IP (Layer 3) addresses. Other layers use different addressing systems.
Hierarchical Addressing – Conceptual
Recall: The Internet is a network of networks.
4.1
4.2
4.3
4.4
4.5
4.6
2.5
2.4
2.6
2.7
2.1
2.2
2.3
1.1
1.2
3.1
3.2
3.3
Network 2
Network 1
Network 3
Network 4
Hierarchical Addressing – Conceptual
R9 can summarize all hosts in another network with a single table entry.
Huge scaling improvement! Tables are smaller now.
4.1
4.2
4.3
4.4
4.5
4.6
2.5
2.4
2.6
2.7
2.1
2.2
2.3
1.1
1.2
3.1
3.2
3.3
Network 2
Network 1
Network 3
Network 4
R8
R9
R6
R9's Table | |
Destination | Next Hop |
1.* | R6 |
3.* | R6 |
4.* | R8 |
... | ... |
Hierarchical Addressing – Conceptual
Hierarchical addressing limits table churn.
Changes inside a network don't affect tables in other networks.
4.1
4.2
4.3
4.4
4.5
2.5
2.4
2.6
2.7
2.1
2.2
2.3
1.1
1.2
3.1
3.2
3.3
Network 2
Network 1
Network 3
Network 4
R8
R9
R6
R9's Table | |
Destination | Next Hop |
1.* | R6 |
3.* | R6 |
4.* | R8 |
... | ... |
4.6 left the network!
No change in table entry!
Hierarchical Addressing – Conceptual
Size of the forwarding table scales with number of hosts in the current network, plus number of other networks.
Network 4
...
Network 2
R4's Table | |
Destination | Next Hop |
2.1 | R3 |
2.2 | R3 |
2.3 | R3 |
2.4 | R3 |
2.5 | R3 |
2.6 | R5 |
2.7 | R5 |
1.* | R9 |
3.* | R9 |
4.* | R9 |
2.1
2.2
2.3
2.5
2.4
R2
2.6
2.7
R3
Network 1
R8
R6
...
R1
R5
R9
R4
Internal destinations.
External destinations.
Implications of Hierarchical Addressing
Inter-domain routing computes routes between networks.
Intra-domain routing computes routes inside a network.
R4's Table | |
Destination | Next Hop |
2.1 | R3 |
2.2 | R3 |
2.3 | R3 |
2.4 | R3 |
2.5 | R3 |
2.6 | R5 |
2.7 | R5 |
1.* | R9 |
3.* | R9 |
4.* | R9 |
Internal destinations.
External destinations.
Aggregation – Conceptual
Sometimes, we can aggregate several rows into a single row.
Network 4
...
Network 2
2.1
2.2
2.3
2.5
2.4
R2
2.6
2.7
R3
Network 1
R8
R6
...
R1
R5
R9
R4
R4's Table | |
Destination | Next Hop |
2.1 | R3 |
2.2 | R3 |
2.3 | R3 |
2.4 | R3 |
2.5 | R3 |
2.6 | R5 |
2.7 | R5 |
*.* | R9 |
R4's Table | |
Destination | Next Hop |
2.1 | R3 |
2.2 | R3 |
2.3 | R3 |
2.4 | R3 |
2.5 | R3 |
2.6 | R5 |
2.7 | R5 |
1.* | R9 |
3.* | R9 |
4.* | R9 |
Aggregation – Conceptual
From R2, everything is reached through R3, so we can aggregate entries.
Network 4
...
Network 2
2.1
2.2
2.3
2.5
2.4
R2
2.6
2.7
R3
Network 1
R8
R6
...
R1
R5
R9
R4
R2's Table | |
Destination | Next Hop |
2.4 | Direct |
2.5 | Direct |
*.* | R3 |
R2's Table | |
Destination | Next Hop |
2.4 | Direct |
2.5 | Direct |
2.1 | R3 |
2.2 | R3 |
2.3 | R3 |
2.6 | R3 |
2.7 | R3 |
1.* | R3 |
3.* | R3 |
4.* | R3 |
Assigning Addresses
Lecture 6, CS 168, Summer 2025
Link-State Protocols
IP Addressing
Assigning Addresses
Hierarchical addressing makes routing scalable.
When a host joins the network, it's assigned an IP address based on its location in the network.
Assigning Addresses, Attempt 1/3 – Early Internet
Addresses are 32 bits long.
Each organization gets a unique network ID.
Bob's address: 11010110 10000100 00111010 01101110
Joe's address: 11010110 10010001 00000000 01001101
Network ID
Host ID
Same network ID, so they must be in the same network.
Assigning Addresses, Attempt 1/3 – Early Internet
Addresses are 32 bits long.
Problems:
Assigning Addresses, Attempt 2/3 – Classful Addressing
Idea: Allocate different network sizes based on need.
0 | Network (7 bits) | Host (24 bits) | |||||||||||||||||||||||||||||
10 | Network (14 bits) | Host (16 bits) | |||||||||||||||||||||||||||||
110 | Network (21 bits) | Host (8 bits) | |||||||||||||||||||||||||||||
Class A:
Class B:
Class C:
~128 networks
~16m hosts per network
~16k networks
~65k hosts per network
~2m networks
~256 hosts per network
Assigning Addresses, Attempt 2/3 – Classful Addressing
0 | Network (7 bits) | Host (24 bits) | |||||||||||||||||||||||||||||
10 | Network (14 bits) | Host (16 bits) | |||||||||||||||||||||||||||||
110 | Network (21 bits) | Host (8 bits) | |||||||||||||||||||||||||||||
Class A:
Class B:
Class C:
Bob's address: 10010110 10000100 00111010 01101110
Joe's address: 10010110 10000100 00000000 01001101
Host ID
The top bits indicate this is Class B...
Network ID
...so read the next 14 bits as the network ID...
...and read the last 16 bits as the host ID.
Assigning Addresses, Attempt 2/3 – Classful Addressing
Problems:
1989
1990
1991
1992
1993
1994
20,000
10,000
Number of inter-domain routes by year (approximate)
Assigning Addresses, Attempt 3/3 – CIDR
With classful addressing, we tried to use convenient 8-bit boundaries.
What if we could assign network IDs of any length?
0 | Network (7 bits) | Host (24 bits) | |||||||||||||||||||||||||||||
10 | Network (14 bits) | Host (16 bits) | |||||||||||||||||||||||||||||
110 | Network (21 bits) | Host (8 bits) | |||||||||||||||||||||||||||||
Class A:
Class B:
Class C:
Assigning Addresses, Attempt 3/3 – CIDR
Suppose Joe's Tire Shop has 450 hosts.
Classful addressing:
Classless (CIDR) addressing:
Network ID (23 bits) | Host ID (9 bits) | ||||||||||||||||||||||||||||||
Granular Hierarchical Assignment with CIDR
CIDR enables multi-layered hierarchical assignment of addresses.
Granular Hierarchical Assignment with CIDR
ICANN owns all addresses: ................................
ARIN (North America) owns: 1101............................
4 bits fixed, 228 ≈ 268m addresses.
AT&T (large ISP) owns: 110111001.......................
9 bits fixed, 223 ≈ 8m addresses.
UC Berkeley owns: 110111001110100010..............
18 bits fixed, 214 ≈ 16k addresses.
Soda Hall owns: 110111001110100010011010........
24 bits fixed, 28 ≈ 256 addresses.
Prof. Ratnasamy owns: 11011100111010001001101001011101
All bits fixed, 1 address.
Writing Addresses
Lecture 6, CS 168, Summer 2025
Link-State Protocols
IP Addressing
Writing IPv4 Addresses
We could write an IP address as a 32-bit number: 11011100111010001001101001011101
Dotted quad notation:
11011100 11101000 10011010 01011101
220
232
93
154
.
.
.
Writing IPv4 Address Ranges
Slash notation for writing ranges of addresses:
Examples:
11011100 11101000 10010000 00000000
220
232
0
144
.
.
.
11011100 11101000 1001.... ........
Set all unfixed bits to 0.
/20
Number of fixed bits.
Writing IPv4 Address Ranges
Netmask is an alternative to the number after the slash..
Slash notation: 220.232.144.0/20
Netmask notation: 220.232.144.0 (netmask 255.255.240.0)
11111111 11111111 11110000 00000000
255
255
0
240
.
.
.
11011100 11101000 1001.... ........
Set all bits to 0 or 1.
Aggregating Routes
Lecture 6, CS 168, Summer 2025
Link-State Protocols
IP Addressing
Inter-Domain Routing
In inter-domain routing, we're looking for routes to other networks.
AT&T
4.0.0.0/8
UC Berkeley
130.0.0.0/8
Stanford
146.0.0.0/8
Orange (France)
R6's Table | |
Destination | Next Hop |
4.0.0.0/8 | R2 |
130.0.0.0/8 | R2 |
146.0.0.0/8 | R2 |
... | ... |
R6
R2
Inter-Domain Routing
With CIDR, AT&T allocates parts of its ranges to UC Berkeley and Stanford.
AT&T
4.0.0.0/8
UC Berkeley
4.12.0.0/16
Stanford
4.29.0.0/16
Orange (France)
R6's Table | |
Destination | Next Hop |
4.0.0.0/8 | R2 |
4.12.0.0/16 | R2 |
4.29.0.0/16 | R2 |
... | ... |
R6
R2
Inter-Domain Routing
Now, Stanford wants to connect to multiple networks. This is called multi-homing.
AT&T
4.0.0.0/8
UC Berkeley
4.12.0.0/16
Stanford
4.29.0.0/16
Orange (France)
R6's Table | |
Destination | Next Hop |
4.0.0.0/8 | R2 |
4.12.0.0/16 | R2 |
4.29.0.0/16 | R7 |
... | ... |
R6
R2
R7
Inter-Domain Routing
Ranges in the table might overlap.
AT&T
4.0.0.0/8
UC Berkeley
4.12.0.0/16
Stanford
4.29.0.0/16
Orange (France)
R6's Table | |
Destination | Next Hop |
4.0.0.0/8 | R2 |
4.12.0.0/16 | R2 |
4.29.0.0/16 | R7 |
... | ... |
R6
R2
R7
IPv6 Changes
Lecture 6, CS 168, Summer 2025
Link-State Protocols
IP Addressing
Running Out of IPv4 Addresses
IPv4 addresses are 32 bits long. 232 ≈ 4 billion addresses. Is that enough?
2017: Every regional registry had fewer than 224 ≈ 16m addresses left.
2021: We're running out!
Running Out of IPv4 Addresses
A ceremony where the last range of IPv4 addresses was allocated. (February 2011)
Introducing IPv6
IPv6 was introduced in 1998 to deal with IPv4 address exhaustion.
Is 128 bits enough?
IPv5 was an experimental protocol from the 1990s. It was never widely implemented.
IPv6 Addresses
IPv6 uses hexadecimal instead of decimal.
Shorthand:
Can still use slash notation for ranges.
IPv6 Addresses
IPv6 generally uses the same hierarchical addressing approach as IPv4.
Some changes:
IPv6 Adoption
IPv6 introduced in the 1990s, but wide adoption started in the 2010s.
Today, ~40% of hosts have adopted IPv6.
IPv6 Adoption
Adoption generally correlated with areas where there are many Internet users.
IPv6 Adoption – Challenges
Why is IPv6 adoption hard?
Main driver for IPv6 adoption: We're running out of IPv4 addresses!
Summary: IP Addressing