CEN 445 - Routing Algorithms

CEN445 – Network Protocols and Algorithms
Chapter 5 – Network Layer
5.2 Routing Algorithms
Dr.MostafaHassanDahshan
DepartmentofComputerEngineering
CollegeofComputerandInformationSciences
KingSaudUniversity
[email protected]
http://faculty.ksu.edu.sa/mdahshan
Routing Algorithms


Routing– mainfunctionofnetworklayer
Routingalgorithm



decideswhichoutputlineincomingpacket
shouldbetransmittedon
fillsupandupdatesroutingtables
Forwarding

lookuptheroutingtablesandputthepacketin
theappropriateoutputline
2
Desired Properties






Correctness
Simplicity
Robustness:abilitytohandlefailures
Stability:convergetoequilibrium
Fairness
Possible Conflict
Optimality
3
Two Major Classes

Non‐adaptive/staticrouting



routingdecisionsnotbasedontraffic,topology
instead,routesarecomputedinadvance
Adaptiverouting


Changetheirdecisionstoreflectchangesinthe
topologyandtraffic
Differin:informationsource,updatefrequency
andoptimizationmetrics
4
Optimality Principle



IfrouterJ isontheoptimalpathfrom
routerI torouterK,thentheoptimalpath
fromJ toK alsofallsalongthesameroute
Setofoptimalroutesfromallsourcestoa
givendestinationformatreerootedat
thedestination“sinktree”
Goalofallroutingalgorithms:discover
andusesinktreeforallrouters
5
The Optimality Principle
Eachportionofabestpathisalsoabestpath;theunion
ofthemtoarouterisatreecalledthesinktree

Bestmeansfewesthopsintheexample
B
Network
Sink tree of best paths to router B
Shortest Path Routing




Buildagraphofnetwork
Eachnoderepresentarouter
Eacharcrepresentalink
Findshortestpathbetweenthetwonodes
7
Shortest Path Routing

Eacharcislabeledwithaweight





numberofhops
geographicdistance
meanqueuing/transmissiondelay
bandwidth
cost
8
Dijkstra’s Algorithm




Findsshortestpathsfromgivensource
nodes toallothernodes
Developspathsinorderofincreasingpath
length
Runsinstages,eachtimeaddingnodewith
nextshortestpath
algorithm terminateswhenallnodes
processedbyalgorithm(insetT)
9
Dijkstra’s Algorithm

Step1[Initialization]



T ={s} Setofnodessofarincorporated
L(n)=w(s,n)forn ≠s
initial pathcoststoneighboringnodesare
simplylinkcosts
10
Dijkstra’s Algorithm

Step2 [GetNextNode]




findneighboringnodenotinT with least‐costpath
froms
incorporatenodeintoT(nodemarkedaspermanent)
alsoincorporatetheedgethatisincidentonthatnode
andanodeinT thatcontributestothepath
Step3 [UpdateLeast‐CostPaths]


L(n)=min[L(n),L(x)+w(x,n)] foralln  T
iflattertermisminimum,pathfroms ton ispathfroms
tox concatenatedwithedgefromx ton
11
Dijkstra’s Algorithm
8
5
C
3
5
6
B
8
2
3
2
A
G
3
3
1
1
2
1
4
7
1
D
1
F
12
Dijkstra’s Algorithm
C
8
5
∞
3
B
5
6
∞
8
2
A
∞ F
3
3
1
3
2
0
1
2
1
4
7
1
∞
D
T={A}
∞
1
E
13
Dijkstra’s Algorithm
C
8
5
5
3
B
5
6
2
8
2
A
3
2
0
∞ F
3
3
1
1
2
1
4
7
T={A}
1
1
D
1
∞
E
14
Dijkstra’s Algorithm
C
8
5
4
3
B
5
6
2
8
2
A
∞ F
3
3
1
3
2
0
1
2
1
4
7
1
1
D
T={A,D}
2
1
E
15
Dijkstra’s Algorithm
C
8
5
4
3
B
5
6
2
8
2
A
3
2
0
∞ F
3
3
1
1
2
1
4
7
T={A,B,D}
1
1
D
1
2
E
16
Dijkstra’s Algorithm
C
8
5
3
3
B
5
6
2
8
2
A
4 F
3
3
1
3
2
0
1
2
1
4
7
1
1
D
T={A,B,D,E}
2
1
E
17
Dijkstra’s Algorithm
C
8
5
3
3
B
5
6
2
8
2
A
3
2
0
4 F
3
3
1
1
2
1
4
7
T={A,B,C,D,E}
1
1
D
1
2
E
18
Dijkstra’s Algorithm
C
8
5
3
3
B
5
6
2
8
2
A
1
3
2
0
4 F
3
3
1
2
1
4
7
1
1
D
T={A,B,C,D,E,F}
2
1
E
19
Dijkstra’s Algorithm
Iter
T
L(B)
Path L(C)
(B)
Path
(C)
L(D)
Path
(D)
L(E)
Path
(E)
L(F)
Path
(F)
1
{A}
2
A–B
5
A-C
1
A–D

