8 Routing Part2
8 Routing Part2
Routing
Part-2-
Link State Routing
• Each router knows the entire network topology.
LSP Created by A
A B 2
A D 1
A C 5
Computing shortest paths
• N: set of all nodes to which we know shortest path, initially this is empty.
• C(i,j): cost of link i,j , where c(i,j)= ∞ if i,j are not directly connected.
• p(v): previous node (neighbor of v) along current least cost path from
source to v
Dijkstra’s Algorithm
• Initialization
• N={A} /* suppose A is source */
• For all nodes V
• If V is adjacent to A
• D(V)=C(A,V)
• Else
• D(V)=∞
• Loop
• Find node W not in N such that D(W) is smallest.
• Add W into N
• Update D(V) for all nodes V not in N
• D(V)=min{ D(V) , D(W)+C(W,V) } /* new cost to v is either old cost to v or known
shortest path cost to w plus cost from w to v */
• Until all nodes are in N
•In the first iteration, we look among those nodes not yet added to the set N and find that node with the least cost as of
the end of the previous iteration. That node is D, with a cost of 1, and thus D is added to the set N. Line 12 of the LS
algorithm is then performed to update D(v) for all nodes v, yielding the results shown in the second line (step 1) in Table
4.2-1. The cost of the path to B is unchanged. The cost of the path to C (which was 5 at the end of the initialization)
through node D is found to have a cost of 4. Hence this lower cost path is selected and C's predecessor along the shortest
path from A is set to D. Similarly, the cost to E (through D) is computed to be 2, and the table is updated accordingly.
•In the second iteration, nodes B and E are found to have the shortest path costs (2), and we break the tie arbitrarily and
add E to the set N so that N now contains A, D, and E. The cost to the remaining nodes not yet in N, i.e., nodes B, C and
F, are updated via line 12 of the LS algorithm , yielding the results shown in the third row in the above table.
•and so on …
When the LS algorithm terminates, we have for each node, its predecessor along the least cost path from the source node.
For each predecessor, we also have its predecessor and so in this manner we can construct the entire path from the source
to all destinations.
What is the computation complexity of this algorithm?
That is, given n nodes (not counting the source), how much computation must be done in the worst case to find the
least cost paths from the source to all destinations? In the first iteration, we need to search through all n nodes to
determine the node, w, not in N that has the minimum cost. In the second iteration, we need to check n-1 nodes to
determine the minimum cost; in the third iteration n-2 nodes and so on. Overall, the total number of nodes we
need to search through over all the iterations is n*(n+1)/2, and thus we say that the above implementation of the
link-state algorithm has the worst-case complexity of order n squared: O(n2).
Link cost
In the end, neither algorithm is a "winner" over the other, both algorithms
are used in the Internet.
Generally speaking
• Solution?!!
Hierarchical Routing
• Divide the network into a set of administrative domains or
autonomous systems (AS)
• Open shortest path first (OSPF): link state routing using Dijkstra’s
algorithm, has some extra features as compared to RIP (e.g. QoS
routing, multiple paths ,etc.) but is much more complex.