Spanning Tree Protocol


Key Point

STP is a Layer 2 protocol that prevents logical loops in switched networks that have redundant links.


In the following sections, we first examine why such a protocol is needed in Layer 2 networks. We then introduce STP terminology and operation.

Note

In the following sections, we are only concerned with Layer 2 switching; as you see in Chapter 3, routed (Layer 3) networks inherently support networks with multiple paths, so a protocol such as STP is not required.


Redundancy in Layer 2 Switched Networks

Redundancy in a network, such as that shown in Figure 2-3, is desirable so that communication can still take place if a link or device fails. For example, if switch X in this figure stopped functioning, devices A and B could still communicate through switch Y. However, in a switched network, redundancy can cause problems.

Figure 2-3. Redundancy in a Switched Network Can Cause Problems


The first type of problem occurs if a broadcast frame is sent on the network. (Recall that a switch floods broadcast frames to all ports other than the one that it came in on.) For example, consider what happens when device A in Figure 2-3 sends an ARP request to find the MAC address of device B. The ARP request is sent as a broadcast. Both switch X and switch Y receive the broadcast; for now, consider just the one received by switch X, on its port 1. Switch X floods the broadcast to all its other connected ports; in this case, it floods it to port 2. Device B can see the broadcast, but so can switch Y, on its port 2; switch Y floods the broadcast to its port 1. This broadcast is received by switch X on its port 1; switch X floods it to its port 2, and so forth. The broadcast continues to loop around the network, consuming bandwidth and processing power. This situation is called a broadcast storm.

The second problem that can occur in redundant topologies is that devices can receive multiple copies of the same frame. For example, assume that neither of the switches in Figure 2-3 has learned where device B is located. When device A sends data destined for device B, switch X and switch Y both flood the data to the lower LAN, and device B receives two copies of the same frame. This might be a problem for device B, depending on what it is and how it is programmed to handle such a situation.

The third difficulty that can occur in a redundant situation is within the switch itselfthe MAC address table can change rapidly and contain wrong information. Again referring to Figure 2-3, consider what happens when neither switch has learned where device A or B are located, and device A sends data to device B. Each switch learns that device A is on its port 1, and each records this in its MAC address table. Because the switches don't yet know where device B is, they flood the frame, in this case on their port 2. Each switch then receives the frame, from the other switch, on its port 2. This frame has device A's MAC address in the source address field; therefore, both switches now learn that device A is on their port 2. The MAC address table is therefore overwritten. Not only does the MAC address table have incorrect information (device A is actually connected to port 1, not port 2, of both switches), but because the table changes rapidly, it might be considered to be unstable.

To overcome these problems, you need a way to logically disable part of the redundant network for regular traffic while still maintaining the redundancy for the case when an error occurs. The Spanning Tree Protocol does just that.

STP Terminology and Operation

The following sections introduce the Institute of Electrical and Electronics Engineers (IEEE) 802.1d STP terminology and operation.

STP Terminology

STP terminology can best be explained by examining how an example network, such as the one in Figure 2-4, operates.

Figure 2-4. STP Chooses the Port to Block


Note

Notice that STP terminology refers to the devices as bridges rather than switches. Recall (from Appendix B) that bridges are previous-generation devices with the same logical functionality as switches; however, switches are significantly faster because they switch in hardware, whereas bridges switch in software. Functionally, the two terms are synonymous.


Within an STP network, one switch is elected as the root bridgeit is at the root of the spanning tree. All other switches calculate their best path to the root bridge. Their alternate paths are put in the blocking state. These alternate paths are logically disabled from the perspective of regular traffic, but the switches still communicate with each other on these paths so that the alternate paths can be unblocked in case an error occurs on the best path.

All switches running STP (it is turned on by default in Cisco switches) send out bridge protocol data units (BPDUs). Switches running STP use BPDUs to exchange information with neighboring switches. One of the fields in the BPDU is the bridge identifier (ID); it is comprised of a 2-octet bridge priority and a 6-octet MAC address. STP uses the bridge ID to elect the root bridgethe switch with the lowest bridge ID is the root bridge. If all bridge priorities are left at their default values, the switch with the lowest MAC address therefore becomes the root bridge. In Figure 2-4, switch Y is elected as the root bridge.

Note

The way that STP chooses the root bridge can cause an interesting situation if left to the default values. Recall that the MAC address is a 6-octet or 48-bit value, with the upper 24 bits as an Organizational Unique Identifier (OUI) (representing the vendor of the device) and the lower 24 bits as a unique value for that OUI, typically the serial number of the device. A lower MAC address means a lower serial number, which likely means an older switch. Thus, because STP by default chooses a switch with a lower MAC address, the oldest switch is likely to be chosen. This is just one reason why you should explicitly choose the root bridge (by changing the priority), rather than getting the STP default choice.


All the ports on the root bridge are called designated ports, and they are all in the forwarding statethat is, they can send and receive data. (The STP states are described in the next section of this chapter.)

On all nonroot bridges, one port becomes the root port, and it is also in the forwarding state. The root port is the one with the lowest cost to the root. The cost of each link is by default inversely proportional to the bandwidth of the link, so the port with the fastest total path from the switch to the root bridge is selected as the root port on that switch. In Figure 2-4, port 1 on switch X is the root port for that switch because it is the fastest way to the root bridge.

