So the Spanning Tree Orotocol exists to have bridges dynamically discover that subset of the topology which is loop free or it's a tree and yet it has just enough connectivity so that where physically possible there is a path between every switch. If, of course, the wiring breaks, then that switch is no longer connected. So it's no longer part of the topology. So when you look at a spanning tree protocol there are several standard flavors this traditional spanning tree which is standardized in 802.1d there is rapid spanning tree or rstp which is standardizing 802.1w and there's multiple spanning tree or mstp in 802.1s these are all ieee standards they're also proprietary flavors of spanning tree mostly done by cisco so there is the old pavilion spanning tree or pvsd cisco also decided to come up with rapid pavilion spanning tree or rpvsd plus we are now going to look at traditional spanning tree because all other spanning trees are based on this traditional spanning tree and understanding how it works will tell us how spanning tree in general works so switches will exchange messages that i will allow them to compute the spanning tree these messages are called bridge protocol data units or bpdus and there are two types there's configuration usually when it's starting and there is a tcn topology change notification when there's a change in topology either link has gone down or switches off or something so the first step and this actually goes into four steps in total so the first step is you need to decide on a point of reference which we will call the root bridge and this is done through an election process the process is based on the bridge id the bridge id is comprised of the bridge priority which is a two byte value that is configurable and the mac address which comes set by the manufacturer of the switch so every switch starts by sending bpdus with a root bridge id equal to its own bridge id so all the switches are saying i am the root and then every bpdu that is received is analyzed to see if there is a lower root bridge id being announced by somebody else if so every switch will replace the value of the advertised route bridge in the pbt bpd is it sending with this lower one that it has received so eventually all the switches will agree on who the root bridge is so let us look at this in action we have three switches switch a switch b and switch c interconnected as shown all switches have the same priority which we've shown as a number three two seven six eight then the other part is the mac address so switch a has a mac address that ends in aa in hexadecimal switch b ends in bb in hexadecimal and switch c in cc so looking at this and they all have the same priority which one will be elected as a root bridge the answer is switch a because it has the smallest mac address in hexadecimal aaa is smaller than b and c now that you have elected the bridge step two is you now need to determine the root port on each switch this is done by finding the port which has the lowest route path cost which is the cumulative cost of all the links leading to the root bridge if you try to reach the route going out through that port now every link on the switch has a path cost the path cost is defined by the spanning tree protocol and it's inversely proportional to the link speed so the faster the link the lower the cost so at 10 mbps if you see the spanning tree cost will be a hundred the rapid spanning tree cost is a lot higher and this is because if you look down at the table for a hundred gig or one terabyte links there is no defined spanning tree cost and most vendors will just set it to one or zero so you cannot tell the difference between a one terabyte link or a 100 gig link but for rapid spanning tree you have 200 400 gig and 224 uh one terabit the important ones the ones which are most common on networks as of today will be either 100 meg a gig or 10 gig mostly within their 200 will be 19 4 and 2 first traditional spanning tree so the root path cost is an accumulation of all of these link costs and the cost that it has learned from neighboring switches so the question that you switch is trying to answer is if i send packets through this link how much will it cost total to read the root bridge so to find a root port the root bridge sends out bpd use with a root path cost of 0 because it is the root bridge so it costs 0 to reach it the neighbor receives this bpdu and then adds the path cost of that port it received it on to the root path cost and then it sends these bpdus out through other ports with that new cumulative value as the root path cost every time you receive a bpdu with the root path cost as a switch you add the the cost of the port that you've received it on and send it out to the other ports so on each switch the port which has the lowest root path cost becomes the root port this is the port with the best path to the root bridge so if we look at our three switches again we've now added some details port one of switch a is connected to port one of switch b port two of switch a is connected to port one of switch c and ports two of switches b and c are connected to each other these are all fast ethernet or 100 mbps links which is why the cost is 19. so the question is what is a path cost on each port and the switches have to out decide which is the root pot on each switch so from switch a to switch b the path cost on port 1 will become 19 that link and then from switch a to switch c the path cost will also be 19. then between switch b and switch c if switch b is to use port 2 it will need to go uh 19 which is a cost to c plus 19 which is a cost to a so that is 38 and that is the same thing with switch c if it uses port 2 that is 19 to switch b plus another 19 to switch a so based on that the root port on both switch b and switch c will be port one okay so now we have root pots step three we haven't solved the loop problem yet because we still have all the links are still active so each network segment needs to have only one switch for adding traffic to and from that segment and the way it's done is you identify a designated port per network segment and that is the one with the lowest cumulative root path cost to the root bridge we shall see how this happens later now it's possible for two or more parts in a single segment to have identical root path costs this is a tie condition now all spanning tree decisions are based on the following sequence of conditions to break ties number one you choose the lowest root bridge id number two the lowest root path cost to the root bridge number three the lowest sender bridge id and number four the lowest sender port id so if we look at our same network again we have switches which we switch c we already know which one the root ports are but now the question is which port should be the designated part on each segment for the segment between a and b it's going to be so for any segment that includes the root port so a and b or a and c of course the designated part is going to be the port on the root bridge because switch a is a root bridge so any segment that includes a root bridge the designated parts will always be on switch a now between switch B and switch C you had two ports which had the same cost of 38 but if you look at the hierarchy of tie breakers switch b has a lowest bridge id because the mac address is smaller so port 2 of switch B will be the designated port for that B-to-C link. The fourth and final step is any port that is not elected as either a root port or nor a designated port is put inside the blocking state so this breaks the loop and completes spanning tree so if we go back to our diagram all the ports of switch a will be designated ports obviously part one of switch B is a root port port 1 of switch C is also a root port port 2 of switch C is not a designated and it's not a root port so it is put inside blocking state so it's neither root port nor a designated port.

© Produced by Philip Smith and the Network Startup Resource Center, through the University of Oregon.

Attribution-NonCommercial 4.0 International (CC BY-NC 4.0)
This is a human-readable summary of (and not a substitute for) the license. Disclaimer. You are free to: Share — copy and redistribute the material in any medium or format Adapt — remix, transform, and build upon the material The licensor cannot revoke these freedoms as long as you follow the license terms. Under the following terms: Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. NonCommercial — You may not use the material for commercial purposes. No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.