STP Operations

Steps to a Loop-Free Topology

Now you know how loops are created and the basics of using spanning tree protocol to prevent them. This topic will take you, step by step, through the operation of STP. Using the STA, STP builds a loop-free topology in a four-step process:

  1. Elect the root bridge.
  2. Elect the root ports.
  3. Elect designated ports.
  4. Elect alternate (blocked) ports.

During STA and STP functions, switches use Bridge Protocol Data Units (BPDUs) to share information about themselves and their connections. BPDUs are used to elect the root bridge, root ports, designated ports, and alternate ports. Each BPDU contains a bridge ID (BID) that identifies which switch sent the BPDU. The BID is involved in making many of the STA decisions including root bridge and port roles. As shown in the figure, the BID contains a priority value, an extended system ID, and the MAC address of the switch. The lowest BID value is determined by the combination of these three fields.

The graphic shows three boxes, each representing a component of the bridge ID. From left to right the first box is Bridge Priority which is 4 bits in length, the second box is Extended System ID which is 12 bits in length, and the third box is the MAC address which is 48 bits in length. Text to the right of the boxes reads Bridge ID with the Extended System ID. Text at the bottom of the graphic reads The BID includes the Bridge Priority, the Extended System ID, and the MAC address of the switch.

The Fa0/2 interface of S2 is the designated port on the segment with S3.

4. Elect Alternate (Blocked) Ports

If a port is not a root port or a designated port, then it becomes an alternate (or backup) port. Alternate ports and backup ports are in discarding or blocking state to prevent loops. In the figure, the STA has configured port F0/2 on S3 in the alternate role. Port F0/2 on S3 is in the blocking state and will not forward Ethernet frames. All other inter-switch ports are in forwarding state. This is the loop-prevention part of STP.

The Fa0/2 interface of S3 is not a root port or a designated port, so it becomes an alternate or blocked port

Elect a Root Port from Multiple Equal-Cost Paths

Root port and designated ports are based on the lowest path cost to the root bridge. But what happens if the switch has multiple equal-cost paths to the root bridge? How does a switch designate a root port?

When a switch has multiple equal-cost paths to the root bridge, the switch will determine a port using the following criteria:

  1. Lowest sender BID
  2. Lowest sender port priority
  3. Lowest sender port ID

Click each criteria for an example and explanation.

1. Lowest Sender BID

The figure shows a topology with four switches, including switch S1 as the root bridge. Examining the port roles, port F0/1 on switch S3 and port F0/3 on switch S4 have been selected as root ports because they have the lowest cost path (root path cost) to the root bridge for their respective switches. S2 has two ports, F0/1 and F0/2 with equal cost paths to the root bridge. In this case the bridge IDs of the neighboring switches, S3 and S4, will be used to break the tie. This is known as the sender’s BID. S3 has a BID of 32769.5555.5555.5555 and S4 has a BID of 32769.1111.1111.1111. Because S4 has a lower BID, the F0/1 port of S2, which is the port connected to S4, will be the root port.

2. Lowest Sender Port Priority

To demonstrate these next two criteria, the topology is changed to one where two switches are connected with two equal-cost paths between them. S1 is the root bridge, so both of its ports are designated ports.

S4 has two ports with equal-cost paths to the root bridge. Because both ports are connected to the same switch, the sender’s BID (S1) is equal. So the first step is a tie.

Next on the list is the sender’s (S1) port priority. The default port priority is 128, so both ports on S1 have the same port priority. This is also a tie. However, if either port on S1 was configured with a lower port priority, S4 would put its adjacent port in forwarding state. The other port on S4 would be a blocking state.

3. Lowest Sender Port ID

The last tie-breaker is the lowest sender’s port ID. Switch S4 has received BPDUs from port F0/1 and port F0/2 on S1. Remember the decision is based on the sender’s port ID, not the receiver’s port ID. Because the port ID of F0/1 on S1 is lower than port F0/2, the port F0/6 on switch S4 will be the root port. This is the port on S4 that is connected to the F0/1 port on S1.

