STP (Spanning Tree Protocol) is a Protocol established according to the IEEE 802.1D standard to eliminate physical loops of the data link layer in the LAN. Devices running the Protocol discover the loops in the network through mutual interaction information, and choose to block some ports, and finally trim the loop network structure into a non-loop tree network structure, this prevents the packets from accumulating and infinite loops in the Loop Network, and prevents the device from degrading the packet processing capability due to repeated reception of the same packets.
The Protocol packets used by STP are BPDU (Bridge Protocol Data Unit), also known as configuration messages, BPDU contains sufficient information to ensure that the device completes the Spanning Tree computing process. STP is to determine the network topology by transmitting BPDU between devices.
BPDU format and field description
To implement the Spanning Tree function, BPDU packets are transmitted between switches for information interaction. All switches that support the STP protocol receive and process received packets. The text contains all the useful information used to generate tree computing in the data area.
Description of the BPDU frame format and fields of the standard Spanning Tree:
Protocol identifier: Protocol identifier
Version: Protocol Version
Message type: BPDU type
Flag: Flag
Root ID: Root bridge ID, which consists of two-byte priority and six-byte MAC address
Root path cost: Root path overhead
Bridge ID: Bridge ID, indicating the ID of the Bridge that sends BPDU, which consists of a 2-byte priority and a 6-byte MAC address
Port ID: Port ID, which identifies the Port from which the BPDU is sent
Message age: BPDU survival time
Maximum age: the aging time of the Current BPDU, that is, the Maximum time for the port to save the BPDU
Hello time: the period in which the root bridge sends BPDU
Forward delay: the time for the switch to maintain the listening and learning status before sending data packets after the topology changes.
Basic concepts of STP
Bridge ID (Bridge Identifier): The Bridge ID is the sum of the Bridge priority and its MAC address. The Bridge priority is a configurable parameter. The lower the bridge ID, the higher the priority of the bridge, which increases the possibility of becoming a root bridge.
Root Bridge: The vswitch with the smallest Bridge ID is the Root Bridge. Set the best of all switches in the loop as the root bridge switch to ensure the best network performance and reliability.
Designated Bridge: in each network segment, the Bridge with the lowest path overhead to the root Bridge will become the specified Bridge, and data packets will be forwarded to the network segment through it. When all vswitches have the same root path overhead, the vswitches with the lowest bridge ID will be selected as the specified bridge.
Root Path overhead (Cost): the Root Path overhead of A vswitch is the sum of the Root Path overhead of the Root port and the Root Path overhead of all switches passing through the data packet. The root path overhead of the root bridge is zero.
Bridge Priority: a parameter that you can set. The value range is from 0 to 32768. The smaller the set value, the higher the priority. The higher the bridge priority of a vswitch, the more likely it is to become the root bridge.
Root Port: the Port closest to the Root bridge on a non-Root bridge switch. It is responsible for communicating with the Root bridge. This Port has the lowest path overhead to the Root bridge. When multiple ports share the same path overhead to the root bridge, the port with the highest port priority will become the root port.
Specified Port: Specifies the Port on which data is forwarded to the switch.
Port Priority: the value ranges from 0 to 255. The smaller the value, the higher the Port Priority. The higher the port priority, the more likely it is to become the root port.
Path Cost: the STP protocol is used to select the reference value of a link. By calculating the path overhead, the STP protocol selects a strong link to block redundant links and trim the network into a non-loop tree network structure.
Build a tree. Switch A, B, C three sequentially connected, after STP calculation, switch A is selected as the root bridge, the line between Port 2 and port 6 is blocked.
Bridge: Switch A is the root bridge of the entire network, and switch B is the specified Bridge of switch C.
Ports: PORTS 3 and 5 are the root ports of vswitch B and vswitch C respectively. Ports 1 and 4 are the specified ports of vswitch A and vswitch B respectively; port 6 is the blocking port of switch C.
STP Timer
Contact Time (Hello Time ):
The value range is from 1 second to 10 seconds. It refers to the time interval between the root bridge and all other switches that send BPDU data packets. It is used for the switch to check whether the link is faulty.
Aging time (Max. Age ):
The value ranges from 6 seconds to 40 seconds. If the BPDU packet sent from the root bridge is not received after the aging time, the switch sends the BPDU packet to all other switches and recalculates the Spanning Tree.
Transmission latency (Forward Delay ):
The value range is from 4 seconds to 30 seconds. It refers to the time used to migrate the port status of the vswitch.
When a network failure causes the spanning tree to be re-computed, the structure of the Spanning Tree changes accordingly. However, the new configuration message after re-calculation cannot be immediately distributed throughout the network. If the port status is migrated immediately, a temporary loop may occur. Therefore, the Spanning Tree Protocol adopts a State migration mechanism, which requires two times of transmission latency before the new root port and the specified port start data forwarding, this delay ensures that new configuration messages have been distributed throughout the network.
Comparison of BPDU priorities in STP Mode
If there are two bpdu x and Y, then:
If the root bridge ID of X is less than the root bridge ID of Y, X is better than Y.
If the root bridge ID of X and Y is the same, but the root path overhead of X is less than Y, X is better than Y.
If the root bridge ID and root path overhead of X and Y are the same, but the bridge ID of X is less than Y, X is better than Y
If the root bridge ID, root path overhead, and bridge ID of X and Y are the same, but the port ID of X is less than Y, X is better than Y
STP computing process
Initial status: Each vswitch generates a BPDU with its own root bridge. The root path overhead is 0, the bridge ID is its device ID, and the specified port is the port.
Optimal BPDU Selection: each switch sends its own BPDU to the outside, and it also receives the BPDU sent by other switches. The comparison process is described in the following table:
Root bridge Selection: by exchanging configuration messages, the root bridge ID is compared between devices, and the device with the smallest root bridge ID in the network is selected as the root bridge.
The selection process of the root port and specified port is as follows:
RSTP
RSTP (Rapid Spanning Tree Protocol) is an optimized version of STP, which greatly shortens the delay of port forwarding, this shortens the time required for the Network to eventually achieve topology stability. The prerequisites for fast migration are as follows:
The condition for fast migration of the root port status is that the old root port on the device has stopped forwarding data, and the specified upstream port has started forwarding data.
The condition for fast migration of the specified port status is that the specified port is an edge port or the specified port is connected to the point-to-point link. If the specified port is an edge port, the specified port can directly enter the forwarding status. If the specified port is connected to a point-to-point link, the device can shake hands with the downstream device, after receiving a response, the system immediately enters the forwarding status.
Basic concepts of RSTP
Edge Port: a Port that is directly connected to a terminal rather than other vswitches.
Point-to-point link: A link directly connected to two vswitches.
MSTP
MSTP (Multiple Spanning Tree Protocol) is based on STP and RSTP and is established according to the 802.1S standard developed by the IEEE Association. It can quickly converge, it can also forward traffic from different VLANs along their respective paths, providing a better load balancing mechanism for redundant links.
MSTP has the following features:
MSTP uses the VLAN-instance ing table to associate VLANs with the Spanning Tree, bind multiple VLANs to an instance, and implement Load Balancing Based on instances.
MSTP divides a spanning tree network into multiple domains, forming multiple internal spanning trees in each domain. Each spanning tree is independent of each other.
MSTP implements load balancing of VLAN data during data forwarding.
MSTP is compatible with STP and RSTP.
Basic concepts of MSTP
MST domain (Multiple Spanning Tree Region): consists of a switch with the same domain configuration and the same Vlan-instance ing relationship.
IST (Internal Spanning Tree, Internal Spanning Tree): a Spanning Tree in the MST domain.
CST (Common Spanning Tree, Common Spanning Tree): connects to the single Spanning Tree of all MST domains in the network.
CIST (Common and Internal Spanning Tree, public and Internal Spanning Tree): connects the single Spanning Tree of all devices in the network, which is composed of IST and CST.
The networking diagram of the basic concepts of MSTP.
Basic Principles of MSTP
MSTP divides the entire network into multiple MST domains, and each domain generates CST through calculation. Multiple Spanning Trees are generated through calculation in the domain, each spanning tree is called a multi-spanning tree instance. Like STP, MSTP uses BPDU for tree generation calculation, but BPDU carries the MSTP configuration information.
Comparison of BPDU priorities in MSTP Mode
If there are two mstp bpdu x and Y, then:
If the total root ID of X is less than the total root ID of Y, X is better than Y.
If the total root ID of X and Y is the same, but the external path overhead of X is less than Y, X is better than Y.
If the total root ID and external path overhead of X and Y are the same, but the root ID of X is less than the root ID of Y, X is better than Y
If the total root ID, external path overhead, and domain root ID of X and Y are the same, but the internal path overhead of X is less than Y, X is better than Y
If the total root ID, external path overhead, domain root ID, and internal path overhead of X and Y are the same, but the bridge ID of X is less than Y, X is better than Y
If the total root ID, external path overhead, domain root ID, internal path overhead, and bridge ID of X are the same, but the port ID of X is less than Y, X is better than Y
Port Status
In MSTP, the port status can be divided into the following four types based on whether the port forwards data and how to process BPDU packets:
Forward: receives and forwards data, receives and sends BPDU packets, and learns the address.
Learning: do not receive or forward data, receive and send BPDU packets, and perform address learning.
Blocking: do not receive or forward data, receive but not send BPDU packets, and do not perform address learning.
Disconnected: The physical link is disconnected.
Port role
The port roles of MSTP are divided into the following types:
Root port: The Path to the root bridge has the lowest overhead and is responsible for forwarding data to the root bridge.
Specified port: the port that forwards data to the downstream network segment or device.
Master port: the port connecting the MST domain to the total root, located in the shortest path from the entire domain to the total root.
Replace port: the backup port of the root port and Master port.
Backup port: the backup port of the specified port.
Disabled port: the port that the physical link is disconnected from.