Ming Liu mgliu@cs.wisc.edu Introduction to Computer Networks CS640 https://pages.cs.wisc.edu/~mgliu/CS640/F21/ Intra-domain Routing 1
Ming Liu [email protected]
Introduction to Computer Networks
CS640 https://pages.cs.wisc.edu/~mgliu/CS640/F21/
Intra-domain Routing
1
Today
Last lecture • Subnetting/Supernetting
• ARP/DHCP/ICMP
2
Today • Introduction to Routing
• Distance Vector Algorithm
Announcements • Lab2 due on 10/19/2021 at 11:59PM
What makes the network — router (L1)
Network = nodes + links + switch + router • router: a multi-port bridge connecting different switched network
End Point
Link
Switch
Router
Switched network 1
Switched network 2
Switched network 3Internetwork
3
The Goal of Routing
Build router forwarding tables in an internetwork using intra-domain routing protocols
4
The Goal of Routing
Build router forwarding tables in an internetwork using intra-domain routing protocols
Domain: a single administrative entity or organization that owns one or more switched networks
4
Switched network 1
CS
Switched network 2
ECE
Switched network 3
Others (…)Internetwork
UW-Madison Campus
Domain Example
5
Switched network 1
CS
Switched network 2
ECE
Switched network 3
Others (…)Internetwork
UW-Madison Campus
Domain Example
5
The Goal of Routing
Build router forwarding tables in an internetwork using intra-domain routing protocols
High level approach • Distributed execution
• Send message about network links • Each router uses this info to compute routes
6
Forwarding v.s. Routing
Forwarding • To select an output port based on destination address and routing table
Routing • Process by which routing table is built
7
Forwarding Table v.s. Routing Table
Forwarding table • Used when a packet is being forwarded and so must contain enough information to
accomplish the forwarding function
• A row in the forwarding table contains the mapping from a network number to an
outgoing interface and some MAC information, such as Ethernet address of the next hop (inferred from ARP, or manual configured)
Routing table • Built by the routing algorithm as a precursor to build the forwarding table
• Generally contains mapping from network numbers to next hops
8
Routing Overview
We are computing paths to subnets (i.e., switched networks)
9
Routing Overview
We are computing paths to subnets (i.e., switched networks)
Represent Internetwork as a Graph • Assume nodes in the graph are routers • Assume links have cost • This cost could be latency of the link, or a
function of link bandwidth
• Could also have a dynamic model for costs9
Routing Overview
We are computing paths to subnets (i.e., switched networks)
Represent Internetwork as a Graph • Assume nodes in the graph are routers • Assume links have cost • This cost could be latency of the link, or a
function of link bandwidth
• Could also have a dynamic model for costs
The basic problem of routing is to find the lowest-cost path between any two nodes •Where the cost of a path equals the sum of the costs of all the edges that make up the path
9
Challenges of Designing Routing Protocols
#1: It may be simple to calculate least cost path if graph is static but …
#2: Links and routers are added or go down
#3: Traffic can cause links to be overloaded
#4: How are costs calculated to reflect current load on links?
#5: Algorithms must be distributed in order to scale 10
Challenges of Designing Routing Protocols
#1: It may be simple to calculate least cost path if graph is static but …
#2: Links and routers are added or go down
#3: Traffic can cause links to be overloaded
#4: How are costs calculated to reflect current load on links?
#5: Algorithms must be distributed in order to scale
Rich area for research due to distributed, dynamic nature of the problem
• Routing on Multiple Optimality Criteria, Sigcomm’20
10
Such a static approach has several shortcomings • It does not deal with node or link failures • It does not consider the addition of new nodes or links • It implies that edge costs cannot change
Routing Mechanism
For a simple network, we can calculate all shortest paths and load them into some non-volatile storage on each node
11
Routing Mechanism (cont’d)
What is the solution? • Need a distributed and dynamic protocol • Two main classes of protocols • Distance Vector • Link State
12
Distance Vector Overview
Key idea: Each node constructs a one dimensional array (a vector) containing the “distance” (costs) to all other nodes and distributes that vector to its immediate neighbors
Assumption • Each node knows the cost of the link to each of its directly connected neighbors
13
Distance Vector Algorithm
A
F
E
G
BC
D
Distance is defined as the number of hops
14
Distance Vector Alg. — Initial Distance
A
F
E
G
BC
D
Distance to Reach Node (Global View)
A B C D E F GABCDEFG 15
Distance Vector Alg. — Initial Distance
A
F
E
G
BC
D
Distance to Reach Node (Global View)
A B C D E F GA 0 1 1 ∞ 1 1 ∞BCDEFG 15
Distance Vector Alg. — Initial Distance
A
F
E
G
BC
D
Distance to Reach Node (Global View)
A B C D E F GA 0 1 1 ∞ 1 1 ∞B 1 0 1 ∞ ∞ ∞ ∞CDEFG 15
Distance Vector Alg. — Initial Distance
A
F
E
G
BC
D
Distance to Reach Node (Global View)
A B C D E F GA 0 1 1 ∞ 1 1 ∞B 1 0 1 ∞ ∞ ∞ ∞C 1 1 0 1 ∞ ∞ ∞DEFG 15
Distance Vector Alg. — Initial Distance
A
F
E
G
BC
D
Distance to Reach Node (Global View)
A B C D E F GA 0 1 1 ∞ 1 1 ∞B 1 0 1 ∞ ∞ ∞ ∞C 1 1 0 1 ∞ ∞ ∞D ∞ ∞ 1 0 ∞ ∞ 1
E 1 ∞ ∞ ∞ 0 ∞ ∞F 1 ∞ ∞ ∞ ∞ 0 1
G ∞ ∞ ∞ ∞ ∞ 1 015
Distance Vector Alg. — Initial Routing Table
A
F
E
G
BC
D
Destination Cost NextHopB 1 BC 1 CD ∞ —
E 1 EF 1 FG ∞ —
16
Distance Vector Alg. — Initial Routing Table
A
F
E
G
BC
D
Destination Cost NextHopA 1 AC 1 CD ∞ —
E ∞ —
F ∞ —
G ∞ —16
Distance Vector Alg. — Initial Routing Table
A
F
E
G
BC
D
Destination Cost NextHopA 1 AB 1 BD 1 DE ∞ —
F ∞ —
G ∞ —16
Distance Vector Alg. — Initial Routing Table
A
F
E
G
BC
D
Destination Cost NextHopA 1 AB ∞ —
C ∞ —
D ∞ —
F ∞ —
G ∞ —16
Distance Vector Alg. — Initial Routing Table
A
F
E
G
BC
D
Destination Cost NextHopA 1 AB ∞ —
C ∞ —
D ∞ —
E ∞ —
G 1 G16
Distance Vector Alg. — Exchange Distances
A
F
E
G
BC
D
Dest. Cost NextHopB 1 BC 1 CD ∞ —
E 1 EF 1 FG ∞ —
Dest. Cost NextHopBCDEFG
A
+
B
=
ADest. Cost NextHopA 1 AC 1 CD ∞ —
E ∞ —
F ∞ —
G ∞ —
t0
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopB 1 BC 1 CD ∞ —
E 1 EF 1 FG ∞ —
Dest. Cost NextHopB 1 BCDEFG
A
+
B
=
ADest. Cost NextHopA 1 AC 1 CD ∞ —
E ∞ —
F ∞ —
G ∞ —
A
F
E
G
BC
Dt0
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopB 1 BC 1 CD ∞ —
E 1 EF 1 FG ∞ —
Dest. Cost NextHopB 1 BC 1 CD ∞ —
E 1 EF 1 FG ∞ —
A
+
B
=
ADest. Cost NextHopA 1 AC 1 CD ∞ —
E ∞ —
F ∞ —
G ∞ —
A
F
E
G
BC
Dt0
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopB 1 BC 1 CD ∞ —
E 1 EF 1 FG ∞ —
Dest. Cost NextHopBCDEFG
A
+
C
=
ADest. Cost NextHopA 1 AB 1 BD 1 DE ∞ —
F ∞ —
G ∞ —
A
F
E
G
BC
Dt0 t1
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopB 1 BC 1 CD ∞ —
E 1 EF 1 FG ∞ —
Dest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG ∞ —
A
+
C
=
ADest. Cost NextHopA 1 AB 1 BD 1 DE ∞ —
F ∞ —
G ∞ —
A
F
E
G
BC
Dt0 t1
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG ∞ —
Dest. Cost NextHopBCDEFG
A
+
E
=
ADest. Cost NextHopA 1 AB ∞ —
C ∞ —
D ∞ —
F ∞ —
G ∞ —
A
F
E
G
BC
Dt0 t1 t2
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG ∞ —
Dest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG ∞ —
A
+
E
=
ADest. Cost NextHopA 1 AB ∞ —
C ∞ —
D ∞ —
F ∞ —
G ∞ —
A
F
E
G
BC
Dt0 t1 t2
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG ∞ —
Dest. Cost NextHopBCDEFG
A
+
F
=
ADest. Cost NextHopA 1 AB ∞ —
C ∞ —
D ∞ —
F 0 FG 1 G
A
F
E
G
BC
Dt0 t1 t2 t3
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG ∞ —
Dest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG 2 F
A
+
F
=
ADest. Cost NextHopA 1 AB ∞ —
C ∞ —
D ∞ —
F 0 FG 1 G
A
F
E
G
BC
Dt0 t1 t2 t3
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG ∞ —
Dest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG 2 F
A
+
F
=
ADest. Cost NextHopA 1 AB ∞ —
C ∞ —
D ∞ —
F 0 FG 1 G
A
F
E
G
BC
Dt0 t1 t2 t3
• New_Cost (node) = Cost(node) (from neighbor) + Cost (node-neighbor) • Cost (node-neighbor) = 1 in the above discussion
• Cost = Min (New_Cost, Old_Cost) • If New_Cost is chosen, update the next hop to the neighbor node
• Routing table is evolving
• Based on the event sequence
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopA 1 AB ∞ —
C ∞ —
D ∞ —
F ∞ —
G ∞ —
Dest. Cost NextHopA 1 AB 2 AC 2 AD 3 AF 2 AG ∞ —
E
+
A (t1)
=
EDest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG ∞ —
A
F
E
G
BC
D
t0 t1 t2 t3A
t0 t1 t2 t3E
17
Distance Vector Alg. — Exchange Distances
Dest. Cost NextHopA 1 AB ∞ —
C ∞ —
D ∞ —
F ∞ —
G ∞ —
Dest. Cost NextHopA 1 AB 2 AC 2 AD 3 AF 2 AG 2 A
E
+
A (t3)
=
EDest. Cost NextHopB 1 BC 1 CD 2 CE 1 EF 1 FG 2 E
A
F
E
G
BC
D
t0 t1 t2 t3A
t0 t1 t2 t3E
17
A
F
E
G
BC
D
Distance to Reach Node (Global View)
A B C D E F GA 0 1 1 2 1 1 2
B 1 0 1 2 2 2 3
C 1 1 0 1 2 2 2
D 2 2 1 0 3 2 1
E 1 2 2 3 0 2 3
F 1 2 2 2 2 0 1
G 2 3 2 1 3 1 0
Distance Vector Alg. — Final Distances
18
Distance Vector Discussion
The distance vector routing is based on the Bellman-Ford algorithm
Every T seconds each router sends a list of distance to all the routers to its neighbor
Each router then updates its table based on the new information
19
Distance Vector Discussion
The distance vector routing is based on the Bellman-Ford algorithm
Every T seconds each router sends a list of distance to all the routers to its neighbor
Each router then updates its table based on the new information
• Good
• Fast response to good news
• Bad
• Slow response to bad news
19
When a node detects a link failure
A
F
E
G
BC
D
X
20
When a node detects a link failure
A
F
E
G
BC
D
X• F detects that link to G has failed
• F sets distances to G to infinity and sends updates to A
• A sets distance to G to infinity since it uses F to reach G
20
When a node detects a link failure
A
F
E
G
BC
D
X• F detects that link to G has failed
• F sets distances to G to infinity and sends updates to A
• A sets distance to G to infinity since it uses F to reach G
• A receives periodic update from C with 2-hop path to G
• A sets distance to G to 3 and sends update to F
• F decides it can reach G in 4 hops via A
20
When a node detects a link failure
A
F
E
G
BC
D
X• F detects that link to G has failed
• F sets distances to G to infinity and sends updates to A
• A sets distance to G to infinity since it uses F to reach G
• A receives periodic update from C with 2-hop path to G
• A sets distance to G to 3 and sends update to F
• F decides it can reach G in 4 hops via A G notifies D that its distance to F is infinity
20
Distance Vector Converges Slowly
Slightly different circumstances can prevent the network from stabilizing
21
Distance Vector Converges Slowly
A
F
E
G
BC
DX
• At t0, A detects the link failure and advertises a distance of infinity to E
• At t1, B and C receive the message, and update the routing table accordingly
t0 t1A
t0 t1B
t0 t1C
21
Distance Vector Converges Slowly
A
F
E
G
BC
DX
• At t0, A detects the link failure and advertises a distance of infinity to E
• At t1, B receives the message from A and updates the routing table as <E, Infinity>
• At t2, B receives the message from C (saying the distance to E is 2), and updates the
routing table as <E, 3>
t0 t1 t2 t3A
t0 t1 t2 t3B
t0 t1 t2 t3C
21
Distance Vector Converges Slowly
A
F
E
G
BC
DX
• At t0, A detects the link failure and advertises a distance of infinity to E
• At t1, B receives the message from A and updates the routing table as <E, Infinity>
• At t2, B receives the message from C (saying the distance to E is 2), and updates the
routing table as <E, 3>
• At t3, C receives the message from A and updates the routing table as <E, Infinity>
t0 t1 t2 t3A
t0 t1 t2 t3B
t0 t1 t2 t3C
21
Distance Vector Converges Slowly
A
F
E
G
BC
DX
• At t4, C receives the message from B (saying the distance to E is 3), and updates the
routing table as <E, 4>
• At t4, A receives the message from B (saying the distance to E is 3), and updates the
routing table as <E, 4>
t0 t1 t2 t3A
t0 t1 t2 t3B
t0 t1 t2 t3C
t4
t4
t4
21
Distance Vector Converges Slowly
A
F
E
G
BC
DX
• At t4, C receives the message from B (saying the distance to E is 3), and updates the
routing table as <E, 4>
• At t4, A receives the message from B (saying the distance to E is 3), and updates the
routing table as <E, 4>
• A will advertise this new changes to C, then C advertises B, B advertises A, …
t0 t1 t2 t3A
t0 t1 t2 t3B
t0 t1 t2 t3C
t4
t4
t4
21
Distance Vector Converges Slowly
A
F
E
G
BC
DX
• At t4, C receives the message from B (saying the distance to E is 3), and updates the
routing table as <E, 4>
• At t4, A receives the message from B (saying the distance to E is 3), and updates the
routing table as <E, 4>
• A will advertise this new changes to C, then C advertises B, B advertises A, …
t0 t1 t2 t3A
t0 t1 t2 t3B
t0 t1 t2 t3C
t4
t4
t4
This cycle stops only when the distances reach some threshold that is large enough to be considered infinite
• This is called the Count-to-infinity problem
21
Count-to-infinity Problem: Fixes
Use some relatively small number as an approximation of infinity
For example, the maximum number of hops to get across a certain network is never going to be more than 16
22
Count-to-infinity Problem More
A B S
Dest. Cost NextHopB 1 BS 2 B
Dest. Cost NextHopA 1 AS 1 S
• Initial state
23
Count-to-infinity Problem More
A B S
Dest. Cost NextHopB 1 BS 2 B
Dest. Cost NextHopA 1 AS 1 S
X
Dest. Cost NextHopB 1 BS 2 B
Dest. Cost NextHopA 1 AS 1 ∞=16
• B to S link goes down
• Initial state
23
Count-to-infinity Problem More
A B S
Dest. Cost NextHopB 1 BS 2 B
Dest. Cost NextHopA 1 AS 1 S
• Initial state
X
Dest. Cost NextHopB 1 BS 2 B
Dest. Cost NextHopA 1 AS ∞=16 —
• B to S link goes down
Dest. Cost NextHopB 1 BS 2 B
Dest. Cost NextHopA 1 AS 3 A
• B receive A’s advertisement before
B can advertise to A
• B finds shorter router to S
23
Count-to-infinity Problem More
A B SXDest. Cost NextHopB 1 BS 4 B
Dest. Cost NextHopA 1 AS 3 A
• B advertises updated table to A
• A registers change in path length to
S via B
• A accordingly updates distance to S
23
Count-to-infinity Problem More
A B SXDest. Cost NextHopB 1 BS 4 B
Dest. Cost NextHopA 1 AS 3 A
• B advertises updated table to A
• A registers change in path length to
S via B
• A accordingly updates distance to S
Dest. Cost NextHopB 1 BS 4 B
Dest. Cost NextHopA 1 AS 5 A
• A advertises updated table to B
• B registers change in path length to
S via A
• B accordingly updates distance to S
23
Count-to-infinity Problem More
A B SXDest. Cost NextHopB 1 BS 4 B
Dest. Cost NextHopA 1 AS 3 A
• B advertises updated table to A
• A registers change in path length to
S via B
• A accordingly updates distance to S
Dest. Cost NextHopB 1 BS 4 B
Dest. Cost NextHopA 1 AS 5 A
• A advertises updated table to B
• B registers change in path length to
S via A
• B accordingly updates distance to S
Such back-and-forth advertisements between A and B continues => path lengths to S keeps increase => count-to-infinity
23
Count-to-infinity Problem: Another Fixes
Split horizon • When a node sends a routing update to its neighbors, it does not send those routes it learned from each neighbor back to that neighbor • A never advertises <S, 2, B> to B
A B S
Dest. Cost NextHopB 1 BS 2 B
Dest. Cost NextHopA 1 AS 1 S
X• Initial state
24
Count-to-infinity Problem: Another Fixes
Split horizon • When a node sends a routing update to its neighbors, it does not send those routes it learned from each neighbor back to that neighbor • A never advertises <S, 2, B> to B
Split horizon with poison reverse • When a node sends a routing update to its neighbors, it puts negative information in the
route to ensure that the route is never being used
• A advertises <S, ∞, B> to B
24
Split Horizon with Poison Reverse Example
A B S
Dest. Cost NextHopB 1 BS 2 BR 1 R
Dest. Cost NextHopS 2 BR 1 R
• w/o split horizon with poison reverse
R
Dest. Cost NextHopA 1 AS 1 SR 2 A
Dest. Cost NextHopS 2 ∞=16
R 1 R
• w/ split horizon with poison reverse
• This prevents B from using the path
A -> B
25
Split Horizon (/w Poison Reverse) Pitfalls
A
F
E
G
BC
DXt0 t1 t2 t3A
t0 t1 t2 t3B
t0 t1 t2 t3C
t4
t4
t4
Only works for small routing loops that involve two nodes • Please work through the example we discussed before
26
Routing Information Protocol (RIP)
Earliest IP routing protocol • 1982 BSD of Unix • Current standard is version 2 (RFC 1723)
Features • Every link has cost 1 -> Hop count • “Infinity” = 16, limits to network where everything
reachable within 15 hops
Sending updates • Every router listens for updates on UDP port 520
• Frequency: 30 seconds • Triggered when an entry is changed
27
Summary
Today • Introduction to Routing
• Distance Vector Algorithm
Next lecture • Link State Routing
• Link Weights • Router/Switch Design
28