CCIE 400-101: Layer 2 Technologies - Switch priority, port priority, path cost


Switch Priority

  • The IEEE 802.1D standard requires that each switch has an unique bridge identifier (bridge ID or BID).
  • With PVST+ and RSTP+, the same switch must have different bridge IDs for each configured VLAN.
  • The bridge ID (8 bytes) consists of a 2-byte switch priority and a 6-byte MAC address. 
  • The 2-byte switch priority is actually constructed of a 4-bit priority value and 12-bit extended system ID value, which is equal to the VLAN ID. 



  • Because of how the switch priority is built, the priority value can only be increased in increments of 4096. 
  • The BID is used to select the root switch. Lower is better. 
  • If there is a tie in priority, the switch with the lowest MAC address is elected root.
  • The default switch priority value is 32,768.
  • There are two ways of changing the switch priority:
    1. Setting an exact value. The value must be between 0 and 65,535 and in increments of 4096. The command is spanning-tree vlan vlan-id priority value.
    2. Setting the primary root bridge with a macro command spanning-tree vlan vlan-id root primary. If the current root priority is more than 24,576, the switch sets its priority to 24,576. If the root priority is lower than 24,576, the switch sets its priority to 4096 less than the current root bridge. If the current root priority is set to 0, configuring the switch with the macro command will yield no results.

Example:

Switch2#show spanning-tree
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0006.d6ab.a040
             Cost        19
             Port        11 (FastEthernet0/11)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0006.d6ac.46c0
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 15
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2            Desg FWD 19        128.2    P2p
Fa0/11           Root FWD 19        128.11   P2p
Fa0/12           Altn BLK 19        128.12   P2p



Path Cost

  • The STP cost value is based on the associated interface bandwidth. 
  • The cost is inversely proportional to the interface bandwidth: the higher the bandwidth, the lower the cost.
  • A lower path cost is preferred.
  • The root path cost is the lowest cost path to the root bridge.
  • The are two methods to calculate and assign the path cost value (port cost). The short method (default) uses a 16-bit format that yields values from 1-65,535. The long method format yields values from 1-200,000,000. All switches in the network should the same method. 
  • The default port cost values for the short method are:


  • The default port cost values for the long method are:


  • The port cost can be manually set with the spanning-tree cost value command under the interface configuration mode.

Example:

Switch2#show spanning-tree
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0006.d6ab.a040
             Cost        19
             Port        11 (FastEthernet0/11)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0006.d6ac.46c0
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 15
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2            Desg FWD 19        128.2    P2p
Fa0/11           Root FWD 19        128.11   P2p
Fa0/12           Altn BLK 19        128.12   P2p



Port Priority

  • Quick recap: Switches exchange BPDUs, which the STP algorithm uses to calculate the loop-free topology.
  • These BPDUs are strictly classified depending on their content. 
  • A BPDU is superior than another if it has:
    1. A lower root bridge ID.
    2. A lower path cost to the root.
    3. A lower sending bridge ID.
    4. A lower sending port ID.
  • These four parameters are examined in order.
  • If the first three parameters match, as in the case below, the port ID is used to break the tie. 


  • In this specific case, all the BPDUs sent by Catalyst R have the same root bridge ID, the same path cost to the root and the same sending bridge ID. The only parameter left to select the best one is the sending port ID. 
  • The sending port ID is a 16-bit parameter, split in two fields: the port priority and the port number.
  • The port number is fixed, because it is based only on its hardware location. 
  • The port priority is a configurable value (between 0 and 255). The default is 128.
  • To change the port priority value, use the spanning-tree port-priority value command under the interface configuration mode.

Example:

Switch2#show spanning-tree
VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0006.d6ab.a040
             Cost        19
             Port        11 (FastEthernet0/11)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0006.d6ac.46c0
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 15
Interface        Role Sts Cost      Prio.Nbr Type
---------------- ---- --- --------- -------- --------------------------------
Fa0/2            Desg FWD 19        128.2    P2p
Fa0/11           Root FWD 19        128.11   P2p
Fa0/12           Altn BLK 19        128.12   P2p


References
Configuring Spanning Tree
Cisco IOS LAN Switching Command Reference
VLAN Load Balancing Between Trunks Using the Spanning-Tree Protocol Port Priority

Comments