Vous êtes sur la page 1sur 31

Advance

Computer Networks
#2 Rou7ng Algorithm
Semester Ganjil 2012
PTIIK Universitas Brawijaya

Todays Lecture
This Course
Goals :
Understand Routing Algorithm
Distance Vector & Link State Routing

Outline/Schedule
Grading Policy

Dynamic Routing ( Link State vs


Distance Vector )
Dynamic Routing vs Static Routing ?
#1 - Review of Networks

References
Kurose & Ross, Computer Networking : Top down
Approach, 6th Ed., Pearson/Addison, 2012.
Chapter 4
Network Layer

#1 - Review of Networks

#1 Rou7ng Algorithm
Routing & Forwarding
Graph Theory
Routing Algorithm

Interplay between rou7ng, forwarding


rou7ng algorithm determines
end-end-path through network

rou$ng algorithm

local forwarding table


dest address output link
address-range 1
address-range 2
address-range 3
address-range 4

forwarding table determines


local forwarding at this router

3
2
2
1

IP des7na7on address in
arriving packets header

1
3 2

Network Layer

4-5

Graph abstrac7on
5

1
graph: G = (N,E)

v
2

3
3
1

N = set of routers = { u, v, w, x, y, z }
E = set of links ={ (u,v), (u,x),(u.w), (v,x), (v,w), (x,w), (x,y), (w,y), (w,z), (y,z) }
aside: graph abstrac7on is useful in other network contexts, e.g.,
P2P, where N is set of peers and E is set of TCP connec7ons

Network Layer

4-6

Graph abstrac7on: costs


5

v
2

3
3
1

c(x,x) = cost of link (x,x)


e.g., c(w,z) = 5

cost could always be 1, or


inversely related to bandwidth,
or inversely related to
congestion

cost of path (x1, x2, x3,, xp) = c(x1,x2) + c(x2,x3) + + c(xp-1,xp)

key question: what is the least-cost path between u and z ?


routing algorithm: algorithm that finds that least cost path
Network Layer

4-7

Rou7ng algorithm classica7on


Q: global or decentralized informa6on?
global:
all routers have complete topology,
link cost info
link state algorithms
decentralized:
router knows physically-connected
neighbors, link costs to neighbors
itera7ve process of computa7on,
exchange of info with neighbors
distance vector algorithms

Q: sta6c or dynamic?
sta6c:
routes change slowly over
7me
dynamic:
routes change more
quickly
periodic update
in response to link cost
changes

Network Layer

4-8

A Link-State Rou7ng Algorithm


Dijkstras algorithm
net topology, link costs
known to all nodes
accomplished via link state
broadcast
all nodes have same info

computes least cost paths


from one node (source)
to all other nodes
gives forwarding table for
that node

nota6on:
c(x,y): link cost from node

x to y; = if not direct
neighbors
D(v): current value of cost
of path from source to dest.
v
p(v): predecessor node
along path from source to v
N': set of nodes whose
least cost path deni7vely
known

itera7ve: aher k
itera7ons, know least cost
Network Layer
path to k dest.s

4-9

Dijsktras Algorithm
1 Ini$aliza$on:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) =
7
8 Loop
9 nd w not in N' such that D(w) is a minimum
10 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 known
14 shortest path cost to w plus cost from w to v */
15 un$l all nodes in N'
Network Layer

4-10

Dijkstras algorithm: example


Step
0
1
2
3
4
5

N'

u
uw
uwx
uwxv
uwxvy
uwxvyz

D(v) D(w) D(x) D(y) D(z)


p(v)

p(w)

p(x)

7,u
6,w
6,w

3,u


5,u
5,u 11,w
11,w 14,x
10,v 14,x
12,y

p(y)

p(z)

notes:

construct shortest path tree by


tracing predecessor nodes
ties can exist (can be broken
arbitrarily)

4
3

u
7

9
7
8

w
3

v
Network Layer

4-11

Dijkstras algorithm: another example


Step
0
1
2
3
4
5

N'
u
ux
uxy
uxyv
uxyvw
uxyvwz

D(v),p(v) D(w),p(w)
2,u
5,u
2,u
4,x
2,u
3,y
3,y

D(x),p(x)
1,u

D(y),p(y)

2,x

D(z),p(z)

4,y
4,y
4,y

v
2

3
3
1

Network Layer

4-12

Dijkstras algorithm: example (2)


resulting shortest-path tree from u:
v

z
x

resulting forwarding table in u:


des7na7on

link

v
x

(u,v)
(u,x)

(u,x)

(u,x)

(u,x)
Network Layer

4-13

Dijkstras algorithm, discussion


algorithm complexity: n nodes
each itera7on: need to check all nodes, w, not in N
n(n+1)/2 comparisons: O(n2)
more ecient implementa7ons possible: O(nlogn)

oscilla6ons possible:
e.g., support link cost equals amount of carried trac:
D
1

C
e

1+e

ini7ally

2+e

1+e 1

2+e

0 0

1+e

2+e

1+e 1

given these costs,


given these costs,
given these costs,
find new routing.
find new routing.
find new routing.
resulting in new costs resulting in new costs resulting in new costs
Network Layer
4-14

Distance vector algorithm


Bellman-Ford equa6on (dynamic
programming)
let
dx(y) := cost of least-cost path from x to y
then
dx(y) = min {c(x,v) + dv(y) }
v

cost from neighbor v to destination y

cost to neighbor v
min taken over all neighbors v of x
Network Layer

4-15

Bellman-Ford example
5

v
2

3
3
1

clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3

B-F equa7on says:


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 achieving minimum is next


hop in shortest path, used in forwarding table
Network Layer

4-16

Distance vector algorithm


Dx(y) = es7mate of least cost from x to y
x maintains distance vector Dx = [Dx(y): y N ]

node x:
knows cost to each neighbor v: c(x,v)
maintains its neighbors distance vectors. For
each neighbor v, x maintains
Dv = [Dv(y): y N ]

Network Layer

4-17

Distance vector algorithm


key idea:
from 7me-to-7me, each node sends its own
distance vector es7mate to neighbors
when x receives new DV es7mate from
neighbor, it updates its own DV using B-F
equa7on:

under minor, natural conditions, the estimate Dx(y)


converge to the actual least cost dx(y)
Dx(y) minv{c(x,v) + Dv(y)} for each node y N
Network Layer

4-18

Distance vector algorithm


itera6ve, asynchronous:

each node:

each local itera7on


caused by:
local link cost change
DV update message from
neighbor

distributed:
each node no7es
neighbors only when its
DV changes

wait for (change in local link


cost or msg from neighbor)

recompute es7mates
if DV to any dest has changed,
no6fy neighbors

neighbors then no7fy their


neighbors if necessary
Network Layer

4-19

Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}


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

from

node y
table
x
y
z

from

node z
table
x
y
z

cost to

cost to

x y z
0 2 7

x y z
from

from

node x
table
x
y
z

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

x 0 2 3
y 2 0 1
z 7 1 0

cost to

x y z

2 0 1

y
7

cost to

x y z



7 1 0
Network Layer

7me

4-20

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

Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}


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

x y z


x y z


7 1 0

from

cost to

x y z

x y z

x 0 2 7
y 2 0 1
z 7 1 0

x 0 2 3
y 2 0 1
z 3 1 0

cost to

cost to

x 0 2 3
y 2 0 1
z 3 1 0

cost to

cost to


2 0 1

x 0 2 3
y 2 0 1
z 7 1 0

x y z

from

from

0 2 7

cost to

x y z

y
7

cost to

x y z

x y z

x 0 2 7
y 2 0 1
z 3 1 0

x 0 2 3
y 2 0 1
z 3 1 0

from

from

node z
table
x
y
z

x y z

from

from

node y
table
x
y
z

cost to

cost to

from

from

node x
table
x
y
z

Network Layer

7me

4-21

Distance vector: link cost changes


link cost changes:

node detects local link cost change


updates routing info, recalculates
distance vector
if DV changes, notify neighbors

good
news
travels
fast

y
50

t0 : y detects link-cost change, updates its DV, informs its neighbors.


t1 : z receives update from y, updates its table, computes new least
cost to x , sends its neighbors its DV.
t2 : y receives zs update, updates its distance table. ys least costs do not
change, so y does not send a message to z.
Network Layer

4-22

Comparison of LS and DV algorithms


