# Routing Algorithms

Networking and Communications

Jul 13, 2012 (5 years and 10 months ago)

352 views

1
StanKurkovsky
Computer NetworksComputer Networks
Routing AlgorithmsRouting Algorithms
BasedonComputerNetworking,4
th
EditionbyKuroseandRoss
StanKurkovsky
Interplay between routing, forwardingInterplay between routing, forwarding
1
2
3
0111
valueinarriving
routingalgorithm
localforwardingtable
0100
0101
0111
1001
3221
2
StanKurkovsky
Graph abstractionGraph abstraction
•• Graph:G=(N,E)Graph:G=(N,E)
•• N=setofrouters={u,v,w,x,y,z}N=setofrouters={u,v,w,x,y,z}
(y,z)}(y,z)}
•• Remark:GraphabstractionisusefulinothernetworkcontextsRemark:Graphabstractionisusefulinothernetworkcontexts
•• Example:P2P,whereNissetofpeersandEissetofTCPconnectionsExample:P2P,whereNissetofpeersandEissetofTCPconnections
u
y
x
w
v
z
2
2
1
3
1
1
2
5
3
5
StanKurkovsky
Graph abstraction: costsGraph abstraction: costs
,,e.g.,c(w,z)=5e.g.,c(w,z)=5
•• costcouldalwaysbe1,costcouldalwaysbe1,
orinverselyrelatedtobandwidth,orinverselyrelatedtobandwidth,
orinverselyrelatedtocongestionorinverselyrelatedtocongestion
•• Costofpath(xCostofpath(x
11
,x,x
22
,x,x
33
,…,x,…,x
pp
)=c(x)=c(x
11
,x,x
22
)+c(x)+c(x
22
,x,x
33
)+…+c(x)+…+c(x
pp,,11
,x,x
pp
))
•• Question:What’stheleastQuestion:What’stheleast,,costpathbetweenuandz?costpathbetweenuandz?
•• Routingalgorithm:algorithmthatfindsleastRoutingalgorithm:algorithmthatfindsleast,,costpathcostpath
u
y
x
w
v
z
2
2
1
3
1
1
2
5
3
5
3
StanKurkovsky
Routing Algorithm classificationRouting Algorithm classification
Global or decentralized Global or decentralized
information?information?
Global:Global:
•• allroutershavecompleteallroutershavecomplete
••
Decentralized:Decentralized:
•• routerknowsphysicallyrouterknowsphysically,,
toneighborstoneighbors
•• iterativeprocessofcomputation,iterativeprocessofcomputation,
exchangeofinfowithneighborsexchangeofinfowithneighbors
••
“distancevector”algorithms“distancevector”algorithms
Static or dynamic?Static or dynamic?
Static:Static:
•• routeschangeslowlyovertimerouteschangeslowlyovertime
Dynamic:Dynamic:
•• routeschangemorequicklyrouteschangemorequickly
•• periodicupdateperiodicupdate
changeschanges
StanKurkovsky
Dijkstra’sDijkstra’s algorithmalgorithm
•• allnodeshavesameinfoallnodeshavesameinfo
•• computesleastcostpathsfromonenode(‘source”)toallothernodescomputesleastcostpathsfromonenode(‘source”)toallothernodes
•• givesgives
forwardingtableforwardingtable
forthatnodeforthatnode
•• iterative:afterkiterations,knowleastcostpathtokdestinationsiterative:afterkiterations,knowleastcostpathtokdestinations
Notation:Notation:
••
c(c(x,yx,y):):
••
D(v):D(v):
currentvalueofcostofpathfromsourcetocurrentvalueofcostofpathfromsourcetodestdest.v.v
••
p(v):p(v):
predecessornodealongpathfromsourcetovpredecessornodealongpathfromsourcetov
••
NN''::
setofnodeswhoseleastcostpathdefinitivelyknownsetofnodeswhoseleastcostpathdefinitivelyknown
4
StanKurkovsky
Dijsktra’s AlgorithmDijsktra’s Algorithm
1
Initialization:
2N'={u}
3forallnodesv
5thenD(v)=c(u,v)
6elseD(v)=∞
7
8
Loop
9findwnotinN'suchthatD(w)isaminimum
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
until all nodes in N'
StanKurkovsky
Dijkstra’s algorithm: exampleDijkstra’s algorithm: example
Step
012345
N'
u
ux
uxy
uxyv
uxyvw
uxyvwz
D(v),p(v)
2,u
2,u
2,u
D(w),p(w)
5,u
4,x
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
u
y
x
w
v
z
2
2
1
3
1
1
2
5
3
5
5
StanKurkovsky
Dijkstra’s algorithm: example (2)Dijkstra’s algorithm: example (2)
u
y
x
w
v
z
Resultingshortest,pathtreefromu:
v
x
y
w
z
(u,v)
(u,x)
(u,x)
(u,x)
(u,x)
destination
Resultingforwardingtableinu:
StanKurkovsky
Dijkstra’s algorithm, discussionDijkstra’s algorithm, discussion
Algorithmcomplexity:Algorithmcomplexity:
nnodesnnodes
•• eachiteration:needtocheckallnodes,w,notinNeachiteration:needtocheckallnodes,w,notinN
•• n(n+1)/2comparisons:O(nn(n+1)/2comparisons:O(n
22
))
•• moreefficientimplementationspossible:O(nlogn)moreefficientimplementationspossible:O(nlogn)
Oscillationspossible:Oscillationspossible:
A
D
C
B
1
1+e
e
0
e
1
1
0
0
A
D
C
B
2+e
0
0
0
1+e1
A
D
C
B
0
2+e
1+e1
0
0
A
D
C
B
2+e
0
e
0
1+e1
initially
…recompute
routing
…recompute
…recompute
6
StanKurkovsky
Distance Vector AlgorithmDistance Vector Algorithm
BellmanBellman,,FordEquation(dynamicprogramming)FordEquation(dynamicprogramming)
•• DefineDefine
dd
xx
(y):=costofleast(y):=costofleast,,costpathfromxtoycostpathfromxtoy
•• ThenThen
dd
xx
(y)=min{c(x,v)+d(y)=min{c(x,v)+d
vv
(y)}(y)}
whereministakenoverallneighborsvofxwhereministakenoverallneighborsvofx
StanKurkovsky
BellmanBellman--Ford exampleFord example
u
y
x
w
v
z
2
2
1
3
1
1
2
5
3
5
Clearly,d
v
(z)=5,d
x
(z)=3,d
w
(z)=3
d
u
(z)=min{c(u,v)+d
v
(z),
c(u,x)+d
x
(z),
c(u,w)+d
w
(z)}
=min{2+5,
1+3,
5+3}=4
Nodethatachievesminimumisnext
hopinshortestpath➜ forwardingtable
B,Fequationsays:
7
StanKurkovsky
Distance Vector AlgorithmDistance Vector Algorithm
••
DD
xx
(y)(y)
=estimateofleastcostfromxtoy=estimateofleastcostfromxtoy
•• Distancevector:Distancevector:
DD
xx
=[D=[D
xx
(y):y(y):yєє N]N]
•• Nodexknowscosttoeachneighborv:Nodexknowscosttoeachneighborv:
c(x,v)c(x,v)
•• NodexmaintainsNodexmaintains
DD
xx
=[D=[D
xx
(y):y(y):yєє N]N]
•• Nodexalsomaintainsitsneighbors’distancevectorsNodexalsomaintainsitsneighbors’distancevectors
•• Foreachneighborv,xmaintainsForeachneighborv,xmaintains
DD
vv
=[D=[D
vv
(y):y(y):yєє N]N]
Basicidea:Basicidea:
•• EachnodeperiodicallysendsitsowndistancevectorestimatetoEachnodeperiodicallysendsitsowndistancevectorestimateto
neighborsneighbors
ownDVusingBownDVusingB,,Fequation:Fequation:
Dx(y)

