In this post we will see how to manipulate STP root port selection in a given topology. We will use the VLAN 10 (management vlan) STP instance to see which ports will be Root Port in each switch. Any given switch Bridge ID consist of Bridge Priority (default 32768 + system extend ID) & MAC address. Since we are taking vlan10 as example default bridge priority will be 32778.
Here are the basic rules of STP
1. Lowest bridge ID (Priority:MAC Address) switch becomes the Root-Bridge
2. Each non-root bridge should have ONE root port (RP) which is the port having lowest path-cost to Root Bridge.
3. All ports in Root Bridge become Designated Ports (DP)
4. Each segment should have one Designated Port (DP)
5. All RP/DPs will be in FORWARDING state & all other ports will be in BLOCKING state.
According to the topology CAT1 is having lowest MAC address (hence lowest bridge ID) & will become the Root Bridge. Butif you do not want to rely on MAC addreses you can lower priority of a given switch to make them as the Root Bridge for all VLANs. In my case will make priority for all Vlans to lowest value( which is 0) in CAT1.
CAT1(config)#spanning-tree vlan 1-4094 priority ? <0-61440> bridge priority in increments of 4096 CAT1(config)#spanning-tree vlan 1-4094 priority 0 CAT1#sh spanning-tree vlan 10 VLAN0010 Spanning tree enabled protocol ieee Root ID Priority 10 Address 0017.94ba.bc80 This bridge is the root Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority 10 (priority 0 sys-id-ext 10) Address 0017.94ba.bc80 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec
Now we will look at which port become Root Port in each non-root bridges (CAT2,CAT3,CAT4). Root Port selection is based on the port having lowest cost to the Root Bridge (CAT1). For PVST (Per VLAN Spanning Tree) path cost will depend on bandwidth of links and cost value is as shown below for most commonly used links.
10Gbps -> 2
1 Gbps -> 4
100 Mbps -> 19
10 Mbps -> 100
Also it is important to understand how path cost calculate. From Root Bridge it will send BPDU with cost to Root Bridge as “0”. When this BPDU receive by any other switch it will add its own port cost (according to the above mentioned value). So if BPDU receive by a Fast Ethernet port (100 Mbps) it will calculate path cost to root as 19 (0+19).
For CAT3, it has 3 different option (label b,t,p). Here Root Port choice is obvious, only via Fa 0/22 (b) is having lowest path cost to Root Bridge. So that will become the Root Port.
For CAT2’s it has 4 different ports (label d,f,u,r). Out of which two ports (d & f) are having same path cost (19) to Root Bridge. Via port “u” it is having path cost of 38 & via port “r” it is having path cost of 57. Since we have two equal cost paths, you need to know tie breaking rules in this scenario. Here they are,
1. Lowest Sending Bridge ID
2. Lowest Port Priority (of sender)
3. Lowest Interface number (of sender)
In our case both port “d” & “f” receiving BPDU from same bridge (CAT1) which suggest “lowest port priority of sender” will be the tie breaker. By default each port is having priority value of 128 (can be 0-256 multiplier of 16). This makes “lowest interface number of sender” it tie breaker. In our case CAT1’s fa1/0/23 is having lower interface number & therefore that BPDU received by CAT2’s fa1/0/24 will become root port.
CAT2#sh spanning-tree vlan 10
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 10
Address 0017.94ba.bc80
Cost 19
Port 26 (FastEthernet1/0/24)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 001a.e3a7.ff00
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa1/0/2 Desg FWD 19 128.4 P2p
Fa1/0/21 Desg FWD 19 128.23 P2p
Fa1/0/23 Altn BLK 19 128.25 P2p
Fa1/0/24 Root FWD 19 128.26 P2p
Now let’s see what will happen if you change CAT1’s fa1/0/24 port priority.
CAT1(config-if)#spanning-tree vlan 10 port-priority ? <0-240> port priority in increments of 16 CAT1(config-if)#spanning-tree vlan 10 port-priority 0 CAT1(config-if)#do sh span vlan 10 Interface Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- -------------------------------- Fa1/0/22 Desg FWD 19 128.24 P2p Fa1/0/23 Desg FWD 19 128.25 P2p Fa1/0/24 Desg FWD 19 0.26 P2p
Now if you look in CAT2 you would see Fa1/0/23 (connected to CAT1’s fa1/0/24) will become root port because of the lower port priority of sender.
CAT2#sh spanning-tree vlan 10
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 10
Address 0017.94ba.bc80
Cost 19
Port 25 (FastEthernet1/0/23)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 001a.e3a7.ff00
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa1/0/2 Desg FWD 19 128.4 P2p
Fa1/0/21 Desg FWD 19 128.23 P2p
Fa1/0/23 Root FWD 19 128.25 P2p
Fa1/0/24 Altn BLK 19 128.26 P2p
For CAT4, both port G0/3 “q” & G0/2 “s” are having equal path cost(38) to root bridge(CAT1). But in this case port “s” is getting BPDU from a lower bridge id switch CAT2 (32778: 001a.e3a7.ff00) comparison to port “q” from CAT3 (32778: 0024.137b.5a00). In this case Port “s” – G0/2 become root port & Port Priority or Interface ID won’t come into play.
CAT4#sh span vlan 10
VLAN0010
Spanning tree enabled protocol ieee
Root ID Priority 10
Address 0017.94ba.bc80
Cost 38
Port 2 (GigabitEthernet0/2)
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Bridge ID Priority 32778 (priority 32768 sys-id-ext 10)
Address 58bf.ea59.f800
Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec
Aging Time 15 sec
Interface Role Sts Cost Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/2 Root FWD 19 128.2 P2p
Gi0/3 Altn BLK 19 128.3 P2p
But in here if you want to make G0/3 as root port you can change it’s port cost to a lower value which results lower path cost to root. In this example I will change it to cost of 1 which resulting path cost to root is 20 via that port. So that will become root port.
CAT5(config-if)#spanning-tree vlan 10 cost ? <1-200000000> Change an interface's per VLAN spanning tree path cost CAT5(config-if)#spanning-tree vlan 10 cost 1 CAT5#sh spanning-tree vlan 10 VLAN0010 Spanning tree enabled protocol ieee Root ID Priority 10 Address 0017.94ba.bc80 Cost 20 Port 3 (GigabitEthernet0/3) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority 32778 (priority 32768 sys-id-ext 10) Address 58bf.ea59.f800 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 sec Interface Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- -------------------------------- Gi0/2 Altn BLK 19 128.2 P2p Gi0/3 Root FWD 1 128.3 P2p
Now you know which port becomes a root port in each non-root switches. So Port “b”, “f” & “q” will become root port in this topology. If you want to identify which ports become Designated Ports (DP) you can follow below rules.
1. All ports in Root Bridge will become Designated Ports
2. Each segment (link) will have ONE Designated Port.
If a given link does not have a Root Port, either of them could be a designated port. But lower bridge ID switch port wins in this situation (“u” in “t-u” link & “r” in “r-s” link ) become a DP. In this way ports other than “d”, “t” & “s” will become either DP or RP. Hence those will become “FORWARDING” ports & others (d,t,s) become “BLOCKING” Ports as shown in the below diagram.
Here is “show spanning tree vlan 10” output to verify the above.
CAT2#sh spanning-tree vlan 10 Interface Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- -------------------------------- Fa1/0/2 Desg FWD 19 128.4 P2p Fa1/0/21 Desg FWD 19 128.23 P2p Fa1/0/23 Root FWD 19 128.25 P2p Fa1/0/24 Altn BLK 19 128.26 P2p <- "port d" CAT3#sh spanning-tree vlan 10 Interface Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- -------------------------------- Fa0/3 Desg FWD 19 128.3 P2p Fa0/21 Altn BLK 19 128.21 P2p <- "Port t" Fa0/22 Root FWD 19 128.22 P2p CAT4#sh spanning-tree vlan 10 Interface Role Sts Cost Prio.Nbr Type ------------------- ---- --- --------- -------- -------------------------------- Gi0/2 Altn BLK 19 128.2 P2p <- "port S" Gi0/3 Root FWD 1 128.3 P2p
In this way you can manipulate the Root Port selection of your network.
References:
1. VLAN Load Balancing between Trunk link
2. Understanding Rapid Spanning Tree Protocol (802.1w)
You say “CAT1’s fa1/0/23 is having lower interface number & therefore that BPDU received by CAT2’s fa1/0/24 will become root port.”
Then the diagram and configuration show fa1/0/24 as blocking.
Please clarify
Hi Suren,
Since CAT1 fa1/0/23 having lower interface number that connected port on CAT2 (fa1/0/24) will become the root port. So in Cat2 fa1/0/23 will be blocked by STP. Diagram shows that in CAT2
Hope that clear.
Rasika
hi, Suren, actually I was misled at first, me too.
I would have also put another design where the F1 / 024 port of Cat2 would be the root port because as you rightly wrote:
In our case both port “d” & “f” receiving BPDU from same bridge (CAT1) which suggest “lowest port priority of sender” will be the tie breaker. By default each port is having priority value of 128 (can be 0-256 multiplier of 16). This makes “lowest interface number of sender” it tie breaker. In our case CAT1’s fa1/0/23 is having lower interface number & therefore that BPDU received by CAT2’s fa1/0/24 will become root port.
In fact, after you change the priority the F 1/0/24 interface of Cat1 (Root Bridge) so that port F 1/0/23 of Cat2 becomes root port, with the drawing you reported.
However this is an excellent example from an educational point of view. Compliments!
Thanks a lot
Luca
Hi Luca, Glad you found it useful to understand how STP works. Once you understand basics, it looks easy.
KIT
Rasika
hi nayarasi..
I have a question so this election is for VLAN 10 only? so Root port, Designate Port and Block ports will be different in different VLANs? Like for ex, if we have VLAN 20, another STP election will happen for VLAN 20? please reply
That’s correct if you run PVST(per vlan spanning tree) which is default STP type in most of the case.
HTH
Rasika
If I run PVST? what if it is Rapid PVST or the standard STP?
It is same for RSTP (it is enhanced version of PVST). if you run standard STP setup I think single STP instance for all vlan.
HTH
Rasika
Hi Nayarasi,
I enjoyed and I really love your steps. Now, How about designated port? if one port is set as root port and there are remaining 4 ports on the switch connected to different switches, which port will be designated port? what are the rules/election process for designated port?
mmm. interesting.. we should only have one designated port per router what if there are many ports, how to choose the designated port?
Typically if it is a router, that will not be running STP (as STP is L2 technology to prevent L2-Loops).
If it is a L2 topology (like I have showns), then each link should have one DP.
HTH
Rasika
Hi, thanks for the great tutorial.
I find the explanations help me in understanding basic of STP.
But, i am a bit lost when it comes to the part of choosing the DP.
‘If a given link does not have a Root Port, either of them could be a designated port. But lower bridge ID switch port wins in this situation (“u” in “t-u” link & “r” in “r-s” link ) become a DP.’
In my opinion, for “t-u” link, u should be the designated Port instead of t. because its bridge ID (0024) is lower than t’s bridge ID (001a)
Hi
You are correct “U” is the DP in “t-u” link for the same reason you mentioned. I think in my blog same conclusion for that link.
HTH
Rasika
where is the blocking port???
All non-designated ports will get blocked (yellow color)
HTH
Rasika
HEY!, nice post!! helped me to clear some things out.
Greetings from venezuela
Thanks Miguel 🙂
Is path cost considered while selecting designated port, before using bridge ID as criteria?
No, in a given segment (or line) there is no RP, then lowest bridge ID end will becom DP on that segment.
Path cost consideration is when to determine RP and not DP
HTH
Rasika
Hi Rasika,
this time I do not agree with you.
in all the manuals I read this
Step 3 – Designate Port selection – (1 per segment) Lowest cost to root bridge
If all costs are equal, which non-root bridge has the lowest BID?
If all BIDs are equal, which advertised switchport is the lowest numbered port?
For me, the “r” port should be in blocking mode. I’m in confusion because
sh spanning-tree vlan 10 :the port “s” is in blk
thanks a lot
Luca
Hi Rasika, forgive me what you say is not right. Also to establish the DP the first thing is the root path cost. In the event of a tie, the lowest priority bridge wins.
Luca
Hi nayarasi, thank you very much for the clear post. It helped me finally to understand it.
Regards
Thorsten
Great..
hi,
you say: via port “r” it is having path cost of 57… In my opinion is 39.. right?
thanks a lot
Hi Luca,
If you look at CAT4 “show span vlan 10” output, you can see G0/2 and G0/3 STP cost is 19 (I believe link is negotiated to 100Mbps & that is the value use to calculate STP cost, not the physical port speed).
So in that case cost would be 57 via port “r”.
Note that I have changed CAT4-G0/3 STP port cost to 1 later in the post and that point onward, STP path cost via CAT2-port “r” would be 39 (19+1+19)
HTH
Rasika
excellent stuff Rasika, you should write your own book 🙂
1 question:
CAT1(config-if)#spanning-tree vlan 10 port-priority 0
why above command changed port priority of 1 port and not others ?
Just noticed, it’s interface level command and not global command 🙂
Please ignore my question.
Good sharing….
Thank you
“CAT2 (fa1/0/24) will become the root port” …. I agree but in your image CAT 2 fa1/0/24 is blocked. It should be root port as it is connected to CAT1 fa1/0/23.
Hi Mario,
As part of my config, I have changed CAT1-G1/0/24 port priority to 0. So from CAT2’s perspective, it will go by lowest port priority of sender, which is connected to CAT2 – g1/0/23.
Hope that clear
Rasika
Great article, Keep it up man.
http://www.routexp.com/2017/12/switching-basics-stp-root-bridge.html
STP well explains
Thank you Bol…