7.2. Least-Cost- Path AlgorithmsIn practice, the majority of Internet routing methods are based on least-cost algorithms. In such algorithms, a link cost is proportional to the links's current traffic load. However, the link cost may not always be proportional to the current load. The link cost is defined on both directions between each pair of nodes. Several least-cost-path algorithms have been developed for packet-switched networks. In particular, Dijkstra's algorithm and the Bellman-Ford algorithm are the most effective and widely used algorithms. 7.2.1. Dijkstra's AlgorithmDijkstra's algorithm is a centralized routing algorithm that maintains information in a central location. The objective is to find the least-cost path from a given source node to all other nodes. This algorithm determines least-cost paths from a source node to a destination node by optimizing the cost in multiple iterations. Dijkstra's algorithm is as follows : Begin Dijkstra's Algorithm
If any two nodes i and j are not connected directly, the cost for that link is infinity, indicated by ² ij =x. Steps 2 and 3 are repeated until paths are assigned to all nodes. At step 1, k represents s , and ² sj computes the cost of the least-cost path from s to node j . At step 2, we want to find x among the neighboring nodes but not in k such that the cost is minimized. At step 3, we simply update the least-cost path. The algorithm ends when all nodes have been visited and included in the algorithm.
7.2.2. Bellman-Ford AlgorithmThe Bellman-Ford algorithm finds the least-cost path from a source to a destination by passing through no more than links. The essence of the algorithm consists of the following steps Begin Bellman-Ford Algorithm
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
² sj ( 0) | = | x, for all j s | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
² ss ( ) | = | 0, for all |
Least-cost path:
for any node j s with predecessor node i :
² sj ( + 1) = min i [ ² si ( ) + ± ij ]
If any two nodes i and j are not connected directly, ² ij ( ) =x. At step 2, every value of ² is initialized . At step 3, we increase the number of links in a sequence of iterations. During each iteration, we find the least-cost path, given the value of . The algorithm ends when all nodes have been visited and included in the algorithm.
Example. | Use the Bellman-Ford algorithm to find the least-cost path from node A to node B in Figure 7.2. | ||||||||||||||||||||||||||||||||||||||||||
Solution. | Table 7.2 shows the details of least-cost-path iterations. For iteration = 1, only AC with cost 1 and AF with cost 1 exist, owing to the restriction enforced by = 1. This trend changes at iteration = 2, when ACE with cost 3 can be added to the set of least-cost paths. As seen, the result of the final least-cost path is identical to the one obtained by Dijkstras algorithm. Table 7.2. Use of the Bellman-Ford algorithm
|
We can now compare these two algorithms. In step 2 of Bellman-Ford, the calculation of the link cost to any node j requires knowledge of the link cost to all neighboring nodes. In step 3 of Dijkstra's algorithm, each node requires knowledge of the network topology at each time of iteration. The performance of each algorithm varies network to network and depends on the topology and size of a particular network. The comparison of these two algorithms, therefore, depends on the speed of each to achieve its objective at its corresponding step given a network under routing. A simulation can clarify the efficiency of each algorithm given a certain network topology.