cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
599
Views
2
Helpful
8
Replies

Questions regarding STP

AmmarAlbis
Level 1
Level 1

Hi guys.

I have two questions regarding STP

1-Why have an alternate path in STP?

STP keeps redundant paths in standby in case the current path goes down right? But, when a link failure occurs, the STP is recalculated. So, what's the point of having an alternate path if it's gonna recalculate the whole thing anyway? Why not just open the alternate path and keep going as is? 

2-Switches may cause loops. That's why STP exists. But, before the STP is calculated it has to determine the root bridge. Each switch will send BPDUs to its neighboring switches to see the switch with lowest BID. Initially each one has itself as the root bridge. Then any time it sees one with lower BID, it changes the root BID in the BPDU. But, if a loop exists, wouldn't they just keep sending each other these BPDUs? At what point do the switches know they have root bridge? Is it time based? Or do they just keep doing it until all switches have decided on the same switch? and if so, how do they know all of them have the same switch as the root bridge?

I am somewhat of newbie to networking, so it would be most appreciated if you could explain it as simple as possible.

Thanks in advance.

8 Replies 8

If Sw have one port 1 g abd other 10 g 

Here you can not use PO so stp will select 10g and primary and 1g as backup' 

Access SW connect to two agg SW' both two agg SW interconnect' access SW have one primary and one as backup 

Why we need backup' if there is one link then failed of this link will make your SW can not anymore forward traffic.

MHM

Joseph W. Doherty
Hall of Fame
Hall of Fame

Why not just open the alternate path and keep going as is? 

STP doesn't keep track of alternates, if computes the best path and blocks all others.

So, if the current path fails, it needs to re-compute the best path, as we don't want to just open all alternates (yes, possibly more than one), which may create a loop.

Unfortunately, STP, especially the non-rapid variants, is slow to compute the best path.  Even the "rapid" is slow compared to most L3 routing protocols.

Keep in mind, when STP was defined (1985), you didn't have much, if any, VoIP and real-time video, so multi second to many, many second (i.e. up to nearly a minute) convergence was acceptable.  Also keep in mind, the hardware resources were much more limited (especially based on cost [my first Microcomputer system, in '79, cost me a third of my annual salary, and that was even discounted mail-order]) for doing such computations, so STP is "simple minded".

Also keep in mind, as "slow" as STP is, compare that to a link failure where you need to manually intervene.  How long might that take?  I.e. even original non-rapid STP would very likely bring up an alternate path faster than that.

For #2, STP starts in everything blocked status.  If the root bridge changes, all the STP bridges block everything again (I'm ignoring Cisco's proprietary and rapid-STP fast unblocking of configured edge ports).  Basically, the whole L2 domain network will freeze until STP works out what should be unblocked.

Part of the original standard had allowances for wait times, with adjustments, and defaults, for maximum "diameter", i.e. how long to wait.

Rapid-STP, uses more of a hop count allowance (one of its differences that helps make it "rapid") but I recall it still has some timers too.

Again, STP, depending on the "event" and the non-rapid vs. rapid, can take a few seconds to a good chunk of a minute to resolve a L2 topology.  (L3 routing protocols, can deal with topology "events", from, oh maybe in tens of milliseconds to a few seconds.)

Thank you @MHM Cisco World and @Joseph W. Doherty.

For the first question, It seems I might have misunderstood something. I thought that when the root port link fails, it opens the alternate port and uses it as a new path. But, after reading the protocol again, the alternate port is just blocked. It doesn't just open when the root port fails. That's why we need to recalculate the STP.  It never had an alternate path in mind in the first place. Is this conclusion right?

Second question, so basically their are timers and hop counts. So if a switch learns of a new better root bridge, it resets the timer. If this root bridge remain the same for a certain time, then this root bridge is the best(lowest BID) and all switches also chose it within this time. As for Rapid-STP it has a counter implementation to reduce the time for convergence. Is this conclusion correct?  

And thanks again.

When primary is failed abd SW use backup there is no need for SW to re-calculate STP.

For second Q I dont get' how it relate to primary/backup link of stp.

MHM


@AmmarAlbis wrote:

For the first question, It seems I might have misunderstood something. I thought that when the root port link fails, it opens the alternate port and uses it as a new path. But, after reading the protocol again, the alternate port is just blocked. It doesn't just open when the root port fails. That's why we need to recalculate the STP.  It never had an alternate path in mind in the first place. Is this conclusion right?


Hopefully, my prior reply will demonstrate that an alternate role pole doesn't necessarily guarantee it will become a root port, if the root port fails.

BTW, have some fun, experiment with the PT attachment, for example, look at what happens when I add another link to between some of the switches:

JosephWDoherty_2-1751211464426.png