Note

If multiple ports on a switch have the same fastest total path costs to the root bridge, STP considers other BPDU fields. STP looks first at the bridge IDs in the received BPDUs (the bridge IDs of the next switch in the path to the root bridge); the port that received the BPDU with the lowest bridge ID becomes the root port. If these bridge IDs are also equal, the port ID breaks the tie; the port with the lower port ID becomes the root port. The port ID field includes a port priority and a port index, which is the port number. Thus, if the port priorities are the same (for example, if they are left at their default value), the lower port number becomes the root port.


Each LAN segment must have one designated port. It is on the switch that has the lowest cost to the root bridge (or if the costs are equal, the port on the switch with the lowest bridge ID is chosen), and it is in the forwarding state. In Figure 2-4, the root bridge has designated ports on both segments, so no more are required.

Note

The root bridge sends configuration BPDUs on all its ports periodically, every 2 seconds by default. (These configuration BPDUs include the STP timers, therefore ensuring that all switches in the network use the same timers.) On each LAN segment the switch that has the designated port forwards the configuration BPDUs to the segment; all switches in the network therefore receive these BPDUs, on their root port.


All ports on a LAN segment that are not root ports or designated ports are called nondesignated ports and transition to the blocking statethey do not send data, so the redundant topology is logically disabled. In Figure 2-4, port 2 on switch X is the nondesignated port, and it is in the blocking state. Blocking ports do, however, listen for BPDUs.

If a failure happensfor example, if a designated port or a root bridge failsthe switches send topology change BPDUs and recalculate the spanning tree. The new spanning tree does not include the failed port or switch, and the ports that were previously blocking might now be in the forwarding state. This is how STP supports the redundancy in a switched network.

STP States

Figure 2-5 illustrates the various STP port states.

Figure 2-5. A Port Can Transition Among STP States


When a port initially comes up, it is put in the blocking state, in which it listens for BPDUs and then transitions to the listening state. A blocking port in an operational network can also transition to the listening state if it does not hear any BPDUs for the max-age time (a default of 20 seconds). While in the listening state, the switch can send and receive BPDUs but not data. The root bridge and the various final states of all the ports are determined in this state. If the port is chosen as the root port on a switch or as a designated port on a segment, the port transitions to the learning state after the listening state. In the learning state, the port still cannot send data, but it can start to populate its MAC address table if any data is received. The length of time spent in each of the listening and learning states is dictated by the value of the forward-delay parameter, which is 15 seconds by default. After the learning state, the port transitions to the forwarding state, in which it can operate normally. Alternatively, if in the listening state the port is not chosen as a root port or designated port, it becomes a nondesignated port and it transitions back to the blocking state.

Key Point

Do not confuse the STP learning state with the learning process that the switch goes through to populate its MAC address table. The STP learning state is a transitory state. While a switch can learn MAC addresses from data frames received on its ports that are in the STP learning state, it does not forward those frames. In a stable network, switch ports are in either the forwarding or blocking state. Ports in the blocking state do not listen to data frames and therefore do not contribute to the switch's MAC address table. Ports in the forwarding state do, of course, listen to (and forward) data frames, and those frames populate the switch's MAC address table.


STP Options

Figure 2-5 illustrates that it could take up to 50 seconds for a blocked port to transition to the forwarding state after a failure has occurred in the forwarding path. This lengthy time is one of the drawbacks of STP.

Several features and enhancements to STP can help to reduce the convergence time, that is, the time it takes for all the switches in a network to agree on the network's topology after that topology has changed. The following are some of these features that are implemented in Cisco switches:

  • PortFast This feature should be used for ports that have only end-user stations or servers attached to them, in other words, for ports that are not attached to other switches (so that no BPDUs are received on the port). Because no other switches are attached, the port cannot be part of a loop, so the switch immediately puts the port in the forwarding state. Thus, the port transitions to the forwarding state much faster than it otherwise would.

  • UplinkFast This feature is intended to be used on redundant ports on access layer switches.[1] If the root port (pointing to the root bridge) on a switch goes down, the nondesignated port (the redundant blocking port) on the switch is quickly put in the forwarding state, rather than going through all the other states.

  • BackboneFast This feature helps to reduce the convergence time when links other than those directly connected to a switch fail. This feature must be deployed on all switches in the network if it is to be used.

Rapid STP (RSTP)

RSTP is defined by IEEE 802.1w. RSTP incorporates many of the Cisco enhancements to STP, resulting in faster convergence. Switches in an RSTP environment converge quickly by communicating with each other and determining which links can be forwarding, rather than just waiting for the timers to transition the ports among the various states. RSTP ports take on different roles than STP ports. The RSTP roles are root, designated, alternate, backup, and disabled. RSTP port states are also different than STP port states. The RSTP states are discarding, learning, and forwarding. RSTP is compatible with STP.




Campus Network Design Fundamentals
Campus Network Design Fundamentals
ISBN: 1587052229
EAN: 2147483647
Year: 2005
Pages: 156

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net