minv{c(x,v)+Dv(y)}foreachnodey∊N
•• Underminor,naturalconditions,theestimateUnderminor,naturalconditions,theestimateDx(y)convergetotheDx(y)convergetothe
actualleastcostactualleastcostdx(y)dx(y)
StanKurkovsky
Distance Vector AlgorithmDistance Vector Algorithm
Iterative,asynchronous:Iterative,asynchronous:
eacheach
localiterationcausedby:localiterationcausedby:
•• DVupdatemessagefromDVupdatemessagefrom
neighborneighbor
Distributed:Distributed:
•• eachnodenotifiesneighborseachnodenotifiesneighbors
onlyonly
whenitsDVchangeswhenitsDVchanges
•• neighborsthennotifytheirneighborsthennotifytheir
neighborsifnecessaryneighborsifnecessary
Eachnode:Eachnode:
wait
costofmsgfromneighbor)
recompute
estimates
ifDVtoanydesthas
changed,
notify
neighbors
8
StanKurkovsky
distancevectordistancevector
•• ifDVchanges,notifyneighborsifDVchanges,notifyneighbors
••
“Goodnewstravelsfast”“Goodnewstravelsfast”
•• AttimeAttime
tt
00
,,
yy
neighbors.neighbors.
•• AttimeAttime
tt
11
,,
zz
yy
newleastcosttonewleastcostto
xx
andsendsitsneighborsitsDV.andsendsitsneighborsitsDV.
•• AttimeAttime
tt
22
,,
yy
zz
yy
’sleastcosts’sleastcosts
donotchangeandhencedonotchangeandhence
yy
doesdoes
notnot
sendanymessagetosendanymessageto
zz
..
x
z
14
50
y
1
StanKurkovsky
•• goodnewstravelsfastgoodnewstravelsfast
•• 44iterationsbeforealgorithmstabilizes44iterationsbeforealgorithmstabilizes
Poissonedreverse:Poissonedreverse:
•• IfZroutesthroughYtogettoX:IfZroutesthroughYtogettoX:
•• ZtellsYits(Z’s)distancetoXisinfinite(soYwon’troutetoXviaZ)ZtellsYits(Z’s)distancetoXisinfinite(soYwon’troutetoXviaZ)
•• willthiscompletelysolvecounttoinfinityproblem?willthiscompletelysolvecounttoinfinityproblem?
x
z
14
50
y
60
9
Distance VectorDistance Vector: example: example
StanKurkovsky
x y z
xyz
0 27
∞ ∞ ∞
∞ ∞ ∞
from
costto
fromfrom
xyz
xyz
023
from
costto
xyz
xyz
023
from
costto
x y z
xyz
∞ ∞
∞ ∞ ∞
costto
x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to
xyz
xyz
027
from
costto
x yz
xyz
∞ ∞ ∞
7 1 0
costto
20 1
∞ ∞∞
201
710
201
710
201
310
201
310
201
310
201
310
time
x
z
12
7
y
node x table
node y table
node z table
D
x
(y) = min{c(x,y) + D
y
(y),c(x,z) + D
z
(y)}
= min{2+0,7+1} = 2
D
x
(z) = min{c(x,y) +
D
y
(z),c(x,z) + D
z
(z)}
= min{2+1,7+0} = 3

