TechKnowSurge
Cisco CCNA 2.5 Cisco CCNA 1.13
VideoNetworkFree

Spanning Tree Algorithm Example #2

A hands-on walkthrough of Spanning Tree Protocol election on a four-switch topology, covering root bridge selection, root path cost calculation, root port election, and designated port assignment.

Complete this video to capture a CTF flag worth 1 point.

About this video

This content applies Spanning Tree Protocol (STP) election logic to a four-switch topology, using a worked example to reinforce the decision-making process behind loop prevention. The root bridge is identified by comparing bridge priority values first, with the switch holding the lowest priority — in this case 4,096 compared to the default 32,768 on the remaining switches — winning the election without needing to evaluate MAC addresses. With the root bridge established, root path costs are calculated for each switch based on link speeds: 1 Gbps links carry a cost of 4 and 10 Gbps links carry a cost of 2. These per-hop costs accumulate along each possible path, and each non-root switch selects the port with the lowest total cost to the root bridge as its root port. Where costs are equal, the tiebreaker sequence moves through sender bridge ID and then port ID, with the numerically lowest value winning in each case. Designated ports are then elected on a per-segment basis, with the port closest to the root bridge — meaning the one with the lowest cumulative path cost — winning on each link. All remaining ports that are neither root ports nor designated ports are placed into a blocking state, forming the loop-free active topology that STP is designed to produce. The example also notes why preferring the lower sender bridge ID matters operationally: it pre-positions switches to adapt quickly if the current root bridge fails.

What you'll learn

What's covered

Spanning Tree Protocol Example

Aligned to

Cisco CCNA
2.5 Interpret basic operations of Rapid PVST+ Spanning Tree Protocol
1.13 Describe switching concepts

Key terms

Spanning Tree Protocol
STP
A network protocol that prevents loops in Ethernet networks by creating a loop-free logical topology.
Bridge
A network device that connects two or more network segments and filters traffic based on MAC addresses.
Switch
A network device that connects devices within a LAN and forwards traffic based on MAC addresses.
Media Access Control
MAC
A sublayer of the Data Link layer that controls how devices on a network gain access to a medium and transmit data.
Bridge Protocol Data Unit
BPDU
A data message exchanged between switches running Spanning Tree Protocol to detect network loops and elect a root bridge. BPDUs contain the sending switch's BID and path cost information used to build the loop-free spanning tree.
Root Bridge
The switch elected as the reference point for the Spanning Tree Protocol topology, determined by the switch with the lowest Bridge ID (priority + MAC address). All other switches calculate their best path to the root bridge and block redundant links to create a loop-free tree.
Bridge Priority
A configurable numeric value within the Bridge ID, defaulting to 32768 and incrementing in multiples of 4096, used to influence which switch is elected as the root bridge in STP.
Root Port
The port on a non-root switch that provides the least-cost path to the root bridge.
Designated Port
DP
In STP, the port on each network segment that provides the best path to the root bridge and is placed in a forwarding state. Each segment has exactly one designated port, which is selected based on the lowest cumulative path cost to the root.
Blocking Port
A non-designated port placed into a blocking state by STP to prevent network loops.

Topics

Spanning Tree Protocol Network Switching Bpdu Root Bridge Election Port Roles Networking

Transcript

Now that we know about the bridge protocol data units, a little more about the process, and have a little more information, let's try one of those examples again and see if we can fill this in. I'm going to add an extra switch to this, but do the same thing.

Electing the root bridge

Let's see if you've come up with the right answer. The first thing that we want to do is we want to elect the root bridge. What is the root bridge? We base that off of the priority, and then the extended system ID, and then the MAC address.

So let's take a look at the priorities first and see if we can hone in on one device here. When we take a look at the priority, I see here a 4096, which I can see 28672 is less than, and we're looking for the lowest. So that could be a contender right there. And then we see a couple of defaults, which is 32768, so we've got those in there. So we can see that this is actually the lowest priority, and we don't even need to look at MAC addresses. If we were to look at MAC addresses, because all of the priorities were set the same, we would also see that this has the lowest MAC address as well. So this switch right here — we'll call this switch 4 — is the root bridge. So we'll call this one, two, three and four. So switch 4 is the root bridge here.

Calculating root path cost

Next we need to calculate the root path cost to the root bridge. So from switch 2, this link to switch 2 would be a cost of four. So let's put four in there. So there's a cost of four there and a cost of four there.

