STP——STP Spanning Tree Protocol Explanation

Table of contents

Basic concept of STP

STP Port Role Election

Two port roles of the standard STP protocol

First understand two concepts

STP election steps

How Port Roles Are Elected

electoral root bridge 

Elect the root port RP - the port on the switch that can receive the best BPDU message

Election Designated Port DP - the port with the best BPDU that can be sent to the root bridge on the link

Election blocked port------All ports except RP and DP are blocked ports AP

Three Standards for STP Port Cost Calculation

Five port states of STP

STP failover

root bridge failure

direct fault

indirect fault

 View STP related information


Basic concept of STP

STP is the abbreviation of Spanning Tree Protocol, which is mainly used to prevent the loop problem in the two-layer network (in the three-layer network, the IP field TTL can be used to break the loop)

Why is there a loop on the second layer

There is no anti-loop field in the Ethernet frame, and there is no TTL-1 mechanism when the frame is forwarded

Impact of Layer 2 Loops

Broadcast storm --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

MAC address drift-------------MAC address oscillation

The phenomenon of multiple submissions of a single frame -------- generally occurs in the same Vlan


STP Port Role Election

Two port roles of the standard STP protocol

Root port RP, designated port DP, blocked port AP (non-standard STP protocol)

  • In the standard STP protocol, there are only two port roles, namely RP and DP, and there is no role definition for ports in the Block state.
  • However, on Huawei equipment, the STP protocol defines the Block status port by referring to the AP port role of the RSTP protocol.
  • That is, the AP port is the port role of the RSTP protocol. There is no definition of the AP port in the standard STP, but Huawei's STP uses the AP port to express the port status as Block.

First understand two concepts

BID: Bridge ID (including the priority of the switch and the MAC address of the switch)

Priority -----0~65535, default 32768. And the priority must be a multiple of 4096 ----- the smaller the priority

MAC address--select the smallest MAC address among all ports of the switch for comparison --------------- the smaller the priority

PID: Port ID (including port priority and port number)

Priority -----0~255, default 128. And the priority must be a multiple of 16 -------------- the smaller the priority

Port number ------------------------------------------------ ------------------------------ the smaller the priority 

STP election steps

  • Elect the root bridge, there is only one root bridge in the same Layer 2 network
  • Other switches are non-root bridges, and the root port (RP) is elected on the non-root bridge. Each non-root bridge switch has one and only one root port, and there is no root port on the root bridge.
  • Elect a designated port on each link, and each link has one and only one designated port (root port and designated port cannot be the same port)
  • A port that is not a root port or a designated port is called a blocked port.

How Port Roles Are Elected

After the switch is started, it automatically starts spanning tree convergence calculation. By default, all switches consider themselves as the root bridge when they start up, and all their ports are designated ports, so BPDU packets can be forwarded through all ports.

electoral root bridge 

 The switch with the smallest BID is called the root bridge (the root bridge can be robbed)

 Compare the bridge priority, the smaller the better

 Compare MAC addresses, the smaller the better


Elect the root port RP - the port on the switch that can receive the best BPDU message

 The root port with the smallest Root ID among the BPDU packets received by the comparison port is the root port (the root ID is the same for the same bridge)

 Compare the path cost, this cost is the minimum path cost received by the port, the smaller the better

 Compare the BID of the peer and choose the one with higher priority

 Compare the PIDs of the peers and choose the one with higher priority

 Compare the PID of this port and choose the one with higher priority


Election Designated Port DP - the port with the best BPDU that can be sent to the root bridge on the link

For the root bridge, all its ports are generally designated ports

Compare the path cost, this cost refers to the root path cost sent by the port, the smaller the priority (Eth port cost is 20000 by default)

Compare the BID of the local end and select the one with the higher priority

Compare the PIDs in this section and choose the one with higher priority

    


Election blocked port------All ports except RP and DP are blocked ports AP

Three Standards for STP Port Cost Calculation

dot1d-1998 The calculation method of the path cost is the IEEE 802.1d-1998 standard method (old standard, generally not recommended)

The calculation method of dot1t path cost is IEEE802.1t standard method (new standard, Huawei default)

The calculation method of the legacy path cost is the Huawei calculation method (Huawei private standard)

 


Five port states of STP

Disabled       does not run STP               

                                   InterfaceShutdown

Blocking       Only accept STP, do not send STP, do not learn MAC, do not forward user data ----- AP port status    

                                    Interface Enabled/Root and Designated Ports have not been selected as Root or Designated Ports

Listening       Accept and forward STP, do not learn MAC, do not forward user data           

                                    The port is selected as root port or designated port

Learning       Accept and forward STP, learn MAC, do not forward user data   

                                    The interface forward delay timer expires

Forwarding   accepts and forwards STP, learns MAC, and forwards the number of users 

                                    The interface forward delay timer expires

state transition time

Block → Listen 0s~20s time

Listen → study for 15s

Learn → Forward 15s

Therefore, STP takes at least 30s and a maximum of 50s from opening to forwarding.


STP failover

root bridge failure

1. If the root bridge goes down directly, LSW2 and LSW3 will directly re-elect the root bridge

2. When the root bridge closes STP, it stops sending BPDUs, and the switch without AP ports sends BPDU messages with itself as the root.

A switch with an AP port waits for the BPDU of the previous root bridge to age before processing this BPDU (20s)

Then according to the situation, it takes 15+15=30s for the blocked port to be converted to the designated/root port

Therefore, when the root bridge fails, it will take up to 50s to recover

direct fault

RP direct connection failure occurs on a switch with an AP port

The AP becomes the new RP, enters the forwarding state after experiencing twice the forwarding delay, and recovers from the fault

A switch without an AP port is directly connected to the RP.

The switch will send BPDUs with itself as the root

The downstream switch waits until the BPDU20s of the previous root bridge ages out before processing the BPDU

When the downstream interface is determined to be a DP port, it enters the forwarding state after 2 times the forwarding delay

Recover failure after a total of 50s

indirect fault

After the indirect failure of the RP occurs on the switch with the AP port

The BPDU of the RP ages, the AP becomes the new RP, enters the forwarding state after experiencing twice the forwarding delay, and recovers after a 50s failure

An indirect failure of the RP occurs on a switch without an AP port

The switch will send BPDUs with itself as the root

The downstream switch waits until the BPDU20s of the previous root bridge ages out before processing the BPDU

When the downstream interface is determined to be a DP port, it enters the forwarding state after 2 times the forwarding delay

Recover failure after a total of 50s


 View STP related information

Guess you like

Origin blog.csdn.net/m0_49864110/article/details/123549387