Spanning Tree Protocol (STP) root bridge election, root path cost calculation, and port role assignment are walked through using a multi-switch topology example. The process covers how bridge IDs, link costs, and port IDs determine which ports forward traffic and which are blocked.
Spanning Tree Algorithm Example
Now that we have a good understanding of spanning tree algorithm, let's look at an example. See if you can figure it out, and then we'll go over it together.
The first step is to find out what the root bridge is. We need to elect a root bridge. The root bridge is based off of whichever is the lowest bridge ID. The bridge ID is a combination of the priority plus the extended system ID plus the MAC address.
So we take a look at the priorities, and we can see that two of these are default priorities, while one of these is 36,864. The default is 32,768, so both these defaults are 32,768. So we know that this switch 3 is not going to be a root bridge; it's going to be one of the other two. And we know that the priority is the same on switch one and switch two, so we have to look at the MAC address. In the MAC address, we start to see that this one starts with a 1, versus this other one starts with a 0. So we're going to prefer the one that starts with a 0 because it's a lower number. Therefore this switch 2 will be the root bridge. So switch 2 is the root bridge.
Next, let's go ahead and calculate the root path cost, and we've got to do that for every switch link. Switch 2 is our root bridge. Let's take a look at switch one, and we can see that the cost that goes to the root bridge from this first one is going to be 19. I look at this, this is 100 megabits per second, and 100 megabits per second means that we're at a cost of 19. So that's 19. This next one is the same one, so this is 19 as well.
The gigabit per second connections are at four, so these are four, plus whatever it takes to get across here. So this switch 3 also has a cost of four for each of these, so total, each of these links are actually going to be eight to get to the root bridge. And these are both four right there. So that is the root path cost for each one of these.
The next one is we need to elect root ports. So we take a look at this and we say, well, these two on switch one are not going to be root ports, so it's got to be one of these other two, 046 or 045. And so if they are the same cost, which they are, then we look at what the sending port ID is. So we see 047 and 048, so it's going to be 047, the lowest, if there's no priority set. We don't see that there's any priority listed, so we're going to assume that it's the default priority. So this first one, 045, is actually going to be the root port.
And we do the same process on switch three. So on switch three, we can see that this is a 45 right here versus 46, so this is going to be the root port — it's going to be 045 on switch 3. So there we have it. Now we've figured out the root ports.
Now we've got to figure out designated ports. The designated ports are going to be whatever is closest to the root bridge. Obviously these ports on the root bridge are the closest, so those are all designated ports. And then we will see on switch 3 we've got designated ports on both these links right here.
So let's see, are all the links accounted for? This link has a designated port here, this link has a designated port, this link has a designated port, this link has a designated port, this one and this one. Okay, so we've got every link has a designated port.
Now we need to elect the alternate ports, the ones that we're going to block. So this 045 is the root port for switch three, so now we're going to block 046 because that is an alternate. So let's mark that as an alternate, put an A right there. And then these other two ports on switch three are designated ports already.
So then on switch one we can see that 046 is going to be the alternate, so we'll mark that as an A. And then also 43 and 44 are redundant links also, so we need to make both those alternates. So there we have it. Now we have elected the designated ports and elected the alternate ports, and we have finished.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →