Stops broadcast storms in your network.
STP looks for redundant connections in your network and blocks them until they really are needed.
Why we need STP?
Switches send broadcast traffic everywhere!
If clients send a broadcast message it would blow your network. Because we cause a loop through those redundant connections. This also is called a broadcast storm.
For a routed network, the packet eventually dies because there is a TTL (time to live) in this packet. Starts at 255 and with every router it decrements by 1.
For switches we are at level 2. There is no routed network here.
Key STP Concepts, Simplified
a key concept of STP is redundancy. We want to use the redundant links but don’t want to blow up our network.
Root bridge = the center of the network, the switch that is most centralized
Where the root bridge is, affects which link get blocked.
BPDU = bridge protocol data unit -> switches perform the election and test if the link is active (unblock redundancy if the link is down), that happens every 2 seconds.
BID = bridge ID -> [priority].[mac-address] -> that determines who has priority (the lowest value wins) -> default priority is 32’768, by default the oldest switch gets the root bridge. If the newest became the root bridge by default, everytime a new switch enter the networks, we have a recalculation and that causes a brief network outage. And if you put a new 8-port switch in the network, that would become the root bridge and isn’t probably the most stable one.
Priority = we can change the priority -> if we lower the value we can choose which switch is the root bridge.
Port cost = If we set the root bridge manually via the priority, al the other switches determine the best way to get to this root bridge. This happens over the port cost.
100 Mbit/s = Cost of 19
1000 Mbit/s = Cost of 4
10000 Mbit/s = Cost of 2
The switch calculates which route has the lowest end value, like route 1 has a cost of 4, route 2 has a cost of 8, the switch chooses the route of 4. And boom, the switch has chosen it’s route port! The route port is the interface that the switch uses to get to the route bridge. Designated ports are the ports that is forwarding.
Three Rules for STP Port Selections
Factors to define
1 segment = 1 link between switches
Port States and STP Configuration
CST -> classic spanning tree
RST -> rapid spanning tree
Port states:
- Blocking – 20sec
stays in that state for up to 20 secs. Why cause the other interface which went down, could also be in a flapping state. - Listening – 15 sec
listening for BPDU’s - Learning – 15 sec
learn the MAC-addresses - Forwarding – 0
A VLAN equals a network, so you running an instance of spanning-tree for each VLAN you have.
Best practise is that different switches are root bridges for different VLANs.
PVST -> per VLAN spanning-tree
Rapid and Multiple Spanning Tree
- Turn it on on every switches
- It remembers these backup connections instead to go through a fresh set of timers
- It expands the port cost to the new port speeds (25 Gbit/s, and so on)
- Multiple spanning-tree
industry standard version of per vlan spanning-tree
we can choose groups of VLANs together. One set for groups of VLANs - Blocking
6 seconds
Cisco IOS commands learned in this chapter
| Command | Description | ||||
| Spanning-tree | Vlan | <VLAN-ID> | Priority | <VALUE> | Manually sets the switch’s STP priority for a specific VLAN |
| Spanning-tree | Vlan | <VLAN-ID> | Root | primary | A macro command that automatically lowers the switch’s priority below the current root bridge so it becomes the primary root bridge for that VLAN |
| Spanning-tree | Vlan | <VLAN-ID> | Root | Secondary | Sets the priority slightly higher than a primary root, serving as the designated backup switch if the primary root fails |
| Spanning-tree | Mode | Rapid-pvst | Changes the global spanning-tree mode to Rapid PVST+ (Per-VLAN Spanning Tree) | ||
| Spanning-tree | Mode | Mst | Switches the mode to Multiple Spanning Tree (MST) | ||
| Spanning-tree | Vlan | <VLAN-ID> | Cost | <VALUE> | Manually alters the STP port cost of a specific interface for a specific VLAN, forcing the switch to choose or avoid this port as a Root Port or Designated Port |