Friday, February 19, 2016

CCIE 400-101: Layer 2 Technologies - Switch Priority, Port Priority, Path Cost, STP Timers

Switch Priority


  • The IEEE 802.1D standard requires that each switch has an unique bridge identifier (BID),  which controls the selection of the root switch.
  • For PVST+/RPvST+, the same switch must have different bridge IDs for each configured VLAN.
  • Each VLAN on the switch has a unique 8-byte bridge ID. 
  • The 2 most-significant bytes are used for the switch priority, and the remaining 6 bytes are derived from the switch MAC address.
  • The switch supports the IEEE 802.1t spanning-tree extensions, and some of the bits previously used for the switch priority are now used as the VLAN identifier. 
  • The result is that fewer MAC addresses are reserved for the switch, and a larger range of VLAN  IDs can be supported, all while maintaining the uniqueness of the BID.
  • The 2 bytes previously used for the switch priority are reallocated into a 4-bit priority value and a 12-bit extended system ID value equal to the VLAN ID.


  • The default switch priority is 32768.
  • The switch priority can be manually configured with the spanning-tree vlan <vlan-id> priority <0-61440> command.
  • The priority can be changed only in increments of 4096. 
  • Valid priority values are 0, 4096, 8192, 12288, 16384, 20480, 24576, 28672, 32768, 36864, 
  • 40960, 45056, 49152, 53248, 57344, and 61440. All other values are rejected.
  • There are also two indirect ways to affect the switch priority: spanning-tree vlan <vlan-id> root primary and spanning-tree vlan <vlan-id> root secondary.
  • The primary keyword sets the switch priority to 24576 if that priority allows the switch to become the root. Otherwise, this command sets the switch priority to 4096 lower than the current root.
  • The secondary keyword always sets the switch priority to 28672.
  • This primary/secondary logic is only applied at the time of command execution. The switch priority does not dynamically change if another switch later advertises a better priority.


Port Priority


  • Much like the bridge ID, STP also assigns a unique port ID for each interface.
  • The port ID is a 2-byte field, divided into a 4-bit priority value and a 12-bit interface identifier.
  • The interface identifier is fixed.
  • The default port priority value is 128.
  • The port priority can be manually reconfigured with the spanning-tree vlan <vlan-id> port-priority <0-224>, in increments of 32.
  • The priority values are 0, 32, 64, 96, 128, 160, 192, and 224. All other values are rejected.
  • IMPORTANT: The switch looks at the information in the received BPDU to decide which port to block - not what is locally configured on the switch.
  • This can be confusing when show spanning-tree vlan <vlan-id> output displays seemingly conflicting information.


Cat2#sh spanning-tree vlan 1

VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    24577
             Address     0018.1820.2700
             Cost        19
             Port        24 (FastEthernet0/24)
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     000b.46e2.6980
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time 300

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Fa0/23              Altn BLK 19        128.23   P2p
Fa0/24              Root FWD 19        128.24   P2p


  • From the above output, you might mistakenly conclude that Fa0/23 should be Root Port and Fa0/24 should be Alternate Port because of the lower port ID (Fa0/23 - 128.23 < Fa0/24 - 128.24). However, this is what is locally configured on the switch and does not affect the STP port blocking process.
  • To see what the switch is learning from its upstream neighbor, you must look at more detailed output.


Cat2#show spanning-tree vlan 1 int fa0/23 detail
 Port 23 (FastEthernet0/23) of VLAN0001 is alternate blocking
   Port path cost 19, Port priority 128, Port Identifier 128.23.
   Designated root has priority 24577, address 0018.1820.2700
   Designated bridge has priority 24577, address 0018.1820.2700
   Designated port id is 128.25, designated path cost 0
   Timers: message age 1, forward delay 0, hold 0
   Number of transitions to forwarding state: 1
   Link type is point-to-point by default
   BPDU: sent 1938, received 694

Cat2#show spanning-tree vlan 1 int fa0/24 detail
 Port 24 (FastEthernet0/24) of VLAN0001 is root forwarding
   Port path cost 19, Port priority 128, Port Identifier 128.24.
   Designated root has priority 24577, address 0018.1820.2700
   Designated bridge has priority 24577, address 0018.1820.2700
   Designated port id is 64.26, designated path cost 0
   Timers: message age 2, forward delay 0, hold 0
   Number of transitions to forwarding state: 2
   Link type is point-to-point by default
   BPDU: sent 1993, received 697


  • The highlighted information signifies why Fa0/24 is forwarding and Fa0/23 is not (received port ID 64.26 < 128.25).


Path Cost


  • Path cost is simply the cost to reach the root switch.
  • Each interface has a default cost assigned to it based on bandwidth (for example, 100 Mbps = 19).
  • There are two cost assignment methods: the short method (spanning-tree pathcost method short -  the default) and the long method (spanning-tree pathcost method long).
  • The short method uses a 16-bit format that yields values from 1-65535. 
  • The long method uses a 32-bit format that yields values from 1-200,000,000. 


  • Why is the maximum 200,000,000 when a 32-bit number can clearly have a higher value?
    • Limiting the range of the Path Cost parameter to 1-200,000,000 ensures that the accumulated Path Cost cannot exceed 32 bits over a concatenation of 20 hops.
  • The switch calculates its port cost by adding its interface cost to the root path cost in the  received BPDU. Example: a switch located two 100 Mbps hops away from the root bridge would  have a path cost of 38 (19 + 19 = 38).
  • The cost value can be manually altered with the spanning-tree vlan <vlan-id> cost <value> command.


STP Timers


  • There are several STP timers, three of which are commonly known and play a key role in STP operation:
    • Hello: The hello time is the time between each BPDU that is sent on a port. This time is equal to 2 seconds (sec) by default, but you can tune the time to be between 1 and 10 sec.
    • Forward Delay: The forward delay is the time that is spent in the listening and learning state. This time is equal to 15 sec by default, but you can tune the time to be between 4 and 30 sec.
    • Max Age: The max age timer controls the maximum length of time that a switchport saves its configuration BPDU information. This time is 20 sec by default, but you can tune the time to be between 6 and 40 sec.
  • Each configuration BPDU contains these three parameters. 
  • Each configuration BPDU also contains another time-related parameter that is known as the Message Age. 
  • The Message Age contains the length of time that has passed since the root bridge initially originated the BPDU. 
  • The root bridge sends all its BPDUs with a message age value of 0, and all subsequent switches add 1 to this value. 
  • Effectively, this value contains the information on how far you are from the root bridge when you receive a BPDU.
  • In addition to the timers, IEEE 802.1D defines other parameters related to STP (like the STP domain diameter). See: Understanding and Tuning Spanning Tree Protocol Timers.


References

CCIE Routing and Switching v5.0 Official Cert Guide, Volume 1
Understanding Spanning Tree Port Priority
Configuring STP
Spanning Tree Port Costs
Understanding and Tuning Spanning Tree Protocol Timers

No comments:

Post a Comment