Tags

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.

STP-Root-01

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.

STP-Root-02

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)