-

-
2
{A,D}
2
A–B
4
A-D-C
1
A–D
2
A-D-E

-
3
{A, B,
D}
2
A–B
4
A-D-C
1
A–D
2
A-D-E

-
4
{A, B, D,
E}
2
A–B
3
A-D-E-C
1
A–D
2
A-D-E
4
A-D-E-F
5
{A, B, C,
D, E}
2
A–B
3
A-D-E-C
1
A–D
2
A-D-E
4
A-D-E-F
6
{A, B, C,
D, E, F}
2
A-B
3
A-D-E-C
1
A-D
2
A-D-E
4
A-D-E-F
20
Bellman‐Ford Algorithm



Findshortestpathsfromgivennodesubject
toconstraintthatpathscontainatmostone
link
Find theshortestpathswithaconstraintof
pathsofatmosttwolinks
and soon
21
Bellman‐Ford Algorithm

Step1[Initialization]



L0(n)=,foralln  s
Lh(s)=0,forallh
Step2[Update]



n:nodenumber
s:sourcenode
h:hopcount
Lh(n):leastcostton withno
morethanh hops
Foreachsuccessiveh  0


•
•
•
•
Foreachn ≠s,compute:
Lh+1(n)=min(foreachj) [Lh(j)+w(j,n)]
connectn withpredecessornodej thatgivesmin
eliminate anyconnectionofn withdifferent
predecessornodeformedduringanearlieriteration
path froms ton terminateswithlinkfromj ton
22
Bellman‐Ford Algorithm
C
8
5
∞
3
B
5
6
∞
8
2
A
∞ F
3
3
1
3
2
0
1
2
1
4
7
1
∞
D
h=0
∞
1
E
23
Bellman‐Ford Algorithm
C
8
5
5
3
5
6
2
8
2
A
3
2
0
∞ F
3
3
1
1
2
1
4
7
h=1
1
1
D
1
∞
E
24
Bellman‐Ford Algorithm
C
8
5
4
3
5
6
2
8
2
A
10 F
3
3
1
3
2
0
1
2
1
4
7
1
1
D
h=2
2
1
E
25
Bellman‐Ford Algorithm
C
8
5
3
3
5
6
2
8
2
A
3
2
0
4 F
3
3
1
1
2
1
4
7
h=3
1
1
D
1
2
E
26
Bellman‐Ford Algorithm
C
8
5
3
3
5
6
2
8
2
A
4 F
3
3
1
3
2
0
1
2
1
4
7
1
1
D
h=4
2
1
E
27
Bellman‐Ford Algorithm
h Lh(B) Path Lh(C) Path
Lh(D)
Path Lh(E) Path
0 
-
-

-

-

-
1 2
A-B 5
A-C
1
A-D 
-

-
2 2
A-B 4
A-D-C
1
A-D 2
A-DE
10
A-C-F
3 2
A-B 3
A-D-EC
1
A-D 2
A-DE
4
A-D-E-F
4 2
A-B 3
A-D-EC
1
A-D 2
A-DE
4
A-D-E-F

Lh(F) Path
28
Flooding





Sendeverypackettoalllinesexcepttheone
itarrivedon
Largenumberofduplicatepackets
Shouldusecounter topreventinfinite
duplicates
Shouldusesequencenumberstoidentify
duplicates
Willalwaysfindshortestpath
29
Flooding




Militaryapplications
Distributeddatabasesystems
Wirelessstationsuseitbynature
Metricforotheralgorithms(e.g.delay)
30
Distance Vector Routing

Eachroutermaintainsatablecontaining






destination
bestknowndistancetothatdestination
linetousetogetthere
UsesBellman‐Fordalgorithm
UsedinARPANETandnowusedinRIP
Distancecanbeanymetric:delay,hop
count,queuelength,etc.
31
Distance Vector Routing


Eachrouterexchangewithitsneighborslist
ofdelaystoeachdestination
RouterXestimatesdelaytorouterZ


RouterYisaneighbortorouterX
D(X,Z)=D(X,Y)+D(Y,Z)
32
Distance Vector Routing
(a) Asubnet(b) InputfromA,I,H,K,andthenewrouting
tableforJ
33
The Count‐to‐Infinity Problem
FailurescancauseDVto“counttoinfinity”
whileseekingapathtoanunreachablenode
X
Good news of a path
to A spreads quickly
Bad news of no path to
A is learned slowly
Link State Routing