This link right here to the root bridge is 10 gigabits per second, so that's two and two right there.

From this switch right here to this switch right here, that's 10 gigabits per second, so that's two, plus the four, so this would be six to get there, and six. And then to come down this direction, this is a one gigabit per second, so that is a cost of four plus the two, so this is six and six.

So there we have it. Now we have, for switch 1, four equal cost routes right there.

Electing root ports

So the next thing we need to do is we need to elect root ports. What are going to be the root ports? What is going to want to be communicated here?

So for switch 2, let's take a look at it. We take a look at all four of these lines on switch 2, and we can see that two of them have a cost of six to get around to this root bridge and two of them have the cost of four. So it's going to be one of these smaller cost of four that we see over here. So let's choose one of those. It's going to either be 043 or 044. When it comes to it, we're either looking at the lowest cost to the bridge, or we're looking at the lowest sender bridge ID. In this case the sender for both of these links is the same switch, so it's the same thing. So now we're going to have to revert to the lowest port ID. So if these are both set to the default port ID, then what's being sent across here is a 047 and 048. It's going to choose the lowest, so 047. So this right here is going to be the root port for switch 2.

Let's take the same thing for switch 3. We go and take a look at the cost to go around this way. It looks like the cost to go all the way around is actually going to be this link right here, which is one gigabit per second, which is a cost of four, plus another cost of six, so it's actually going to be 10 to go around in that direction right there. So it's going to be 10 to get that way. It's definitely going to prefer this to going this way in this direction right here, so across 045 or 046.

Now, since it's the same cost of two, it takes a look at the sender bridge ID, which happens to be the same, because it's coming from the same switch. And so now it has to look at the ports that it's sending on. So 045 and 046 — provided that they're the same priority, it's going to choose 045, and this is going to be a root port right here. So we'll call that a root port for switch 3.

Next we look at switch 1, and we have — it looks like it's even whether it goes this way, which is going to be 6 and 6, or this way, which is going to be 6 and 6. So the next step is that we have to look at the bridge ID, and which one is lower. We see this is set to 4096 and this is 32768. So the lower bridge ID is this way, so it's going to send it in one of these two links over here. So it's chosen, it's going to choose one of these now because of that, and now we need that tiebreaker.

By the way, just a side note: the reason why this is important, that it chooses the lowest bridge ID next, is because let's say this switch 4 goes offline. Then what will happen is this one will probably become the root bridge next, and so now it's already established that connection and it doesn't need to do any other changes. It will just start sending things now to this new switch. So that's the reason why that's the next step when choosing a root port.

So it's chosen either 045 or 046, and since we need the tiebreaker for that, we need the port ID. So we have 045 and 046. It's going to choose 045 because that's the lower one. So now this is the other root port that it's going to send on.

Electing designated ports

So now we have a root port for each of the non-root bridges, and so now what we have to do is we have to elect designated ports. What's going to win is going to be the closest to the root bridge, and the closest to the root bridge on this link is going to be obviously the root bridge itself. So we're going to mark both these with a D for designated port, and both these for designated port. There we go, we've got D on each of those. In fact, what I'm going to do is I'm going to change the color here, because it's getting a little bit cloudy. Maybe we'll do an orange here, so maybe mark that with a D. D, D, D.

So now the designated ports for the rest of these links. Let's tackle these two links up here. Which is the designated side? Whatever is closest to the root bridge. So this is a gigabit per second and it's a cost of four, versus the other side is going to be a cost of six to go around the other way. So these are going to be the designated ports on this side right here.

And then for these two links on this side, the last two links that we have: if it goes around this way it's going to be a total of six, it looks like, and if it goes around this way it's going to be a total of two. So these are going to be the designated ports on this side, so let's mark those with these right there.

Blocking the remaining ports

Next, now that we've got the designated ports, we can get to what we really want to get to, which is: which ones are we going to shut down? So let me use a red X for that. Which ones are we going to shut down? If this is the root port right here, we're going to shut the other one down, so I'll put an X on that one right there.

Now we've got the root port here on switch 1, so the other one is going to be shut down, and I'll put an X right there. And then also these other two right here are going to be shut down. I shouldn't use the term shutdown — it's actually going to go into a blocking state. So those are going to be our non-designated ports, or our alternate ports.

And then same thing, I look at the root port, and the only one that's not done anything with is this 046. So there you have it. Now we have everything marked on these switches and what they're going to be.

About TechKnowSurge

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 →