Section 4.2: Spanning-Tree Protocol (STP)

In a Layer 3 environment, the routing protocols keep track of redundant paths to a destination network so that a secondary path can be quickly utilized if the primary path fails. Layer 3 routing allows many paths to a destination to remain up and active and allows load sharing across multiple paths. However, in a Layer 2 environment, no routing protocols are used and, hence, redundant paths are not allowed. Instead, the Spanning-Tree Protocol (STP) is used to provide network link redundancy and load balancing so that a Layer 2 switched network can recover from failures without intervention in a timely manner.

A Layer 2 switch mimics the function of a transparent bridge. A transparent bridge must offer segmentation between two networks, while remaining transparent to all the end devices connected to it. A transparent bridge operates in the following manner:

• The bridge has no initial knowledge of the location of any end device; therefore, the bridge must listen to frames coming into each of its ports to figure out on which network a device resides.

• The bridge constantly updates its bridging table upon detecting the presence of a new MAC address or upon detecting a MAC address that has changed location from one bridge port to another. The bridge is then able to forward frames by looking at the destination address, looking up the address in the bridge table, and sending the frame out the port where the destination device is located.

• If a frame arrives with the broadcast address as the destination address, the bridge must forward or flood the frame out all available ports. However, the frame is not forwarded out the port that initially received the frame. Hence, broadcasts are able to reach all available networks. A bridge only segments collision domains but does not segment broadcast domains.

• If a frame arrives with a destination address that is not found in the bridge table, the bridge is unable to determine which port to forward the frame to for transmission. This is known as an unknown unicast. In this case, the bridge treats the frame as if it were a broadcast and forwards it out all remaining ports. After a reply to that frame is received, the bridge will learn the location of the unknown station and add it to the bridge table.

• Frames that are forwarded across the bridge cannot be modified.

Bridging or switching in this fashion works well but offers no additional links for redundancy purposes. To add redundancy, a second switch must be added. Now two switches offer the transparent bridging function in parallel. However, when the switches receive an unknown unicast, both will flood the frame out all their available ports, including the ports that link to the other switch, resulting in what is known as a bridging loop, as the frame is forwarded around and around between two switches. This occurs because parallel switches are unaware of each other. The Spanning-Tree Protocol (STP) was developed to overcome the possibility of bridging loops. It enables switches to become aware of each other so that they can negotiate a loop-free path through the network. Loops are discovered before they are opened for use, and redundant links are shut down to prevent the loops from forming. STP is communicated between all connected switches on a network. Each switch executes the Spanning-Tree Algorithm (STA) based on information received from other neighboring switches. The algorithm chooses a reference point in the network and calculates all the redundant paths to that reference point. When redundant paths are found, STA picks one path to forward frames with and disables or blocks forwarding on the other redundant paths. STP computes a tree structure that spans all switches in a subnet or network. Redundant paths are placed in a blocking or standby state to prevent frame forwarding. The switched network is then in a loop-free condition. However, if a forwarding port fails or becomes disconnected, the STA will run again to recompute the Spanning-Tree topology so that blocked links can be reactivated.

By default, STP is enabled on all ports of a switch. STP should remain enabled in a network to prevent bridging loops from forming. However, if STP has been disabled on a CLI-based switch, it can be reenabled with the following command:

Switch (enable) set spantree enable [ all | module_number/port_number ]

If STP has been disabled on an IOS-based switch, it can be re-enabled with the following command:

Switch (config)# spantree vlan_list

You can use the show spantree [ vlan ] command to view the status of STP on either a CLI- or IOS-based switch.