Spanning Tree protocol is one of the key topics in switching. It is mainly used to prevent switching loops in a network. A switching loop can occur in a lot of scenarios in switches. Consider a few switches connected with each other in full mesh order with one or two cables like this,
If every port is in the forwarding state, each switch will keep forwarding traffic to other switches which could cause a loop. Because of a switching loop, a few problems can occur, like
- Inconsistency of MAC-Table
- Broadcast Storm
- Data Loss
- High Bandwidth utilization and much more.
So, to prevent these problems, STP will block some ports to avoid the loop. Blocking ports cannot send the traffic but they can be utilized if the main port is down.
Here, to understand STP, we are listing some terminology of Spanning tree protocol.
Spanning tree protocol, IEEE standard 802.1D (Original) is a protocol that is mainly designed to avoid switching loops in the network. It was originally designed for bridges but later on, it was implemented on Switches as well.
Bridge Protocol Data Unit, are forwarded out of all ports in every two seconds to build the topology database. Configuration and Topology change notification are two types.
- Root Bridge:
It works as a central reference point of STP topology. Mainly responsible for sending BPDU to downstream switches. It is also referred as Root Switch.
- Root Port:
A port Role that is assigned to a port on Non-Root Bridge. Lowest Root Path Cost to get to the root bridge is considered as Root Port.
- Designated Port:
Responsible for forwarding BPDUs and Frames to the segment. It can never be in blocking state.
- Alternate Port:
An alternate path to reach the root bridge. It will be used only when the main path goes down. BPDUs are received on blocking ports.
Common Spanning Tree, utilizes a single instance for all the VLANs. It is also referred as Mono spanning tree. Load Balancing according to VLANs is not possible.
Per VLAN Spanning Tree separates STP instance for each VLANs, improving flexibility and Performance but leaving with too many instances of STP. Not compatible with CST.
An enhanced version that is compatible with bot CST and PVST and supports both ISL and 802.1q encapsulation. It defaults on many Cisco Platforms.
Rapid STP is enhanced and much faster version of STP. Discarding state is introduced here.
Multiple Spanning Tree maps multiple instances into a single instance of STP reducing CPU Utilization and the number of Instances of STP on a switch.
- Blocking State:
A state of the port where it cannot forward a frame or learn MAC. Still, it receives BPDU. An initial state of all the ports.
- Listening State:
Sends and listens BPDU but cannot forward frames or learn MAC. 15 sec is the time that a port has to wait before going to next state
- Learning State:
Continues sending and listening BPDUs plus, it will start learning MAC addresses. Still, it cannot forward frames. Here too, 15 sec is the time that a port has to wait before going to next state.
- Forwarding State:
Sends, Receives BPDU, Learn MAC address and Forwards Frames. Root and Designated ports will jump to this state eventually.
- Forward Delay Timer:
It determines how long a port must wait before going into next state. It is 15 sec by default.
- Max Age Timer:
How long will a switch retain BPDU info from the neighbor before discarding it? It is 20 sec by default.
- STP Diameter:
It is the length of the topology, measured in the number of switches including the Root Bridge. By default it is 7 and maximum is 7.
- Spanning Tree Portfast:
A feature when enabled, a switch port will jump directly from blocking to the forwarding state without going into listening and Learning State.
- Spanning Tree Uplinkfast:
Mainly used for faster convergence in case if Root Port goes down. When enabled, blocking port will directly jump to forwarding state if Root Port goes down.
- Root Guard:
When enabled on a port, it will put the port in a root-inconsistent state if any superior BPDU is received. Port still receives BPDU.
- BPDU Guard:
BPDU Guard will place a port in an err-disable state if a BPDU is received, regardless if the BPDU is superior or inferior. It is generally run with Portfast command.
- BPDU Filter:
It will stop sending and receiving (depending on how it is configured) of BPDU on certain interfaces.
Unidirectional Link Detection: It is mainly used to check unidirectional links in the network, mainly in fiber media. UDLD sends out ID frames on a port and waits for the remote switch to respond with its own ID frame. If the remote switch does not respond, UDLD assumes the port has a unidirectional fault.
- Loop Guard:
It takes action against not receiving BPDU on blocking ports. Not receiving BDPU on blocking port can cause the switch to thinking that it is the Root Bridge and incorrectly transitioning root port into designated port, causing a loop