The document discusses routing in switched networks, focusing on least-cost algorithms used for packet-switching networks and internets. It explains Dijkstra's algorithm, which finds the shortest paths from a source node to all other nodes by incrementally adding nodes based on the least-cost path. The document outlines the steps involved in Dijkstra's algorithm, including initialization, selecting the next node, and updating least-cost paths.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
7 views
Net.-Fall-2024-Lec.-13
The document discusses routing in switched networks, focusing on least-cost algorithms used for packet-switching networks and internets. It explains Dijkstra's algorithm, which finds the shortest paths from a source node to all other nodes by incrementally adding nodes based on the least-cost path. The document outlines the steps involved in Dijkstra's algorithm, including initialization, selecting the next node, and updating least-cost paths.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24
Faculty of Engineering
Department of Electronics and Communications Engineering
Fall, 2024
COMPUTER NETWORKS
Lec. 13
Prof. Ahmed Salah EL-Din Mohamed Ali
Routing in Switched Networks Least Cost Algorithms Virtually all packet-switching networks and all internets base their routing decision on some form of least-cost criterion. If the criterion is to minimize the number of hops, each link has a value of 1. More typically, the link value is inversely proportional to the link capacity, proportional to the current load on the link, or some combination. In any case, these link or hop costs are used as input to a least-cost routing algorithm, which can be simply stated as:
“Given a network of nodes connected by bidirectional links,
where each link has a cost associated with it in each direction, define the cost of a path between two nodes as the sum of the costs of the links traversed. For each pair of nodes, find a path with the least cost.” Least Cost Algorithms
Note that the cost of a link may differ in its two
directions. This would be true, for example, if the cost of a link equaled the length of the queue of packets awaiting transmission from each of the two nodes on the link.
Most least-cost routing algorithms in use in packet-
switching networks and internets are variations of one of two common algorithms, known as Dijkstra's algorithm and the Bellman-Ford algorithm. Dijkstra’s Algorithm Finds shortest paths from given source node “S” to all other nodes.
By developing paths in order of increasing path
length.
Algorithm runs in stages
Each time adding node with next shortest path.
Algorithm terminates when all nodes processed
by algorithm (in set T). Dijkstra’s Algorithm Dijkstra's Algorithm has three steps; steps 2 and 3 are repeated until T = N. That is, steps 2 and 3 are repeated until final paths have been assigned to all nodes in the network. It can be formally described as shown above, given the following definitions: N = set of nodes in the network s = source node T = set of nodes so far incorporated by the algorithm w(i, j) = link cost from node i to node j; w(i, i) = 0; w(i, j) = ∞ if two nodes not directly connected; w(i, j) ≥ 0 if two nodes are directly connected L(n) = cost of the least-cost path from node s to node n that is currently known to the algorithm; at termination, this is the cost of the least-cost path in the graph from s to n. Dijkstra’s Algorithm The algorithm terminates when all nodes have been added to T. At termination, the value L(x) associated with each node x is the cost (length) of the least-cost path from s to x. In addition, T defines the least-cost path from s to each other node. One iteration of steps 2 and 3 adds one new node to T and defines the least-cost path from s to that node. That path passes only through nodes that are in T. To see this, consider the following line of reasoning. After k iterations, there are k nodes in T, and the least-cost path from s to each of these nodes has been defined. Now consider all possible paths from s to nodes not in T. Among those paths, there is one of least cost that passes exclusively through nodes in T, ending with a direct link from some node in T to a node not in T. This node is added to T and the associated path is defined as the least-cost path for that node. Dijkstra’s Algorithm Method Step 1 [Initialization] T = {s} Set of nodes so far incorporated
L(n) = w(s, n) for n ≠ s
Initial path costs to neighboring nodes are simply link costs Step 2 [Get Next Node] Find neighboring node not in T with least-cost
path from s. Incorporate node into T
Also incorporate the edge that is incident on
that node and a node in T that contributes to the
path Dijkstra’s Algorithm Method
Step 3 [Update Least-Cost Paths]
L(n) = min[L(n), L(x) + w(x, n)] for all n T
f latter term is minimum, path from s to n is path from s to x concatenated with edge from x to n Costs in the Dijkstra Algorithm