You are on page 1of 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 2
References
Kurose & Ross, Computer Networking : Top down
Approach, 6th Ed., Pearson/Addison, 2012.
Chapter 4
Network Layer

#1 - Review of Networks 3
#1 Rou7ng Algorithm

Routing & Forwarding


Graph Theory
Routing Algorithm
Interplay between rou7ng, forwarding
rou7ng algorithm determines
rou$ng algorithm
end-end-path through network
forwarding table determines
local forwarding table
dest address output link
local forwarding at this router
address-range 1 3
address-range 2 2
address-range 3 2
address-range 4 1

IP des7na7on address in
arriving packets header
1
3 2

Network Layer 4-5


Graph abstrac7on
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
graph: G = (N,E)

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
c(x,x) = cost of link (x,x)
v 3 w
e.g., c(w,z) = 5
2 5
u 2 1 z cost could always be 1, or
3 inversely related to bandwidth,
1 2 or inversely related to
x 1
y
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? Q: sta6c or dynamic?
global:
sta6c:
all routers have complete topology,
link cost info routes change slowly over
link state algorithms 7me
decentralized: dynamic:
router knows physically-connected routes change more
neighbors, link costs to neighbors
quickly
itera7ve process of computa7on,
exchange of info with neighbors periodic update
distance vector algorithms in response to link cost
changes

Network Layer 4-8


A Link-State Rou7ng Algorithm
Dijkstras algorithm nota6on:
net topology, link costs c(x,y): link cost from node
known to all nodes x to y; = if not direct
neighbors
accomplished via link state
broadcast D(v): current value of cost
all nodes have same info
of path from source to dest.
v
computes least cost paths p(v): predecessor node
from one node (source) along path from source to v
to all other nodes N': set of nodes whose
gives forwarding table for least cost path deni7vely
that node known
itera7ve: aher k
itera7ons, know least cost
Network Layer 4-9
path to k dest.s
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
D(v) D(w) D(x) D(y) D(z)
Step N' p(v) p(w) p(x) p(y) p(z)
0 u 7,u 3,u 5,u
1 uw 6,w 5,u 11,w
2 uwx 6,w 11,w 14,x
3 uwxv 10,v 14,x
4 uwxvy 12,y x
5 uwxvyz 9

5 7
notes: 4
construct shortest path tree by 8
tracing predecessor nodes 3 w z
u y
ties can exist (can be broken 2
arbitrarily) 3
7 4
v
Network Layer 4-11
Dijkstras algorithm: another example
Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)
0 u 2,u 5,u 1,u
1 ux 2,u 4,x 2,x
2 uxy 2,u 3,y 4,y
3 uxyv 3,y 4,y
4 uxyvw 4,y
5 uxyvwz

5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y

Network Layer 4-12


Dijkstras algorithm: example (2)
resulting shortest-path tree from u:

v w
u z
x y

resulting forwarding table in u:


des7na7on link
v (u,v)
x (u,x)
y (u,x)
w (u,x)
z (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:

1
A 1+e A A A
2+e 0 0 2+e 2+e 0
D 0 0 B D 1+e 1 B D B D 1+e 1 B
0 0
0 e 0
1
C C 0 1
C 1+e
0
C 0
1
e
ini7ally 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
3
clearly, dv(z) = 5, dx(z) = 3, dw(z) = 3
v w 5
2
u 2 1 z B-F equa7on 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

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: wait for (change in local link
local link cost change cost or msg from neighbor)
DV update message from
neighbor
recompute es7mates
distributed:
each node no7es
if DV to any dest has changed,
neighbors only when its
no6fy neighbors
DV changes
neighbors then no7fy their
neighbors if necessary
Network Layer 4-19
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} Dx(z) = min{c(x,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
table x y z x y z
x 0 2 7 x 0 2 3

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
7
from

y 2 0 1
z

node z cost to
table x y z
x
from

y
z 7 1 0
7me
Network Layer 4-20
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)} Dx(z) = min{c(x,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

node y cost to cost to cost to


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

from

y 2 0 1 y 2 0 1

from
y 2 0 1
z z 7 1 0 z 3 1 0

cost to cost to
node z cost to
x y z x y z
table x y z
x x 0 2 7 x 0 2 3
from

from
y 2 0 1 y 2 0 1
from

y
z z 3 1 0 z 3 1 0
7 1 0
7me
Network Layer 4-21
Distance vector: link cost changes

link cost changes: 1


node detects local link cost change y
4 1
updates routing info, recalculates x z
50
distance vector
if DV changes, notify neighbors

good t0 : y detects link-cost change, updates its DV, informs its neighbors.
news
travels t1 : z receives update from y, updates its table, computes new least
fast 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 robustness: what happens if
LS: with n nodes, E links, O(nE) router malfunc7ons?
msgs sent LS:
DV: exchange between neighbors node can adver7se incorrect
only link cost
convergence 7me varies each node computes only its
own table
speed of convergence
DV:
LS: O(n2) algorithm requires O(nE)
msgs DV node can adver7se
incorrect path cost
may have oscilla7ons
each nodes table used by
DV: convergence 7me varies
others
may be rou7ng loops error propagate thru
count-to-innity problem network
Network Layer 4-23
Hierarchical rou7ng
our routing study thus far - idealization
all routers identical
network flat

not true in practice

scale: with 600 million administra6ve autonomy


des7na7ons: internet = network of
cant store all dests in networks
rou7ng tables! each network admin may
rou7ng table exchange want to control rou7ng in
would swamp links! its own network

Network Layer 4-24


Hierarchical rou7ng
aggregate routers into gateway router:
regions, autonomous at edge of its own AS
systems (AS) has link to router in
routers in same AS run another AS
same rou7ng protocol
intra-AS rou7ng
protocol
routers in dierent AS
can run dierent intra-
AS rou7ng protocol

Network Layer 4-25


Interconnected ASes

3c
3a 2c
3b 2a
AS3 2b
1c AS2
1a 1b AS1
1d
forwarding table
congured by both intra-
Intra-AS Inter-AS
and inter-AS rou7ng
Rou7ng
algorithm
Rou7ng
algorithm
algorithm
intra-AS sets entries
Forwarding
table for internal dests
inter-AS & intra-AS sets
entries for external
Network Layer dests 4-26
Inter-AS tasks
suppose router in AS1 AS1 must:
receives datagram 1. learn which dests are
des7ned outside of AS1: reachable through AS2,
router should forward which through AS3
packet to gateway 2. propagate this
router, but which one? reachability info to all
routers in AS1
job of inter-AS rou6ng!
3c
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 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)
3c
x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
Network Layer 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!

3c
x
3a
3b
AS3 2c other
1c 2a networks
other 1a 2b
networks 1b AS2
AS1 1d
?
Network Layer 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.

use rou7ng info determine from


learn from inter-AS hot potato rou7ng: forwarding table the
from intra-AS
protocol that subnet choose the gateway interface I that leads
protocol to determine
x is reachable via costs of least-cost that has the to least-cost gateway.
mul7ple gateways smallest least cost Enter (x,I) in
paths to each
of the gateways forwarding table

Network Layer 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

You might also like