20
Bellman-Ford Algorithm Dijkstra’s Algorithm Course 7

Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

  • Upload
    vunhi

  • View
    251

  • Download
    3

Embed Size (px)

Citation preview

Page 1: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Bellman-Ford Algorithm Dijkstra’s Algorithm

Course 7 

Page 2: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Routing Algorithms Kernel of routing protocols

Find the packets routing path for a set of network nodes between the source and destination nodes

Cost criteria

The set of nodes is modeled with a graph

nodes – routers

branches – links (each line has

a number which represents the cost of

the corresponding link)

Page 3: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -
Page 4: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Example 

A - source; C – destination; Lowest cost route - ADEC.

If all the links have the same cost, then the best route is the shortest one (with the lowest number of links).

Page 5: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Goal 

Each router informs its neighbors about the content of its routing table.

The routing table contains identifiers of all possible routes and their associated costs.

For any path, the router will select the direction towards the neighbor which communicated the lower cost towards the destination.

This selection will be registered in the routing table of the considered router, which will be transmitted to all neighbors.

Page 6: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

The Distance Vector (DV) Routing Algorithm 

The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics:

- Distributed (each node could receive information from one or multiple neighbors);

- Iterative (the information exchange process between routers continues until there is not information to be exchanged between two neighbors);

- Asynchronous (all the nodes works in the same rhythm).

Page 7: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Bellman‐Ford Method 

Each router maintains a two-dimensional costs table - distance table.

- Number of lines = number of destinations;

- Number of columns=number of neighbors.

- Each column is a vector indicating the total costs, the distances and the lowest cost routes towards each possible destination, corresponding to a neighbor.

At each information exchange with the considered neighbor, this information is updated.

The current values from a column indicates the total costs towards all the possible destinations, communicated by that neighbor, plus the cost of the link between the current node and the considered neighbor.

Page 8: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

DE(A,B) lowest cost from E to A considering that the first node of the route is B.

( ) ( ){ },*ADmin)B,E(cB,AD BE +=Initially, each node knows the costs on the direct links (towards its neighbors).

That node sends messages towards its neighbors with information about its routing table.

Receiving information from its neighbors, the current node is able to enlarge its horizon, to learn the neighbors of each neighbor, what destinations can be reached and the costs.

It will update its costs table and will compare it with the current routing table, modifying it if necessary.

Next, the new routing table will be transmitted to neighbors.

These transmissions will take end when no modifications will be observed in the routing table.

Page 9: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -
Page 10: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

The Algorithm (in node X) Initialization-for all nodes adjacent v: D(*,v)=infinite D(v,v)=c(X,v) Sending the cost of the shortest path towards each adjacent node In loop Execute the topology updating algorithm Continuously the topology updating algorithm In node X: 1. wait (until a modification of the cost on the link towards a neighbor Y appears or an update of a routing table arrives from a neighbor W) 2. If c(X,Y) changed with delta { /* change the current cost towards Y*/    - Change (with delta) all the inputs from the table towards all the nodes Z which pass trough the

node Y if these modifications imply the change of the lowest cost path towards each Z

Page 11: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -
Page 12: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Drawbacks 

counting to infinity

If the destination computer falls down, none of the nodes will not know this fact and the current data packet will be transmitted to infinity between the nodes who communicated the lowest costs towards this destination.

routing loops

These loops appear due to the communication latency and the slow convergence of the algorithm, when network’s state modifications appear. Invalid routing table entries could appear.

There are multiple solutions to solve these problems.

Page 13: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Possible solutions Split Horizon

A minimum cost path learned on one of the links of a node is not retransmitted on that link. This way, the possibility of apparition of a loop on that link disappears. Loops implying more than two nodes are not avoided.

The selection of a maximal value of the metric used

A maximal value of the DV metric (for example 16 in the case of the protocol RIP) keeps the signification of infinity.

Hold Down

The router ignores the updates for a specified interval of time. So, the possibility of apparition of some loops is avoided.

Route poisoning

The router maintains a special entry with the computer which failed, providing sufficient time to other routers to update the network topology.

Triggered update

The traffic in the network is increased for few seconds to maintain the correct links.

Page 14: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Link‐State Routing Algorithm Was proposed by Dijkstra in 1959.

Uses the state of the link (SL) for routing.

Hypotheses :

- each node knows the topology of the network and the cost of each link,

- each router broadcasts periodically the costs of its attached links,

Types of links :

- the propagation time on the link;

- the bandwidth of the link.

This algorithm is used in the OSPF protocol.

Page 15: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Principle 

The total cost of a path results as the sum of the cost of the links which forms that path. The lowest cost between the nodes A and F is the lowest cost of all possible links between A and F. The following notations are used:

c(i,j) – the cost between the links from i to j. This cost is considered infinite i and j are not directly connected. It is considered that c(i,j)=c(j,i).

D(v) – the lowest cost between the source and the node v.

Page 16: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

The Algorithm An initialization phase followed by a computation phase.

The computation loop is reiterated a number of times equal with the number of nodes.

The results are the lowest cost path between the source node and all the other nodes of the network.

Example considering that the node A is the source node. Initialization: N={A} For all the nodes v If v is adjacent to A Then D(v)=c(A,v) Else D(v)=infinity The loop Find w which is not in N such that D(w) is minimum Add w to N Update D(v) for all v which are not in N: D(v)=min{D(v), D(w)+c(w,v)} /* the new cost to v is either the old cost to v or the known cost of the shortest path to w plus the cost from w to v*/ Until all the nodes arrive in N 

Page 17: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Example: in the first step: D(C)=D(D)+c(D,C) For each column, the last input give immediately information about the path with the lowest cost to/from A and the cost to that node The delay for the worst case: O(N**2)  

Page 18: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

Congestions in routers 

 • 3 principal causes:

– The search of the address – The switching – The output queue

 

Page 19: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

The search of the address   

• Supposes to find the output line on which the packet will be sent based on its IP address.

Ex: the packet x from the input line “i” must be transferred on the output line “j”

• Algorithm: – A routing processor will inspect the destination

address to find where must be routed that packet.

– The processor will consult a routing table (statically or dynamically created) to find the output link for that packet.

– The searching result will furnish the output line “j” on which the packet will be transferred.

Page 20: Bellman-Ford Algorithm Dijkstra’s Algorithm - tc.etc.upt.ro · The DV algorithm uses the Bellman-Ford method to choose the lowest cost route. DV algorithm’s characteristics: -

• The routing table also called FIB (Forwarding Information Base) contains a set of headers and the corresponding output links. 

• The header can be seen as a “zone code” of variable length which substantially reduces the size of routing table. 

Ex: a header as 10* matches with all addresses which begin with 10… 

 Problem: When the packet has the header  

100* this matches with both 100* and 10* from the routing table.  

  Solution: The utilization of an algorithm which 

associates the address with the longer header‐the longest prefix matching, so for the packet with the header 100* the output 6 will be selected, not the output 4. 

Header Output … …

100* 6 101* 2 110* 1 10* 4 … …