Tutorial LS DV Routing

download Tutorial LS DV Routing

of 15

Transcript of Tutorial LS DV Routing

  • 8/7/2019 Tutorial LS DV Routing

    1/15

    Link-State and DistanceVector Routing Examples

    CPSC 441

    University of Calgary

  • 8/7/2019 Tutorial LS DV Routing

    2/15

    2

    Link-State (LS) Routing AlgorithmDijkstras algorithm topology and link costs

    known to all nodes

    accomplished via linkstate broadcast

    all nodes have same info

    computes least cost paths

    from one node (source) to allother nodes

    gives forwarding table forthat node

    iterative: after k iterations,know least cost path to kdestination nodes

    Notation:

    c(x,y): link cost from node xto y; set to if a and y are

    not direct neighbors D(v): current value of cost of

    path from source to dest. v

    p(v): vs predecessor node

    along path from source to v N': set of nodes whose least

    cost path is definitivelyknown

  • 8/7/2019 Tutorial LS DV Routing

    3/15

    3

    Dijsktras Algorithm1 Initialization (u = source node):2 N' = {u} /* path to self is all we know */3 for all nodes v

    4 if v adjacent to u5 then D(v) = c(u,v) /* assign link cost to neighbour6 else D(v) =

    7

    8 Loop9 find w not in N' such that D(w) is a minimum10 add w to N'11 update D(v) for all v adjacent to w and not in N' :12 D(v) = min( D(v), D(w) + c(w,v) )

    13 /* new cost to v is either old cost to v or known14 shortest path cost to w plus cost from w to v */15 until all nodes in N'

  • 8/7/2019 Tutorial LS DV Routing

    4/15

    4

    Textbook Problem 4.21 x is source

    6,x1,x3,xx0

    D(z),p(z)D(y),p(y)D(w),p(w)D(v),p(v)D(u),p(u)D(t),p(t)D(s),p(s)NStep

    w

    t

    s3 9

    1

    3

    2

    4

    1

    4

    2

    11

    14

    61

    y

    x v

    u

    z

    Initialization:- Store source node x in N- Assign link cost to neighbours (v,w,y)- Keep track of predecessor to destination node

  • 8/7/2019 Tutorial LS DV Routing

    5/15

    5

    Textbook Problem 4.21 x is source

    6,x2,w4,wxw1

    6,x1,x3,xx0

    D(z),p(z)D(y),p(y)D(w),p(w)D(v),p(v)D(u),p(u)D(t),p(t)D(s),p(s)NStep

    w

    t

    s3 9

    1

    3

    2

    4

    1

    4

    2

    11

    14

    61

    y

    x v

    u

    zNode and its minimum cost

    are colour-coded in each

    step

    Loop step 1:- For all nodes not in N, find one that has minimum cost path (1)- Add this node (w) to N

    - Update cost for all neighbours of added node that are not in Nrepeat until all nodes are in N

  • 8/7/2019 Tutorial LS DV Routing

    6/15

    6

    Textbook Problem 4.21 x is source

    7,txwvuyts6

    7,t6,txwvuyt5

    17,y5,u7,uxwvuy4

    3,v5,u7,uxwvu3

    3,v3,v11,vxwv2

    6,x2,w4,wxw1

    6,x1,x3,xx0

    D(z),p(z)D(y),p(y)D(w),p(w)D(v),p(v)D(u),p(u)D(t),p(t)D(s),p(s)NStep

    w

    t

    s3 9

    1

    3

    2

    4

    1

    4

    2

    11

    14

    6

    1y

    x v

    u

    zNode and its minimum cost

    are colour-coded in each

    step

  • 8/7/2019 Tutorial LS DV Routing

    7/15

  • 8/7/2019 Tutorial LS DV Routing

    8/15

    8

    Distance Vector Routing

    Based on Bellman-Ford Equation

    Define

    dx(y) := cost of least-cost path from x to y

    c(x,v) := cost of direct link from x to v Then, for all v that are neighbours of x

    dx(y) = minv {c(x,v) + dv(y) }

    yx

    vc(x,v)

    dx(y)

    dv(y)

  • 8/7/2019 Tutorial LS DV Routing

    9/15

    9

    Bellman-Ford Equation Example

    u

    yx

    wv

    z

    2

    21

    3

    1

    1

    2

    53

    5

    Consider a path from uto zBy inspection, dv(z) = 5, dx(z) = 3, dw(z) = 3

    du(z) = min { c(u,v) + dv(z),

    c(u,x) + dx(z),c(u,w) + dw(z) }= min {2 + 5,

    1 + 3,

    5 + 3} = 4

    Node that achieves minimum is nexthop in shortest path entry in forwarding table

    B-F equation says:

  • 8/7/2019 Tutorial LS DV Routing

    10/15

    10

    Distance Vector AlgorithmBasic idea:

    Nodes keep vector (DV) ofleast costs to other nodes

    These are estimates, Dx(y)

    Each node periodically sendsits own DV to neighbors

    When node xreceives DV fromneighbor, it keeps it andupdates its own DV using B-F:

    Dx(y) minv{c(x,v) + Dv(y)}

    for each node yN

    Ideally, the estimate Dx(y)converges to the actual leastcostdx(y)

    On each node:

    waitfor (change in local linkcost or msg from neighbor)

    recomputeestimates

    if DV has changed, notifyneighbors

  • 8/7/2019 Tutorial LS DV Routing

    11/15

    117 1 0 time

    x z12

    7

    y

    x y z

    x

    yz

    0 2 7

    from

    cost to

    from

    from

    x y z

    xyz

    cost to

    x y z

    xy

    z

    cost to

    2 0 1

    node x table

    node y table

    node z table

    Step 1: InitializationInitialize costs of direct links

    Set to costs from neighbours

  • 8/7/2019 Tutorial LS DV Routing

    12/15

    127 1 0 time

    x z12

    7

    y

    Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}= min{2+0 , 7+1} = 2 Dx(z)=min{c(x,y)+Dy(z), c(x,z)+Dz(z)}

    = min{2+1 , 7+0} = 3

    x y z

    x

    yz

    0 2 7

    from

    cost to

    from

    from

    x y z

    x

    yz

    0 23

    from

    cost to

    x y z

    xyz

    cost to

    x y z

    xy

    z

    cost to

    2 0 1

    2 017 1 0

    node x table

    node y table

    node z table

    Step 2: Exchange DV and

    iterate-In first iteration, node x savesneighbours DVs-Then, it checks path costs to

    all nodes using received DVs

    -E.g. new cost Dx(z) isobtained by adding costsmarked red

  • 8/7/2019 Tutorial LS DV Routing

    13/15

    137 1 0 time

    x z12

    7

    y

    In similar fashion, algorithm proceeds until all nodes have updated tables

    x y z

    x

    yz

    0 2 7

    from

    cost to

    from

    from

    x y z

    xyz

    0 2 3

    from

    cost tox y z

    x

    yz

    0 2 3

    from

    cost to

    x y z

    xyz

    cost tox y z

    xyz

    0 2 7

    from

    cost to

    x y z

    xyz

    0 2 3

    from

    cost to

    x y z

    xyz

    0 2 3

    from

    cost tox y z

    xyz

    0 2 7

    from

    cost to

    x y z

    xy

    z

    cost to

    2 0 1

    2 0 17 1 0

    2 0 17 1 0

    2 0 1

    3 1 0

    2 0 13 1 0

    2 0 1

    3 1 02 0 1

    3 1 0

    node x table

    node y table

    node z table

  • 8/7/2019 Tutorial LS DV Routing

    14/15

    14

    Distance Vector: link cost changesLink cost changes:

    node detects local link cost change

    updates routing info, recalculatesdistance vector

    if DV changes, notify neighbors

    goodnewstravelsfast

    x z14

    50

    y1

    At time t0, ydetects the link-cost change, updates its DV,and informs its neighbors.

    At time t1, zreceives the update from yand updates its table.

    It computes a new least cost to xand sends neighbors its DV.

    At time t2, yreceives zs update and updates its distance table.

    ys least costs do not change and hence ydoes notsend anymessage to z.

  • 8/7/2019 Tutorial LS DV Routing

    15/15

    15

    Distance Vector: link cost changesLink cost changes:

    bad news travels slow - count to infinityproblem!

    When y detects cost change to 60, it willupdate its DV using the zs cost to x, whichis 5 (via y), to obtain an incorrect new costto x of 6, over the path yzyx that has

    a loop 44 iterations before algorithm stabilizes,

    while y and z exchange updates

    Poisoned reverse:

    If Z routes through Y to get to X : Z tells Y its (Zs) distance to X is infinite (so Y

    wont route to X via Z)

    Will this completely solve the problem?

    x z

    14

    50

    y60