Upload
trannhi
View
224
Download
4
Embed Size (px)
Citation preview
Shortest paths problem:– What path between two vertices offers minimal sum of
edge weights?
• Classic graph algorithms find single-source shortest paths when the entire graph is known centrally– Dijkstra’s Algorithm, Bellman-Ford Algorithm
• Typically, no central knowledge of entire graph– Each router only knows its own interfaces’ addresses
2
Reminder: Intra-domain Routing Problem
Shortest paths problem:– What path between two vertices offers minimal sum of
edge weights?
• Classic graph algorithms find single-source shortest paths when the entire graph is known centrally– Dijkstra’s Algorithm, Bellman-Ford Algorithm
• Typically, no central knowledge of entire graph– Each router only knows its own interfaces’ addresses
3
Reminder: Distance Vector (DV) Approach
…but turned into a distributed algorithm
Shortest paths problem:– What path between two vertices offers minimal sum of
edge weights?
• Classic graph algorithms find single-source shortest paths when the entire graph is known centrally– Dijkstra’s Algorithm, Bellman-Ford Algorithm
• Typically, no central knowledge of entire graph– Each router only knows its own interfaces’ addresses
4
Link State (LS) Approach
unmodified, but run on every router
Link State Approach: Share the Map!
• Dijkstra’s algorithm takes a weighted graph as input– it is a centralized algorithm
• Link State routing protocols instruct routers to collectively build a map of the whole network– each router shares its local information– each router stores the map in a link state database– each router runs Dijkstra’s algorithm locally
5
Comparison between LS and DV principles
• Distance Vector principle: “tell everything you know to your neighbours”– dump routing tables to neighbours
• Link State principle: “tell everybody what you know about your neighbourhood”– flood local information network-wide
6
Agenda
• We deepen how Link State routing protocols work
1. Sharing the map• Finding links: Hello protocol• Building the map: Flooding protocol• Dealing with failures and partitions
2. Computing paths
3. Properties of Link State Routing
7
Routers periodically say hello
• Each router runs a Hello Protocol– transmits a hello packet on each interface, every
time period P
• A hello packet contains:– sender ID– a list of neighbours from which sender has heard
hello on that interface during period D > P • e.g., D=3P
8
Routers establish adjacencies
• Routers need to know who to share the map with– they establish logical links called adjacencies• used to exchange LS messages
• Hello messages enable adjacencies to be built between neighbouring routers– the adjacency is up if each of the two routers has
received a hello message with its own ID, in the last period D
– the adjacency is down otherwise 9
Routers spread news on their neighbourhood
• Goal: build a map and keep it updated– whenever a link in the LS map comes up or goes
down, the map should be changed
• To this end, information is flooded– LS routers run a Flooding Protocol– a router detecting a topology change sends a link
state advertisement (LSA) to all its neighbours• over the established adjacencies
10
Flooding enables to build the network map
• An LSA contains:– ID of the advertising router– a sequence number– information on every local link, including router ID
of the other endpoint and link metric– message parameters: LS age, type, etc.
• Routers store received LSAs in a link-state database– the LSDB keeps all the most recent LSAs– routers flood new LSAs in the database
11
Routers flood information about adjacencies
If link was not previously in database or LSA seq. no. > stored seq. no then:
1. store the LSA in the database2. send the LSA out of all interfaces except the one it arrived on
else if LSA seq. no. < stored seq. no then:send the stored LSA back to that neighbour (it’s out of date)
else ignore the LSA (we’ve already heard it).
12
Agenda
• We deepen how Link State routing protocols work
1. Sharing the map• Finding links: Hello protocol• Building the map: Flooding protocol• Dealing with failures and partitions
2. Computing paths
3. Properties of Link State Routing
13
LS: No bouncing after link failures
• LS distributes complete information on the network– no ambiguity on valid paths à no bouncing
• When a link fails, the network map is updated– flood that link is down, everyone recalculates paths
14
A BC
D E
1
1
0
1
0
1
2
2
0 1
1
1
1
1
1 0
0
LS: No count to infinity
Flooding also implies no count to infinity
When the network partitions, each router will end up with a map of its connected component• computes paths on that sub-map
15
A BC
D E
1
1
0
1
0
1
2
2
0 1 1
1
1
1 0
0
Can LS always heal partitions efficiently?
Consider flooding behavior when partition heals• Link D-E is restored• Link C-E fails nearly at the same time
16
A BC
D E
1
1
0
1
0
1
2
2
0 1
1
1
1
1 0
0
• D detects link (D, E) is now up, and floods LSAs to A– but A and D may still think link (C, E) exists!
• If this is the first time link (D, E) comes up, how will A and D learn about links (B, E) and (B, C)?
17
Some cases seem tricky…
A BC
D E
1
1
0
1
0
1
2
2
0 1
1
1
1
1 0
0
• OSPF sends new LSAs every 30 mins, even for unmodified links– sent often à too much overhead– sent not so often à too slow
18
A BC
D E
1
1
0
1
0
1
2
2
0 1
1
1
1
1 0
0
Periodic state refreshes are inadequate
• Problem: A, D do not know the state of remote links– think about (B,C)
• Root cause: flooding news for neighbouring links is not always sufficient
19
Let’s think about the real problem
A BC
D E
1
1
0
1
0
1
2
2
0 1
1
1
1
1 0
0
• Solution: Routers exchange LS database summaries when they form new adjacencies– upon new adjacency, routers exchange lists of (link
endpoints, sequence numbers)• LS databases contain much more information à
summaries save bandwidth– each router then requests missing or newer entries– anything new is flooded to all the other neighbours
20
Routers briefly sync on new adjacencies!
Agenda
• We deepen how Link State routing protocols work
1. Sharing the map• Finding links: Hello protocol• Building the map: Flooding protocol• Dealing with failures and partitions
2. Computing paths
3. Properties of Link State Routing
21
Link State Database à Routing Table
• After flooding, routers need to transform their map into a routing table
How?• Single-source shortest paths algorithm
– Given a graph, the algorithm computes path with least cost from s to all other vertices
– In LS, each router views itself as source s, and all other routers as destinations
22
Shortest Paths: Definitions
• Each router is a vertex, v ∈ V • Each link is an edge, e ∈ E, also written (u, v) • Each link metric maps to an edge weight, w(u, v) • A path is a sequence of edges • Path cost is sum of edges’ weights
23
Shortest Paths: Definitions
Data structures:
π[v] is predecessor of v: π[v] is vertex before v along current shortest path from s to v
d[v] is shortest path estimate:
least cost found from s to v so far
24
Shortest Paths: Initialization
When we start, we know little:• no cost estimate for any path from s to any other vertex• no predecessor of v along shortest path from s to any v
ini#alize-single-source(V,s)foreachvertexv∈Vdo
d[v]ß∞π[v]ßNULL
d[s]=0
25
Shortest Paths Building Block: Relaxation
Relaxation of an edge:• Suppose we have current estimates d[u], d[v] of
shortest path cost from s to u and v • Does it reduce the cost of the shortest path from s to
v to reach v via edge (u, v) ?
relax(u,v,w)ifd[v]>d[u]+w(u,v):
d[v]ßd[u]+w(u,v)π[v]ßu
26
Relaxation: Example
• Suppose– d[u] = 5 – d[v] = 9 – w(u, v) = 2
• relax(u,v,w)computes:– is d[v] > d[u] + w(u, v)? – is 9 > 5 + 2 ? • Yes, so reaching v via (u, v) reduces path cost
– d[v] ß d[u] + w(u, v) – π[v] ß u
27
5 9
u v
relax(u, v)
5 7
u v
2
2
Dijkstra’s Algorithm: Overall Strategy
1. Maintain running estimates of costs of shortest paths to all vertices (initially all infinity)
2. Keep a set S of vertices that are “finished”; shortest paths to these vertices already found (initially empty)
3. Pick the unfinished vertex v with smallest shortest path cost estimate
4. Add v to set S 5. Relax all edges leaving v 6. Repeat from 3.
[Note: only correct for graphs where edge weights are not negative!]
28
Dijkstra’s Algorithm: Pseudocode
Dijkstra(V,E,w,s)ini#alize-single-source(V,s)Sß∅QßVwhileQ≠∅do
ußextract-min(Q)SßS∪{u}foreachvertexvthatneighborsu
relax(u,v,w)
29
extract-min(Q):return vertex v from Q that has minimal shortest-path estimate d[v]; remove v from Q
Dijkstra’s Algorithm: Example
s: sourced[i]: number inside of vertex i π[b]: if (a, b) is red, then π[b] = a members of set S: blue verticesmembers of priority queue Q: grey vertices
30
0
∞∞
∞∞
s
u v
yx
101
2 3
52
764
90
∞10
∞5
u v
yx
101
2 3
52
764
9s
Dijkstra’s Algorithm Example (cont’d)
31
0
∞10
∞5
u v
yx
101
2 3
52
764
9
0
138
75
v
yx
101
2 3
52
74
96
u
0
148
75
u v
yx
101
2 3
52
74
96s
0
98
75
v
yx
101
2 3
52
74
96
u
s
s
s
7
89
Dijkstra’s Algorithm Example (cont’d)
• At termination, we know shortest-path routes from s to all other routers
• Shortest-path tree, rooted at s
32
0
98
75
v
yx
101
2 3
52
74
96
u
0
98
75
v
yx
101
2 3
52
74
96
u
ss
Dijkstra’s Algorithm: Pseudocode
Dijkstra(V,E,w,s)ini#alize-single-source(V,s)Sß∅QßVwhileQ≠∅do
ußextract-min(Q)SßS∪{u}foreachvertexvthatneighborsu
relax(u,v,w)
33
extract-min(Q):return vertex v from Q that has minimal shortest-path estimate d[v]; remove v from Q
Dijkstra’s Algorithm: Efficiency
• Implement Q with binary heap– total cost to insert |V| entries into Q: O(V)
• Cost of all extract-min()calls is O(V log2 V)– cost of single call: O(log2 N), if N items in Q – |V| calls, since the initial size of Q is |V|
• Cost of all relax()isO(E log2 V)– cost of single call: O(log2 V) • each call reduces d[] value for one vertex in Q
– at most |E| calls
34
Dijkstra’s Algorithm: Efficiency (cont’d)
• Total algorithm cost: O((V + E) log2 V) – or O(E log2 V) when all vertices are reachable from
the source
• Dijsktra runs in POLYNOMIAL time!– fast in practice
• Also, note that most networks are sparse graphs– E << V2 à Dijkstra algorithm is almost linear
35
Agenda
• We deepen how Link State routing protocols work
1. Sharing the map• Finding links: Hello protocol• Building the map: Flooding protocol• Dealing with failures and partitions
2. Computing paths
3. Properties of Link State Routing
36
Link State Routing: Properties
• At first glance, flooding status of all links seems costly– cost reasonable for hundreds of routers– vanilla LS doesn’t scale indefinitely • e.g., for thousands of nodes
– yet, scalability can be improved with hierarchy
• In practice, LS has won over DV– LS is more commonly used, especially in large (ISP)
networks, where routing is critical– DV rarely used except in small networks • e.g., enterprise ones
37
Performance Comparison with Distance Vector
• LS has more guarantees and better performance than DV– no loops after flooding, provided all nodes have
consistent link state databases– flooding à faster convergence after topology changes
• However, LS is also more complex to implement than DV– sequence numbers crucial to protect against stale
announcements– adjacencies have to be established and maintained– link state database is needed
38
Disclaimer: The real world is more complex
• Yet, LS does not solve all problems– e.g., transient loops during convergence
• Such problems are relevant in practice – connectivity is of utmost relevance: £££ – 99.999% uptime à max downtime: 5.26 minutes / year
• They attracted many industrial and research efforts– Loop Free Alternate (LFA) and all its variants– progressive metric increment– …
39
Disclaimer: The real world is more complex
• Also, network operators face more requirements– avoid congestion, enforce firewall traversal, …
• Routers’ primitives and Traffic Engineering (TE) techniques enable routing on non-shortest paths
• Big players started to develop their own routing systems– even centralized: Google B4 [2013], Microsoft SWAN
[2013], Google BwE [2015], …
• … and this seems just an interesting beginning!
40