Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Attention: The Community will be in read-only mode on 12/14/2017 from 12:00 am pacific to 11:30 am.

During this time you will only be able to see content. Other interactions such as posting, replying to questions, or marking content as helpful will be disabled for few hours.

We apologize for the inconvenience while we perform important updates to the Community.

New Member

Spanning Tree Protocol-state

Hi Experts,

I have a conceptual doubt in Spanning Tree Protocol logic.

I have 3 Switches R0, R1 & R2 connected in Triangular fashion. R0-R1-R2-R0 as shown in diagram attached. R0 is Root Bridge being the Lowest Bridge ID

I am seeing that R2 Port connected to R1 port is blocked as a normal behavior of STP. I assume STP chosen R1 ports as Designated Port because it has Lowest Bridge ID (Since both R1 & R2 has equal cost path to R0).

I am trying to change the Blocked port in R2 so that it will become FWD port and R1 port will become BLK port. So, I entered command “spanning -tree cost 5” in R1.

But I am not seeing this cost get reflected in any of the switches. I even tried to change the Spanning tree cost of R0's Fa0/0 and Fa0/1 Port to 100 for testing. It is also not getting advertised to R1 & R2.

I am confused with my understanding. Can anyone please help me, what does this command “spanning -tree cost “ does and how to make R2 switch's all the ports to become FWD state.

Thanks in advance for helping me

Sairam

2 ACCEPTED SOLUTIONS

Accepted Solutions
Cisco Employee

Re: Spanning Tree Protocol-state

Hello Sairam,

I must admit that the output of "show spanning-tree" is confusing at best.

What confuses you is probably the line "Designate port id is XXX.X, designated path cost C". Well, you have to interpret it depending on the state of the port:

1.) If the port is a root port, then the designated path cost shows you the value of the BPDU Root Path Cost as received on that port before adding the port's own cost.

2.) Otherwise (the port is forwarding or blocking), the designated path cost shows you your own distance from the root which is inserted in the BPDUs sent out on that port (if they are sent out, of course).

In essence, the "designated path cost" line always shows you the raw value of the BPDU field "root path cost" - on root port, you see the value from the received BPDU, on all other ports, you see the value in transmitted BPDUs.

Note the sequence of the ports and distances in your last topology where the Fa0/1 on R0 is shutdown:

R0 f0/0 (0) ---> f0/0 (0) R1 f0/1 (19) ---> f0/1 (19) R2 f0/0 (38)

The numbers in parentheses show you the value of the "designated path cost" as described in the "show span" output for the respective port. Note that the value always corresponds to the raw "Root Path Cost" BPDU value that is either received or sent on that port.

Perhaps this helps a bit.

Best regards,

Peter

Hall of Fame Super Silver

Re: Spanning Tree Protocol-state

Hello Peter, Sairam

the fields

Designated port id is 128.2, designated path cost 19

are taken from the BPDU of the port that has winned the DP election on the lan segment.

Sairam, if you swap the ports you should be able to see port-id changing and following the port-id of DP port on segment.

Sometimes it is better to have asymmetrical connections to see what happens.

As a result of the fact that these values are those of the lowest best BPDU on segment they can reflect or not the current root path cost of the local node.

For a lan segment where local switch port is the DP

designated path cost = local switch root path cost

for a port in forwarding state but not DP on the segment that is the root port for non root bridge devices the designated cost is that received from the upstream switch DP port.

Note: looking at bridge-id can help

Also to help understand the output we can look at the bridge-id information

for example in Sairam's lab:

R2 bridge id is:

Bridge ID Priority 32768

>>> Address cc02.0ec0.0000

if we look at the lines

Designated bridge has priority 32768, address cc02.0ec0.0000

for port fas0/0 this tells us that R2 fas0/0 has winned the DP election on this segment as a result of this designated cost is = root path cost of R2 that is 38.

on fas0/1 we see:

Designated bridge has priority 32768, address cc01.0ec0.0000

this bridge-id is different from local switch bridge-id and this tells us that the other switch port has winned the DP election on this other segment.

As a result of this designated path cost is lower then root path cost of R2 switch

