Vous êtes sur la page 1sur 6

15/04/2016

CCNATrainingSpanningTreeProtocolSTPTutorial

Spanning Tree Protocol STP Tutorial


June1st,2011

Gotocomments

Toprovideforfaulttolerance,manynetworksimplementredundantpathsbetweendevicesusingmultiple
switches.However,providingredundantpathsbetweensegmentscausespacketstobepassedbetweenthe
redundantpathsendlessly.Thisconditionisknownasabridgingloop.
(Note:thetermsbridge,switchareusedinterchangeablywhendiscussingSTP)
Topreventbridgingloops,theIEEE802.1dcommitteedefinedastandardcalledthespanningtreealgorithm
(STA),orspanningtreeprotocol(STP).SpanningTreeProtocolisalinkmanagementprotocolthatprovides
pathredundancywhilepreventingundesirableloopsinthenetwork.ForanEthernetnetworktofunction
properly,onlyoneactivepathcanexistbetweentwostations.
Letsseeasituationwhenthereisnoloopavoidanceprocessinoperation.Supposeyouhavetwoswitches
connectedwithredundantlinks.OneswitchconnectedtoPCAandtheotherswitchconnectedtoPCB.
NowPCAwantstotalktoPCB.Itthensendsabroadcast,sayanAddressResolutionProtocol(ARP)tofind
outwherethelocationofPCB,thegreenarrowshowsabroadcastframesentbyPCA.
WhentheswitchAreceivesabroadcastframe,itforwardsthatframetoallportsexcepttheportwhereit
receivestherequest>SwAforwardsthatARPframeoutoffa0/0andfa0/1ports.

SupposeSwBreceivesthebroadcastframefromfa0/0firstthenitwillforwardthatframetothetwoother
links(fa0/1andfa0/5ofSwB).

TheotherbroadcastframefromSwAcomestofa0/1ofSwBsoSwBforwardsittofa0/0andfa0/5.

Asyoucansee,SwAhassent2broadcastframesoutofitsfa0/0andfa0/1,SwBreceiveseachofthem,
creates2copiesandsendsoneofthembacktoSwA(theotherissenttoPCB).
WhenSwAreceivesthesebroadcastframesitcontinuesbroadcastingthemagaintoitsotherinterfaces,this
willkeepgoingonforeveruntilyoushutdownthenetwork.Thisphenomenoniscalledabroadcaststorm.
Broadcaststormconsumesentirebandwidthanddeniesbandwidthfornormalnetworktraffic.Broadcast
stormisaseriousnetworkproblemandcanshutdownentirenetworkinseconds.
Otherproblems:
http://www.9tut.com/spanningtreeprotocolstptutorial

1/6

15/04/2016

CCNATrainingSpanningTreeProtocolSTPTutorial

Multipleframetransmission:Multiplecopiesofunicastframesmaybedeliveredtodestinationstations.
Manyprotocolsexpecttoreceiveonlyasinglecopyofeachtransmission.Multiplecopiesofthesameframe
cancauseunrecoverableerrors.Intheaboveexample,ifthefirstframeisnotaARPbroadcastbutaunicast
andSwAandSwBhaventlearnedaboutthedestinationinthatframeyetthentheyfloodtheframeonall
portsexcepttheoriginatingport.ThesamephenomenonoccursandPCBwillreceivemorethanonecopyof
thatframe.
MACDatabaseInstability:MACdatabaseinstabilityresultswhenmultiplecopiesofaframearriveon
differentportsofaswitch.WecanseeitintheaboveexampletoowhenthetwoportsonSwB(fa0/0and
fa0/1)receivethesameframe.
Nowyoulearnedaboutproblemswhenthereisnoloopingavoidancemechanismrunningonthenetwork.
AlloftheseproblemscanbesolvedwiththeSpanningTreeProtocol(STP)
STPpreventsloopbyblockingoneofswitchsport.Forexample,byblockingportfa0/0ofSwA,nodatatraffic
issentonthislinkandtheloopinthenetworkiseliminated.

ButhowSTPdecideswhichportshouldbeblocked.Thewholeprocessismorecomplexthanwhatisshown
above.Wewilllearnitinthenextpart.
HowSpanningTreeProtocol(STP)works
SPTmustperformsthreestepstoprovidealoopfreenetworktopology:
1.Electsonerootbridge
2.Selectonerootportpernonrootbridge
3.Selectonedesignatedportoneachnetworksegment
Nowletshaveacloserlookfromthebeginning,whenyouhavejustturnedontheswitches
1.Electsonerootbridge
Afunthingisthatwhenturnedon,eachswitchclaimsitselfastherootbridgeimmediatelyandstarts
sendingoutmulticastframescalledBridgeProtocolDataUnits(BPDUs),whichareusedtoexchangeSTP
informationbetweenswitches.

ABPDUcontainsmanyfieldsbutthereare4mostimportantfieldsforSTPtooperatecorrectly:
*TheBridgeIDsoftheRootBridgeandtheBridgeIDoftheTransmittingBridge:
Intheinitialstage,eachswitchclaimsitselfasarootbridgesothebridgeIDoftherootbridgeandthebridge
http://www.9tut.com/spanningtreeprotocolstptutorial

2/6

15/04/2016

CCNATrainingSpanningTreeProtocolSTPTutorial

IDofthetransmittingbridgearethesame.
TheBridgeIDiscomposedofthebridgepriorityvalue(065535,2bytes)andthebridgeMACaddress(6
bytes).
BridgeID=BridgePriority+MACAddress
Forexample:
+ThebridgepriorityofSwAis32768anditsMACaddressis0000.0000.9999>thebridgeIDofSwAis
32768:0000.0000.9999
+ThebridgepriorityofSwBis32768anditsMACaddressis0000.0000.1111>thebridgeIDofSwBis
32768:0000.0000.1111
TherootbridgeisthebridgewiththelowestbridgeID.
TocomparetwobridgeIDs,thepriorityiscomparedfirst.Iftwobridgeshaveequalpriority,thentheMAC
addressesarecompared.Intheaboveexample,bothSwAandSwBhavethesamebridgeID(32768)so
theywillcomparetheirMACaddresses.BecauseSwBhaslowerMACaddressitwillbecomerootbridge.

Ontherootbridge,allportsaredesignatedports.Designatedportsareintheforwardingstateandcansend
andreceivetraffic.
Note:Thedefaultbridgepriorityvalueis32768.Anadministratorcandecidewhichbridgewillbecomethe
rootbridgebyloweringthepriorityvalue(thusloweringBridgeID).Forexample,wecanlowerSwAsbridge
priorityto28672(smallerthan32768)tomakeitrootbridge.Butnoticethatthebridgeprioritynumbercan
beincrementedonlyinstepof4096.
Inconclusion,STPdecideswhichswitchwillbecomerootbridgebycomparingtheBridgeIDintheBPDUs.
ThebridgeprioritiesarecomparefirstiftheyareequalthentheMACaddresseswillbeused.Becauseeach
switchhasauniqueMACaddresssosurelyonerootbridgewillbeelected.
*Thecosttoreachtherootfromthisbridge(RootPathCost):Thisvalueissetto0atthebeginning
ofSTProotbridgeelectionprocesssinceallbridgesclaimtobetheroot.Thecostrangeis065535.

Link
Speed

Cost(RevisedIEEE
Specification)

Cost(PreviousIEEE
Specification)

10Gbps

1Gbps

100Mbps

19

10

10Mbps

100

100

Therootpathcostisusedtoelectrootportandwewilldiscussinthenextpart.
*ThePortID:ThetransmittingswitchportID,willbediscussedlater.
http://www.9tut.com/spanningtreeprotocolstptutorial

3/6

15/04/2016

CCNATrainingSpanningTreeProtocolSTPTutorial

2.Selectonerootportpernonrootbridge
Rootportistheportthatisclosesttotherootbridge,whichmeansitistheportthatreceivingthe
lowestcostBPDUfromtheroot.
Everynonrootbridgemusthavearootport.Allrootportsareplacedinforwardingstate.
Intheaboveexample,ifwesupposetheupperlink(betweentwofa0/0interfaces)are10Mbpsandthe
lowerlink(betweentwofa0/1interfaces)is100Mbpslinkthenfa0/1ofSwAwillbecomerootportasithas
lowercostthanfa0/0(cost19<cost100).

3.Selectonedesignatedportoneachnetworksegment
STPselectsonedesignatedportpersegmenttoforwardtraffic.Otherswitchportsonthesegmenttypically
becomenondesignatedportsandareblocked.Thereforeinterfacefa0/0ofSwAwillbecomenondesignated
port(blockingstate).Inblockingstate,althoughswitchescannotsenddatatrafficbutcanstillreceive
BPDUs.

Nowthenetworkreachesastatecalledconvergence.ConvergenceinSTPoccurswhenallportsonbridges
andswitcheshavetransitionedtoeitherforwardingorblockingstates.Nodataisforwardeduntil
convergenceiscompletesothetimeforconvergencewhennetworktopologychangesisveryimportant.
Fastconvergenceisverydesirableinlargenetworks.Thenormalconvergencetimeis50secondsfor802.1D
STP(whichisratherslow)butthetimerscanbeadjusted.
STPswitchportstates
WhenSTPisenabled,everyswitchinthenetworkgoesthroughtheblockingstateandthetransitorystates
oflisteningandlearning.Theportsthenstabilizetotheforwardingorblockingstate.
*Blockingnouserdataissentorreceivedbutitmaygointoforwardingmodeiftheotherlinksinusefail
andthespanningtreealgorithmdeterminestheportmaytransitiontotheforwardingstate.BPDUdatais
stillreceivedinblockingstatebutdiscardsframes,doesnotlearnMACaddress.
*ListeningTheswitchprocessesBPDUsandawaitspossiblenewinformationthatwouldcauseittoreturn
totheblockingstate,discardsframesandMACaddress.
*LearningreceivesandtransmitsBPDUsandlearnsMACaddressesbutdoesnotyetforwardframes.
*Forwardingreceivesandsendsdata,normaloperation,learnsMACaddress,receivesandtransmits
BPDUs.
BelowisaquicksummaryofSTPstates:

State

Can

http://www.9tut.com/spanningtreeprotocolstptutorial

Learn

Timer

Transitoryor
4/6

15/04/2016

CCNATrainingSpanningTreeProtocolSTPTutorial

forward
data?

MAC?

StableState?

Blocking

No

No

MaxAge(20
sec)

Stable

Listening

No

No

ForwardDelay
(15sec)

Transitory

Learning

No

Yes

ForwardDelay

Transitory

Forwarding

Yes

Yes

Stable

*MaxAgeHowlonganybridgeshouldwait,afterbeginningtonothearhellos,beforetryingtochangethe
STPtopology.Usuallythisisamultipleofthehellotimethedefaultis20seconds.
*ForwardDelayDelaythataffectsthetimeinvolvedwhenaninterfacechangesfromblockingstateto
forwardingstate.Aportstaysinlisteningstateandthenlearningstateforthenumberofsecondsdenedby
theforwarddelay.Thistimeriscoveredinmoredepthshortly.
Thespanningtreealgorithmprovidesthefollowingbenefits:
*Eliminatesbridgingloops
*Providesredundantpathsbetweendevices
*Enablesdynamicroleconfiguration
*Recoversautomaticallyfromatopologychangeordevicefailure
*Identifiestheoptimalpathbetweenanytwonetworkdevices
Nowletstakeanexampleusingthesamenetworkasabovebutwesupposethatthebottom100Mbps
connectionisbroken.

Whenthelowerlinkisbroken,SwAmustwaitforMaxAgesecondsbeforeitbeginstotransitionfa0/0
interfacefromblockingtolisteningstate.InlisteningstateitmustwaitfortheForwardDelaysecondsto
movetotheLearningstate.NextitcontinueswaitingformoreForwardDelayseconds.IfnoBPDUis
received,itisthenplacedinforwardingstate.Thesethreewaitingperiodsof(bydefault)20,15,and15
secondscreateSTPsrelativelyslowconvergence.
NowletsconsiderhowBPDUaresentwhenthereare3switchesinthenetwork.Ciscohasagoodflashto
demonstrateitsopleasewatchitathttp://www.cisco.com/image/gif/paws/10556/spanning_tree1.swf
HowSTPperformswhenalinkfails
Supposewehaveatopologywiththreeswitchesasshownbelow:

http://www.9tut.com/spanningtreeprotocolstptutorial

5/6

15/04/2016

CCNATrainingSpanningTreeProtocolSTPTutorial

InwhichSwAiselectedtherootbridge,thelinkbetweenSwBandSwCisbeingblocked.WhenSTPis
converged,theportrolesareshownabove.
NowsupposethelinkbetweenSwAandSwBgoesdown,letusseewhatandhowSTPwillperform

1.First,P1onSwBimmediatelygoesdownandSwBdeclaresitslinktoSwAasdown.
2.SwBconsidersitslinktoSwC(whichisbeingblocked)asanalternatelinktorootport.SwBstartsto
transitionP2fromtheblockingstatetolisteningstate>learningstate>forwardingstate.Eachofthese
stageslasts15secondsbydefault.ThereforeportP2onSwBwillbeholdblockingfor30secondsbeforethe
networkconvergesagain.Thisdowntimeofthenetworkisratherlong(althoughwecantunethetimersto
14seconddowntime)andtheuserscanfeelit.
ThenoticeabledowntimecanbereducedsignificantlyifweuseRapidSpanningTreeProtocol(RSTP).Ifyou
areinterestedinRSTP,pleasereadmyRapidSpanningTreeProtocolTutorial.

http://www.9tut.com/spanningtreeprotocolstptutorial

6/6

Vous aimerez peut-être aussi