Summary of STP knowledge points

Table of contents

1. What is STP protocol?

2. Reasons for the emergence of STP Spanning Tree Protocol

3. Algorithms involved in STP Spanning Tree Protocol

1.802.1D

2.PVST

3.PVST+

4. Rapid spanning tree

5.MSTP


1. What is STP protocol?

        In a layer 2 switching network, a tree structure is generated, and some interfaces are logically blocked so that there is only a unique path from the root to all nodes; when the best path fails, some blocked ports are automatically opened to realize the line The role of backup;

       In order to improve network reliability, some redundant links are usually used in switched networks. However, redundant links will bring loop risks to the switching network and cause problems such as broadcast storms and MAC address table instability, which will in turn affect user communication quality. Spanning Tree Protocol STP (Spanning Tree Protocol) can improve reliability while avoiding various problems caused by loops.

2. Reasons for the emergence of STP Spanning Tree Protocol

The impact if there is no STP Spanning Tree Protocol:

  1. broadcast storm
  2. MAC address table tumbling---On a switch, the same MAC address can only be mapped to a unique interface; but the same interface can be mapped to multiple different MAC addresses;
  3. Duplicate copy of the same data frame
  4. The above 3 conditions eventually lead to equipment overload, resulting in restart protection.

3. Algorithms involved in STP Spanning Tree Protocol

1.802.1D

802.1D There is only one spanning tree instance in a switching network ;

BPDU - Bridge Protocol Data Unit - is used between switches to communicate and interact with each other to send and receive data.

Configure BPDUs—only the root bridge can send them. In the initial state of the switching network, all switches define the local root bridge and send BPDUs; so that all switches in the network receive BPDUs from other devices, and then based on the data in the data The parameters are compared and the root bridge is elected; all non-root bridges no longer send BPDUs, but only receive and forward the BPDUs of the root bridge; the sending cycle is 2s, and the hold time is 20s;

TCN—Topology change message (also BPDU): After the local switch link fails, STP re-converges. In order to quickly refresh the MAC tables of all switches in the entire network, TCN (TCN bit in the flag bit is 1) will be sent to all local STP interfaces. After receiving the TCN, the neighbor 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 to the TC message to all switches step by step; so that all The switch temporarily changes the aging time of the MAC table to 15s (default, forwarding delay)

Election---Root Bridge Root Port Designated Port Non-Designated Port (Blocked Port)

[1] Root bridge – In a spanning tree instance, there is and is only one switch that is root;

Determined by the bridge ID in the BPDU

Bridge ID = Bridge priority (0-65535 public) Default 32768 + MAC address (only switches with svi interfaces have mac addresses, if there are multiple macs, choose the smallest value)

For the election of the root bridge, first compare the priorities, the smaller the better; if the priorities are the same, compare the mac, the smaller the numerical value is better;

[2] Root port—On each non-root bridge, there is only one interface; the local interface closest to the root bridge (shortest, star) receives BPDUs from the root bridge and forwards user traffic ( This interface is not blocking)

rule:

    1. Compare the minimum cost value when entering through this interface after being sent from the root bridge;

    2. If the inbound cost values ​​are the same, compare the BID of the peer device of the interface to find the smaller one;

    3. The peer BID is also the same, compare the PID of the interface of the peer device of the interface; the priority is smaller first, if the priorities are consistent, the number is smaller;

    4. Even the peer PID is the same. Compared with the local PID, the result is small;

PID=port ID interface priority (0-240, step size 16, default 128) interface number

[3] There is only one designated port on each physical link where STP exists ; it forwards BPDUs from the root bridge and can also forward user traffic (without blocking); by default, all interfaces on the root bridge are designated port;

    1. Compare the minimum cost value when entering this link through this interface after it is sent from the root bridge (outbound)

    2. If the outbound cost values ​​are the same, the local BID must be used, which is better;

    3. If the local BID is the same, compare the local PID;

    4. If the local PID is the same, block the port directly;

[4] Non-designated ports (blocked ports) When all the above roles are elected, the remaining interfaces without any roles are non-designated;

 The interface is logically blocked and can actually receive information but does not forward it;

Cost value: Different bandwidths have different costs.

802.1d standard 10M = 100   100M=19   1000M=4 10000M=2 >100000M=1
  802.1T standard 1000M= 20000 100M=200000

In the generated protocol, at least the root bridge should be interfered with at the aggregation layer ;

Interface status:

down: No BPDU is sent or received. Once BPDU can be sent and received, it will enter the next state.

Listening: mandatory 15s; all switches send and receive BPDUs and elect all roles; the interface role is a non-designated port and directly enters the blocking state; if it is a designated port and root port, it enters the next state;

Learning: Mandatory 15s; The designated port and root port learn the MAC addresses of all interface connected devices and generate a MAC table; then enter the next state;

Forwarding: Refers to end port and root port entry, which can forward user packets;

Blocking: logical blocking;

Note: Data packets can be forwarded for users only after the interface enters the forwarding state. No data can be forwarded in the previous 30s;

Convergence time:

Initial convergence—30s = 15 listening + 15s learning

Structural changes:

Existence of direct connection detection: There is a blocked port locally. If other ports are disconnected, the blocked port will immediately enter 15 listening (election); if the result is enabled, it will enter 15s learning---a total of 30s

There is no direct connection detection: there is no blocked port locally. If a port is disconnected, suboptimal BPDUs (with the local as the root) will be sent to other neighbor switches. The other switches will ignore the data, perform a 20s hold time, and block the interface when the time expires. Enter 15s listening, 15s learning = total 50s

802.1D Disadvantages:

1. Slow convergence

2. Low link utilization

802.1 configuration commands:

[sw1]stp mode stp is modified to 802.1d algorithm, and Huawei currently defaults to MSTP;

[sw1]stp priority 4096 Modify 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

2.PVST

PVST cisco private vlan-based spanning tree protocol

Within each vlan, there is a tree, and the working principle of each tree is the same as 802.1d; the difference between BPDUs of different vlans is the priority;

Priority = multiple of 4096 + vlan id. Only multiples of 4096 can be modified manually, and it can only be modified to an integral multiple of 4096.

Only supports trunk encapsulation as ISL (cisco private encapsulation)

3.PVST+

 PVST + is based on PVST and is compatible with 802.1q trunk encapsulation; and has designed some acceleration;

Port acceleration (entry layer interface connecting users) Uplink acceleration - for direct connection detection Backbone acceleration - for sub-optimal BPDU;

Uplink acceleration is only configured on the access layer device, because after configuration, the switch will automatically increase the local bridge priority;

Under direct connection detection conditions, the blocked interface will skip 30s and directly enter the forwarding state - uplink acceleration;

Backbone acceleration is configurable on all switches, and the 20s hold time can be skipped for blocked ports that receive suboptimal BPDUs;

Disadvantages: 1. Slow convergence (incomplete acceleration) 2. Too many trees (only cisco has a separate chip, which cannot be loaded by other vendors)

4. Rapid spanning tree

cisco's RSTP --- vlan-based rapid spanning tree - one vlan, one tree pvst+ upgrade

Public RSTP (802.1w) --- One tree for the entire switching network 802.1d upgrade

Quick principle:

  1. The timer is cancelled, but after the work in one state is completed, it directly enters the next state;
  2. Segmented synchronization, step-by-step convergence between two devices; uses request and consent tags; relies on bits 1 and 6 of the tag bits
  3. The keep-alive time of BPDU is 6s; hello time is 2s;
  4. Integrates port acceleration (edge ​​interface), uplink acceleration, and backbone acceleration
  5. Compatible with 802.1d and PVST, but 802.1d and PVST do not use bits 1-6 of the flag bits, so they cannot converge quickly; therefore, if there is a device in the network that does not support fast convergence, other devices that enable fast convergence cannot also quickly converge. ;

When the tcn message appears, the local cam table can be refreshed without waiting for the BPDU of the root bridge;

Remember: When the interface defaults to half-duplex, even if RSTP is allowed, 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. It will directly be in the forwarding state; but if the interface receives BPDUs from the opposite end, It will lose edge characteristics and converge normally again;

[sw1]interface GigabitEthernet 0/0/1

[sw1-GigabitEthernet0/0/1]stp edged-port enable

[sw1]stp priority? Modify bridge priority

  INTEGER<0-61440>  Bridge priority, in steps of 4096

[sw1]stp root ? Quickly define the root bridge role

  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

MSTP/MST/802.1S Huawei equipment uses this protocol by default

Inherits the basis of rapid spanning tree; places multiple vlans in a group, and creates a spanning tree based on each group;

Priority in BPDU between different groups = multiple of 4096 + group number

[r1]stp mode mstp

Group 0 exists by default, and all vlans are in this group by default; priority = 32768+0

Group

[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 directive must be configured)

Remember: If a group is to be created, but the vlan in the group has not been created on this switch, and there is no interface serving the vlan; the group will not have any information; the grouping information of all devices in the entire switching network must be complete consistent; consistent ;

Define local as the primary root of group 1 and the backup root of group 2

stp instance 1 root primary      priority is modified to 0

stp instance 2 root secondary    priority is 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/qq_63099085/article/details/132456731