@AmmarAlbis wrote:

Second question, so basically their are timers and hop counts. So if a switch learns of a new better root bridge, it resets the timer. If this root bridge remain the same for a certain time, then this root bridge is the best(lowest BID) and all switches also chose it within this time. As for Rapid-STP it has a counter implementation to reduce the time for convergence. Is this conclusion correct?  


Again, if the root bridge fails, that's a big deal, especially with non-rapid STP.  I believe that, per standard, takes 50 seconds.

Off the top of my head, I do not try to remember all the things that rapid-STP does differently, to work "rapidly".  Also, in the Cisco world, besides Cisco extending their STP implementations to be per VLAN (PVST) they provided multiple "enhancements", some, but not all, incorporated into the rapid-STP standard.  Also, I believe, (especially with Cisco?), STP and rapid-STP "terms", might be the same words, but deep down, they don't work exactly the same.  Unless going for a certification test, or troubleshooting STP, the two things to remember, try to avoid complex L2, if L3 can be used instead, and if using STP, if possible, use a rapid variant (which includes MST).  Also, learn about STP feature enhancements, as some of they are very useful.

In other words, things like insuring certain port roles, or changing SPT parameter to improve "speed" of convergence, aren't usually as important as other higher level design considerations.  For example, primary and secondary root selection, or, perhaps, using Etherchannel, for multiple L2 links between switches, than STP for redundancy, or limiting scope of broadcast and unicast flooding, i.e. pruning, etc.

As you mention being a newbie to networking, often, conceptionally, networking isn't too difficult, but to do it well often requires a very broad knowledge of networking.

Joseph W. Doherty
Hall of Fame
Hall of Fame

I've attached a PT file.

When you load it, and STP converges, it should look like:

JosephWDoherty_0-1751208911823.png

BTW, switches are running PVST (non rapid), and top switch is configured as root.

The orange interfaces are blocked.

If I shut the top left active link, when STP again converges, you get:

JosephWDoherty_1-1751209113513.png

Hmm, the alternate link between the top and left most switched not used, port on bottom switch, to right switch unblocked, why?

If we look at before and after port roles for the left and bottom switches, we see:

Left switch:

Before                    After

Interface        Role Sts Interface        Role Sts 
---------------- ---- --- ---------------- ---- --- 
Gi1/0/3          Altn BLK Gi1/0/3          Altn BLK 
Gi1/0/1          Root FWD 
Gi1/0/2          Desg FWD Gi1/0/2          Root FWD  

Bottom switch:

Before                    After

Interface        Role Sts Interface        Role Sts 
---------------- ---- --- ---------------- ---- --- 
Gi1/0/1          Root FWD Gi1/0/1          Desg FWD 
Gi1/0/2          Altn BLK Gi1/0/2          Root FWD 

On the left switch, when I shut the root port, the alternate port stayed the an alternate and the designated port became the new root, so some form of STP calculation was performed, correct?  I.e. the alternative didn't automatically become the new root.

On the bottom switch, the root port became a designated port and the alternative port became the root port, but no links were changed, so some change to the topology, forced a STP calculation, correct?

BTW, if you watch the switches, you'll see ports going into listening/learning roles, during the transition, which is expected.

So, perhaps STP isn't just as simple of alternative role ports always becoming a root when the root port fails.  Additionally, you can have multiple alternatives.

Oh, if you're wondering why the left most switch link to the top most switch didn't become the new root, that was because all links but it are running at gig, while it is running at 10 Mbps.  I.e. higher STP link cost, which impacts selection of best path to root, when doing STP best path calculation.

If you're also wondering why you might actually have a topology as above, perhaps the two gig links are in the same street conduit (i.e. subject to a "backhoe" cut) while the 10 Mbps link is p2p WiFi running across the street between the two switch locations.  (In the real-world, whether your redundant fiber links share a conduit, or whether your two independent service providers use the same POP, can matter for redundancy.)

Royalty
Level 1
Level 1

Hi @AmmarAlbis,

I know the focus is on classic "legacy" STP, but it's worth mentioning that RSTP does work quite differently.


For the first question, It seems I might have misunderstood something. I thought that when the root port link fails, it opens the alternate port and uses it as a new path. But, after reading the protocol again, the alternate port is just blocked. It doesn't just open when the root port fails. That's why we need to recalculate the STP. It never had an alternate path in mind in the first place. Is this conclusion right?

