Switch STP protocol

Spanning Tree Protocol:
Three-tier Enterprise Network Architecture—Redundancy—Line Redundancy—Layer Two Bridged Loops
Causes problems:
1. Broadcast storm
2. MAC address table rollover—On a switch, the same MAC address can only be mapped uniquely However, the same interface can be mapped to multiple different MAC addresses;
3. Repeated copies of the same data frame
4. The above three conditions eventually cause the device to work overload, leading to restart protection of the
spanning tree: In a layer 2 switching network, Generate a tree structure, logically block some interfaces, so that there is only a unique path from the root to all nodes; when the best path fails, automatically open partially blocked ports to achieve the role of line backup;
spanning tree is being generated In the process, a star structure and shortest path tree should be generated as much as possible;
there are algorithms: 802.1D PVST PVST+(CISCO) RSTP(802.1w) MSTP(802.1S),
where 802.1D is the original version algorithm, the latter is referred to Its improvement.
1. 802.1D There is only one spanning tree instance in a switching network;
BPDUs are used between switches—Bridge Protocol Data Unit—Data
configuration BPDUs for communication and interaction between switches— only the root bridge can send. In the initial state of the switching network, All switches define the local as the root bridge and send BPDUs; make all switches in the network receive BPDUs from other devices, and then compare them based on the parameters in the data to elect the root bridge; then all non-root bridges No longer send BPDUs, but only receive and forward the BPDUs of the root bridge; send in 2s period, hold time 20s;
TCN—Topology change message (also BPDU): After the local switch link fails, STP reconverges. In order to quickly refresh the MAC tables of all switches in the entire network, TCN (TCN position in the flag bit is 1) will be sent to all local STP interfaces. After receiving the TCN, the neighboring switch first marks the ACK bit as a reply for reliable transmission of the message; then forwards the TCN to the root bridge step by step, and the root bridge replies with a TC message to reply to all the switches step by step; The switch temporarily changes the old exchange time of the MAC table to 15s (default, forwarding delay).
Election — Root bridge root port designated port non-designated port (blocked port)
Insert picture description here

