STP - Loop Guard
Spanning tree is the L2 control plane protocol we have to ensure a loop-free network. It does so by blocking redundant links.
Topology

Here, SW1 is the root switch with a priority of 4096. SW2 has been configured for root secondary. SW3 is default. Ultimately these configurations result in the above converged STP topology.
Initial configurations
SW1
SW1#sh run | sec span
spanning-tree mode pvst
spanning-tree loopguard default
spanning-tree extend system-id
spanning-tree vlan 1-4094 priority 4096
SW1#
SW2
SW2#sh run | sec span
spanning-tree mode pvst
spanning-tree loopguard default
spanning-tree extend system-id
spanning-tree vlan 1-4094 priority 28672
SW2#
SW3
SW3#sh run | sec span
spanning-tree mode pvst
spanning-tree loopguard default
spanning-tree extend system-id
SW3#
Loop Guard
Loop guard is an STP enhancement. It works by adding an extra check before letting a blocking port transition into forwarding state. If no BDPUs are received on the non-designated port, the port is moved into a loop inconsistent state.