and is 19.

Hope to help

Giuseppe

15 REPLIES
New Member

Re: Spanning Tree Protocol-state

Hi Peter,

Thanks for your help and also I admire your detailed understanding and explanation on the concept and sharing with us. I have never seen these indepth explanation anywhere.

You are rightly said, only by changing the "priority" (lowering the value using command "spanning-tree vlan 1 priority 100") command I was able to change all the ports to FWD state in R2.But it changed the Root switch selection also, and R2 switch has become the Root because of lowest BID amoung all the 3 switches.

I observed 2 behaviours here. Let me share with you:

My understanding on these terminologies are:

designated path cost: COST TO THE ROOT SWITCH FROM THE RESPECTIVE PORT OF THE SWITCH

Port path cost: COST OF THE PORT ITSELF.

ONLY THIS COST IS ADVERTISED TO THE NEIGHBOR SWITCH

Am I right?

In your explanation you said, BPDUs send only the Port path cost not adding the its cost to the Root switch.

If this is the case, I changed the COST of R2's fa 0/1 port to 100 using "spanning-tree cost 100". I expected this to be advertised to R1. It didn't happened.

Thanks for reading this lengthy paragraphs.

can you please comment on this.

Sairam

Hall of Fame Super Silver

Re: Spanning Tree Protocol-state

Hello Sairam,

the root path cost is that carried on the received BPDU+cost of the root port.

Each switch calculates it in this way and advertises it out of all of its non blocked ports.

In STP costs are added on the incoming port not that of the outgoing as it happens in IP routing protocols like OSPF.

This leads to several effects:

you can influence the choice of the root port of downstrem switches:

or changing (lowering ) the priority of the port towards the downstream switch on the upstream switch (nearest to the root bridge I mean) or by changing the STP cost on the downstream switch.

to make a comparison is like RPF check in multicast where you look for the best path to the source of the multicast packet (not the destination)

As soon as R2 is root bridge is advertises a root path cost of 0.

R1 will advertise to a third switch if present a root path cost as:

0 + cost of its own root port.

Example from real network

sh spanning-tree vlan 4

VLAN0004

Spanning tree enabled protocol rstp

Root ID Priority 0

Address 0019.a935.0f84

This bridge is the root

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 0

Address 0019.a935.0f84

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Aging Time 480

Interface Role Sts Cost Prio.Nbr Type

------------------- ---- --- --------- -------- --------------------------------

Te4/1 Desg FWD 2 128.385 P2p

Te4/5 Desg FWD 2 128.389 P2p

Te4/6 Desg FWD 2 128.390 P2p

Te4/7 Desg FWD 2 128.391 P2p

Po1 Desg FWD 3 128.1665 P2p

a switch connected to this node actually the companion distribution switch says about vlan4:

sh spanning-tree vlan 4

VLAN0004

Spanning tree enabled protocol rstp

Root ID Priority 0

Address 0019.a935.0f84

Cost 2

Port 385 (TenGigabitEthernet4/1)

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Bridge ID Priority 1

Address 0019.a935.0384

Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

Aging Time 480

Interface Role Sts Cost Prio.Nbr Type

------------------- ---- --- --------- -------- --------------------------------

Te4/1 Root FWD 2 128.385 P2p

Te4/5 Desg FWD 2 128.389 P2p

Te4/6 Desg FWD 2 128.390 P2p

Te4/7 Desg FWD 2 128.391 P2p

Po1 Altn BLK 3 128.1665 P2p

a root path cost of 2 exactly the cost of its root port:

RT-RM-SXR000-D-E-2#sh spanning-tree int te4/1

Vlan Role Sts Cost Prio.Nbr Type

------------------- ---- --- --------- -------- --------------------------------

VLAN0001 Desg FWD 2 128.385 P2p

VLAN0002 Root FWD 2 128.385 P2p

VLAN0003 Desg FWD 2 128.385 P2p

VLAN0004 Root FWD 2 128.385 P2p

Hope to help

Giuseppe

Cisco Employee

Re: Spanning Tree Protocol-state

Hello Sairam,

