18-Link State Routing Protocol
18-Link State Routing Protocol
Route Calculation
Each node uses Dijkstra's algorithm on the graph to calculate the optimal
routes to all nodes.P
o c( i , j): Link cost from node i to node j. If i and j nodes are not
directly linked, then c(i , j) = ∞.
o D(v): It defines the cost of the path from source code to destination
v that has the least cost currently.
o P(v): It defines the previous node (neighbour of v) along with
current least cost path from source to v.
o N: It is the total number of nodes available in the network.
Algorithm
Initialization
N = {A} // A is a root node.
for all nodes v
if v adjacent to A
then D(v) = c(A,v)
else D(v) = infinity
loop
find w not in N such that D(w) is a minimum.
Add w to N
Update D(v) for all v adjacent to w and not in N:
D(v) = min(D(v), D(w) + c(w,v))
Until all nodes in N
The first step is an initialization step. The currently known least cost path
from A to its directly attached neighbors, B, C, D are 2,5,1 respectively.
The cost from A to B is set to 2, from A to D is set to 1 and from A to C is
set to 5. The cost from A to E and F are set to infinity as they are not
directly linked to A.
Step 2:
In the above table, we observe that vertex D contains the least cost path
in step 1. Therefore, it is added in N. Now, we need to determine a least-
cost path through D vertex.
1. v = B, w = D
2. D(B) = min( D(B) , D(D) + c(D,B) )
3. = min( 2, 1+2)>
4. = min( 2, 3)
5. The minimum value is 2. Therefore, the currently shortest path from A to
B is 2.
1. v = C, w = D
2. D(B) = min( D(C) , D(D) + c(D,C) )
3. = min( 5, 1+3)
4. = min( 5, 4)
5. The minimum value is 4. Therefore, the currently shortest path from A to
C is 4.</p>
1. v = E, w = D
2. D(B) = min( D(E) , D(D) + c(D,E) )
3. = min( ∞, 1+1)
4. = min(∞, 2)
5. The minimum value is 2. Therefore, the currently shortest path from A to
E is 2.
Note: The vertex D has no direct link to vertex E. Therefore, the value of D(F) is infinity.
Step N D(B),P(B) D(C),P(C D(D),P(D) D(E),P(E) D(F),P(F)
)
Step 3:
In the above table, we observe that both E and B have the least cost path
in step 2. Let's consider the E vertex. Now, we determine the least cost
path of remaining vertices through E.
1. v = B, w = E
2. D(B) = min( D(B) , D(E) + c(E,B) )
3. = min( 2 , 2+ ∞ )
4. = min( 2, ∞)
5. The minimum value is 2. Therefore, the currently shortest path from A to
B is 2.
b) Calculating the shortest path from A to C.
1. v = C, w = E
2. D(B) = min( D(C) , D(E) + c(E,C) )
3. = min( 4 , 2+1 )
4. = min( 4,3)
5. The minimum value is 3. Therefore, the currently shortest path from A to
C is 3.
1. v = F, w = E
2. D(B) = min( D(F) , D(E) + c(E,F) )
3. = min( ∞ , 2+2 )
4. = min(∞ ,4)
5. The minimum value is 4. Therefore, the currently shortest path from A to F
is 4.
In the above table, we observe that B vertex has the least cost path in
step 3. Therefore, it is added in N. Now, we determine the least cost path
of remaining vertices through B.
1. v = C, w = B
2. D(B) = min( D(C) , D(B) + c(B,C) )
3. = min( 3 , 2+3 )
4. = min( 3,5)
5. The minimum value is 3. Therefore, the currently shortest path from A to
C is 3.
1. v = F, w = B
2. D(B) = min( D(F) , D(B) + c(B,F) )
3. = min( 4, ∞)
4. = min(4, ∞)
5. The minimum value is 4. Therefore, the currently shortest path from A to F
is 4.
Step 5:
In the above table, we observe that C vertex has the least cost path in
step 4. Therefore, it is added in N. Now, we determine the least cost path
of remaining vertices through C.
1. v = F, w = C
2. D(B) = min( D(F) , D(C) + c(C,F) )
3. = min( 4, 3+5)
4. = min(4,8)
5. The minimum value is 4. Therefore, the currently shortest path from A to F
is 4.
Ste N D(B),P(B D(C),P(C) D(D),P(D) D(E),P(E) D(F),P(F)
p )
5 ADEBC 4,E
Final table:
5 ADEBC 4,E
6 ADEBC
F
Disadvantage:
Heavy traffic is created in Line state routing due to Flooding. Flooding can
cause an infinite looping, this problem can be solved by using Time-to-
leave field
All items in the database must be sent to neighbors to form link-state packets.
OSPF Protocol