Spanning Tree Protocol 802 1 D

Embed Size (px)

Citation preview

  • 7/27/2019 Spanning Tree Protocol 802 1 D

    1/5

    802.1D Spanning Tree ProtocolSTP uses messaging between switches to stabilize the network into a logical, loop-free topology.To do so, STP causes some interfaces (popularly calledports when discussing STP) to simply not

    forward or receive trafficin other words, the ports are in a blockingstate. The remaining ports,in an STPforwardingstate, together provide a loop-free path to every Ethernet segment in the

    network.

    Choosing Which Ports Forward: Choosing RootPorts and Designated PortsTo determine which ports forward and block, STP follows a three-step process, as listed in

    Table 3-2. Following the table, each of the three steps is explained in more detail.

    Electing a Root SwitchOnly one switch can be the rootof the spanning tree; to select the root, the switches hold an

    election. Each switch begins its STP logic by creating and sending an STP Hello bridge protocol

    data unit (BPDU) message, claiming to be the root switch. If a switch hears a superior Helloa

    Hello with a lower bridge IDit stops claiming to be root by ceasing to originate and send Hellos.Instead, the switch starts forwarding the superior Hellos received from the superior candidate.

    Eventually, all switches except the switch with the best bridge ID cease to originate Hellos; thatone switch wins the election and becomes the root switch.

    The original IEEE 802.1D bridge ID held two fields: The 2-byte Priority field, which was designed to be configured on the various switches to

    affect the results of the STP election process.

    A 6-byte MAC Address field, which was included as a tiebreaker, because each switchs

    bridge ID includes a MAC address value that should be unique to each switch. As a result,some switch must win the root election.

    The format of the original 802.1D bridge ID has been redefined. Figure 3-1 shows the original andnew format of the bridge IDs.

    A switch can use a single MAC address to build bridge IDs, and with the VLANnumber in the System ID Extension field still have a unique bridge ID in each VLAN. The use of

    the System ID Extension field is also calledMAC address reduction, because of the need for manyfewer reserved MAC addresses on each switch.

    Determining the Root Port

    Once the root is elected, the rest of the switches now need to determine theirRoot Port (RP). Theprocess proceeds as described in the following list:

    1. The root creates and sends a Hello every Hello timer (2 seconds default).

  • 7/27/2019 Spanning Tree Protocol 802 1 D

    2/5

    2. Each switch that receives a Hello forwards the Hello after updating the following fields in theHello: the cost, the forwarding switchs bridge ID, forwarders port priority, and forwarders

    port number.3. Switches do not forward Hellos out ports that stabilize into a blocking state.

    4. Of all the ports in which a switch receives Hellos, the port with the least calculated cost to theroot is the RP (Root Port).

    A switch must examine the cost value in each Hello, plus the switchs STP port costs, in order todetermine its least cost path to reach the root. To do so, the switch adds the cost listed in the Hello

    message to the switchs port cost of the port on which the Hello was received. For example,Figure 3-2 shows the loop network design and details several STP cost circulations.

    In Figure 3-2, SW1 happened to become root, and is originating Hellos of cost 0. SW3 receivestwo Hellos, one with cost 0 and one with cost 38. However, SW3 must then calculate its cost to

    reach the root, which is the advertised cost (0 and 38, respectively) plus SW3s port costs (100 and

    19, respectively). As a result, although SW3 has a direct link to SW1, the calculated cost is lowerout interface fa0/4 (cost 57) than it is out interface fa0/1 (cost 100), so SW3 chooses its fa0/4interface as its RP.

    While the costs shown in Figure 3-2 might seem a bit contrived, the same result would happenwith default port costs if the link from SW1 to SW3 were Fast Ethernet (default cost 19), and the

    other links were Gigabit Ethernet (default cost 4). Table 3-3 lists the default port costs accordingto IEEE 802.1D. Note that the IEEE updated 802.1D in the late 1990s, changing the suggested

    default port costs.

    When a switch receives multiple Hellos with equal calculated cost, it uses the following

    tiebreakers:1. Pick the lowest value of the forwarding switchs bridge ID.

    2. Use the lowest port priority of the neighboring switch. The neighboring switch added its ownport priority to the Hello before forwarding it.

    3. Use the lowest internal port number (of the forwarding switch) as listed inside the receivedHellos.

    Note that if the first tiebreaker in this list fails to produce an RP, this switch must have multiplelinks to the same neighboring switch. The last two tiebreakers simply help decide which of themultiple parallel links to use.

  • 7/27/2019 Spanning Tree Protocol 802 1 D

    3/5

    Determining the Designated PortA converged STP topology results in only one switch forwarding onto each LAN segment. Theswitch that forwards onto a LAN segment is called the designated switch for that segment, and

    the port that it uses to forward frames onto that segment is called theDesignated Port (DP). Bydefinition, only the DP on that segment should forward frames onto the segment.

    To win the right to be the DP, a switch must send the Hello with the lowest advertised costonto

    the segment. For instance, consider the segment between SW3 and SW4 in Figure 3-2 before theDP has been determined on that segment. SW3 would get Hellos directly from SW1, compute itscost to the root over that path, and then forward the Hello out its fa 0/4 interface to SW4, with cost

    100. Similarly, SW4 will forward a Hello with cost 38, as shown in Figure 3-2. SW4s fa 0/3 port

    becomes the DP due to its lower advertised cost.Only the DP forwards Hellos onto a LAN segment as well. In the same example, SW4 keeps

    sending the cost-38 Hellos out the port, but SW3 stops sending its inferior Hellos.

    When the cost is a tie, STP uses the same tiebreakers to choose the DP as when choosing an RP:lowest forwarders bridge ID, lowest forwarders port priority, and lowest forwarders port

    number.

    Converging to a New STP TopologySTP logic monitors the normal ongoing Hello process when the network topology is stable; when

    the Hello process changes, STP then needs to react and converge to a new STP topology. When

    STP has a stable topology, the following occurs:1. The root switch generates a Hello regularly based on the Hello timer.

    2. Each non-root switch regularly (based on the Hello timer) receives a copy of the roots

    Hello on its RP.3. Each switch updates and forwards the Hello out its Designated Ports.

    4. For each blocking port, the switch regularly receives a copy of the Hello from the DP on thatsegment. (The switches do not forward Hellos out blocking interfaces.)

    When some deviation from these events occurs, STP knows that the topology has changed and thatconvergence needs to take place. For instance, one simple case might be that the root switch loses

    power; the rest of the switches will not hear any Hello messages, and after the maxage timerexpires (default 10 times Hello, or 20 seconds), the switches elect a new root based on the logic

    described earlier in this chapter.For a more subtle example, consider Figure 3-3, which shows the same loop network as in

    Figure 3-2. In this case, however, the link from SW1 to SW2 has just failed.

    The following list describes some of the key steps from Figure 3-3:

    1. SW2 ceases the receive Hellos on its RP.2. Because SW2 is not receiving Hellos over any other path, it begins a new root election by

    claiming to be root and flooding Hellos out every port.3. SW4 notices that the latest Hello implies a new root switch, but SW4 ends up with the same

  • 7/27/2019 Spanning Tree Protocol 802 1 D

    4/5

    RP (for now). SW4 forwards the Hello out toward SW3 after updating the appropriate fieldsin the Hello.

    4. SW3 receives the Hello from SW4, but it is inferior to the one SW3 receives from SW1. So,SW3 becomes the DP on the segment between itself and SW4, and starts forwarding the

    superior Hello on that port.Remember, SW1 had won the earlier election; as of Steps 3 and 4, the Hellos from SW1 and

    SW2 are competing, and the one claiming SW1 as root will again win. The rest of the processresults with SW3s fa0/4 as DP, SW4s fa 0/3 as RP, SW4s fa 0/2 as DP, and SW3s fa 0/4

    as RP.

    Topology Change Notification and Updating the CAMWhen STP reconvergence occurs, some Content Addressable Memory (CAM) entries mightbe invalid (CAM is the Cisco term for whats more generically called the MAC address table,

    switching table, or bridging table on a switch). For instance, before the link failure shown in

    Figure 3-3, SW3s CAM might have had an entry for 0200.1111.1111 (Router1s MAC address)pointing out fa0/4 to SW4. (Remember, at the beginning of the scenario described in Figure 3-3,

    SW3 was blocking on its fa0/1 interface back to SW1.) When the link between SW1 and SW2failed, SW3 would need to change its CAM entry for 0200.1111.111 to point out port fa0/1.

    To update the CAMs, two things need to occur:

    All switches need to be notified to time out their CAM entries.

    Each switch needs to use a short timer, equivalent to the forward delay timer (default 15 seconds),to time out the CAM entries.

    Because some switches might not directly notice a change in the STP topology, any switch thatdetects a change in the STP topology has a responsibility to notify the rest of the switches. To do

    so, a switch simply notifies the root switch in the form of a Topology Change Notification (TCN)BPDU. The TCN goes up the tree to the root. After that, the root notifies all the rest of the switches.

    The process runs as follows:1. A switch experiencing the STP port state change sends a TCN BPDU out its Root Port; it

    repeats this message every Hello time until it is acknowledged.2. The next switch receiving that TCN BPDU sends back an acknowledgement via its next

    forwarded Hello BPDU by marking the Topology Change Acknowledgement (TCA)bit inthe Hello.

    3. The switch that was the DP on the segment in the first two steps repeats the first two steps,sending a TCN BPDU out its Root Port, and awaiting acknowledgement from the DP on that

    segment.By each successive switch repeating Steps 1 and 2, eventually the root receives a TCN BPDU.

    Once received, the root sets the TCA flag on the next several Hellos, which are forwarded to all

    switches in the network, notifying them that a change has occurred. A switch receiving a HelloBPDU with the TCA flag set uses the short (forward delay time) timer to time out entries in

    the CAM.

    Transitioning from Blocking to ForwardingWhen STP reconverges to a new, stable topology, some ports that were blocking might have beendesignated as DP or RP, so these ports need to be in a forwarding state. However, the transition

    from blocking to forwarding state cannot be made immediately without the risk of causing loops.To transition to forwarding state but also prevent temporary loops, a switch first puts a formerly

    blocking port into listeningstate, and then into learningstate, with each state lasting for the lengthof time defined by the forward delay timer (by default, 15 seconds). Table 3-4 summarizes the key

    points about all of the 802.1D STP port states.

  • 7/27/2019 Spanning Tree Protocol 802 1 D

    5/5

    In summary, when STP logic senses a change in the topology, it converges, possibly pickingdifferent ports as RP, DP, or neither. Any switch changing its RPs or DPs sends a TCN BPDU

    to the root at this point. For the ports newly designated as RP or DP, 802.1D STP first uses thelistening and learning states before reaching the forwarding state. (The transition from forwarding

    to blocking can be made immediately.)