Beruflich Dokumente
Kultur Dokumente
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
v w
u z
x y
9
Distance vector algorithm
Bellman-Ford equation (dynamic
programming)
let
dx(y) :=v
cost of least-cost path from
x to y
cost from neighbor v to destination
then
dx(y) = cost {c(x,v)
min to neighbor
+ vd (y) }
v v of x
min taken over all neighbors
Network Layer 4-10
Bellman-Ford example
5
3
clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
v w 5
2
u 2 1 z B-F equation says:
3
1 2 du(z) = min { c(u,v) + dv(z),
x 1
y
c(u,x) + dx(z),
c(u,w) + dw(z) }
= min {2 + 5,
1 + 3,
5 + 3} = 4
ode achieving minimum is next
op in shortest path, used in forwarding table
Network Layer 4-11
Distance vector algorithm
Dx(y) = estimate of least cost from x
to y
x maintains distance vector Dx = [Dx(y):
yN]
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):Network
y Layer
N] 4-12
Distance vector algorithm
key idea:
from time-to-time, each node sends its own
distance vector estimate to neighbors
when x receives new DV estimate from
neighbor, it updates its own DV using B-F
equation:
Dx(y) minv{c(x,v) + Dv(y)} for each node y N
from
from
y y 2 0 1
z z 7 1 0
node y cost to
table x y z y
2 1
x x z
from
y 2 0 1 7
z
node z cost to
table x y z
x
from
y
z 7 1 0
time
Network Layer 4-15
Dx(z) = min{c(x,y) +
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
= min{2+0 , 7+1} = 2 Dy(z), c(x,z) + Dz(z)}
= min{2+1 , 7+0} = 3
node x cost to cost to cost to
table x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3
from
from
y y 2 0 1 y 2 0 1
from
z z 7 1 0 z 3 1 0
y y 2 0 1 7
from
2 0 1 y 2 0 1
from
z z 7 1 0 z 3 1 0
from
y 2 0 1 y 2 0 1
from
y
z z 3 1 0 z 3 1 0
7 1 0
time
Network Layer 4-16
Distance Vector Example:
Step 0
Optimum 1-hop paths
Table for A Table for B
E 3 C
Dst Cst Hop Dst Cst Hop 1
A 0 A A 4 A
F 1
B 4 B B 0 B 2
6
C C
1
D D 3 D 3 D
A 4
E 2 E E
B
F 6 F F 1 F
Table for C Table for D Table for E Table for F
Dst Cst Hop Dst Cst Hop Dst Cst Hop Dst Cst Hop
A A A 2 A A 6 A
B B 3 B B B 1 B
C 0 C C 1 C C C 1 C
D 1 D D 0 D D D
E E E 0 E E 3 E
F 1 F F F 3 F F 0 F
17
Distance Vector Example:
Step 2
Optimum 2-hop paths
Table for A Table for B
E 3 C
Dst Cst Hop Dst Cst Hop 1
A 0 A A 4 A
F 1
B 4 B B 0 B 2
6
C 7 F C 2 F
1
D 7 B D 3 D 3 D
A 4
E 2 E E 4 F
B
F 5 E F 1 F
Table for C Table for D Table for E Table for F
Dst Cst Hop Dst Cst Hop Dst Cst Hop Dst Cst Hop
A 7 F A 7 B A 2 A A 5 B
B 2 F B 3 B B 4 F B 1 B
C 0 C C 1 C C 4 F C 1 C
D 1 D D 0 D D D 2 C
E 4 F E E 0 E E 3 E
F 1 F F 2 C F 3 F F 0 F
18
Distance Vector Example:
Step 3
Optimum 3-hop paths
Table for A Table for B
E 3 C
Dst Cst Hop Dst Cst Hop 1
A 0 A A 4 A
F 1
B 4 B B 0 B 2
6
C 6 E C 2 F
1
D 7 B D 3 D 3 D
A 4
E 2 E E 4 F
B
F 5 E F 1 F
Table for C Table for D Table for E Table for F
Dst Cst Hop Dst Cst Hop Dst Cst Hop Dst Cst Hop
A 6 F A 7 B A 2 A A 5 B
B 2 F B 3 B B 4 F B 1 B
C 0 C C 1 C C 4 F C 1 C
D 1 D D 0 D D 5 F D 2 C
E 4 F E 5 C E 0 E E 3 E
F 1 F F 2 C F 3 F F 0 F
19
Comparison of LS and DV algorithms
3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d
forwarding table
configured by both
Intra-AS
intra- and inter-AS
Inter-AS
Routing Routing routing algorithm
algorithm algorithm
intra-AS sets entries
Forwarding
table
for internal dests
inter-AS & intra-AS
sets entries for
external dests
Network Layer 4-24
Inter-AS tasks
suppose router in
AS1 receives
AS1 must:
datagram destined
outside of AS1: 1. learn which dests
are reachable
router should
through AS2, which
forward packet to
through AS3
gateway router,
but which one? 2. propagate this
reachability info to
3c
all routers in AS1
3a
3b job of inter-AS
2c
routing!
AS3 1c
other
2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 4-25
Example: setting 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 routing info that
its interface I is on the least cost path to 1c
installs
3c forwarding table entry (x,I)
x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 4-26
Example: choosing among multiple
ASes
now suppose AS1 learns from inter-AS protocol
that subnet x is reachable from AS3 and from
AS2.
to configure forwarding table, router 1d must
determine which gateway it should forward
packets towards for dest x
this is also job of inter-AS routing
protocol!
3c x
3b
3a
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
?
Network Layer 4-27
Example: choosing among multiple
ASes
now suppose AS1 learns from inter-AS protocol
that subnet x is reachable from AS3 and from
AS2.
to configure forwarding table, router 1d must
determine towards which gateway it should
forward packets for dest x
this is also job of inter-AS routing
protocol!
hot potato routing: send packet towards closest
of two routers.
use routing info determine from
learn from inter-AS hot potato routing: forwarding table the
from intra-AS
protocol that subnet choose the gateway interface I that leads
protocol to determine
x is reachable via that has the to least-cost gateway.
costs of least-cost
multiple gateways smallest least cost Enter (x,I) in
paths to each
of the gateways forwarding table
z
w x y
A D B
C
routing table in router D
destination subnet next router # hops to
dest
w A 2
y B 2
z B 7
x -- 1
. . ....
Network Layer 4-32
RIP: example
A-to-D advertisement
dest next hops
w - 1
x - 1
z C 4
. ... z
w x y
A D B
C
routing table in router D
destination subnet next router # hops to
dest
w A 2
y B 2 A 5
z B 7
x -- 1
. . ....
Network Layer 4-33
RIP: link failure, recovery
if no advertisement heard after 180
sec --> neighbor/link declared dead
routes via neighbor invalidated
new advertisements sent to neighbors
neighbors in turn send out new
advertisements (if tables changed)
link failure info quickly (?) propagates to
entire net
poison reverse used to prevent ping-
pong loops (infinite distance = 16 hops)
Network Layer 4-34
RIP table processing
RIP routing tables managed by
application-level process called
route-d (daemon)
advertisements
routed sent in UDP packets,
routed
periodically repeated
transport transprt
(UDP) (UDP)
network forwarding forwarding network
(IP) table table (IP)
link link
physical physical
backbone
area
border
routers
area 3
internal
area 1 routers
area 2
R3 R4 R3 R4
source in-network
duplication duplication
B B
c c
D D
F E F E
G G
(a) broadcast initiated at A (b) broadcast initiated at D
A A
3
B B
c c
4
2
D D
F E F E
1 5
G G
(a) stepwise construction of (b) constructed spanning
spanning tree (center: E) tree
Network Layer 4-54
Shortest path tree
mcast forwarding tree: tree of shortest
path routes from source to all receivers
Dijkstras algorithm
s: source LEGEND
R1 2 router with attached
1 R4
group member
R2 5 router with no attached
3 4 group member
R5
i link used for forwarding,
R3 6
i indicates order link
R6 R7 added by algorithm