Home  >  Article  >  Operation and Maintenance  >  What is the principle of Layer 2 STP?

What is the principle of Layer 2 STP?

WBOY
WBOYforward
2023-05-12 21:43:111362browse

STP
The ultimate goal of STP:
From anywhere on the network, it is the shortest loop-free data forwarding path to the switch
1 The same network:
The first problem faced A problem: single point of failure
Solution: Provide network redundancy/backup
1 device backup
2 link backup
New problems caused by:
Layer 2 data Forwarding loop
New solution:
STP/RSTP-spanning-tree protpocol[Spanning Tree Protocol]
Highlights another problem: utilization
Solution: MSTP[Spanning Instance Tree Protocol] 】

There are standard protocols:
STP - 802.1d, slow;
RSTP - 802.1w, a little faster;
MSTP - 802.1s
In order to achieve link backup At the same time, load balancing of data forwarding can also be achieved to improve equipment utilization.
Protocol to solve layer 2 data loop
Working principle/process of STP protocol:
1 Elect switch role:
Root switch (bridge):
There is only one in the entire switch network [The smaller BID value takes precedence]
Non-root switch:
Except the root switch
2 Election port role:
Root port:
On any non-root switch, there is only one,
The closest (cost) port to the root switch
Designated port:
There is only one in any network segment,
The closest (cost) port to the root switch
Non-designated port :
All the remaining ports are non-specified
3 Determine the port status:
down
listening: Listening
[Listening BPDU, in order to collect all BPDUs as much as possible , for comparison]
learning: Learning
[Learning the MAC address table at this stage]
forwarding: forwarding
[The final status of the root port and the designated port]
blocking: blocking
[ The final port corresponding to the non-specified port]

All functions of the STP protocol are implemented through BPDU messages
BPDU -bridge protocol data unit [Bridge protocol data unit]

BPDU message The basic composition of the document:
root-id: Represents the ID of the root switch.
cost: Represents the distance from the switch that sends the BPDU to the root switch.
bridge-id: Represents the location of the switch that sends the BPDU. The name of the switch
port-id: Represents the outgoing port of the switch that sends the BPDU
consists of two parts:
port-priority port-number
[Port priority port number]
Port priority: 1 byte, the default value is 128
Port number; 1 byte, which is the port number on the switch
For example: the port-id of gi0/0/23 of the switch The expression is: 128.23

We can elect the "device role" and "port role" when
Based on the definition of "switch role" and "port role"
The four in the BPDU message Fields are compared from top to bottom.
The first thing to compare is the root-id;
If they are not the same, select the smallest one as Root-switch;
If they are the same, compare the costs; if they are not the same, select the smallest cost;
If they are the same, compare the bridge-ids. If they are not the same, select the smallest one;
If they are the same, compare the port-ids. If they are not the same, select the smallest one;

STP convergence time: 30--50 seconds
hello -2 seconds
[The time period for the root switch to send BPDU, once every two seconds]
forward-delay=15 seconds forward delay
[Indicates staying in listening and learning respectively Time]
max-age=20 seconds Maximum life time 20 seconds
[Deduct one second for each switch passed, up to 20 seconds]

     配置命令以及解释:
[huawei]stp priority

[STP priority, the default is 32768 setting The hour value must be a multiple of 4096]

[huawei-gi0/0/23] stp cost
[Modify the cost of STP on a port]
On Huawei switches, the cost of the 1000M port is by default It is 20000;

[huawei]display stp
[You can view the STP mode running on the switch, as well as the BID information of itself and the root switch]
[huawei]display stp brief
[ You can view the role and status of each STP-enabled port on the switch]

[huawei]display stp interface gi0/0/23
[You can view the cost of the interface, as well as sending and receiving BPDU situation】

MSTP configuration:
[A]stp region-configuration
【stp domain configuration】
[A-mst-region]region-name 1
【 Name the domain】
[A-mst-region]instance 1 vlan 10 20
【Create instance 1 and add vlan 10 20】
[A-mst-region]active region-configuration
[Activate domain configuration]
[A]stp instance 2 priority 4096
[Set the priority for instance 2]
[A]display stp instance 1
[Check whether the stp priority of instance 1 is effective 】

The above is the detailed content of What is the principle of Layer 2 STP?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete