DD490 p4 0 Lecture : Routing algorithms Shortest path, Widest path, and constrained routing Olof Hagsand KTH CSC This lecture contains new material for 0.
Graphs vs networks Algorithms are usually defined on graphs whereas protocols work on networks Graphs have nodes and edges whereas networks have interfaces, boradcast links, addresses, hierarchical layering, etc.
N4 N RT N RT4 8 8 7 RT5 6 8 8 8 N N N RT 6 8 6 RT Ia 7 RT6 N4 Network example N5 Ib 6 6 9 RT0 RT7 N H 0 RT9 RT N9 RT N8 RT8 N6 4 N0 RFC 8 fig N7 Note that the figure is taken from the OSPF RFC. The broadcast links (N, N, N) are denoted somewhat unusually by ellipses. The dotted links denote exernal links (outside the OSPF routing domain). Note that there is one host H. Note also that the link metrics are asymmetrical.
N4 N RT 0 0 0 N 0 RT4 8 8 RT5 7 8 6 8 8 N N N RT RT 8 6 6 RT6 7 N4 Ib 7 (Directed) graph example Ia 5 N5 N H 0 RT9 0 RT 0 N9 0 RT 5 0 N8 RT0 0 6 0 0 N6 0 RT8 9 RT7 N0 4 N7 4 Note the modelling of the broadcast links, such as N. Such a link is modelled by adding a virtual network node (eg N) to which the nodes connect (since all edges connect only two nodes). Since this node is virtual, there is no physical corresponding node, the cost of exiting the node is set to 0. In many protocols such a virtual node (eg N) 'belongs' to a router in the sense that the router announces the network information of the virtual node. Such a router is called the 'designated' router of the network. For example, RT is the designated router of N.
Example graph A B C D E F 5 Simple network with symmetric link metrics. The link with metric is a typical backup path that normally is not used unless an error occurs.
Shortest Path First (SPF) Given link metrics (weights) on each individual link Find the path (sequence of links) where the sum of the metrics of all links (cumulative cost) is lowest ECMP: A set of path with the least cost B D A F C E 6
Bellman-Ford shortest path If it is possible to get from entity i to entity j directly, then a cost, d(i,j), is associated with the hop between i and j. The cost is infinite if i and j are not immediate neighbors. Let D(i,j) represent the metric of the best route from entity i to entity j. Then, the best metric is described by: D i, i =0, for all i. D i, j =min[d i, k D k, j ], otherwise. k j The algorithm: D 0 i,i =0, for alli. D 0 i, j =, otherwise. For h=0 to N- do: D h i,i =0, for alli. D h i, j =min[d i, k D h k, j ], otherwise.. k i In words: Entity i gets estimates from neighbors k of their distances to the destination j. Add d(i,k) to each of the numbers. This is the cost of traversing the network between i and k. Compare the values from all of its neighbors and pick the smallest. 7
Exercise: Bellman-Ford d(i,j) A B C D E F A B C D E F h D(A,F) D(B,F) D(C,F) D(D,F) D(E,F) 0 4 5 8 The example network in earlier slide is used.
The distributed algorithm Keep a table with an entry for each destination N in the network. Store the distance D and next-hop G for each N in the table. Periodically, send the table to all neighbors (the distancevector). For each update that comes in from neighbor G' (to N with a new distance): Add the cost of the link to G' to the new distance to get D'. Replace the route if D' < D. If G = G', always replace the route. 9
Dijkstra's shortest path first From the link-state database, compute a shortest path delivery tree using a permanent set S and a tentative set Q:.Define the root of the tree: the router.assign a cost of 0 to this node and make it the first permanent node..examine each neighbor node of the last permanent node. 4.Assign a cumulative cost to each node and make it tentative. 5.Among the list of tentative nodes: Find the node with the smallest cumulative cost and make it permanent. If a node can be reached from more than one direction, select the direction with the smallest cumulative cost. 6.Repeat steps to 5 until every node is permanent. 0 If you are unsure about Dijkstra, go through the extra material including an example on the web-site
Dijkstra pseudo-code function Dijkstra(Graph, source): for each vertex v in Graph: // Initializations dist[v] := infinity ; // Unknown distance function from source to v previous[v] := undefined ; // Previous node in optimal path from source dist[source] := 0 ; // Distance from source to source Q := the set of all nodes in Graph ; // All nodes in the graph are unoptimized - thus are in Q while Q is not empty: // The main loop u := vertex in Q with smallest dist[] ; remove u from Q ; for each neighbor v of u: // where v has not yet been removed from Q. alt := dist[u] + dist_between(u, v) ; if alt < dist[v]: // Relax (u,v,a) dist[v] := alt ; previous[v] := u ; (from Wikipedia)
Spanning-Tree Protocol In Layer networking (eg Ethernet), there is no 'routing' of individual flows. Instead, a single tree is constructed to avoid loops. This spanning-tree is a shortest path tree to all destinations from a single root. All traffic then follows this single tree, using source address learning: Traffic is initially flooded throughout the tree (up and down the branches), but the nodes learn the location (incoming port) of the sources by inspecting the source address in the frames. Spanning-tree is used in Ethernets including Metro-Ethernets being built today. Very large networks (even global) are being built where spanning-tree is the mechanism used to detect loops.
Spanning-tree algorithm An ID number is assigned to each bridge, and a cost to each port. Process of finding the spanning tree: The bridges choose a bridge to be the root bridge of the tree by finding the bridge with the smallest ID. Each bridge determines its root port, the port that has the least root path cost to the root. The root path cost is the accumulated cost of the path from the port to the root. One designated bridge is chosen for each segment Select ports to be included in the spanning tree (root port plus designated ports) Data traffic is forwarded only to and from ports selected for inclusion in the spanning tree STP (Spanning Tree Protocol) is not a routing protocol since it does not identify individual routes. Instead, it tranforms a general graph to a tree, and uses learning (flood and learn) to distribute information.
Spanning-tree exercise How does traffic go between hosts A and B if learning bridges X, Y, Z are root bridges, respectively? X A Y Z 4 B root port designated blocked/listening/forwarding 4 For generic solution, use priority vectors. Each bridge forms a priority vector on each port/segment it is connected to and sends it out on that port. The lowest priority vector 'succeeds' in the following sense: () Segment: the bridge sending the lowest priority vector on a segment becomes the designated bridge(port) of that segment; () Bridge: among the priority vectors received on all ports on a bridge, the bridge selects port where the lowest was received and assigns that as the root bridge (if not root itself). Priority vector simple form: <rootid, metric, bridgeid>, where: - rootid: id of elected root bridge - metric: accumulated path metric frm sending bridge to root - bridgeid: id of sending bridge Priority vector complete form: <rootid, metric, bridgeid, srcport, dstport> where - srcport: port number of sending port (of the priority vector) - dstport: port number where the priority vector is received. The complete form is only used in cases where there are several ports on the same bridge on a segment.
Minimizing load by adjusting link metric SPF may not utilize a given network well. An operator may be interested in using the network resources better This is called Traffic Engineering A common metric is to minimize load on individual links, i.e., to spread traffic among several links Example: Traffic in the network is as follows: A->E Mb/s D->E Mb/s How does traffic flow given unary weights? What is the optimal solution (using load-balancing)? Can you modify weights(link metrics) to reach the optimal solution? B C A D E 5 Assume equal bandwidth on all links. With unary weights, the D->E link has 4Mb/s The minimal load criteria is to have a smallest maximum load in the network. With generic load-balancing, the optimal solution would be to send: - Mb/s A->B->C->E - Mb/s A->D->E - Mb/s D->E The maximum load on an individual link is then Mb/s. By modifying weights (eg set weight of A->D to ) and ECMP, all you can get is: -.5 Mb/s A->B->C->E -.5 Mb/s A->D->E - Mb/s D->E The maximum load on an individual link is.5mb/s. Thus the optimal solution is not obtainable with ECMP and weight adjustment
Adjusting weights - elaborate exercise Flows: A -> D, A -> E, C -> D, C -> E Each flow 5Mb/s What is the SPF solution? Adjust weights to make the load optimal (smallest max) of at most 0Mb/s 0 B D 5 A C E From A. Gunnar, Aspects of proactive traffic engineering in IP networks, PhD thesis, Feb 0 6 In the solution above, all flows pass via C and E. The best solution is to make the flows from A pass via B and D instead, while keeping the flows from C via E. This can be made by heightening the cost between A-> C to for example 0, and lowering the cost from B -> D to. If you are not careful, though, the traffic from C to D may start leaking over B. Consider also if there are further constraints between other routers, and you see that this is difficult to do, at least intuitively.
Widest path first Both Bellman-Ford and Dijkstra considers the shortest path based on an additive scalar metrics. That is, the shortest path cost is computed by adding all individual link metrics But suppose we need to optimize for bandwidth or load (smallest largest load) of a single link. We should then consider the path with the highest bandwidth / lowest load. Often used: available bandwidth Can be used in conjunction with resource reservation protocols to solve a dynamic traffic engineering problem We may then look at widest path computation It is easy to extend Dijkstra (or Bellman-Ford) with a widestpath computation rather than shortest path. 7 Dijkstra is extended as follows Instead of summing all individual link costs and taking the minimum of all possible paths, The minimum link metric of all possible paths is computed and their maximum selected
Widest path first: exercise Numbers denote width: load or bandwidth What is the widest path from A -> E? B bw:40 D A bw:0 bw:0 bw:5 bw:50 bw:0 C bw:0 E 8 The widest path is A->B->D->E. Its minimal width is 0, which is higher than all other paths from A to E.
Constrained Shortest Path First In traffic engineering a generalization of SPF is normally used: Constrained Shortest Path (CSPF) CSPF is implemented along with MPLS Introduce a boolean condition which may remove links, and compute SPF on that. Examples of conditions: Administrative groups (eg include only gold and silver links) Available bandwidth (No link avbw < min avbw) Available bandwidth ratio (No link utilization > max %) Delay bonds (No path delays > max delay) Hop counts (No path hops > max hc) Resiliency (No common network element w primary path) 9 The constraints can be provided with elaborate configuration syntax, but often general constraints are not implemented. Typical useful constraints are available bandwidth and resilience.
CSPF Example : Available bw A->E with available bandwidth >= 0? A bw:0 B bw:0 bw:40 bw:5 D bw:50 bw:0 C bw:0 E 0 Note: dashed lines do not meet the constraint (bw >= 0) and are therefore removed from the network substrate. Answer: A->B->D->E. Note that this happens to be the same result as the widest path, but this is not generally so, since the underlying protocol is still SPF, not WPF.
CSPF Example : Resiliency Given primary SPF path A->B->E, form a secondary path with resilience constraint A->E This is used in MPLS to compute secondary paths used in fail-over. B D A C E The primary path is given by the dashed lines, and can therefore not be used by the resilient path. The path A->B->E is therefore removed from the network substrate. Answer: the secondary path is A->C->E CSPF with resiliency constraint is similar to k-shortest path: Find a set of (mutually disjoint) shortest paths: Compute SPF in steps, remove a computed path from the substrate for next iteration
Explicit routing Explicit routing is a manual alternative to CSPF Explicit Route Objects (ERO) Provide a set of nodes and compute SPF via this set. Example: A->E via D. B D A C E Answer to the problem: A->B->D->E. Note that the route A->D is not explicitly provided and is therefore computed with SPF.
Summary: Routing algorithms Most routing protocols use Dijkstra or Bellman-Ford IP routing protocols all use SPF L Ethernet uses spanning-tree and learning to transform a network to a tree. In traffic engineering, IP routing protocols are extended with Constrained SPF MPLS is the primary example