I am very deeply complimented by your words.

Yes, the change of the root bridge was to be expected if you changed the priority only on the R2. If you had set the priority on R0 to 0 and left the R1 to the default of 32768, you could set the priority of R2 to any valid value between 4096 and 28672 and it would not affect the current root bridge.

Regarding the terminology: The "designated path cost" can be perceived in various confusing ways. I suggest using a different terminology: the root path cost over a particular port.

Regarding the port path cost: in this case, let's not talk about a "path", simply about a port - a port cost, or, a cost of a port.

Let's see how these costs work together. The rooth path cost of the entire root bridge from itself is 0, of course. This value will be advertised in all BPDUs sent by the root. A switch directly connected to the root bridge with a 100Mbps link will receive this BPDU on some of its ports. It will add the port cost (19 by default for 100Mbps) to the root path cost indicated in the BPDU and it will thus calculate its own root path cost as 0+19=19 from the root bridge through that port. If there are no other ports receiving a better BPDU calculated in a similar way, this port will be the root port and the distance of the entire switch from the root will be 19.

Imagine further that there is another switch connected in line to the previous switch with a 10Mbps link. This switch will receive the BPDUs from its neighbor with a root path cost of 19 that we have calculated in the previous paragraph. It will add its own port cost to the root path cost indicated in the BPDU (100 by default for 10Mbps link) and calculate the root path cost over this port as 19+100=119. Again, if there are no better BPDUs calculated in a similar way received on any ports, this port will be the root port and the distance of the entire switch from the root bridge will be 119.

I am sorry if I suggested that the BPDUs contain only the port cost. Absolutely not! They always contain the cumulative (total) root path cost of their sender. However, what I wanted to say is that the port cost is added to the root path cost in a BPDU only upon receiving a BPDU, never when sending it.

Does all this make a sense? Please feel free to ask further.

Best regards,

Peter

New Member

Re: Spanning Tree Protocol-state

Hi Peter & Guisepee,

This lines made me to think again when comparing it with the scenario I have told you.

Your lines are below:

"It will add its own port cost to the root path cost indicated in the BPDU (100 by default for 10Mbps link) and calculate the root path cost over this port as 19+100=119."

If this is the case, Then R0 BPDU sent to R1 is having ROOT PATH COST of 0. R1 adds its own PORT COST 19 & send a BPDU to R2. So that means R2's Fa0/1 designated path cost (ROOT PATH COST) is 19.

I know that again I am refering your first post now. Why it is not changing designated path cost of Fa0/1 of R2 to 10,When I change PORT COST of R1's Fa0/0 to 10 (Incoming port as Guisepee pointed out).

Why "spanning-tree cost" command is not effective in this case. If it works we can easily makes change the BLK port of FA0/1 of R2 to FWD state

I believe I am not complicating this simple concept and taking your valuable time.

Sairam

Cisco Employee

Re: Spanning Tree Protocol-state

Hello Sairam,

Don't worry to ask about anything you want to discuss. This is why the NetPro exists.

I will go over your individual statements.

Then R0 BPDU sent to R1 is having ROOT PATH COST of 0. - Yes, if R0 is the root bridge then this is correct.

R1 adds its own PORT COST 19 & send a BPDU to R2. - Yes. The distance of R1 to the root bridge will be 19 and this will be the root path cost inserted into BPDU that the R1 sends towards R2.

So that means R2's Fa0/1 designated path cost (ROOT PATH COST) is 19. - No. The root path cost of R2 to the root bridge via Fa0/1 would be the received 19 from the R1's BPDU plus the port cost of the Fa0/1 itself which is 19 again, yielding the total of 38.

Why it is not changing designated path cost of Fa0/1 of R2 to 10,When I change PORT COST of R1's Fa0/0 to 10? - The R2 has obviously two choices - either to reach the root bridge via a direct link through Fa0/0 with a total root path cost of 0(BPDU RPC)+19(PC)=19, or to go through R1 via Fa0/1 with the total cost of 10(BPDU RPC)+19(PC)=29. The shortest path is here obviously the direct link. Therefore even if you change the cost on R1's Fa0/0 to 10, you do not see any change on R2.

