Wednesday, 9 January 2013

The Optimality Principle and Shortest Path Routing


- Before we get into specific algorithms, it may be helpful to note that one can make a general statement about optimal routes without regard to network topology or traffic. This statement is known as the optimality principle.

- It states that if router J is on the optimal path from router I to router K, then the optimal path from J to K also falls along the same route. To see this, call the part of the route from I to Jr1 and the rest of the route r2.
- If a route better than r2 existed from J to K, it could be concatenated with r1 to improve the route from I to K, contradicting our statement that r1r2 is optimal. As a direct consequence of the optimality principle, we can see that the set of optimal routes from all sources to a given destination form a tree rooted at the destination.

- Such a tree is called a sink tree and is illustrated in Fig. 3-6, where the distance metric is the number of hops. Note that a sink tree is not necessarily unique; other trees with the same path lengths may exist. The goal of all routing algorithms is to discover and use the sink trees for all routers.

Figure 3-6. (a) A subnet. (b) A sink tree for router B.



- Since a sink tree is indeed a tree, it does not contain any loops, so each packet will be delivered within a finite and bounded number of hops. In practice, life is not quite this easy.

- Links and routers can go down and come back up during operation, so different routers may have different ideas about the current topology. Also, we have quietly finessed the issue of whether each router has to individually acquire the information on which to base its sink tree computation or whether this information is collected by some other means.

- We will come back to these issues shortly. Nevertheless, the optimality principle and the sink tree provide a benchmark against which other routing algorithms can be measured.

3.2.2 Shortest Path Routing

·         Let us begin our study of feasible routing algorithms with a technique that is widely used in many forms because it is simple and easy to understand. The idea is to build a graph of the subnet, with each node of the graph representing a router and each arc of the graph representing a communication line (often called a link).

·         To choose a route between a given pair of routers, the algorithm just finds the shortest path between them on the graph. The concept of a shortest path deserves some explanation. One way of measuring path length is the number of hops.

·         Using this metric, the paths ABC and ABE in Fig. 3-7are equally long. Another metric is the geographic distance in kilometers, in which case ABC is clearly much longer than ABE.


Figure 3-7. The first five steps used in computing the shortest path from A to D. The arrows indicate the working node





- However, many other metrics besides hops and physical distance are also possible. For example, each arc could be labeled with the mean queueing and transmission delay for some standard test packet as determined by hourly test runs.

- With this graph labeling, the shortest path is the fastest path rather than the path with the fewest arcs or kilometers. In the general case, the labels on the arcs could be computed as a function of the distance, bandwidth, average traffic, communication cost, mean queue length, measured delay, and other factors.

- By changing the weighting function, the algorithm would then compute the ''shortest'' path measured according to any one of a number of criteria or to a combination of criteria. Several algorithms for computing the shortest path between two nodes of a graph are known.

- This one is due to Dijkstra (1959). Each node is labeled (in parentheses) with its distance from the source node along the best known path. Initially, no paths are known, so all nodes are labeled with infinity.

- As the algorithm proceeds and paths are found, the labels may change, reflecting better paths. A label may be either tentative or permanent. Initially, all labels are tentative. When it is discovered that a label represents the shortest possible path from the source to that node, it is made permanent and never changed thereafter.

  • We now start at B and examine all nodes adjacent to it. If the sum of the label on B and the distance from B to the node being considered is less than the label on that node, we have a shorter path, so the node is relabeled.

  • After all the nodes adjacent to the working node have been inspected and the tentative labels changed if possible, the entire graph is searched for the tentatively-labeled node with the smallest value.

  • This node is made permanent and becomes the working node for the next round. Figure 3-7 shows the first five steps of the algorithm. This algorithm is given in Fig. 3-8. The global variables n and dist describe the graph and are initialized before shortest_path is called.

  • The only difference between the program and the algorithm described above is that in Fig. 3-8, we compute the shortest path starting at the terminal node, t, rather than at the source node, s.

  • Since the shortest path from t to s in an undirected graph is the same as the shortest path from s to t, it does not matter at which end we begin. The reason for searching backward is that each node is labeled with its predecessor rather than its successor.

  • When the final path is copied into the output variable, path, the path is thus reversed. By reversing the search, the two effects cancel, and the answer is produced in the correct order.

Figure 3-8. Dijkstra's algorithm to compute the shortest path through a graph.




3 comments:

  1. Try to write something from your side ,plz don't copy whole thing from tanenbaum

    ReplyDelete
  2. Try to write something from your side ,plz don't copy whole thing from tanenbaum

    ReplyDelete
  3. Copied Tannenbaum🚫👿👿👿👿

    ReplyDelete