STP Spanning Tree Protocol and MSTP Simulation Experiment

1. STP background

In a newly started switch connected to the LAN, each switch does not have a corresponding MAC address table, and the PC port on each switch will initiate a large number of flooded broadcast messages, causing broadcast storms, network congestion, and MAC address table records Confusion
as shown:
Insert picture description here

1.1 Broadcast storm

(1) At the beginning of network communication, there is no MAC address of PC2 in the ARP entry of PC1. According to the principle of ARP, PC1 will first send an ARP broadcast request (requesting the MAC address of PC2) to switch SW1.

(2) When the switch sw1 receives the broadcast request of ARP, according to the forwarding principle of the switch, SW1 will forward the broadcast frame from all ports except the receiving port (that is, the broadcast will be from F0/1 and F0/2 respectively Forward to SW2 and SW3).

(3) After SW2 receives the broadcast frame, it also forwards the broadcast frame from F0/2 and the port connected to PC2 according to the forwarding principle of the switch. Similarly, after SW3 receives the broadcast frame, it forwards it from the F0/2 port.

(4) After SW2 receives the broadcast frame sent from SW3 from port F0/2, it forwards it from port F0/2 and the port connected to PC2; similarly, after SW3 receives the broadcast frame sent from SW2, it transfers it from F0 /1 Port forwarding.

(5) SW1 receives broadcast frames from SW2 and SW3 respectively, and then forwards the broadcast frames received from SW2 to SW3, and forwards the broadcast frames received from SW3 to SW2.

SW1, SW2, and SW3 will forward the broadcast frames to each other. At this time, the network forms a loop, and the switches do not know it, which will cause the broadcast frames to circulate in this loop, as shown in the figure. In the actual network environment, the situation is much more complicated. When a broadcast frame passes through a switch, the switch generates a broadcast frame in the form of an index (the switch forwards the broadcast frame from all ports except for the broadcast frame). There will be more and more broadcast frames of this kind, eventually forming a broadcast storm, leading to network paralysis.

1.2 MAC address disorder

Here, there are two ways to send a broadcast to PC2, one and two. When the broadcast through the switch of SW3 reaches SW2, it will be recorded in the MAC address table of SW2. The interface corresponding to the MAC address of PC1 is F0/2. The MAC address interface corresponding to the broadcast from line 1 is F0/1. At this time, PC2 will disorderly record the address record of the MAC table of PC1

1.3 Multi-frame copy

In a complex network, PC2 will receive the same unicast frames forwarded by multiple switches for PC1.
In this context, we have related technologies to avoid it, and STP (Spanning Tree Protocol) came into being.

2. STP Spanning Tree Algorithm

STP (Spanning Tree Protocol) is the English abbreviation of Spanning Tree Protocol. It can be applied to the establishment of tree topology in computer networks. Its main function is to prevent redundant links in the bridge network from forming loops . Anti-loop
Spanning Tree Protocol is a data link layer protocol specified in IEEE 802.1D , which is used to solve the network loop problem generated in the construction of redundant links at the core layer of the network . The above is Baidu's explanation, the following is the general explanation

STP logically blocks some ports to generate a logical tree structure. (Ring to tree shape)

(1) Prevent the occurrence of broadcast storm: logically disconnect the loop and turn it into a tree shape

(2) Play the role of a backup line: when the normal line fails or the port is physically disconnected, the blocked interface will be reactivated to restore communication, so that data can be transmitted normally from this line

3. The algorithm of spanning tree is divided into 3 steps

3.1 Select the root bridge (switch)

Select the root bridge: the
bridge ID (BID), the bridge ID is unique.
Select the switch with the smallest bridge ID in the switching network to become the root bridge. The
bridge consists of the two parts shown in the figure: "bridge priority" and "bridge MAC address".
Bridge priority: the smaller the number contained, the more priority
the MAC address of the bridge: if the priority is the same, the MAC address whoever has the smaller priority will be given priority.

Insert picture description here

3.2 Select the root port