Best regards,

Peter

New Member

Re: Spanning Tree Protocol-state

Hi Peter,

This topic has picked the momentum it seems and i get interested.

I just labed it again to see how it works and I attached result of the scenario I depicted in the diagram I attached in my first post.

As you said I expected the the designated path cost of R2 showuld be 38 (PC=19 + BPDU RPC=19) taking the default values in the fastethernet interface.

But in the lab I am seeing "designated path cost 19" in R2 fa 0/1.

Am i doing mistake in configuration or it is my conceptual mistake?

Your comments are appreciatable

Sairam

Cisco Employee

Re: Spanning Tree Protocol-state

Hello Sairam,

Can you please make one more experiment and post the same show commands again? Shutdown the Fa0/1 port on the R0 and redo all the show commands.

Thanks!

Best regards,

Peter

New Member

Re: Spanning Tree Protocol-state

Hi Peter,

please find the attached output of the activities you asked me to do. R0's fa0/1 is shutdown

HTH to explore more

Thanks

Sairam

Cisco Employee

Re: Spanning Tree Protocol-state

Hello Sairam,

I must admit that the output of "show spanning-tree" is confusing at best.

What confuses you is probably the line "Designate port id is XXX.X, designated path cost C". Well, you have to interpret it depending on the state of the port:

1.) If the port is a root port, then the designated path cost shows you the value of the BPDU Root Path Cost as received on that port before adding the port's own cost.

2.) Otherwise (the port is forwarding or blocking), the designated path cost shows you your own distance from the root which is inserted in the BPDUs sent out on that port (if they are sent out, of course).

In essence, the "designated path cost" line always shows you the raw value of the BPDU field "root path cost" - on root port, you see the value from the received BPDU, on all other ports, you see the value in transmitted BPDUs.

Note the sequence of the ports and distances in your last topology where the Fa0/1 on R0 is shutdown:

R0 f0/0 (0) ---> f0/0 (0) R1 f0/1 (19) ---> f0/1 (19) R2 f0/0 (38)

The numbers in parentheses show you the value of the "designated path cost" as described in the "show span" output for the respective port. Note that the value always corresponds to the raw "Root Path Cost" BPDU value that is either received or sent on that port.

Perhaps this helps a bit.

Best regards,

Peter

Hall of Fame Super Silver

Re: Spanning Tree Protocol-state

Hello Peter, Sairam

the fields

Designated port id is 128.2, designated path cost 19

are taken from the BPDU of the port that has winned the DP election on the lan segment.

Sairam, if you swap the ports you should be able to see port-id changing and following the port-id of DP port on segment.

Sometimes it is better to have asymmetrical connections to see what happens.

As a result of the fact that these values are those of the lowest best BPDU on segment they can reflect or not the current root path cost of the local node.

For a lan segment where local switch port is the DP

designated path cost = local switch root path cost

for a port in forwarding state but not DP on the segment that is the root port for non root bridge devices the designated cost is that received from the upstream switch DP port.

Note: looking at bridge-id can help

Also to help understand the output we can look at the bridge-id information

for example in Sairam's lab:

R2 bridge id is:

Bridge ID Priority 32768

>>> Address cc02.0ec0.0000

if we look at the lines

Designated bridge has priority 32768, address cc02.0ec0.0000

for port fas0/0 this tells us that R2 fas0/0 has winned the DP election on this segment as a result of this designated cost is = root path cost of R2 that is 38.

on fas0/1 we see:

Designated bridge has priority 32768, address cc01.0ec0.0000

this bridge-id is different from local switch bridge-id and this tells us that the other switch port has winned the DP election on this other segment.

As a result of this designated path cost is lower then root path cost of R2 switch

and is 19.

Hope to help

Giuseppe

New Member

Re: Spanning Tree Protocol-state

Dear Peter & Giuseppe,

A million Thanks & appreciation. When I started this thread I didnt expect it will grow like this and also this small but subtle topic took my day (Infact my Holiday sunday) Thanks for problem and doubts as it churn our brain.

