# Routing Algorithms
## What are Routing Algorithms
Routing algorithms are the mathematical procedures used by routers to determine the best path for packets to travel through a network. Different routing algorithms use different approaches to calculate paths and have different characteristics in terms of convergence speed, scalability, and the type of metric they use to determine the best path. Routing algorithms are implemented in routing protocols that routers use to exchange information and build their routing tables.
## Classification of Routing Algorithms
Routing algorithms are classified based on whether they are static or dynamic, and based on the type of information they use. Static routing uses routes manually configured by an administrator that do not change unless the administrator modifies them. Dynamic routing uses protocols that allow routers to automatically discover routes and update their routing tables in response to network changes. Dynamic algorithms are further classified as distance vector, link state, or path vector algorithms.
## Distance Vector Algorithms
Distance vector algorithms are based on the Bellman-Ford algorithm. Each router maintains a table of the distance to every known destination, where distance is measured in hops or some other metric. Routers periodically share their entire routing tables with directly connected neighbors. Each router updates its table based on the information received, taking the shortest path to each destination through any neighbor. RIP is the classic distance vector routing protocol. Distance vector is simple to implement but converges slowly and is prone to routing loops.
## Link State Algorithms
Link state algorithms are based on Dijkstra's shortest path algorithm. Each router learns about the entire network topology by flooding information about its directly connected links to all other routers. Every router builds an identical map of the network topology and independently calculates the shortest path from itself to every other network. OSPF is the most widely used link state routing protocol. Link state converges faster than distance vector and is not prone to routing loops, but requires more processing and memory.
## Path Vector Algorithms
Path vector algorithms are used for routing between autonomous systems on the internet. BGP is the only path vector routing protocol in common use. In path vector routing, route advertisements include the complete path of autonomous systems that the route has passed through. This path information allows routers to detect and avoid routing loops and to implement routing policies based on the path.
## Metrics
Different routing algorithms use different metrics to determine the best path. A metric is a value assigned to a route that represents the cost of using that route. Common metrics include hop count, which counts the number of routers a packet must pass through; bandwidth, which prefers routes with more available bandwidth; delay, which prefers routes with lower latency; reliability, which prefers routes with fewer errors; and load, which considers the current traffic level on each link.Back to Subject