Eachrouterconstructthetopologyofthe
entireconfigurationandcalculatesthe
shortestpathtoeachdestinationnetwork
35
Link State Routing





Discoverneighborsandlearntheir
networkaddresses
Measuredelayorcosttoeachofthe
neighbors
Constructapackettellingallwhathas
justlearned
Sendthispackettoallotherrouters
Computeshortestpathtoeveryother
router(usingDijkstra’salgorithm)
36
Learning about Neighbors


SendHELLOpacketonpoint‐to‐pointlines
IfroutersareconnectedtoaLAN,theLANcan
berepresentedasanode
37
Measuring Line Cost





SendECHOpacket
Waitforresponse
Measureround‐trip‐time
Totakeloadintoaccount:starttimerwhen
packetisqueued
Toignoretheload:starttimerwhenpacket
reachesthefrontofthequeue
38
Building Link State Packets
39
Distributing Link State Packets



Useflooding
Packetcontainssequencenumber
Whenpacketisreceived



Ifnew,forwardtoallexceptcomingfrom
Ifduplicate,discard
Ifold,rejected
40
Distributing Link State Packets
Problems
 Sequencenumberwraparound



Use32‐bitsequencenumbers
Routercrashes,seq.no.startsover
Seq.no.corrupted:65540insteadof4

Includeage,decrementedoncepersecond
41
Distributing Link State Packets
ThepacketbufferforrouterB
42
Hierarchical Routing






Routingtablesgrowwithnetworksize
Moreroutermemory
MoreCPUtimetoscanthem
Morebandwidthtosendupdates
Forlargenetworks,bettertodorouting
hierarchically
Hierarchycanbeinmultiplelevels




regions
clusters
zones
groups…
43
Hierarchical Routing
Hierarchical
routingtablehas
7entries
Fullroutingtablehas
17entries
44
Hierarchical Routing



Thegaininspaceisnotfree
Increasedpathlengthfor
somehosts
Example



bestroutefrom1Ato5Cisvia
R2
withhierarchicalroutingall
traffictoR3isviaR5
becauseitisbetterformost
dests inR5
HomeworkProblem:
Prove!
45
Broadcast Routing



Sendmessagetomanyorallotherhosts
e.g.distributinginformation
Sendonepackettoeachdestination?



wastefulofbandwidth
requirehavingcompletelistofdestinations
Flooding

generatestoomanypackets,wastebandwidth
46
Broadcast Routing

Multi‐destinationrouting



packetcontainlistofdestinations
orbitmapindicatingdesireddestinations
Spanningtree





usesinktreeforrouterinitiatingbroadcast
includesallroutersbutcontainsnoloops
copypackettoallspanningtreelines(‐arrived)
routersneedtoknowspanningtreeofsource
workswithlinkstate,notdistancevector
47
Broadcast Routing

Reversepathrouting





approximatewithoutknowingspanningtree
ifpacketarriveonlinkusedtosendto source
highchanceitfollowedbestpathfrom source
thus,forwardtoallexceptincomingline
fromotherlink?duplicate,discard
48
Example: Reverse Path Routing
49
Example: Reverse‐Path Routing

Firsthop:Isends4packetstoF,H,J,andN



Secondhop:8packetsaregenerated



eachofthesearrivesonthepreferredpathtoI
so,indicatedbycircle;forwarded
all8arriveatpreviouslyunvisitedrouters
5ofthesearrivealongpreferredline
Thirdhop:6packetsgenerated


only3arriveatpreferredpath(C,E,K)
othersareduplicates(copies);discarded
50
Example: Reverse‐Path Routing

Fourthhop:4packetsgenerated



Fifthhop:2packetsgenerated




2arriveatpreferredlines(B,L);forwarded
2areduplicates;discarded
2areduplicates;discarded
nomoreforwardedpackets
Total:24packets,5hops
Ifsinktreewasfollowedexactly

only14packets,4hopsrequired
51
Advantages of Reverse‐Path Forwarding



Reasonablyefficientandeasytoimplement
Routersdon’tneedtoknowspanningtrees
Nooverheadofdestinationlistsinpackets


asinmulti‐destinationaddressing
Nospecialmechanismtostoptheprocess

asinflooding
52
Multicast Routing

Multicasting



Whymulticasting?



sendingmessagetoagroupofnodes
routingalgorithmcalledmulticastrouting
distributedprocessing
broadcastingisinefficient,sometimesinsecure
Requiregroupmanagement


create,destroygroups
processestojoin,leavegroups
53
Multicast Routing
54
References


ComputerNetworks,Tanenbaum,4/E
DataandComputerCommunications,
Stallings,8/E

Dijkstra andBellman‐Fordalgorithm
descriptionsandexamples
55