Best known example of Distance Vector Routing Algorithm is:
Unlike the link state type algorithms, nodes in distance vector type algorithms must exchange many rounds of messages.
The content of the messages are of the form:
(SrcNode) ToNode1 Distance1 ToNode2 Distance2 ToNode3 Distance3 ....
The meaning of (ToNode1, Distance1) is: "the distance from node "SrcNode" to the destination node "ToNode1" is "Distance1"...
The structures of the distance table is given in the following figure (in the pinkish box):
If a node is connected to $k$ neighbor nodes, then its distance table will have $k$ columns (besides the first column).
OK, I know this is a mouthful, so let me illustrate it with a concrete example. Consider this network:
Node D has 3 neighbors: B, C, E. So D's distance table will have 3 columns. Here are some values in the table:
Distance table for node D: To Via B Via C Via E ------+-------+-------+------- A B C 7 <--- D send to E via C with cost 7 D E 3 <--- D send to E via E with cost 3
Clearly, the cost for D to send a message to E is 3... (just read it right from the network)
Now, it is less intuitive to compute the cost for D to send a message to E when D send it first to C... (it is not "natural"). What will C do with such a message ? Answer: send it to D... And D will then send it to E. So... the cost for D to send a message to E by sending it first to C is: 2 + 2 + 3 = 7. And that is why:
for each entry (ToNodeX, DistanceX) in the distance vector message { d(myself, ToNodeX) = d(myself, SrcNode) + DistanceX; Determine the lowest cost between myself and ToNodeX; if ( cost/distance to ToNodeX has changed ) Schedule update message "myself, ToNodeX, d(myself, ToNodeX)" } |
The following is a complete run on how the distance vector routing method works... although the example may look kinda tedious, the principle is very simple (see algorithm above).
Network topology:
Which will cause the following updates in tables of nodes B, C, E and F:
Which will cause the following updates in tables of nodes A and C:
Which will cause the following updates in tables of nodes A, B and D:
Which will cause the following updates in tables of nodes C and G:
Which will cause the following updates in tables of nodes D and F:
Which will cause the following updates in tables of nodes A and G:
Which will cause the following updates in tables of node A:
Which will cause the following updates in tables of node B, C, E and F:
This will cause the following updates in tables of node B, C, E and F:
This will cause the following updates in tables of node A, B, and D:
This will cause the following updates in tables of node C, and G:
This will cause the following updates in tables of node D, and F:
This will cause the following updates in tables of node A, and G:
This will cause the following updates in tables of node A: