Professional Documents
Culture Documents
Calculating An 802.1d Spanning-Tree Operations - Rev-014-KB
Calculating An 802.1d Spanning-Tree Operations - Rev-014-KB
1d Spanning-T r e e T o po lo gy
By Keith Bogart
Learn in g@ C isc o
T S T rain in g T eam
A s an in stru c tor, I en j oy teac hin g stu d en ts how the 8 0 2 .1d S p an n in g-T ree p rotoc ol w ork s
an d en l ighten in g those stu d en ts to the p oin t w here I c an d raw a top ol ogy d iagram on a
w hiteb oard an d , n o m atter how c om p l ex , the stu d en ts c an ev en tu al l y f igu re ou t the
S p an n in g-T ree rol e an d state of al l sw itc hes in that d iagram .
T hat is the sam e k n ow l ed ge I w il l n ow attem p t to im p art to you , the read er, in this
w hitep ap er.
T here are m an y f ac ets to the 8 0 2 .1d S p an n in g-T ree p rotoc ol w hic h I w on ’ t c ov er in this
p ap er. T here are m an y en han c em en ts to the p rotoc ol to m ak e it c on v erge q u ic k er an d
d etec t f ail u res f aster. T his p ap er is n ot m ean t to d esc rib e those f eatu res.
T he goal of this p ap er is v ery sim p l e, af ter read in g this, the l earn er shou l d b e ab l e to l ook
at an y top ol ogy d iagram of LA N S w itc hes an d ( giv en the ap p rop riate in f orm ation ab ou t
eac h sw itc h) he/ she shou l d b e ab l e to d eterm in e the f ol l ow in g:
1. W hic h sw itc h w il l b e the S p an n in g-T ree R oot Brid ge
2 . W hic h sw itc h w il l b e the sec on d ary R oot Brid ge in the ev en t that the p rim ary
R oot Brid ge f ail s
3 . W hic h sw itc hp orts are in the F orw ard in g – D esign ated state
4. W hic h sw itc hp orts are in the F orw ard in g – R oot P ort state
5 . W hic h sw itc hp orts are in the Bl oc k in g – Non -D esign ated state
I’ m al so goin g to start w ith the assu m p tion that the read er is al read y aw are of w hy the
8 0 2 .1d S p an n in g-T ree p rotoc ol is n eed ed in Layer-2 sw itc hed en v iron m en ts. In short,
S p an n in g-T ree w as d ev el op ed to b l oc k b rid gin g l oop s. In its sim p l est term s, a b rid gin g
l oop sim p l y m ean s that a b road c ast f ram e c an b e f l ood ed ou t of on e sw itc h an d , d u e to
the c ab l in g in the top ol ogy, ev en tu al l y f in d its w ay b ac k to that v ery sam e sw itc h. T his is
a l oop . T his is b ad an d I’ m goin g to assu m e at this p oin t that you u n d erstan d w hy it is
b ad .
Let’ s start w ith the p rem ise that you hav e the f ol l ow in g sim p l e top ol ogy:
In the top ol ogy ab ov e, the sw itc h c on sid ers V LA N-1 to b e ‘ ac tiv e’ b ec au se p ort 3 / 1 is
c on f igu red to b e in this V LA N an d this is ac tu al l y c on n ec ted to a l iv e d ev ic e. T he
m om en t that p ort 3 / 1 c om es u p at l ayer-2 , the C P U in this sw itc h w il l b egin to c al c u l ate
the 8 0 2 .1d S p an n in g-T ree p rotoc ol f or V LA N-1. Notic e that in this sim p l e d raw in g there
is n o b rid gin g l oop so tec hn ic al l y sp eak in g, S p an n in g-T ree as a p rotoc ol is n ot n eed ed . In
real ity, it w ou l d j u st b e ad d ition al ov erhead f or the C P U on this sw itc h to ru n S p an n in g-
T ree. H ow ev er, u n l ess you are ab sol u tel y su re that there w il l n ev er b e an other sw itc h
c on n ec ted to this on e, an d there w il l n ev er b e an y p ossib il ity of a b rid gin g l oop , it’ s b etter
to j u st l eav e S p an n in g-T ree tu rn ed on as a saf egu ard again st f u tu re l oop s.
Spanning-T r e e B r id ge -I D
T he f irst thin g the C P U d oes in an y sw itc h w hen startin g the S p an n in g-T ree p rotoc ol is to
d eterm in e a d esc rip tiv e id en tif ier f or itsel f . T his id en tif ier is c al l ed the Brid ge-Id . T his
Brid ge-ID is f req u en tl y u sed in the S p an n in g-T ree p roc ess w hen tw o or m ore sw itc hes
are “ f ightin g it ou t” an d tryin g to d eterm in e w ho is b etter than the other on e. I’ l l tal k
m ore ab ou t that in a m om en t. T hin k of the Brid ge-Id as b ein g sim il ar to the n am e of the
sw itc h. In stead of the sw itc h c al l in g ou t, “ H ey, m y n am e is T om ” it u ses a Brid ge-Id
in stead . A S p an n in g-T ree Brid ge-ID c on tain s tw o p iec es of in f orm ation , a Brid ge
P riority v al u e an d a M A C A d d ress. T hese tw o v al u es p u t together are c al l ed the Brid ge-
ID . T he Brid ge-P riority, u n l ess m an u al l y c han ged , is al w ays the d ef au l t v al u e of 3 2 , 7 68 .
S o w hether you b ou ght a sw itc h tw en ty years ago that on l y has f ou r p orts, or you b ou ght
the l atest $ 2 0 0 , 0 0 0 .0 0 sw itc h w ith al l the b el l s an d w histl es, they w il l al w ays hav e the
sam e Brid ge P riority of 3 2 , 7 68 . T hat b ein g the c ase, the on e v al u e you c an al w ays c ou n t
on b ein g u n iq u e f rom on e sw itc h/ b rid ge to the n ex t is the M A C A d d ress. S o the
c om b in ation of the Brid ge P riority an d Brid ge M A C A d d ress w il l al w ays resu l t in a
u n iq u e Brid ge-ID f or eac h an d ev ery sw itc h.
Spanning-T r e e R o o t B r id ge E l e c t io n
Nex t, ev ery V LA N that is ac tiv e an d ru n n in g S p an n in g-T ree w il l hav e a sin gl e
b rid ge/ sw itc h ac tin g as the R oot Brid ge f or that V LA N. T his hap p en s v ia an el ec tion
p roc ess that I’ l l d esc rib e in a m om en t. A l l the sw itc hes w il l in itial l y ex c han ge sp ec ial
S p an n in g-T ree P D U s ( p rotoc ol d ata u n its) that are c al l ed BP D U s ( Brid ge P rotoc ol D ata
U n its) . A BP D U is j u st an other k in d of E thern et f ram e b u t in this c ase it c arries
in f orm ation that S p an n in g-T ree n eed s to c al c u l ate the top ol ogy. P C s, S erv ers, R ou ters,
etc w il l al so rec eiv e a BP D U if they are c on n ec ted to a sw itc h b u t, b ec au se these d ev ic es
d on ’ t typ ic al l y ru n the 8 0 2 .1d S p an n in g-T ree p rotoc ol they w il l d isc ard these f ram es.
T he R oot Brid ge w ithin S p an n in g-T ree has a f ew , v ery im p ortan t task s su c h as:
1. It is the on l y sw itc h ( w hen ru n n in g 8 0 2 .1d S T P ) that is resp on sib l e f or gen eratin g
n ew BP D U s. A l l other sw itc hes in the top ol ogy w il l sim p l y rec eiv e BP D U s f rom
the R oot Brid ge an d then f orw ard them on to other, d ow n stream sw itc hes. If the
R oot Brid ge tem p oraril y stop s c reatin g BP D U s ( m ayb e b ec au se the C P U is too
b u sy ru n n in g other p rotoc ol s) al l other sw itc hes w il l b e sil en t.
2 . It c on trol s the v ariou s tim ers that S p an n in g-T ree u ses.
3 . It in f orm s the Layer-2 sw itc hed top ol ogy of som ethin g c al l ed , “ top ol ogy
c han ges” ( n ot c ov ered in this p ap er) .
T he other highl ighted f iel d in the BP D U tel l s the w hol e w orl d w ho the S p an n in g-T ree
R oot Brid ge is f or this V LA N. In this c ase, this sw itc h is ad v ertisin g itsel f as the R oot
Brid ge.
T he R oot Brid ge el ec tion p roc ess is v ery sim p l e. S w itc hes sim p l y l ook f or the sw itc h
that has the n u m eric al l y l ow est Brid ge-ID an d el ec t that sw itc h to b e the S p an n in g-T ree
R oot Brid ge.
A t this p oin t, the R oot Brid ge n o l on ger n eed s to p roc eed in an y f u rther el ec tion s. It w il l
start gen eratin g an d tran sm ittin g BP D U s ou t ev ery p ort/ in terf ac e it has in V LA N-1. If
this sw itc h al so b ec am e the R oot Brid ge f or other V LA Ns it w ou l d gen erate BP D U s f or
those other V LA Ns as w el l . A sw itc h c an b e a R oot Brid ge f or m ore than on e V LA N. A s
a m atter of f ac t, if al l the sw itc hes w ere l ef t to their d ef au l t v al u es, w hic hev er sw itc h
b ec am e the R oot Brid ge f or V LA N-1 w ou l d al so, b y d ef au l t, b e the R oot Brid ge f or
V LA N-2 , V LA N-3 , an d so on .
O n e rem ain in g f ac t ab ou t the R oot Brid ge is that al l the p orts it has in this p artic u l ar
V LA N ( in c l u d in g V LA N T ru n k s) w il l b e p l ac ed in the F orw ard in g-D esign ated rol e.
M ore on that in a m om en t.
Spanning-T r e e R o o t P o r t s and C o s t
T he other sw itc hes that l ost the R oot Brid ge el ec tion hav e som e m ore w ork to d o b ef ore
the S p an n in g-T ree p rotoc ol is stab il iz ed .
E v ery p ort that is p artic ip atin g in S p an n in g-T ree ( b asic al l y, ev ery p ort that is “ u p ” ) w il l
ev en tu al l y en d u p in on e of three S p an n in g-T ree p ort rol es:
1. R oot P ort
2 . D esign ated P ort
3 . Non -D esign ated ( Bl oc k in g) P ort
T he n ex t step that eac h sw itc h ( except f or the R oot Brid ge) d eterm in es is w hic h of its
p orts w il l b ec om e the R oot P ort. F or eac h ac tiv e V LA N on a sw itc h, that sw itc h w il l
hav e on l y o n e R oot P ort. T he R oot Brid ge itsel f has n o R oot P orts.
T he R oot P ort is that p ort on the sw itc h that has the f astest p ath b ac k to the R oot Brid ge.
Look at an ex am p l e b el ow :
In the d raw in g ab ov e, b oth Bob an d C in d y c an d riv e d irec tl y to the airp ort. Bob c an
d riv e d irec tl y d ow n K-street an d it w il l tak e him 12 -m in u tes to reac h the airp ort. C in d y
c an d riv e d irec tl y d ow n M -S treet an d it w il l tak e her on l y 5 -m in u tes. Bu t they are al so
b oth c on n ec ted to L-street. U n l ess som eon e c on n ec ted to L-street ad v ertises that this is a
v iab l e p ath to the airp ort, n either Bob n or C in d y w il l ev en c on sid er d riv in g on L-street.
A f ter al l , w ou l d y o u d riv e d ow n a d ark al l ey if you w eren ’ t su re it l ed to w here you
w an ted to go? S o as a c ou rtesy, b oth Bob an d C in d y ad v ertise to eac h other ( al on g L-
S treet) the p aths they k n ow ab ou t to the airp ort. If Bob an d C in d y k n ew ab ou t m u l tip l e
w ays to get to the airp ort, they w ou l d on l y in f orm eac h other of the b est w ay ( the f astest) .
Notic e that w hen Bob shou ts to C in d y that he c an get to the airp ort in 12 -m in u tes, he
d oesn ’ t tel l her ab ou t the 6-ad d ition al m in u tes it w ou l d tak e f or her to trav el ac ross L-
S treet. H e on l y tel l s her ab ou t H IS p ersp ec tiv e. A n d f rom Bob ’ s p ersp ec tiv e, he on l y
k n ow s that K-street l ead s to the airp ort. Lik ew ise, w hen C in d y shou ts ou t, “ H ey , I h a v e a
w a y to th e a i r po r t o v er h er e a n d i t o n l y ta k es m e f i v e m i n u tes ” she al so d oesn ’ t tak e in to
c on sid eration the six m in u tes it w ou l d tak e Bob to d riv e to her on L-S treet.
Both Bob an d C in d y n ow k n ow they eac h hav e tw o p ossib l e w ays to get to the airp ort.
F or Bob , on e w ay w il l tak e a total of 12 -m in u tes ( al on g K-street) . T he other w ay ( al on g
L-street) w il l ac tu al l y tak e l ess tim e… a c om b in ed total of 11-m in u tes. S o ev en thou gh
Bob is d irec tl y c on n ec ted to the airp ort v ia K-street, it w ou l d ac tu al l y b e f aster f or him to
get there b y f irst d riv in g d ow n L-street, throu gh C in d y’ s hou se, an d then al on g M -street.
S o Bob w ou l d c hoose his c on n ec tion to L-street as his R oot P ort.
No. In S p an n in g-T ree term in ol ogy the sp eed of a l in k is rep resen ted b y a n u m eric al
v al u e c al l ed , “ C o s t ” . Y ou d on ’ t n eed to k n ow the ex ac t f orm u l a u sed to d eriv e c ost b u t
you shou l d k n ow that c ost is d irec tl y rel ated to b an d w id th. T he higher the b an d w id th on
a l in k , the l ow er the v al u e of its c ost.
S p e e d o f lin k C o st
10 M b p s E thern et 10 0
10 0 M b p s F astE thern et 19
10 0 0 M b p s G igab it E thern et 4
F rom the R oot Brid ge’ s p ersp ec tiv e it d oesn ’ t c ost an ythin g to reac h itsel f . S o the R oot
Brid ge al w ays ad v ertises BP D U s w ith an in itial c ost of z ero. A n other w ay of l ook in g at
it; if som eon e ask ed you , “ W h en y o u ’ r e a t th e a i r po r t, h o w m a n y m i n u tes d o es i t ta k e
y o u to d r i v e to th e a i r po r t? ” Y ou ’ d p rob ab l y f irst sc ratc h you r head an d assu m e this w as
a tric k q u estion . Bu t the hon est an sw er w ou l d b e, “ I f I ’ m a l r ea d y A T th e a i r po r t i t
d o es n ’ t ta k e m e a n y ti m e a t a l l b eca u s e I ’ m a l r ea d y T H E R E , s o th e a n s w er i s z er o
m i n u tes ” .
W hen Brid ge-A rec eiv es this BP D U w ith a c ost of z ero, it rec eiv es it on in terf ac e G igab it
E thern et 4/ 1. Kn ow in g that this is a G igab it E thern et in terf ac e it c al c u l ates its l oc al c ost
v al u e f or this p ort ( a v al u e of 4) an d ad d s it to the c ost in the BP D U . Now the total c ost
f or Brid ge-A to reac h the R oot Brid ge is 4. C on sid erin g this is the on l y p ath it k n ow s
ab ou t to the R oot Brid ge it w il l ad v ertise this c ost ou t p ort 5 / 2 so Brid ge-B c an l earn
ab ou t it.
S im il arl y, w hen Brid ge-B rec eiv es this BP D U w ith a c ost of z ero, it rec eiv es it on
in terf ac e F astE thern et 3 / 1. Kn ow in g that this is a F astE thern et in terf ac e it c al c u l ates its
l oc al c ost v al u e f or this p ort ( a v al u e of 19 ) an d ad d s it to the c ost in the BP D U . Now the
total c ost f or Brid ge-B to reac h the R oot Brid ge is 19 .
Let’ s f oc u s ou r atten tion on Brid ge-B f or a m om en t. It n ot on l y rec eiv ed a BP D U d irec tl y
f rom the R oot Brid ge on p ort 3 / 1 w ith an in itial c ost of z ero… b u t m il l isec on d s l ater it
rec eiv es an other BP D U on p ort 3 / 2 f rom Brid ge-A . In this BP D U Brid ge-A is
ad v ertisin g that it c an reac h the R oot Brid ge w ith a c ost of f ou r. O n c e again , Brid ge-B
has to tak e in to ac c ou n t the p ath b etw een itsel f an d Brid ge-A an d ad d that to the
eq u ation . T he l oc al in terf ac e c ost of p ort 3 / 2 on Brid ge-B is 19 ( this is a F astE thern et
l in k ) . W hen ad d ed to the ad v ertised c ost of 4 f rom Brid ge-A , Brid ge-B n ow k n ow s that
it has an al tern ativ e p ath to the R oot Brid ge w ith a c om b in ed total c ost of 2 3 .
Brid ge-A m ak es this sam e c al c u l ation b ased on the BP D U that it rec eiv es f rom Brid ge-B
an d d eterm in es that its c om b in ed c ost to reac h the R oot Brid ge f rom p ort 5 / 2 w ou l d b e
3 8 .
Both Brid ge-A an d Brid ge- B are n ow aw are that they hav e tw o p aths to the R oot Brid ge.
S tic k in g w ith the sam e ru l e that “ l ow est is b etter” Brid ge-A w il l sel ec t p ort 4/ 1 as its
R oot P ort an d Brid ge-B w il l sel ec t p ort 3 / 1 as its R oot P ort.
A R oot P ort is al w ays in the “ F orw ard in g” state. T his m ean s that this p ort is w id e op en
to sen d an d rec eiv e al l typ es of traf f ic . It is “ f orw ard in g” E thern et f ram es.
Spanning-T r e e D e s ignat e d P o r t s
S o w hat ab ou t the p orts that are n ot R oot P orts? W hat are they?
I’ v e al read y m en tion ed that the R oot Brid ge itsel f has n o R oot P orts, so w hat w il l b e the
S p an n in g-T ree rol e of p orts on that b rid ge/ sw itc h?
A s I’ v e m en tion ed p rev iou sl y, ev ery p ort that is p artic ip atin g in S p an n in g-T ree w il l
b ec om e on e of three p ossib l e rol es:
4. R oot P ort
5 . D esign ated P ort
6. Non -D esign ated ( Bl oc k in g) P ort
O n Brid ge-A , w e k n ow that p ort 5 / 2 is n ot the R oot P ort so b y p roc ess of el im in ation it
m u st b e either a D esign ated P ort or a Non -D esign ated P ort.
Notic e I u sed the w ord s, “ c ol l ision d om ain ” an d n ot sim p l y “ c ab l e” . In this top ol ogy,
c ab l e segm en t-X is c on sid ered a sin gl e c ol l ision d om ain an d so on e of the p orts
c on n ec ted to this c ab l e w il l b ec om e a D esign ated P ort:
H op ef u l l y you an sw ered the R oot Brid ge. A f ter al l , the R oot Brid ge ad v ertises itsel f w ith
a c ost of z ero an d NO T H ING c an b eat that! ! T his m ean s that ev ery p ort on the R oot
Brid ge ( in that p artic u l ar V LA N) w il l b e a D esign ated P ort.
Both b rid ges w an t to w in this p roc ess b u t there c an b e on l y on e D esign ated P ort p er c ab l e
( c ol l ision d om ain ) . C on sid erin g that S p an n in g-T ree c on sid ers l ow er v al u es to b e b etter, it
is l ogic al that ev en thou gh Brid ge-A has tw o c osts to reac h the R oot Brid ge ( a c ost of
f ou r on p ort 4/ 1 an d a c ost of 3 8 on p ort 5 / 2 ) it w il l ad v ertise the ab sol u te l ow est c ost it
has to Brid ge-B to attem p t to w in this D esign ated P ort el ec tion p roc ess.
In this top ol ogy, Brid ge-A w il l w in an d p ort 5 / 2 w il l b ec om e the D esign ated P ort on this
c ab l e. J u st l ik e R oot P orts, D esign ated P orts are al w ays in the “ F orw ard in g” state.
Notic e that the G igab it E thern et l in k b etw een the R oot Brid ge an d Brid ge-A has b een
c han ged to a F astE thern et l in k . T his c han ge w ou l d resu l t in the f ol l ow in g n ew c ost
v al u es:
A s w e c an see, Brid ge-A stil l show s p ort 4/ 1 as b ein g its R oot P ort b ec au se it has l ess
total c ost to u se this p ort to reac h the R oot Brid ge than if it u sed p ort 5 / 2 w ith an
aggregated c ost of 3 8 . A n d the sam e hol d s tru e f or Brid ge-B… its R oot P ort hasn ’ t
c han ged . Bu t how w il l these sw itc hes d eterm in e w hic h p ort w il l b e the D esign ated P ort
on the c ab l e that they b oth share? Both sw itc hes are ad v ertisin g the sam e c ost to eac h
other ( a c ost of 19 ) .
In this situ ation , w hen tryin g to d eterm in e the D esign ated P ort in a C ol l ision D om ain an d
tw o or m ore of the c osts are id en tic al , there is a tie-b reak er that w il l b e u sed … the Brid ge-
ID .
Bu t n ow , b ec au se the c osts are id en tic al Brid ge-B w in s! Brid ge-B’ s Brid ge-Id is l ow er
than Brid ge-A ’ s Brid ge-Id . R ec al l that the Brid ge-Id is c om p osed of the Brid ge P riority
f ol l ow ed b y the M A C ad d ress. R ight aw ay w e c an see that Brid ge-B has a l ow er Brid ge
P riority than Brid ge-A , so w e d on ’ t ev en n eed to c om p are the M A C ad d resses.
1. Wh ic h sw itc h w ill b e th e S p a n n in g -T r e e R o o t B r id g e ?
2 . W h ic h p o r t( s) w ill b e S p a n n in g -T r e e R o o t P o r ts a n d in th e F o r w a r d in g s ta te ?
3 . W h ic h p o r t( s) w ill b e S p a n n in g -T r e e D e s ig n a te d P o r ts a n d in th e F o r w a r d in g s ta te ?
4 . W h ic h p o r t( s) w ill b e S p a n n in g -T r e e N o n -D e s ig n a te d P o r ts a n d in th e B lo c k in g
sta te ?
Lastl y, there is on e m ore p erm u tation of a top ol ogy that you m ost l ik el y w il l ex p erien c e.
H op ef u l l y, b y this p oin t you u n d erstan d w hy the sw itc h on the l ef t w as el ec ted the R oot
Brid ge ( it had a l ow er Brid ge-ID ) . A n d I’ v e ex p l ain ed that al l the p orts on the R oot
Brid ge are al w ays D esign ated P orts b ec au se they hav e a c ost of z ero.
Norm al l y, the n ex t step in the p roc ess w ou l d b e to d eterm in e the R oot P ort on Brid ge-B
an d that w ou l d b e d on e b y tryin g to f igu re ou t w hic h p ort on Brid ge-B had the l ow est
c ost b ac k to the R oot Brid ge. Bu t in this p ic tu re, b oth p orts on Brid ge-B hav e the sam e
c ost to the R oot Brid ge… a c ost of 19 .
I then had m en tion ed that the n ex t tie-b reak er ( w hen the c ost w as id en tic al ) w as to l ook at
the Brid ge-ID of you r n eighb or. Bu t the BP D U Brid ge-B rec eiv es on p ort 3 / 2 c on tain s
the sam e sen d in g Brid ge-ID ( 3 2 7 68 -0 4-11-11-c c -12 -7 7 ) as the BP D U it rec eiv es on p ort
3 / 1.