StanKurkovsky
Comparison of LS and DV algorithmsComparison of LS and DV algorithms
MessagecomplexityMessagecomplexity
••
LS:LS:
msgssentmsgssent
••
DV:DV:
exchangebetweenneighborsexchangebetweenneighbors
onlyonly
•• convergencetimevariesconvergencetimevaries
SpeedofConvergenceSpeedofConvergence
••
LS:LS:
O(nO(n
22
)algorithmrequires)algorithmrequires
O(nE)msgsO(nE)msgs
•• mayhaveoscillationsmayhaveoscillations
••
DVDV
:convergencetimevaries:convergencetimevaries
•• mayberoutingloopsmayberoutingloops
•• countcount,,toto,,infinityprobleminfinityproblem
Robustness:Robustness:
whathappensifrouterwhathappensifrouter
malfunctions?malfunctions?
LS:LS:
costcost
•• eachnodecomputesonlyitseachnodecomputesonlyits
ownown
tabletable
DV:DV:
pathpath
costcost
•• eachnode’stableusedbyotherseachnode’stableusedbyothers
•• errorpropagatethrunetworkerrorpropagatethrunetwork
10
StanKurkovsky
Hierarchical RoutingHierarchical Routing
OurroutingstudythusfarOurroutingstudythusfar,,idealizationidealization
•• allroutersidentical;network“flat”allroutersidentical;network“flat”￿￿
…not…not
trueinpracticetrueinpractice
scale:scale:
with200milliondestinations:with200milliondestinations:
•• can’tstorealldest’sinroutingtables!can’tstorealldest’sinroutingtables!
•• internet=networkofnetworksinternet=networkofnetworks
•• aggregateroutersintoregions,aggregateroutersintoregions,
“autonomoussystems”(AS)“autonomoussystems”(AS)
•• routersinsameASrunsameroutingprotocolroutersinsameASrunsameroutingprotocol
••
“intra“intra,,AS”routingAS”routing
protocolprotocol
•• routersindifferentAScanrundifferentintraroutersindifferentAScanrundifferentintra,,ASroutingprotocolASroutingprotocol
GatewayrouterGatewayrouter
StanKurkovsky
Interconnected ASesInterconnected ASes
•• ForwardingtableisconfiguredbybothintraForwardingtableisconfiguredbybothintra,,andinterandinter,,ASroutingASrouting
algorithmalgorithm
•• IntraIntra,,ASsetsentriesforinternaldestsASsetsentriesforinternaldests
•• InterInter,,AS&IntraAS&Intra,,AssetsentriesforexternaldestsAssetsentriesforexternaldests
3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
Intra:AS
Routing
algorithm
Inter:AS
Routing
algorithm
Forwarding
table
3c
11
StanKurkovsky
•• Routershouldforwardpackettowardsoneofthegatewayrouters,butwhichRoutershouldforwardpackettowardsoneofthegatewayrouters,butwhich
one?one?
AS1needs:AS1needs:
1.1.tolearnwhichdestsarereachablethroughAS2andwhichthroughAS3tolearnwhichdestsarereachablethroughAS2andwhichthroughAS3
2.2.topropagatethisreachabilityinfotoallroutersinAS1topropagatethisreachabilityinfotoallroutersinAS1
JobofinterJobofinter,,ASrouting!ASrouting!
3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
3c