Decoding Spanning Tree Protocol (STP): A Comprehensive Guide
Most network engineers design LANs with redundant links between switches
In networks with redundant links, broadcast frames could loop indefinitely—a broadcast storm
Another problem is multiple frame copies, which could occur when a frame arrives from different segments at the same time, which could also lead to MAC address table thrashing.
Let’s consider the following scenario:
STP (Spanning Tree Protocol
STP (Spanning Tree Protocol IEEE 801.1D) “scans” the network to find all links, making sure that there are no loops by “switching off” all redundant links.
It first uses the STA (Spanning Tree Algorithm ) to figure out the topology, and then identifies the links that form loops. Those links are blocked one by one, removing loops.
For this to function properly, all switches must cooperate: one of the switches is chosen as a reference point the “Root Bridge
?
An Example:
Since the spanning tree is enabled, all our switches will send a special frame to each other called a BPDU.
“Bridge Protocol Data Unit”
This is what it looks like:
STP- Why configure manually
When you boot a switch, STP is on by default. I still think you should configure it manually. Here’s why:
As an administrator, you can pick the Root switch (bridge) manually, which will greatly influence the resulting tree.
?
STP: How to configure?
Switch(config)# spanning tree vlan VLAN_ID root primary
Switch(config)# spanning tree vlan VLAN_ID root secondary
Switch(config)# spanning tree vlan VLAN_ID priority PRIORITY
?
The default priority value is 32768, so it’s enough to set any value lower than that for the given switch to become Root. The priority value must be an increment of 4096. The highest possible value is 61440.
?
STP: multiple VLAN
Spanning Tree Protocol was initially designed to work with bridges, and support only one LAN (or one VLAN).
Even if you have multiple VLANs in your network, you can still only have a single instance of STP all VLANs will share the same tree. But to best utilize your gear, you should have a different tree for each VLAN.
This is achieved by running a separate instance of STA per VLAN. It’s called PVST Per VLAN Spanning Tree
STP: PVST Faster
After a change is made, the network takes 30 to 50 seconds to converge. To improve this, a “rapid” version of STP was introduced by IEEE.
A network that uses RSTP Rapid Spanning Tree Protocol ) will converge faster, but it still depends on the size of the network. For smaller networks, it’s a matter of seconds.
Switch(config)#spanning tree mode rapid pvst
In case the administrator knows that a port will for sure not be in a loop, they can configure the port to converge faster STA takes its time, but if it knows that a loop is not possible on a given interface, it can simply skip the procedure and send the port into forwarding state right away.
Switch(config if)#spanning tree portfast
?
?STP – Spanning Tree Protocol (802.1D)
?STP states do not change the other information about the interface: connected/not connected (#show interfaces status), and operational state – access/trunk (#show interfaces switchport), it only adds an additional STP state.
?
?STP versions and types:
IEEE 802.1d (STP, CST – Common Spanning-Tree): slow but requires very little bridge resources.
PVST+: Cisco proprietary enhancement for STP that provides a separate 802.1d spanning-tree instance for each VLAN. Creates more efficiency of the links in the network, but is just as slow as 802.1d, and it does use more bridge resources than 802.1d.
IEEE 802.1w (RSTP – Rapid Spanning-Tree Protocol): enhanced BPDU exchange, faster network convergence, but still allows only one RB per VLAN. Bridge resources used with RSTP are higher than CSTs but less than PVST+.
领英推荐
Rapid PVST+: Cisco’s version of RSTP also uses PVST+ and provides a separate instance of 802.1w per VLAN. Fast convergence times and optimal traffic flow require the most CPU and memory of all.
?
Bridge port roles:
FORWARDING PORT – forwards frames and will either be a root port or a DR.
BLOCKING PORT (blocked port) – won’t forward frames in order to prevent loops. A blocked port will still listen to BPDU frames from neighbor switches, but it will drop any and all other received frames and will never transmit a frame.
ALTERNATE PORT – corresponds to the BLOCKING state of 802.1d (STP), and is a term used with the newer 802.1w (Rapid STP). An alternate port is located on a switch connected to a LAN segment with two or more switches connected, where one of the other switches holds the DP. The alternate port is a backup for RP.
BACKUP PORT – also corresponds to the BLOCKING state of 802.1d, and is a term now used with the newer 802.1w. A backup port is connected to a LAN segment where another port on that switch is acting as the DP. A backup port is a backup for DP.
STP port states:
Forwarding state – use the interface as normal
Blocking state – block all user traffic; do not send or receive user traffic on that interface (in that VLAN), except STP messages (and some other overhead messages)
Disabled state – technically not a transition state; a port in the administratively disabled state doesn’t participate in frame forwarding or STP. Is virtually nonoperational
Listening state – listens to BPDUs to make sure no loops occur on the network before passing data frames. A port in the listening state prepares to forward data frames without populating the MAC address
table. Old (unused) MAC addresses are removed from the table during this state. Switches populate the MAC address table in learning and forwarding modes only
Learning state – listens to BPDUs and learns all the paths in the switched network. A port in the learning state populates the MAC address table but still does not forward data frames. “Forward delay” refers to the time it takes to transition a port from listening mode to learning mode, which is set to 15s. by default and can be seen in the #show spanning-tree output
“Working” ports/interfaces (those in a connected state) are all interfaces that COULD forward frames if STP placed them into a forwarding state. Failed interfaces (for example, interfaces with no cable installed) or administratively shutdown interfaces are placed into an STP-disabled state.
“Port Cost” determines the best path when multiple links are used between two switches. The cost of a link is determined by its bandwidth.
“Path Cost” = “Root Cost”: all unique paths to the RB are analyzed individually, and a PATH COST is calculated by adding up the individual outbound PORT COSTS encountered on the (outbound) way to the Root Bridge.
“STP stable states”: Blocking, Forwarding, Disabled
“STP transitory states”: Listening, Learning
?
STP steps:
(1) STP ELECTS A ROOT SWITCH (Root Bridge – RB). Switch with the lowest BID value (priority) becomes the RB. All “working” interfaces on the root switch become Designated Ports (DPs)
(2) EACH “NONROOT BRIDGE” CHOOSES ITS ROOT PORT – the lowest cost interface to reach the RB through. Root switches don’t have RPs. Each switch in a given network has EXACTLY 1 root port per VLAN. RB will send “Root Cost = 0” in Hello packets.
STP tiebreakers when choosing the Root Port:
In these tie-breakers, only those paths that are tied are considered;
3 and 4 only come into play when 2 switches connect to each other with multiple links
(3) DESIGNATED PORT ELECTION: on each network segment (link), the port that advertises the lowest price to RB becomes DP. All other ports in that segment will, if they’re not RP, become “non-designated” ports and they’ll be put into either a “blocking” or “discarding” mode.
Access ports will also automatically become DPs because the switch is the only device on the segment to send Hellos -> switch is sending least-cost Hellos.
Network segments are marked with red circles.
How STP works in steady-state (nothing changing in the STP topology):
When a switch ceases to receive Hellos or receives a changed Hello -> something has failed -> the switch starts the process of changing the spanning-tree topology.
If an interface fails on a switch, the switch can assume that Hellos won’t be arriving in that interface anymore.
Hello BPDU fields:
?
STP timers (RB dictates timers):
RSTP – Rapid STP (IEEE 802.1w):
?
?Both 1 and 2 are full duplex.
Portfast: allows a switch to immediately transition from blocking to forwarding, bypassing listening and learning states. Should only be enabled on ports where no other bridges, switches, or other STP-speaking devices will be connected. If enabled, the port will move to an STP forwarding state and forward traffic as soon as the NIC is active on the end device connected to the port.
BPDU guard: disables a port if any BPDUs are received on the port. Should only be enabled on access/Portfast interfaces.
Benefits of STP:
Note: Let us know how was the article.
STP Lab Topology:
Lab Guide:
If you need this lab guide with a complete configuration command let me know in the comment section.
Thank you for your time.
Also learn: VLAN Trunking Protocol (VTP): A Comprehensive Guide with Lab https://www.dhirubhai.net/pulse/vlan-trunking-protocol-vtp-comprehensive-guide-lab-md-abu-sayed-fttcc/?trackingId=%2FG70v9ZfQkuV%2BcFbP6gv1A%3D%3D