Choosing the root port
What is the root port? The
lowest root path cost to the network bridge, the directly connected bridge ID is the smallest, and the port ID is the smallest.
Root path cost:
The sum of the costs of all links on the path from the bridge to the root bridge.
The relationship between some commonly used bandwidth and path costs

Link bandwidth Path cost
10 100
100 19
1000 4

As can be seen from the above figure, the greater the bandwidth, the lower the path cost

3.3 Select designated port

Select designated port
Each physical network segment needs to select a designated port.
All ports on the root bridge are designated ports, and the port of the opposite device corresponding to the root port is the root port.

As shown below.
(1) First find out the root network, the one with the smallest value in the priority is the root network, so SW2 is the root network here.
(2) Find out the root port. It is known that all ports on the root network switch are designated ports, and the opposite port corresponding to the designated port is the root port. Therefore, the root port is at the end of SW1 and SW3 that is closer to SW2.
(3) Find out the blocked port. Here we compare the remaining ports of SW3 and SW1 and find that the priorities are the same. We will continue to compare the MAC addresses here. Whoever is the smaller is the designated port, then the remaining port is the blocked port.
Insert picture description here
This is also the case in the network in the figure below
Insert picture description here

4.BPDU :

4.1 What is BPDU

It is a bridge protocol data unit, transmission carrier, used to exchange BUPD message fields (including: root bridge ID, root path cost, sending bridge ID, port ID, etc.) between switches through multicast.
BPDU type
configuration BPDU ---------
Topology Change Notification (TCN) used for spanning tree calculation BPDU-------Used to notify network topology change

BUDU message fields
Root bridge ID, root path cost, sending bridge ID, port ID

4.2 Use BPDU to select the root bridge

When the switch is started, all switches will assume that they are the root bridge. The root bridge ID field in the BPDU sent out will fill in their own bridge ID, send BPDUs to other switches, and receive BPDUs sent by other switches, which is the smallest After the bridge ID is determined, the smaller one is determined as the only root bridge, and then continue to be passed down until the convergence is determined.

Insert picture description here
Insert picture description here

q

5. Experiments on simulating MSTP

Complete the following experiment to enable VLAN 10 and VLAN 20 to communicate with each other
Insert picture description here

To summarize:
1. First enter each switch to turn on the STP mode and configure:
For the SW3 switch in the figure, you only need to put the VLAN into the instance, and you don't need to configure the priority of the instance. Insert picture description here
For SW1 and SW2 switches, enter the configuration STP mode like SW3, but you need to pay attention here, you need to configure one more VLAN priority for each instance. As shown in the figure below,
for SW1 configuration, then his instance 1 priority is primary, and instance 2 priority is secondary. If for the SW2 configuration, the priority of instance 1 is secondary, and the priority of instance 2 is primary. (The ports with low priority are blocked)

Insert picture description here
The relevant configuration of sw2 is as follows:

Insert picture description here
Here we have all configured the STP mode of the switch in the picture. The next step is to configure the interface type and VLAN of each switch. I won't introduce too much here, and I will directly upload the picture of my operation.
2. Enter and configure each interface and VLAN according to the specific conditions of the network equipment.
SW3l:
Add VLAN to
Insert picture description here
configure each port type: I
Insert picture description here
won’t go into details about the interface configuration later.
3. Connectivity experiment:
here we delete one of the lines to see if it can still be connected.
Insert picture description here
According to our configuration, the ideal data trend should be as shown in the figure:

Insert picture description here

Enter the PC side to tracert PC2's ip address

Insert picture description here
Therefore, the main and backup experiments from PC1 to PC2 are successful. Let's go the other way.

Insert picture description here

Insert picture description here

We can find that after the original main line is disconnected, PC1 can still send data packets to PC2, and the sending path is indeed the same as we expected, and it is also operable when sending from PC2 to PC1. Therefore, the STP spanning tree experiment was successful

Summary: The author has operated the MSTP experiment successfully for 5-6 times
. The problem is that some commands are unfamiliar and confused with the previous routing-related. So we still need to watch and practice more.

Guess you like

Origin blog.csdn.net/weixin_44324367/article/details/109357761