message complexity
LS: with n nodes, E links, O(nE)
msgs sent
DV: exchange between neighbors
only
convergence 7me varies

speed of convergence

LS: O(n2) algorithm requires O(nE)

msgs
may have oscilla7ons
DV: convergence 7me varies
may be rou7ng loops
count-to-innity problem

robustness: what happens if


router malfunc7ons?
LS:
node can adver7se incorrect
link cost
each node computes only its
own table

DV:
DV node can adver7se
incorrect path cost
each nodes table used by
others

Network Layer

error propagate thru


network
4-23

Hierarchical rou7ng
our routing study thus far - idealization
all routers identical
network flat
not true in practice
scale: with 600 million
des7na7ons:
cant store all dests in
rou7ng tables!
rou7ng table exchange
would swamp links!

administra6ve autonomy
internet = network of
networks
each network admin may
want to control rou7ng in
its own network

Network Layer

4-24

Hierarchical rou7ng
aggregate routers into
regions, autonomous
systems (AS)
routers in same AS run
same rou7ng protocol

gateway router:
at edge of its own AS
has link to router in
another AS

intra-AS rou7ng
protocol
routers in dierent AS
can run dierent intra-
AS rou7ng protocol
Network Layer

4-25

Interconnected ASes
3c

3a
3b
AS3
1a

2a

1c
1d

1b AS1

2c
AS2

2b

forwarding table
congured by both intra-
and inter-AS rou7ng
Intra-AS
Inter-AS
Rou7ng
Rou7ng
algorithm
algorithm
algorithm
intra-AS sets entries
Forwarding
for internal dests
table
inter-AS & intra-AS sets
entries for external
dests
Network Layer
4-26

Inter-AS tasks
suppose router in AS1
receives datagram
des7ned outside of AS1:
router should forward
packet to gateway
router, but which one?

3c
3b
other
networks

AS1 must:
1. learn which dests are
reachable through AS2,
which through AS3
2. propagate this
reachability info to all
routers in AS1
job of inter-AS rou6ng!

3a
AS3

1c

1a
1d
AS1

1b

Network Layer

2a

2c
AS2

2b

other
networks

4-27

Example: seyng forwarding table in router 1d


suppose AS1 learns (via inter-AS protocol) that subnet x
reachable via AS3 (gateway 1c), but not via AS2

inter-AS protocol propagates reachability info to all


internal routers
router 1d determines from intra-AS rou7ng info that its interface
I is on the least cost path to 1c

installs forwarding table entry (x,I)


x

3c
3b
other
networks

3a
AS3

1c

1a
1d
AS1

1b

Network Layer

2a

2c
AS2

2b

other
networks

4-28

Example: choosing among mul7ple ASes


now suppose AS1 learns from inter-AS protocol that subnet
x is reachable from AS3 and from AS2.
to congure forwarding table, router 1d must determine
which gateway it should forward packets towards for dest x

this is also job of inter-AS rou7ng protocol!


x

3c
3b
other
networks

3a
AS3

1c

1a
1d
AS1

1b

?
Network Layer

2a

2c
AS2

2b

other
networks

4-29

Example: choosing among mul7ple ASes


now suppose AS1 learns from inter-AS protocol that subnet
x is reachable from AS3 and from AS2.
to congure forwarding table, router 1d must determine
towards which gateway it should forward packets for dest x

this is also job of inter-AS rou7ng protocol!

hot potato rou6ng: send packet towards closest of two


routers.

learn from inter-AS


protocol that subnet
x is reachable via
mul7ple gateways

use rou7ng info


from intra-AS
protocol to determine
costs of least-cost
paths to each
of the gateways

hot potato rou7ng:


choose the gateway
that has the
smallest least cost

Network Layer

determine from
forwarding table the
interface I that leads
to least-cost gateway.
Enter (x,I) in
forwarding table

4-30

Assignment
Prepare a discussion group
5 Member each group

Prepare 3 Guest VM in Linux Fedora Core 16


without GUI. Connect those 3 guest VM
network. Each VM must able to ping each
other. ( Use VmWare, KVM, Virtual Box, Etc )
Install Quagga Rou7ng Applica7on in each
version ( Use the newest version of Quagga )
#1 - Review of Networks

Slide 31

Vous aimerez peut-être aussi