Distance vector routing protocols create their routing tables based on the networks to which they are directly connected, and the information passed to them by neighboring routers in the form of routing table updates. The term “distance-vector” actually describes the way in which these protocols work. The “vector” is simply a combination of two pieces of information that describe how to get to a network – the direction, and the distance.
For example, a router may find out that a previously unknown network is accessible via its E0 interface (the direction), with a metric of 2 hops (the distance). A metric is simply the piece – or pieces – of information that a router uses in determining which path is the “best” in reaching a destination network. In the case of a protocol like RIP, the metric is the number of routers that need to be crossed in getting to a destination, also called the hop count. In other distance-vector protocols, like IGRP, the default metric is a calculation based on network bandwidth and delay. While we’ll look at both shortly, for now it’s enough to say that a metric is used by a routing protocol to find the best path to reach a destination network.
Distance-vector protocols work on a principle that is sometimes called “routing by rumor”. This is because a router running a distance-vector protocol learns about other networks based on the information provided by neighboring routers. In other words, the knowledge it obtains is not first-hand. The way in which a router learns from neighboring routers is by routing table updates. At certain intervals, a router sends out its complete routing table, which will be received by other routers running the same routing protocol. These other routers look at the information contained in the routing table update, and add routes to their own tables for networks they didn’t previously know about.
Consider the figure above, in which Router A sends out its routing table, which is ultimately received by Router B. Router A knows about networks 192.168.1.0 and 10.0.0.0. Router B doesn’t yet have an entry for network 192.168.1.0, so it adds it to its routing table with a hop count of 1, as shown in Figure 10. When Router B needs to reach network 192.168.1.0, it will forward the packets to Router A. In the same way, Router B will also send out updates to Router A. Through these, Router A will learn that network 172.16.0.0 is available via router B with a hop count of 1. Recall that the hop count is the number of routers that need to be traversed in order to reach a network. Because Router B only needs to go through one other router to reach network 172.16.0.0, the hop count is 1. Hop count is the metric used by RIP. In other words, RIP will choose the best path to a network based on the lowest number of hops.
If Router C (running the same distance vector routing protocol) were added to our network as shown in the figure above, it would also begin exchanging updates with its neighbors. In this case, it would send a routing table update to Router B, letting it know about network 192.168.2.0. Router B will add this to its routing table with a hop count of 1. In Router B’s next update to Router A, this network would also be included in the table. Router A would thus add it to its routing table, with a hop count of 2. Once all the updates were complete, and all routers knew about all networks, the network is considered to have converged. At that point, the routing tables would appear as shown in the figure below.