And I have to give full rating to Peter and Giuseppe for taking your time in explaining this which we cannot google and get.

Thanks again. I am very on the concepts now.

Sairam.

Hall of Fame Super Blue

Re: Spanning Tree Protocol-state

Sairam

Are the links between your switches trunks or access links ?

If they are trunks then you need to use the spanning-tree vlan cost commmand ie.

switch R1

int fa0/1

spanning-tree vlan cost 5

Jon

Jon

Cisco Employee

Re: Spanning Tree Protocol-state

Hello Sairam,

Nice to hear from you again.

The command "spanning-tree cost" is taken into account only when selecing a root port. As you may know, the root port on a switch is that one which receives the best BPDU from among all ports on the switch. The "best" BPDU is given by the following multiple-step comparison:

1.) The lowest root bridge ID indicated in the received BPDU

2.) The lowest total root path cost = cost in the received BPDU + "spanning-tree cost"

3.) The lowest sender bridge ID indicated in the received BPDU

4.) The lowest port priority indicated in the received BPDU

5.) The lowest port index indicated in the received BPDU

After a root port is chosen, then for each segment (each link), a designated switch is elected. This is also simple: on a link, compare all the received BPDU to our own BPDU that would be sent out that port. If our BPDU is better than the other, the port remains forwarding, otherwise it goes into blocking state and stops sending BPDUs altogether.

Note a very important thing here: when electing a designated port, we already have the root port elected and thereby also our distance from the root bridge. Therefore, we do not add any other costs to the BPDUs we send or receive because our distance (and our neighbor's as well) from the root is already known. That is why the "spanning-tree cost" is ignored on all presently non-root ports. Also note that if it were taken into account (which is not), the result of the addition could not be compared between the two switches: I receive a BPDU from you and add some cost to it and I get a number X. The same does the neighbor switch with the BPDU you have sent to it and it calculates a number Y. Now, how do we compare those two numbers? We do not send them out in any packets. So, once again, the "spanning-tree cost" command is used only when electing a root port. On all other ports for all other STP purposes, the configured cost does not apply.

If you wanted to reverse the order of Blocking/Forwarding ports on the link between R1 and R2 you have to consider the five-step order mentioned earlier. If you want the R2 to be FWD and R1 to be BLK, you must somehow make the R2's BPDUs to be better than R1's. You do not have much choices, however. You can either lower the "spanning-tree cost" on the R2 root port to make the entire switch appear more close to the root bridge. Then, in step 2, the R2's BPDUs would be better than R1's. The other option is to make the R2's BID better (that is, lower) than R1's which could be done by lowering the R2's priority. Of course, all this can also be done on R1 by deliberately worsening the same parameters in the same places. However, you can't influence the position of FWD/BLK port on a link by configuring STP parameters of the ports directly on it.

The STP is one of the most cumbersome protocols I know about. Yes, sure, there are other which are far more complicated... but there is something strange about STP that makes it quite difficult to grasp.. I believe that there is little literature that would explain it concisely and clearly.

You are welcome to ask further.

Best regards,

Peter

Hall of Fame Super Blue

Re: Spanning Tree Protocol-state

Peter

Great explanation and thank you for covering up my rather bad post :).

Defintely worth a rating.

Oh and congrats on the gold star.

Jon

Cisco Employee

Re: Spanning Tree Protocol-state

Hello Jon,

Great explanation and thank you for covering up my rather bad post :)

Thank you very much for your kind words - and also for your rating. Your post was not bad at all. In fact, when I started writing my rather lengthy reply, I did not see your answer yet. You must have submitted it before I finished writing mine. I just felt that Sairam was trying to understand something in STP that in my own opinion is often misunderstood so I engaged in that lengthy explanation so I could be sure that we and Sairam are on the same "wavelength".

Oh and congrats on the gold star.

Thank you very much again! To receive such commendation from a vet like you is particularly valuable for me. Nevertheless, I can not compare to your rating level... :-) I am just trying to follow the best :)

Best regards,

Peter

319
Views
30
Helpful
15
Replies
CreatePlease to create content