# Distance Vector Routing
## What is Distance Vector Routing
Distance vector routing is a class of routing algorithms in which each router maintains a table, called a distance vector, that records the best-known distance to each destination network and the direction, or vector, in which to forward packets to reach that destination. The distance is measured using a metric such as hop count. Routers using distance vector routing periodically exchange their distance vectors with directly connected neighbors. Each router updates its table based on the information received from neighbors, selecting the path with the smallest metric to each destination.
## How Distance Vector Works
Initially, each router only knows about its directly connected networks, which have a distance of zero or one hop. A router advertises its distance vector to all directly connected neighbors. When a router receives a distance vector from a neighbor, it adds the metric of the link to that neighbor to each distance in the received vector. It then compares these adjusted distances to its current table. If a new shorter distance is found to any destination, the router updates its table and schedules an advertisement to its own neighbors. This process continues until no more updates are needed, at which point the network has converged.
## Bellman-Ford Algorithm
Distance vector routing is based on the Bellman-Ford algorithm. The algorithm states that the shortest distance from router X to destination D through neighbor N is the cost of the link from X to N plus N's shortest distance to D. Each router applies this calculation for every neighbor and every destination to find the shortest path through any neighbor.
## Problems with Distance Vector
The count-to-infinity problem is a significant issue with naive distance vector implementations. When a link fails, the information about the failure may propagate slowly because routers may continue to advertise stale routes to each other, gradually increasing their hop count toward infinity. Split horizon is a technique that prevents a router from advertising routes back through the interface from which they were learned. Poison reverse advertises failed routes with an infinite metric to immediately inform neighbors that the route is unreachable. Triggered updates send routing updates immediately when a route changes rather than waiting for the next scheduled update.
## RIP as Distance Vector Protocol
RIP, the Routing Information Protocol, is the most commonly studied distance vector protocol. It uses hop count as its metric with a maximum value of 15, meaning any destination more than 15 hops away is considered unreachable. RIP sends complete routing table updates every 30 seconds.Back to Subject