Port F0/5 on S4 will become an alternate port and placed in the blocking state, which is the loop-prevention part of STP.

STP Timers and Port States

STP convergence requires three timers, as follows:

  • Hello Timer -The hello time is the interval between BPDUs. The default is 2 seconds but can be modified to between 1 and 10 seconds.
  • Forward Delay Timer -The forward delay is the time that is spent in the listening and learning state. The default is 15 seconds but can be modified to between 4 and 30 seconds.
  • Max Age Timer -The max age is the maximum length of time that a switch waits before attempting to change the STP topology. The default is 20 seconds but be modified to between 6 and 40 seconds.

Note: The default times can be changed on the root bridge, which dictates the value of these timers for the STP domain.

STP facilitates the logical loop-free path throughout the broadcast domain. The spanning tree is determined through the information learned by the exchange of the BPDU frames between the interconnected switches. If a switch port transitions directly from the blocking state to the forwarding state without information about the full topology during the transition, the port can temporarily create a data loop. For this reason, STP has five ports states, four of which are operational port states as shown in the figure. The disabled state is considered non-operational.

Note: To avoid problems with STP, IEEE recommends a maximum diameter of seven switches when using the default STP timers.

The graphic shows a flow chart depicting the four STP operational states. At the top of the flow chart is the Blocking state. In the Blocking state No BPDU is recieved and the Max Age = 20 seconds. An arrow points from the Blocking state to the Listening state. The Listening state has a forward delay of 15 seconds. There is an arrow pointing from the Listening state to the Learning state. The Learning state has a forward delday = 15 seconds. There is an Arrow pointing from the Learning state to the Forwarding state. There is a flow chart box titles Link comes up with an arrow pointing to a second box titled Blocking. The text in the Blocking box states In blocking state until SPT determines if port is root or designated port. This box has an arrow pointing to the Listening state.

The details of each port state are shown in the table.

Table caption
Port State Description
Blocking The port is an alternate port and does not participate in frame forwarding. The port receives BPDU frames to determine the location and root ID of the root bridge. BPDU frames also determine which port roles each switch port should assume in the final active STP topology. With a Max Age timer of 20 seconds, a switch port that has not received an expected BPDU from a neighbor switch will go into the blocking state.
Listening After the blocking state, a port will move to the listening state. The port receives BPDUs to determine the path to the root. The switch port also transmits its own BPDU frames and informs adjacent switches that the switch port is preparing to participate in the active topology.
Learning A switch port transitions to the learning state after the listening state. During the learning state, the switch port receives and processes BPDUs and prepares to participate in frame forwarding. It also begins to populate the MAC address table. However, in the learning state, user frames are not forwarded to the destination.
Forwarding In the forwarding state, a switch port is considered part of the active topology. The switch port forwards user traffic and sends and receives BPDU frames.
Disabled A switch port in the disabled state does not participate in spanning tree and does not forward frames. The disabled state is set when the switch port is administratively disabled.

Operational Details of Each Port State

The table summarizes the operational details of each port state.

 
Port State BPDU MAC Address Table Forwarding Data Frames
Blocking Receive only No update No
Listening Receive and send No update No
Learning Receive and send Updating table No
Forwarding Receive and send Updating table Yes
Disabled None sent or received No update No

Per-VLAN Spanning Tree

Up until now, we have discussed STP in an environment where there is only one VLAN. However, STP can be configured to operate in an environment with multiple VLANs.

In Per-VLAN Spanning Tree (PVST) versions of STP, there is a root bridge elected for each spanning tree instance. This makes it possible to have different root bridges for different sets of VLANs. STP operates a separate instance of STP for each individual VLAN. If all ports on all switches are members of VLAN 1, then there is only one spanning tree instance.

 

Evolution of STP