Little knowledge of spanning tree

Posted by nowaydown1 on Sun, 16 Jan 2022 11:41:30 +0100

1, Definition

In a switching network, a logical blocking part interface; Form a unique path from the source to the target; When the available path fails, open some blocking interfaces to continue network communication and realize line backup.

2, Backup: Root - star, shortest

3, Type: 802.1D PVST PVST+ 802.1W 802.1S RSTP MSTP

4, Spanning tree protocol: spanning tree STP. All spanning tree protocols are electing by sending comparison information to find the interface that should be closed in the loop (interface blocking).

5, BPDU: bridge protocol data unit, which is divided into configuration BPDU – config BPDU (used for spanning tree election and re convergence) and topology change – TCN-BPDU (notifying switching network of topology change).

6, Data structure of BPDU

*notes:
1,Message type:  On behalf of BPDU Type of (0) X00 Configuration 0 X80 topology TC)
2,Flags : Flag bit, at 802.1D Medium, identification BPDU Topology change or topology change confirmation BPDU
3,Root ID : Root identifier, used to mark the root of a tree. Connection with root bridge BID agreement.
4,Bridge ID : Bridge identifier, BID , It is used to identify the uniqueness of the device in the spanning tree.
5,Port ID : Port identifier, PID ,It is used to identify the uniqueness of an interface on the device.
6,Cost of path :  Path overhead. In Huawei equipment, it is called root path cost (RPC)Root path overhead.
7,hello time:  The default is 2 s ,BPDU Interval for sending.
8,Max-age :  The maximum time can be understood as hello Timeout for the package. The default time is 20 s
9,Forward delay :  Forwarding delay, state switching time, default: 15 s
10,Message age : In Cisco, the default is 300 s,Is the corresponding MAC Aging time of address entries, (but actually
 This time is BPDU Number of hops passed); In Huawei, it represents the BPDU Number of hops passed (the default value is 0, which is not verified)
Value of one switch+1)
11,Max-hop : The default is 20, received BPDU After will message age Time and in max-hop Compare if small
 In case of failure, it is used normally BPDU ,If greater than, ignore BPDU. 
12,BID:  It is composed of 8 bytes in the following way: BID Priority fields (4) bit)+Extended system ID(12 individual
bit)+Mac Address (6 bytes)



I BID Use of: 1.compare BID Priority 2.compare MAC address 
II BID Priority: 4 bits, the default value is 32768, and the range is 0-65535(Actual range 0-61440),The smaller the better. BID
 Priority unit 4096.adjustment BID Priority time value must be a multiple of 4096.
Extended system ID:  8 Bit, at 802.1D And 802.1W Meaningless, in 802.1S Useful in
Mac Address: all addresses in the switch backplane address pool MAC The smallest of the addresses, MAC The smaller the address, the better.
PID: The port identifier consists of 2 bytes and consists of: PID Priority (4) bit Composition)+Port identifier (12)
bit Composition)
Usage: 1.compare PID Priority 2.Port number 
PID Priority: the default value is 128 and the range is 0-255(Actual range 0-240),Unit 16
Port number : Identity uniqueness
RPC: Root path overhead
COST:  Cost value
 Links with different bandwidths use different bandwidth cost (Should cost Values are internally encoded), nonlinear processes.
802.1D-1998 
10G---2
1G---4
100M---19
10M---100
802.1T Standards, cost Range

7, Election process

1. Root bridge - a switch - there is only one root bridge in a switching network
Function: the center of the whole tree structure; Manage the whole tree and send BPDU periodically;
Compare BID = bridge ID = bridge priority + MAC address in BPDU; First compare the priority of 0-65535, 32768 by default. The smaller the priority, the better; If the priority is the same, compare the MAC address of the device. The smaller the MAC address, the better.
2. Root port - there is only one interface on each non root bridge; Local interface closest to the root bridge
Function: it is responsible for periodically receiving BPDU from the root bridge and forwarding user data without blocking
1. Compare the BPDU sent from the root bridge, enter the switch through this interface, and the minimum cost value
2. If the input cost values of multiple local interfaces are consistent, compare the BID of the (last hop) device, and the smaller the BID, the better
3. If the above parameters are consistent, compare the PID of the superior (previous hop), the smaller the better - compare the interface priority first, the smaller the better; If the priority is the same, compare the interface number, the smaller the better.
4. If the above parameters are consistent, compare the local PID, the smaller the better

*PID: PORT-ID interface priority + interface number priority: 0-255 default 128 the smaller the better

