Analysis on simple algorithms of STP Spanning Tree Protocol

Source: Internet
Author: User

The following is an article from H3C, which was reorganized to facilitate the study.STP Spanning Tree ProtocolIs easy to understand.

You can download the instructions in another article:Analysis of STP Spanning Tree Protocol principles and Algorithms. The following articles are extracted from this document, because it is too long to extract only a part.

Reprinted Please note: http://blog.csdn.net/shanzhizi

Analyze it nowSTPAlgorithmTheoretically speaking, the algorithm is too boring. Here we take three fully-connected switches as an example to describe the implementation process. (Note: For the standard implementation of the state machine, refer to ieee.802.1d. Here we only use easy-to-understand languages to describe the entire process. Some details may not be standardized, but it is easier to understand .)


For ease of description, here we compare the first four items of the BPDU: root bridge ID (expressed in the priority of the Ethernet switch), root path overhead, specify the vswitch ID (expressed by the priority of the Ethernet switch) and the port ID (expressed by the port number ).

Assume that the bridge priority of SWA, SWB, and SWC is 0, 1, and 2, respectively. The overhead of each link is 2, 3, and 6. Note: The root path cost is not a configuration item, that is, it is accumulated by the switch according to the port path cost comparison, and the port path cost is a configurable option. The link overhead in the figure can be understood as the port path cost of the 2-end port, but they are exactly the same.

(1) initial status

Each port of each vswitch generates a configuration message based on itself at the beginning. The root path overhead is 0, the vswitch ID is its own vswitch ID, and the specified port is the port.

Switch:

Port AP1 configuration message: {0, 0, AP1}

Port AP2 configuration message: {0, 0, AP2}

Switch B:

Port bp1 configuration message: {1, 0, 1, bp1}

Port bp2 configuration message: {1, 0, 1, bp2}

Switch C:

Port CP2 configuration message: {2, 0, 2, CP2}

Port CP1 configuration message: {2, 0, 2, CP1}

(2) select the optimal configuration message

Each vswitch sends its own configuration message. When a port receives a configuration message with a lower priority than its own configuration message, the switch discards the received configuration message and does not process the configuration message on the port. When the port receives a configuration message with a higher priority than the configuration message of the current port, the Switch replaces the configuration message of the port with the content in the received configuration message. Then, the Ethernet switch compares the configuration message of this port with the configuration message of other ports on the switch, and selects the optimal configuration message.

The comparison principle of message configuration is as follows:

The configuration message with a smaller root ID has a higher priority. If the root ID is the same, the root path overhead is compared. The comparison method is as follows: if the root path overhead of the configuration message is added to the sum of the path overhead corresponding to the current port (set to S), the priority of the configuration message with smaller S is higher. If the root path overhead is the same, then compare the specified switch ID, the specified port ID, and the port ID that receives the configuration message. In this example, we assume that you only need to compare the root ID to select the optimal configuration message.

(3) determine the root port, block the redundant link, and update the configuration message of the specified port.

The port on which the switch receives the optimal configuration message is set as the root port, and the port configuration message is not changed. In other ports, if the configuration message of a port is updated during the "select optimal configuration message" process, the switch blocks the port, and the port configuration message remains unchanged, the port no longer forwards data, and only receive but not send the configuration message. If the configuration message of a port is not updated in the "select the optimal configuration message" process, the switch will set it as the specified port, change the configuration message as follows: Replace the root ID with the root ID of the configuration message of the root port; replace the root path overhead with the root path overhead of the configuration message of the root port plus the corresponding path overhead of the root port; replace the specified vswitch ID with the ID of its own vswitch, and the specified port ID with its own port ID. Http://blog.csdn.net/shanzhizi

The comparison process of each vswitch in this example is as follows:

Switch:

Port AP1 receives the configuration message of Switch B. Switch A finds that the configuration message priority of this port is higher than the priority of the received configuration message, and discards the received configuration message. The message processing process of port AP2 configuration is similar to that of port ap1. Switch A finds that both the root of the configuration message and the specified switch of each port are itself, and considers itself as the root of the configuration message. The configuration message of each port is not modified, you can periodically send configuration messages to and from Alibaba Cloud. The configuration messages for the two ports are as follows:

Port AP1 configuration message: {0, 0, AP1 }.

Port AP2 configuration message: {0, 0, AP2 }.

Switch B:

Port bp1 receives the configuration message from Switch A. After comparison, switch B finds that the priority of the received configuration message is better than that of the configuration message on port bp1, therefore, the configuration message of port bp1 is updated.

Port bp2 receives the configuration message from Switch C, and switch B finds that the configuration message priority of this port is higher than the priority of the received configuration message, then the received configuration message is discarded.

The configuration messages for each port are as follows: Port bp1 configuration message: {0, 0, AP1}, port bp2 configuration message: {1, 0, 1, bp2 }.

Switch B compares the configuration messages of each port, selects the configuration message of port bp1 as the optimal configuration message, and then sets port bp1 as the root port, in this process, if the configuration message of port bp2 is not updated, port bp2 is located at the specified port. The configuration message of each port of the entire vswitch is updated as follows: the configuration message of the root port bp1 is not changed: {0, 0, AP1 }. In the bp2 configuration message, the root ID is updated to the root ID in the optimal configuration message, the root path overhead is updated to 2, and the switch ID is updated to the switch ID, the specified port ID is updated to this port ID. The configuration message is changed to: {0, 2, 1, bp2 }. The specified ports of Switch B periodically send their own configuration messages.

Switch C:

Port CP2 first receives the configuration message {, 1, bp2} from the switch B port before the bp2 update, and switch C triggers the update process. The updated configuration message is as follows: {, 1, bp2 }.

After receiving the configuration message {0, 0, AP2} from Switch A, port CP1 also triggers the update process. The updated configuration message is as follows: {0, 0, 0, AP2 }.

After comparison, the configuration message of port CP1 is selected as the optimal configuration message, and port CP1 is set as the root port, and port CP2 is selected as the specified port, and the updated BPDU is sent: {0, 6, 2, CP2}

Then, port CP2 receives the configuration message {0, 2, 1, bp2} After switch B is updated. Because the received configuration message is better than the original configuration message, switch C triggers the update process, the updated configuration message is {0, 2, 1, bp2 }.

At the same time, port CP1 receives the configuration message from Switch A. After comparison, switch C does not trigger the update process, and the configuration message is still: {0, 0, AP2 }.

After internal comparison, (CP1 {0, 6, 0, AP2}, CP2 {0, 5, 1, bp2}) the configuration message of port CP2 is selected as the optimal

Configure the message. Port CP2 is selected as the root port. The configuration message of port CP1 is blocked because it has been updated. After the status is stable, data forwarded from Switch A is not received, until the new situation triggers the calculation of the Spanning Tree, for example, the link from Switch A to switch C is down, or the port receives a better configuration message.

The above is for beginners onlySTP Spanning Tree ProtocolFor more information, see.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.