Yes, in the original specification of STP, 802.1d or 'CST', ports can be in blocking or forwarding when the topology is converged. However, there is no concept of a backup or alternate path - there is no pre-designated backup/alternate port that can take over immediately in the event of a root port failure. If connectivity to the root switch from a non-root is lost, the non-root switch must transition another port to a root port, but only after going through the listening and learning port states (and potentially the max age - message age timer calculation if the failure is not directly detected). Your understanding is correct in that there is no fast or automatic failover to another predetermined link/path, and the Spanning Tree Algorithm (STA) needs to be run. If using Cisco switches you can enable a proprietary optional STP enhancement called UplinkFast which does 'precalculate' an alternate path/port that can be used immediately when a failure to the root is detected on a current root port. Alternatively, if you are using RSTP (originally defined in 802.1w) this functionality of immediate failover to another path/port is facilitated natively by RSTP through a built-in mechanism of determining an Alternate port.

It also gets confusing because the words 'backup' and 'alternate' are either describing redundancy or scenarios or they are referring to the actual name given to one of the RSTP port roles.

In case it is causing any confusion, it is worth noting that on Cisco switches, PVST+ (classic STP) shows ports as being in the Alternate port role, but technically that does not exist in classic STP (CST) and is purely cosmetic to the CLI (unless using UplinkFast, where I suppose it would have relevance). In classic STP, it's referred to as a non-designated port role, but shows in the CLI as an 'Altn'. If someone searches for information on alternate ports and sees the RSTP description (which is what would show up), it wouldn't be unreasonable for them to assume alternate ports exist in STP, or at least get confused. It's similar to how when a switch is operating in RSTP mode but still shows ports as in a 'blocking' state rather than 'discarding',. What I'm getting at is there is an extreme amount of confusion with these technologies with how they are documented vs how the vendor implementation in terms of technicalities and naming conventions. There is also confusion as in RSTP there can be more than 1 'Alternate' port. Only the 'Alternate' port with the best/superior BPDU will transition to forwarding. Joseph has also already mentioned that a designated port may become the new root port also.


2-Switches may cause loops. That's why STP exists. But, before the STP is calculated it has to determine the root bridge. Each switch will send BPDUs to its neighboring switches to see the switch with lowest BID. Initially each one has itself as the root bridge. Then any time it sees one with lower BID, it changes the root BID in the BPDU. But, if a loop exists, wouldn't they just keep sending each other these BPDUs? At what point do the switches know they have root bridge? Is it time based? Or do they just keep doing it until all switches have decided on the same switch? and if so, how do they know all of them have the same switch as the root bridge?

In classic STP, only the root bridge can originate Configuration BPDUs. Other non-roots are allowed to forward them but not originate their own. This is contrast to RSTP which uses RSTP Synchronisation and every switch creates their own BPDUs (albeit influenced by the current root bridge) and do not 'forward' other BPDUs created by other switches. Whilst STP is converging there is of course no data forwarding as ports in the listening and learning port states cannot forward data traffic. However, they can exchange BPDUs.

Again in classic/legacy STP, when a Configuration BPDU (also called Hello BPDUs) are sent by a root switch and received by a non-root switch, the non-root switch forwards these BPDUs (after updating the relevant fields such as the root path cost, message age, etc.) out of other designated ports leading to other segments.

A non-root switch does not forward Configuration BPDUs out of root ports or blocking ports, and also, a non-root switch does not forward Configuration BPDUs received on non-root ports, but does process them. Because of this, a root switch does not always receive its own originated BPDU back in on another port. If the root bridge does receive its own originated BPDU back in on another port, the root path cost could be higher than its own cost to reach the root (0), or there are further tiebreakers. I believe this behaviour is also why the PT file that Joseph attached is behaving how it does - MLS4 is not receiving any BPDUs from MLS6 and therefore it has no idea a path to the root exists out of Gi1/0/2 initially.

As for RSTP, there are cases that can cause transient loops of BPDUs which comes from the 'count to infinity' or 'race condition' problems causing old information to be circulated which causes repeated root switch elections. But these loops are temporary and the message age and max age are used as hop counters to prevent an infinite loop. So to answer the question, I believe a loop of BPDUs and flapping of elected root switches does happen in classic STP. It's worth noting that Message Age and Max Age have different meanings and operation in STP vs RSTP.

I hope some of this makes sense, but I think the main takeaway is that STP and RSTP can be extremely complex and does require a lot of concentration and persistence to learn everything and truly understand it. If you can be persistent it will start to become clearer. Do ask all that you can!

Very nice additional information about some of differences between STP, rapid-STP and Cisco enhancements.  Also confirms my mention of "STP and rapid-STP "terms", might be the same words, but deep down, they don't work exactly the same."

. . . I think the main takeaway is that STP and RSTP can be extremely complex and does require a lot of concentration and persistence to learn everything and truly understand it.

They certainly can be, but a deep, deep understanding of either isn't always required to use either effectively, although such understanding may be required for troubleshooting.