Configuring spanning tree is relatively straightforward and consists of the following steps:
The configuration scenarios show how to configure each of these steps, with a series of scenarios being presented for the many STP enhancements that are available and a final troubleshooting scenario.
In this scenario, you learn how to configure the root bridge. When you start configuring spanning tree, decide which switch will be the root bridge and then ensure that the desired root bridge becomes the root bridge. Figure 4-5 illustrates a network that consists of four switches connected in a looped topology.
Figure 4-5. Scenario Network Topology
Switch-A is a Catalyst 4000 switch that connects servers and Switch-B is a Catalyst 3550 switch, also connecting servers. Switch-C (Catalyst 3550) and Switch-D (Catalyst 4000) are access layer switches that connect end user devices, such as PCs and printers.
The network in Figure 4-5 is using a single VLAN for all devices, and the heaviest client/server traffic is between servers connected to Switch-A and clients on Switch-C and Switch-D. At all times, live data located on the servers attached to Switch-A is replicated to backup servers attached to Switch-B. The network must be configured so that the spanning-tree topology provides the most efficient route for the majority of traffic.
Root Bridge Placement
In this scenario and for any spanning-tree network, the most important component that needs to be decided is which switch becomes the root bridge. To demonstrate the design philosophy associated with spanning-tree root bridge selection, a few different choices for the root bridge are now considered, with the pros and cons of using each bridge as the root bridge described.
Figure 4-6 shows Switch-C as the root bridge and the spanning-tree topology calculated from this. The ports connected to Switch-C on Switch-A and Switch-B become root ports because they are closest ports to the root bridge. Next, consider the segment between Switch-A and Switch-B, where a designated port must be chosen for the segment. When a switch transitions from a shutdown state to the Listening state, each switch sends BPDUs listing Switch-C as the root, with a path cost of 19 (the cost of the link to Switch-C). Each switch receives the opposite switch configuration BPDUs and adds the cost of the gigabit link (4) to the advertised root path cost of 19, giving a root path cost of 23 on Switch-A via port 1/1 and on Switch-B via interface Gig0/1. Because the cost to the root is the same for both ports on the segment, the next selection criteria described in the STA (see Table 4-4) is the sender bridge ID. Assuming Switch-A has a lower bridge ID, Switch-A assumes the designated port on the segment (port 1/1) and Switch-B blocks interface Gig0/1.
Figure 4-6. Spanning Tree Topology with Switch-C as the Root Bridge
Now, consider Switch-D. A similar process occurs, where Switch-D receives configuration BPDUs from both Switch-A and Switch-B, each with an equal path cost of 19. Switch-D adds the cost of each link (19) on which the configuration BPDUs were received to the root path cost and determines that the root bridge is reachable via both Switch-A and Switch-B with a total cost of 38. Switch-D chooses port 2/1 as its root port (because Switch-A has a lower bridge ID). On the segment attached to the non-root port 2/2, Switch-D next determines whether or not the port should be designated for the segment. Because Switch-B is advertising that it can reach the root bridge with a cost of 19, and the lowest cost to the root is 38 (via Switch-A), Switch-D chooses Switch-B as the designated bridge for the segment and places port 2/2 into a blocking state.
Switch-C has a direct connection to both Switch-A and Switch-B, which optimizes traffic for user PCs connected to Switch-C accessing servers on either Switch-A or Switch-B. However, it means that for servers on Switch-A to communicate with servers on Switch-B, the communications transit via Switch-C over 100-Mbps uplinks, as opposed to the gigabit link between Switch-A and Switch-B (Switch-B has blocked interface Gig0/1). This arrangement slows down the data replication process and introduces heavy congestion on the Switch-C switch and links during the day. Also, consider the effect on communications for Switch-D. With Switch-C as the root, the spanning tree is lopsided and long because Switch-C is at one edge of the network. This configuration causes inefficient and lengthy paths between devices, such as the four switch hops between end users on Switch-D and servers on Switch-B (the path will be Switch-D Switch-A Switch-C Switch-B). If you choose Switch-D as the root bridge, the same spanning tree topology is created (a mirror image) with exactly the same problems just listed.
When you are selecting the root bridge, one of the most important objectives is to ensure the network diameter (the distance in switch hops between any two devices) is minimized. The simple rule of thumb to achieve this goal is to use a core switch at the center of the network; if you choose an edge switch, the maximum network diameter increases.
You must also consider major traffic paths in the network when selecting the root bridge. The root bridge should be placed close to major servers and other sources of high network traffic to ensure the topology of the network is optimized to the traffic flows of the network.
In this scenario, either Switch-A or Switch-B should be configured as the root bridge because they are at the center of the network. So now that you have narrowed your selection to two choices, which bridge should be selected as the root bridge? Figure 4-7 shows the topology if Switch-B is chosen as the root bridge.
Figure 4-7. Spanning Tree Topology with Switch-B as the Root Bridge
Clearly this is an improvement over the topology shown in Figure 4-6. The largest number of hops between any devices has been reduced from four to three (e.g., Switch-D Switch-B Switch-A). Now, consider the main traffic distribution path. Remember, this path is between clients on switches Switch-C or Switch-D and servers attached to Switch-A. With Switch-B as the root, all of this traffic must transit via the path Switch-C Switch-B Switch-A and vice versa. Ideally, you would like the connections between Switch-A and the client switches to be active because this configuration would reduce the path to Switch-C Switch-A. How do you achieve this? By configuring Switch-A as the root bridge! Figure 4-8 shows the topology with Switch-A as the root bridge.
Figure 4-8. Spanning Tree Topology with Switch-A as the Root Bridge
With Switch-A configured as the root bridge, the network topology is optimized for the traffic characteristics of the network. End user traffic needs to traverse only two switch hops, and data replication traffic is transported across the high-speed gigabit connection between Switch-A and Switch-B. It is important that you understand these characteristics to ensure that the network topology configured is performing correctly and adequately.
In summary, the main concepts to take into account when you are determining the root bridge are as follows:
In this scenario, choosing Switch-A or Switch-B minimizes the network diameter. Because of the main servers being attached to Switch-A, choosing Switch-A as the root bridge is the correct choice because it optimizes the spanning-tree topology to the traffic paths between the end users and servers.
Secondary Root Bridge Placement
Now that you have chosen your root bridge, it's time to select a secondary or backup root bridge. The secondary root bridge becomes the root in the event of something going wrong with the root bridge, which includes root bridge failure, root bridge malfunction, or administrative error. Figure 4-9 shows the Layer 2 topology with Switch-A (the root bridge) having failed.
Figure 4-9. Spanning Tree with Switch-A Having Failed
The new topology basically consists of three switches interconnected in a straight line. Because Switch-A has failed, all redundant paths have been removed from the network. You might now notice that with this particular topology, it really doesn't matter which bridge is the root bridge. The spanning tree topology is the same regardless of which bridge is the root bridge. You might now wonder why you should even bother thinking about a second-ary root bridge. Well, assume that Switch-A is replaced, but the network administrator forgets to configure Switch-A with the appropriate bridge priority to force it to become the root bridge. Now a redundant topology exists, and you are working with the same issues shown in Figures 4-4 through 4-6. Clearly, in this scenario, you want Switch-B to become the root bridge because this configuration alleviates the issue of a long, inefficient spanning tree topology. So, you now have some motivation for choosing a secondary root bridge. In more complex LAN topologies, choosing a secondary root bridge is crucial because even with the root bridge having failed, redundant paths might still exist. Follow the same principles for choosing the root bridge when selecting the secondary root bridge; the resulting spanning tree topology should be balanced (a central root bridge means the maximum diameter of your network is minimized) and ensure that the major traffic distributions are given the fastest and most efficient path. In our lab topology, Switch-B should be chosen as the secondary root because it is in the center of the network, and has servers directly attached.