[1] Root bridge-In a spanning tree instance, there is one and only one switch as root;
1. The bridge ID in the BPDU determines the
bridge ID = bridge priority + MAC address (number in the backplane address pool The smallest value—the transparent switch has no MAC, there is one layer 2 switch, and there are multiple layer 3 switches)
Bridge priority 0-65535 The default is 32768, the smaller the better
, the election of the root bridge first compares the priority, and the smaller is better; If the level is the same, compare the mac, the smaller the value is better;
PID=port ID=interface priority + interface number priority 0—255 default 128
[2] Root port—On each non-root bridge, there is one and only one interface; The local interface closest to the root bridge (shortest, star) receives BPDUs from the root bridge and forwards user traffic (the interface is not blocked).
Rules:
1. Compare the time when it is sent from the root bridge and enters through this interface The smallest cost value;
2. If the inbound cost value is the same, compare the BID of the peer device of the interface, which is small.
3. The peer BID is also the same, compare the PID of the interface of the peer device; the priority is lower first, if priority Level is the same, the number is lower
4, even the PID of the opposite end is the same, compare the local PID, the smaller is better;
PID=port ID interface priority (0-240, step length 16, default 128) interface number
[3] designated port, in each There is one and only one physical link on a section of STP; it forwards BPDUs from the root bridge and can forward user traffic (not blocked); all interfaces on the root bridge are designated ports by default;
1. Compare from the root network After the bridge is sent out, the cost value when entering the link through this interface is the smallest (outgoing)
2. If the outgoing cost value is the same, the local BID must be small;
3. If the local BID is the same, compare the local PID;
4. The local PID, the same, directly block the port;
[4] Non-designated port (blocking port) After all the above roles are elected, the remaining interfaces without any role are non-designated;
the interface is logically blocked and can actually be received Information, but not forwarded;
cost value: different bandwidths exist in different cost
generation protocols, at least the root bridge should be interfered to the convergence layer;
interface state:
down: no BPDU transmission and reception, once BPDU transmission and reception can be carried out, enter the next state to
listen : Mandatory 15s; all switches perform BPDU sending and receiving and elect all roles; if the interface role is a non-designated port, enter the blocking state directly; if it is a designated port and root port, enter the next state;
learn: mandatory 15s; designated ports and root ports learn all interfaces Connect the MAC address of the device to generate the MAC table; then enter the next state;
forwarding: refers to the entry of the end port and the root port, and can forward user messages;
blocking: logical blocking; (can receive but not forward)
Note: only to the interface After entering the forwarding state, data packets can be forwarded for the user. No data can be forwarded in the previous 30s;
convergence time: initial convergence—30s = 15 listening + 15s learning
structure change: direct connection detection: local blocked port, if If other ports are disconnected, the blocked port will immediately enter 15 for listening (election); if the result is enabled, it will then enter for 15s to learn-
there is no direct connection detection for 30s : there is no blocked port locally, if a port is disconnected, It will send the sub-optimal BPDU (with the local root as the root) to other neighboring switches. The other switches ignore the data and perform a 20s hold time. At that time, the interface will be blocked to enter 15s listening, 15s learning = total 50s
802.1D Disadvantages:
1. Slow convergence
2. Low link utilization (proposed by cisco)
2. PVST (cisco private)
VLAN-based Spanning Tree Protocol There is a tree in each VLAN, and the working principle of each tree is the same as 802.1d; the difference between the BPDUs of different VLANs lies in the priority;
priority = 4096 multiple + The vlan id can only be modified to a multiple of 4096, and can only be modified to a multiple of 4096. It
only supports trunk trunk encapsulation as ISL (cisco private encapsulation).
3. PVST + is based on PVST, compatible with 802.1q trunk encapsulation; and is designed Partial acceleration;
port acceleration (enter the interface of the user connected to the layer) Uplink acceleration-for direct connection detection backbone acceleration-for sub-optimal BPDU
Disadvantages: 1. Slow convergence (incomplete acceleration) 2. Many trees (only cisco has a separate (This chip cannot be supported by other vendors).
Fourth,
the RSTP of the rapid spanning tree cisco-vlan-based rapid spanning tree-one vlan one tree pvst+ upgrade
Public RSTP (802.1w)-the entire switching network one tree 802.1d upgrade
fast The principle of:
1. Cancel the timer, but directly enter the next state after the work of one state is completed;
2. Segmented synchronization, convergence between the two devices step by step; use request and consent flags; rely on the flag bit No. 1 and No. 6
3. BPDU keepalive is 6s; hello time 2s;
4. Port acceleration (edge ​​interface), uplink acceleration, and backbone acceleration are integrated
5. Compatible with 802.1d and PVST, but 802.1d and PVST does not use the 1-6 bits of the flag bit, so it cannot converge quickly; therefore, if one device in the network does not support fast convergence, other devices that enable fast convergence cannot be fast either;
When the tcn message appears, you can refresh the local cam table without waiting for the BPDU of the root bridge;
remember: when the interface defaults to half-duplex, even if RSTP is allowed, the convergence is still based on the slow 802.1D algorithm;
[sw1]stp mode rstp
edge interface—the interface used to connect to the PC, once it is set as an edge interface; it will no longer send BPDUs, and does not perform STP convergence, and will directly be in the forwarding state; but if the interface receives the BPDU from the opposite end, The edge feature will be lost, and normal convergence will resume;
[sw1]interface GigabitEthernet 0/0/1
[sw1-GigabitEthernet0/0/1]stp edged-port enable

[sw1]stp priority? Modify the bridge priority
INTEGER<0-61440> Bridge priority, in steps of 4096

[sw1]stp root? Quickly define the role of the root bridge
primary Primary root switch
secondary Secondary root switch

[sw1-GigabitEthernet0/0/1]stp port priority? Modify the interface priority
INTEGER<0-240> Port priority, in steps of 16

[sw1-GigabitEthernet0/0/1]stp cost? Modify interface cost
INTEGER<1-200000000> Port path cost

5. MSTP/MST/802.1S Huawei devices use this protocol by default.
802.1 configuration commands:
[sw1]stp mode stp is modified to 802.1d algorithm, and Huawei defaults to MSTP at present;
[sw1]stp priority 4096 Modify the bridge priority
[sw1- GigabitEthernet0/0/1]stp cost? Modify the interface cost value
INTEGER<1-200000000> Port path cost
[sw1-GigabitEthernet0/0/1]stp port priority? Modify the interface priority
INTEGER<0-240> Port priority, in steps of 16
inherits the basis of rapid spanning tree; place multiple VLANs in a group, based on one spanning tree for each group;
priority in BPDUs between different groups = 4096 multiples + group number
[r1]stp mode mstp
default There is group 0, and all VLANs are in this group by default; priority = 32768+0
grouping
[sw1]stp enable
[sw1]stp region-configuration
[sw1-mst-region]region-name a All devices should be in one group
[ sw1-mst-region]instance 1 vlan 1 to 5
[sw1-mst-region]instance 2 vlan 6 to 10
[sw1-mst-region] active region-configuration activates the current configuration (this command must be configured)
Remember: if a group will be created, but the VLANs in the group are not created on this switch, and there is no service for the VLAN at the same time Interface; the group will not have any information; the grouping information of all devices in the entire switching network must be completely consistent;
define the local as the primary root of group 1, and
modify the priority of stp instance 1 root primary to 0
stp instance 2 root secondary Priority modified to 4096

[sw1]stp instance 1 priority ?
INTEGER<0-61440> Bridge priority, in steps of 4096

[sw1]interface GigabitEthernet 0/0/1
[sw1-GigabitEthernet0/0/1]stp instance 1 cost ?
INTEGER<1-200000000> Port path cost

[sw1-GigabitEthernet0/0/1]stp instance 1 port priority ?
INTEGER<0-240> Port priority, in steps of 16

Guess you like

Origin blog.csdn.net/m0_53067332/article/details/112724366