STP (Spanning-tree Protocol, Spanning Tree Protocol), the protocol can be used to establish a tree topology in the network, eliminate loops in the network, and can be achieved through a certain method of path redundancy.
1.1 Problems in a redundant topology
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5A/17/wKiom1T2W7Gi2-9CAADY8l6k6sQ671.jpg "title=" No redundancy. png "alt=" wkiom1t2w7gi2-9caady8l6k6sq671.jpg "/>
Figure 1-1 Topology of a single link
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/5A/13/wKioL1T2XXCCvWGnAADbn9Ra1F4593.jpg "title=" There are redundant. png "alt=" wkiol1t2xxccvwgnaadbn9ra1f4593.jpg "/>
Figure 1-2 topology with redundant links
In Figure 1-1, PC1 and PC2 are only transmitted over a single link, and if the link fails, the communication is interrupted.
In Figure 1-2, redundant links are added to resolve network outages caused by single-link failures in SW1 and SW2.
But in Figure 1-2, there may be a problem:
1. Broadcast Storm
There is broadcast through the F1/1 mouth out, and then through the f1/2 mouth back, then go out, back again, the loopback problem.
2, MAC Address Table is not stable
3. Duplicate frame Copy
1.2 STP Introduction
Redundancy can solve the network interruption due to single-link or single-switch failure, improve the availability of the network, but in the second layer of redundancy, it will bring broadcast storms, MAC address instability, duplicate frame copy and other issues, STP is used to solve the above problems.
1.2.1 STP algorithm
STP makes sure that there is only one logical link to any destination address by blocking some ports on the redundant path. STP uses STA (Spanning tree algorithm, spanning tree algorithm) to determine which ports on the switch are blocked to prevent loops from occurring. The STA selects a switch as the root switch, also known as the Root Bridge, which calculates all the paths as a reference point for the switch. All switches Exchange BPDUs (bridge Protocol data Unit, bridging unit), which includes bid (bridge ID), and bid is used to identify which switch sends the BPDU.
1. Root switch election
Bid generally consists of 3 parts: priority, the MAC address of the sending switch, and the extended system ID (the Extended Systems ID, optional).
Sw1#show Spanning-tree (brief) view spanning tree
Bid is made up of priority and Mac (old switch, which integrates many Macs)
Bid consists of the priority, the Extended system ID (the Extended Systems ID) and the MAC address (new switch)
By default, the switch with the lowest bid in the same VLAN is selected as the root switch.
SW1 (config) #spanning-tree VLAN 1 priority (multiples of 4096) change precedence
SW (config) #spanning-tree vlan 1 root primary Set the switch for the new root switch
2. Port cost and path cost
(1) The port is spent by default and bandwidth:
Speed |
Spend |
10gb/s |
2 |
1gb/s |
4 |
100mb/s |
19 |
10mb/s |
100 |
Port Cost Modification:
SW (config) #int fa 1/1sw (config-if) #spanning-tree cost <1-65535>
(2) The path cost is equal to the sum of the ports spent from the root switch to the direction of the final switch in the forward direction.
1.2.2 BPDUs
The root bridge is selected between switches by exchanging bpdus.
Bytes |
Field |
Explain |
2 |
Protocol ID |
|
1 |
Version |
|
1 |
Message type |
|
1 |
Flags |
The tag field. Contains this information: TC (topology change, topology changes) bit, indicates topology Change event, TCA (Topology change acknowledgment, topology changes confirm) bit, indicates received topology change notification, confirm |
8 |
Root ID |
The bid of the root switch |
4 |
Cost of Path |
The path to the root switch is spent |
8 |
Bridge ID |
The bid of the switch that forwards BPDUs |
2 |
Port ID |
Port PID of the switch forwarding BPDUs, equal to port priority (default is 128) + port number |
2 |
Message Age |
The time that BPDUs have existed |
2
|
Max Age |
Maximum presence time of BPDUs |
2 |
Hellotime |
The time interval for the root bridge to send configuration information, which is 2 seconds by default |
2 |
Forward delay |
Forwarding delay |
1.2.3 Port role
When the STA decides which path to use, the STA configures the port role of the switch, and the port role describes its relationship to the root bridge and whether to allow traffic to be forwarded. The port roles for the switch are:
(1) root ports (root port, abbreviated as RP). The port closest to the root switch on a non-root switch is called the root port, and each non-root switch has only one root port. is in the forwarding (forwarded) state.
(2) Assign port (designated port, referred to as DP). Each network segment has an assigned port, which is the port of the network segment to the closest switch on the root switch. is in the forwarding (forwarded) state.
(3) non-assigned port. An activation port that is neither a root port nor a designated port is called a non-assigned port. In blocking (blocked) state
(4) Disable the port. The shutdown port does not participate in the spanning tree algorithm.
1.2.4 Port status and BPDU time.
1. Port State Transitions
Port status: Down, Blocking, Listening, learning, Forwarding5 species.
①down (disabled) state. You can use the no shut command and insert a network cable for activation.
②blocking (blocked) state. The link is activated, the port transitions to the blocking state, and the state stays about 20 seconds, which is used primarily to determine the role of the port, if the port is the root port or the port is assigned, and the status will continue to remain in the blocking state if the port is a non-assigned port A port that is already in the blocking state will be loaded to the next state if it does not receive a BPDU.
③listening (listening) state. In addition to receiving BPDUs, BPDUs are sent to the neighbor switch, which notifies the neighbor switch that it will participate in the activation topology. This state will stay for about 15 seconds.
④learning (learning) state. Start learning MAC addresses. This state stays for about 15 seconds.
⑤forwarding (forwarding) status. The port can forward the data frame. 650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/5A/2C/wKioL1T5BuiD3bKxAAIQBcHST0Y284.jpg "title=" STP port State transitions. png "alt=" wkiol1t5buid3bkxaaiqbchst0y284.jpg "/>
2, the port State function
|
Receive BPDUs |
Send BPDUs |
Learn Mac |
Forward data
|
Down |
X |
X |
X |
X |
Blocking |
√ |
X |
X |
X |
Listening |
√ |
√ |
X |
X |
Learning |
√ |
√ |
√ |
X |
Forwarding |
√ |
√ |
√ |
√ |
3. Time of BPDUs
The associated time parameters in the BPDU are: Hello (2 seconds), Max age (20 seconds), Forward delay (15 seconds).
SW (config) #spanning-tree vlan 1 max-age 30 not recommended for modification
1.3 STP Convergence
Convergence is the entire network to a stable state: The election of the root switch, and determine the role of all ports, the elimination of all potential loops.
Election of 1.3.1 Spanning tree
In order to finally converge the network with STP into a network topology without loops, the following 4 steps need to be implemented.
① only one root switch per broadcast domain
② PID for each non-root switch that has and only one root port spends > sender's bid> sender
③ each network segment has only one assigned port
④ is neither a root port nor a port that is assigned a port will be blocked
1.3.2 Enhanced STP Capabilities
Configure the fast port on the port where the host is connected. The forwarding status can be entered immediately.
SW (config-if) #spanning-tree portfast%warning:portfast should only is enabled on ports connected to a singlehost. Connecting hubs, concentrators, switches, bridges, etc ... To Thisinterface when Portfast is enabled, can cause temporary bridging loops. Use with Caution%portfast have been configured on FASTETHERNET0/1 but would onlyhave effect when the interface was in a non-t runking mode.
1.4 Advanced STP
Cisco private
|
PVST (Per-vlan STP, one spanning tree protocol per VLAN) Support ISL Encapsulation Protocol Each VLAN has a spanning tree instance Enables load balancing on the second tier Supports Backhomefast, Uplinkfast, and Portfast features |
pvst+ (Per-vlan STP Plus, one spanning tree protocol per VLAN Plus) Supports ISL and 302.1Q encapsulation protocols Extensions that support Cisco STP private properties Increased BPDU guard and root guard functionality |
rapid-pvst+ (Rapid Per-vlan STP, fast one spanning tree protocol per VLAN) Criteria based on the fast spanning tree Faster than the 802.1D convergence rate Supports Backhomefast, Uplinkfast, and Portfast features |
IEEE Standards
|
RSTP (Rapid STP, fast spanning Tree protocol) 1982 was presented, faster than the 802.1D convergence rate Implementation of Cisco common private properties extension IEEE RSTP synthesis into 802.1D, called IEEE 802.1d-2004 specification |
MSTP (multiple STP, multi spanning Tree protocol) Multiple VLANs are mapped to the same spanning tree instance IEEE 802.1q-2003 now contains MSTP |
SW (config) #spanning-tree mode? View the spanning tree protocol supported by the switch
CCNA Learning Note STP