802.1d Standard:             
10M=100
100M=19
1000M=4
10000M(10G)=2
>100000=1
3. Designated port - there is only one interface on each STP link;
Function: responsible for forwarding BPDU of root bridge; Forward user data at the same time without blocking; All root port pairs are designated ports, and all ports on the root bridge are designated ports.
1. Compare the BDPU minimum cost of the outgoing root bridge and the cost value of the outgoing direction
2. If the outgoing cost value is the same, the smaller the local BID, the better
3. Compare the local PID, the smaller the better
4. If PID is the same - self blocking
4. Unspecified port - blocked port
After all the above roles are elected, the remaining interfaces; Logical blocking, data can be received, but data is not forwarded

*In the three-tier architecture, the aggregation layer (distribution layer) is used as the traffic center of the switching part; The root bridge of spanning tree, as the center of a tree structure; In a network segment, the gateway is the center; Requirements: Center in one

3, 802.1D algorithm

1. Role: root bridge, root port, specified port, unspecified port

2. Status: down, learning, listening, blocking, forwarding

3. Process

1. All interfaces enter the down state
2. All interfaces enter listening (15)s; All interfaces send and receive BPDU and elect various roles; Root port specify port - > learn
3. The learning state (15S) interface records the mac addresses of all data frames and generates a mac table
4. After learning, the interface enters the forwarding state

4. Convergence time

1. Initial convergence: 30s
2. Structural changes
A. Presence of direct connection detection - 30s
B. No direct connection detection - 50s 20s hold time+30s convergence time (hold time listening detection time)
*Direct connection detection: only one local blocking port can receive BPDU from the root bridge

5. Disadvantages of 802.1

1. Slow convergence - after 30s, the DHCP on the PC side cannot automatically obtain the IP address
2. Low link utilization (Cisco)

4, Cisco PVST - VLAN based spanning tree

(Cisco to solve the low utilization of 802.1D link)

Based on a vlan and a tree in the switching network; The tree of each vlan implements the 802.1D standard;

1. How to distinguish BPDU s of different VLANs:

The remainder of priority ÷ 4096 is vlan id; People can only modify the priority in a multiple of 4096, and the device automatically adds vlan id to the priority!

2. The root bridges of different VLANs can be placed in different aggregation layer devices to block different links in different VLANs; Finally, all links are utilized and backed up to each other to improve the utilization of links.

3. Advantages: shunting, using all physical links - improved utilization

4. Disadvantages: 1. Full convergence 2. Many trees - (there is an independent STP dedicated chip in Cisco equipment.) 3. Pure private protocol - only ISL (the standard for encapsulating vlan id on Cisco's dedicated trunk, and the other is 802.1q)

5, PVST plus - upgraded from PVST

1. Partial acceleration

1. Acceleration:
A. Port acceleration - the interface used to connect the terminal without convergence and direct forwarding
B. Uplink acceleration - used to directly enter the forwarding state on the interface that meets the direct connection detection conditions, omitting 30s (direct connection detection time) - (condition: it can only be configured on the access layer switch, and automatically increase the local bridge priority and interface cost - non root bridge.)
C. Backbone acceleration - for suboptimal BPDU - can be configured on all switches - provinces consume about 20s hold time when receiving suboptimal BPDU, and 30s normal convergence cannot be omitted
2. Advantages
1. High utilization (one vlan and one tree)
2. Partial acceleration
3. Compatible with 802.1q
3. Shortcomings
1. Many trees - different VLANs have one tree
2. Incomplete acceleration

6, Fast spanning tree

1. Principle of fast:

1. The timer is cancelled, but the next generation state is directly entered after the work of one state is completed
2. Sectional synchronization, convergence between two equipment level by level; Use of request and consent marks; Depends on the first and sixth bits of the tag bit.
3.BPDU is kept alive for 6s (original 20s); hello time is 2s
4. Integrate port acceleration (edge interface), uplink acceleration and backbone acceleration
5. Compatible with 802.1d and PVST

7, MSTP -- group based spanning tree -- takes a group as a tree, places multiple VLANs in the same group, and finally shunts based on the group

It inherits the basis of fast spanning tree; Placing multiple VLANs in a group and a spanning tree based on each group; Priority in BPDU between different groups = 4096 multiple + group number

[r1]stp mode mstp
 Group 0 exists by default and all vlan It is in this group by default; priority= 32768+0
 grouping
[sw1]stp enable 
[sw1]stp region-configuration 
[sw1-mst-region]region-name a    All equipment shall be in one domain
[sw1-mst-region]instance 1 vlan 1 to 5
[sw1-mst-region]instance 2 vlan 6 to 10
[sw1-mst-region]active region-configuration     Activate the current configuration (the command must be configured)
Remember: if a group will be created, but vlan,Not created on this switch, and not created for this switch vlan Service interface; The group will not have any information; The packet information of all equipment in the whole switching network must be completely consistent;
Define the local as the primary root of group 1 and the backup root of group 2
stp instance 1 root primary      The priority is modified to 0
stp instance 2 root secondary    Priority changed 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