## Algorithm To Build Routing Table In The Routers

The distance vector (DV) algorithm is iterative, *asynchronous and*

*distributed.* It matlab help is distributed in that each node receives some information from one or more of its *directly* attached neighbors, performs a calculation and may then distribute the results of its calculation back to its neighbours. It is iterative in that this process continues on until no more information is exchanged between neighbors.

The principal data structure in the DV algorithm is the distance table maintained at each node. Each node’s distance table has a row for each destination in the network and a column for each of its directly attached neighbours. Consider a node X that is interested in routing to

destination Y via its directly attached neighbour Z. Node X’s distance table entry**,** Dx(Y,Z) is the sum of the cost of the direct one hop link between X and Z, c(X,Z), plus neighbour Z’s currently known minimum cost path from itself (Z) to Y. That is: Dx(Y,Z) = c(X,Z) + minw{Dz(Y,w)} (1)

The minw term in equation 1 is dynamic programming matlab code taken over all of Z’s directly attached neighbours.

Equation 1 shows dynamic programming matlab example, the form of the neighbour-to-neighbour communication that will take place in the DV algorithm — each node must know the cost of each of its neighbours minimum cost path to each destination Thus, whenever a node computes a new minimum cost to some

destination, it must inform its neighbours of this new minimum cost.

### Distance Vector (DV) Algorithm. At each node, X:

1) *Initialization:*

2) for all adjacent nodes v: /***school matlab project live chat help***/

3) DX(*,v) = infty /* the * operator means “for all rows” */

4) DX(v,v) = c(X,v) /***online tutors matlab***/

5) for all destinations, y

6) send minwD(y,w) to each neighbor /* w over all X’s neighbors */

7) *loop* /***online tutoring matlab***/

8) **wait** (until I see a link cost change to neighbor V

9) or until I receive update from neighbor V)

10) **if** (c(X,V) changes by d)

11) */* change cost to all dest’s via neighbor v by d */*

12) */* note: d could be positive or negative */*

13) for all destinations y: DX(y,V) = DX(y,V) + d

14) **else if** (update received from V wrt destination Y)

15) */* shortest path from V to some Y has changed */*

16) */* V has sent a new value for its minw DV(Y,w), matlab assignment helpers*/*

17) */* call this received new value is “newval” */*

18) for the single destination y: DX(Y,V) = c(X,V) + newval

19) **if** we have a new minw DX(Y,w)for any destination Y

20) send new value of minw DX(Y,w) to all neighbors

21) *forever* /* matlab assignment help fast*/