Routing Algorithms

dicedknockemstiffNetworking and Communications

Jul 13, 2012 (4 years and 11 months ago)

334 views

1
StanKurkovsky
Computer NetworksComputer Networks
Routing AlgorithmsRouting Algorithms
BasedonComputerNetworking,4
th
EditionbyKuroseandRoss
StanKurkovsky
Interplay between routing, forwardingInterplay between routing, forwarding
1
2
3
0111
valueinarriving
packet’sheader
routingalgorithm
localforwardingtable
headervalue outputlink
0100
0101
0111
1001
3221
2
StanKurkovsky
Graph abstractionGraph abstraction
•• Graph:G=(N,E)Graph:G=(N,E)
•• N=setofrouters={u,v,w,x,y,z}N=setofrouters={u,v,w,x,y,z}
•• E=setoflinks={(u,v),(u,x),(v,x),(v,w),(x,w),(x,y),(w,y),(w,z),E=setoflinks={(u,v),(u,x),(v,x),(v,w),(x,w),(x,y),(w,y),(w,z),
(y,z)}(y,z)}
•• Remark:GraphabstractionisusefulinothernetworkcontextsRemark:Graphabstractionisusefulinothernetworkcontexts
•• Example:P2P,whereNissetofpeersandEissetofTCPconnectionsExample:P2P,whereNissetofpeersandEissetofTCPconnections
u
y
x
w
v
z
2
2
1
3
1
1
2
5
3
5
StanKurkovsky
Graph abstraction: costsGraph abstraction: costs
•• c(x,x’)=costoflink(x,x’)c(x,x’)=costoflink(x,x’)
,,e.g.,c(w,z)=5e.g.,c(w,z)=5
•• costcouldalwaysbe1,costcouldalwaysbe1,
orinverselyrelatedtobandwidth,orinverselyrelatedtobandwidth,
orinverselyrelatedtocongestionorinverselyrelatedtocongestion
•• Costofpath(xCostofpath(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’stheleastQuestion:What’stheleast,,costpathbetweenuandz?costpathbetweenuandz?
•• Routingalgorithm:algorithmthatfindsleastRoutingalgorithm:algorithmthatfindsleast,,costpathcostpath
u
y
x
w
v
z
2
2
1
3
1
1
2
5
3
5
3
StanKurkovsky
Routing Algorithm classificationRouting Algorithm classification
Global or decentralized Global or decentralized
information?information?
Global:Global:
•• allroutershavecompleteallroutershavecomplete
topology,linkcostinfotopology,linkcostinfo
••
“linkstate”algorithms“linkstate”algorithms
Decentralized:Decentralized:
•• routerknowsphysicallyrouterknowsphysically,,
connectedneighbors,linkcostsconnectedneighbors,linkcosts
toneighborstoneighbors
•• iterativeprocessofcomputation,iterativeprocessofcomputation,
exchangeofinfowithneighborsexchangeofinfowithneighbors
••
“distancevector”algorithms“distancevector”algorithms
Static or dynamic?Static or dynamic?
Static:Static:
•• routeschangeslowlyovertimerouteschangeslowlyovertime
Dynamic:Dynamic:
•• routeschangemorequicklyrouteschangemorequickly
•• periodicupdateperiodicupdate
•• inresponsetolinkcostinresponsetolinkcost
changeschanges
StanKurkovsky
A LinkA Link--State Routing AlgorithmState Routing Algorithm
Dijkstra’sDijkstra’s algorithmalgorithm
•• nettopology,linkcostsknowntoallnodesnettopology,linkcostsknowntoallnodes
•• accomplishedvia“linkstatebroadcast”accomplishedvia“linkstatebroadcast”
•• allnodeshavesameinfoallnodeshavesameinfo
•• computesleastcostpathsfromonenode(‘source”)toallothernodescomputesleastcostpathsfromonenode(‘source”)toallothernodes
•• givesgives
forwardingtableforwardingtable
forthatnodeforthatnode
•• iterative:afterkiterations,knowleastcostpathtokdestinationsiterative:afterkiterations,knowleastcostpathtokdestinations
Notation:Notation:
••
c(c(x,yx,y):):
linkcostfromnodextoy;=∞ifnotdirectneighborslinkcostfromnodextoy;=∞ifnotdirectneighbors
••
D(v):D(v):
currentvalueofcostofpathfromsourcetocurrentvalueofcostofpathfromsourcetodestdest.v.v
••
p(v):p(v):
predecessornodealongpathfromsourcetovpredecessornodealongpathfromsourcetov
••
NN''::
setofnodeswhoseleastcostpathdefinitivelyknownsetofnodeswhoseleastcostpathdefinitivelyknown
4
StanKurkovsky
Dijsktra’s AlgorithmDijsktra’s Algorithm
1
Initialization:
2N'={u}
3forallnodesv
4ifvadjacenttou
5thenD(v)=c(u,v)
6elseD(v)=∞
7
8
Loop
9findwnotinN'suchthatD(w)isaminimum
10addwtoN'
11updateD(v)forallvadjacenttowandnotinN':
12
D(v)=min(D(v),D(w)+c(w,v))
13/*newcosttoviseitheroldcosttovorknown
14shortestpathcosttowpluscostfromwtov*/
15
until all nodes in N'
StanKurkovsky
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
StanKurkovsky
Dijkstra’s algorithm: example (2)Dijkstra’s algorithm: example (2)
u
y
x
w
v
z
Resultingshortest,pathtreefromu:
v
x
y
w
z
(u,v)
(u,x)
(u,x)
(u,x)
(u,x)
destination
link
Resultingforwardingtableinu:
StanKurkovsky
Dijkstra’s algorithm, discussionDijkstra’s algorithm, discussion
Algorithmcomplexity:Algorithmcomplexity:
nnodesnnodes
•• eachiteration:needtocheckallnodes,w,notinNeachiteration:needtocheckallnodes,w,notinN
•• n(n+1)/2comparisons:O(nn(n+1)/2comparisons:O(n
22
))
•• moreefficientimplementationspossible:O(nlogn)moreefficientimplementationspossible:O(nlogn)
Oscillationspossible:Oscillationspossible:
•• e.g.,linkcost=amountofcarriedtraffice.g.,linkcost=amountofcarriedtraffic
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
StanKurkovsky
Distance Vector AlgorithmDistance Vector Algorithm
BellmanBellman,,FordEquation(dynamicprogramming)FordEquation(dynamicprogramming)
•• DefineDefine
dd
xx
(y):=costofleast(y):=costofleast,,costpathfromxtoycostpathfromxtoy
•• ThenThen
dd
xx
(y)=min{c(x,v)+d(y)=min{c(x,v)+d
vv
(y)}(y)}
whereministakenoverallneighborsvofxwhereministakenoverallneighborsvofx
StanKurkovsky
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
Nodethatachievesminimumisnext
hopinshortestpath➜ forwardingtable
B,Fequationsays:
7
StanKurkovsky
Distance Vector AlgorithmDistance Vector Algorithm
••
DD
xx
(y)(y)
=estimateofleastcostfromxtoy=estimateofleastcostfromxtoy
•• Distancevector:Distancevector:
DD
xx
=[D=[D
xx
(y):y(y):yєє N]N]
•• Nodexknowscosttoeachneighborv:Nodexknowscosttoeachneighborv:
c(x,v)c(x,v)
•• NodexmaintainsNodexmaintains
DD
xx
=[D=[D
xx
(y):y(y):yєє N]N]
•• Nodexalsomaintainsitsneighbors’distancevectorsNodexalsomaintainsitsneighbors’distancevectors
•• Foreachneighborv,xmaintainsForeachneighborv,xmaintains
DD
vv
=[D=[D
vv
(y):y(y):yєє N]N]
Basicidea:Basicidea:
•• EachnodeperiodicallysendsitsowndistancevectorestimatetoEachnodeperiodicallysendsitsowndistancevectorestimateto
neighborsneighbors
•• WhenanodexreceivesnewDVestimatefromneighbor,itupdatesitsWhenanodexreceivesnewDVestimatefromneighbor,itupdatesits
ownDVusingBownDVusingB,,Fequation:Fequation:
Dx(y)

minv{c(x,v)+Dv(y)}foreachnodey∊N
•• Underminor,naturalconditions,theestimateUnderminor,naturalconditions,theestimateDx(y)convergetotheDx(y)convergetothe
actualleastcostactualleastcostdx(y)dx(y)
StanKurkovsky
Distance Vector AlgorithmDistance Vector Algorithm
Iterative,asynchronous:Iterative,asynchronous:
eacheach
localiterationcausedby:localiterationcausedby:
•• locallinkcostchangelocallinkcostchange
•• DVupdatemessagefromDVupdatemessagefrom
neighborneighbor
Distributed:Distributed:
•• eachnodenotifiesneighborseachnodenotifiesneighbors
onlyonly
whenitsDVchangeswhenitsDVchanges
•• neighborsthennotifytheirneighborsthennotifytheir
neighborsifnecessaryneighborsifnecessary
Eachnode:Eachnode:
wait
for(changeinlocallink
costofmsgfromneighbor)
recompute
estimates
ifDVtoanydesthas
changed,
notify
neighbors
8
StanKurkovsky
Distance Vector: link cost changesDistance Vector: link cost changes
Linkcostchanges:Linkcostchanges:
•• nodedetectslocallinkcostchangenodedetectslocallinkcostchange
•• updatesroutinginfo,recalculatesupdatesroutinginfo,recalculates
distancevectordistancevector
•• ifDVchanges,notifyneighborsifDVchanges,notifyneighbors
••
“Goodnewstravelsfast”“Goodnewstravelsfast”
•• AttimeAttime
tt
00
,,
yy
detectsthelinkdetectsthelink,,costchange,updatesitsDV,andinformsitscostchange,updatesitsDV,andinformsits
neighbors.neighbors.
•• AttimeAttime
tt
11
,,
zz
receivestheupdatefromreceivestheupdatefrom
yy
andupdatesitstable.Itcomputesaandupdatesitstable.Itcomputesa
newleastcosttonewleastcostto
xx
andsendsitsneighborsitsDV.andsendsitsneighborsitsDV.
•• AttimeAttime
tt
22
,,
yy
receivesreceives
zz
’supdateandupdatesitsdistancetable.’supdateandupdatesitsdistancetable.
yy
’sleastcosts’sleastcosts
donotchangeandhencedonotchangeandhence
yy
doesdoes
notnot
sendanymessagetosendanymessageto
zz
..
x
z
14
50
y
1
StanKurkovsky
Distance Vector: link cost changesDistance Vector: link cost changes
Linkcostchanges:Linkcostchanges:
•• goodnewstravelsfastgoodnewstravelsfast
•• badnewstravelsslowbadnewstravelsslow,,“counttoinfinity”problem!“counttoinfinity”problem!
•• 44iterationsbeforealgorithmstabilizes44iterationsbeforealgorithmstabilizes
Poissonedreverse:Poissonedreverse:
•• IfZroutesthroughYtogettoX:IfZroutesthroughYtogettoX:
•• ZtellsYits(Z’s)distancetoXisinfinite(soYwon’troutetoXviaZ)ZtellsYits(Z’s)distancetoXisinfinite(soYwon’troutetoXviaZ)
•• willthiscompletelysolvecounttoinfinityproblem?willthiscompletelysolvecounttoinfinityproblem?
x
z
14
50
y
60
9
Distance VectorDistance Vector: example: example
StanKurkovsky
x y z
xyz
0 27
∞ ∞ ∞
∞ ∞ ∞
from
costto
fromfrom
xyz
xyz
023
from
costto
xyz
xyz
023
from
costto
x y z
xyz
∞ ∞
∞ ∞ ∞
costto
xyz
xyz
027
from
costto
xyz
xyz
023
from
costto
xyz
xyz
023
from
costto
xyz
xyz
027
from
costto
x yz
xyz
∞ ∞ ∞
7 1 0
costto
20 1
∞ ∞∞
201
710
201
710
201
310
201
310
201
310
201
310
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

StanKurkovsky
Comparison of LS and DV algorithmsComparison of LS and DV algorithms
MessagecomplexityMessagecomplexity
••
LS:LS:
withnnodes,Elinks,O(nE)withnnodes,Elinks,O(nE)
msgssentmsgssent
••
DV:DV:
exchangebetweenneighborsexchangebetweenneighbors
onlyonly
•• convergencetimevariesconvergencetimevaries
SpeedofConvergenceSpeedofConvergence
••
LS:LS:
O(nO(n
22
)algorithmrequires)algorithmrequires
O(nE)msgsO(nE)msgs
•• mayhaveoscillationsmayhaveoscillations
••
DVDV
:convergencetimevaries:convergencetimevaries
•• mayberoutingloopsmayberoutingloops
•• countcount,,toto,,infinityprobleminfinityproblem
Robustness:Robustness:
whathappensifrouterwhathappensifrouter
malfunctions?malfunctions?
LS:LS:
•• nodecanadvertiseincorrectnodecanadvertiseincorrect
linklink
costcost
•• eachnodecomputesonlyitseachnodecomputesonlyits
ownown
tabletable
DV:DV:
•• DVnodecanadvertiseincorrectDVnodecanadvertiseincorrect
pathpath
costcost
•• eachnode’stableusedbyotherseachnode’stableusedbyothers
•• errorpropagatethrunetworkerrorpropagatethrunetwork
10
StanKurkovsky
Hierarchical RoutingHierarchical Routing
OurroutingstudythusfarOurroutingstudythusfar,,idealizationidealization
•• allroutersidentical;network“flat”allroutersidentical;network“flat”￿￿
…not…not
trueinpracticetrueinpractice
scale:scale:
with200milliondestinations:with200milliondestinations:
•• can’tstorealldest’sinroutingtables!can’tstorealldest’sinroutingtables!
•• routingtableexchangewouldswamplinks!routingtableexchangewouldswamplinks!
administrativeautonomyadministrativeautonomy
•• internet=networkofnetworksinternet=networkofnetworks
•• eachnetworkadminmaywanttocontrolroutinginitsownnetworkeachnetworkadminmaywanttocontrolroutinginitsownnetwork
•• aggregateroutersintoregions,aggregateroutersintoregions,
“autonomoussystems”(AS)“autonomoussystems”(AS)
•• routersinsameASrunsameroutingprotocolroutersinsameASrunsameroutingprotocol
••
“intra“intra,,AS”routingAS”routing
protocolprotocol
•• routersindifferentAScanrundifferentintraroutersindifferentAScanrundifferentintra,,ASroutingprotocolASroutingprotocol
GatewayrouterGatewayrouter
•• DirectlinktorouterinanotherASDirectlinktorouterinanotherAS
StanKurkovsky
Interconnected ASesInterconnected ASes
•• ForwardingtableisconfiguredbybothintraForwardingtableisconfiguredbybothintra,,andinterandinter,,ASroutingASrouting
algorithmalgorithm
•• IntraIntra,,ASsetsentriesforinternaldestsASsetsentriesforinternaldests
•• InterInter,,AS&IntraAS&Intra,,AssetsentriesforexternaldestsAssetsentriesforexternaldests
3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
Intra:AS
Routing
algorithm
Inter:AS
Routing
algorithm
Forwarding
table
3c
11
StanKurkovsky
InterInter--AS tasksAS tasks
•• SupposerouterinAS1receivesdatagramforwhichdestisoutsideofAS1SupposerouterinAS1receivesdatagramforwhichdestisoutsideofAS1
•• Routershouldforwardpackettowardsoneofthegatewayrouters,butwhichRoutershouldforwardpackettowardsoneofthegatewayrouters,butwhich
one?one?
AS1needs:AS1needs:
1.1.tolearnwhichdestsarereachablethroughAS2andwhichthroughAS3tolearnwhichdestsarereachablethroughAS2andwhichthroughAS3
2.2.topropagatethisreachabilityinfotoallroutersinAS1topropagatethisreachabilityinfotoallroutersinAS1
JobofinterJobofinter,,ASrouting!ASrouting!
3b
1d
3a
1c
2a
AS3
AS1
AS2
1a
2c
2b
1b
3c