Cisco CCNA Basics IX: Basic configuration of Spanning Tree Protocol-STP

Today we will talk about the overview of STP-Spanning Tree Protocol and the basic configuration guide on STP. 

What is STP-Spanning Tree Protocol? 
Well, STP is a Layer 2 link management protocol that delivers path redundancy while avoiding loops in the network. For a Layer 2 Ethernet network to work properly, only one active path can exist between any two destinations. Multiple active paths among end stations cause loops in the network. So, if a loop exists in the network, destination might collect duplicate packets. 

Switches might also learn destination MAC addresses on multiple Layer 2 interfaces. These situations effect in an unbalanced network. Spanning-tree process is clear to destinations, which cannot sense whether they are associated to a single LAN segment or a switched LAN of multiple segments.

While talking about STP, it uses the algorithm to choose one switch of a redundantly associated network as the root of the spanning tree. The algorithm analyses the best loop-free path through a switched Layer 2 network by allocating a role to each port based on the role of the port in the active topology.


Fig 1.1-Spanning Tree Protocol
Below is port assigned based in the STP topology. You need to understand the ports assigned to avoid any loop in your switched network.

Root: A forwarding port elected for the spanning-tree topology
Designated: A forwarding port elected for every switched LAN segment
Alternate: A blocked port providing an alternate path to the root bridge in the spanning tree
Backup: A blocked port in a loopback configuration

What are the different Port states in STP?
Listening State: Here in the Listening state, the switch ports do not forward traffic. While in this state, the port will only listen to traffic as they did when in blocking state. This is the first state that comes after the blocking state after the port is set to start frame forwarding. The default time in the listening state is 15 seconds.
Learning State: Here in the learning state, the switch ports do not forward traffic, while in this state the port will listen to traffic and begin to learn addresses from the connected devices on a segment. The default time in the learning state is 15 seconds.
Forwarding State: Here in the forwarding state the switch ports forward traffic as well as continue to learn addresses from the segment.
Disabled State: Here in the disable state, the switch ports not forward traffic or listen to the network traffic.
Blocking State: Here in the blocking state, the switch ports do not forward traffic and they just listen to the network to confirm that they should endure to block traffic. 

Enable STP for VLAN 100
RouteXP-SW > enable
RouteXP-SW # configure terminal
RouteXP-SW (config)# spanning-tree vlan 100
RouteXP-SW (config)# end

Root Bridge for VLAN 100 and 200

RouteXP-SW1
RouteXP-SW1 > enable
RouteXP-SW1 # configure terminal
RouteXP-SW1 (config)# spanning-tree vlan 100 root primary
RouteXP-SW1 (config)# spanning-tree vlan 200 root secondary
RouteXP-SW1 (config)# spanning-tree vlan 100 priority 2100
RouteXP-SW1 (config)# spanning-tree vlan 200 priority 3100
RouteXP-SW1 (config)# end

RouteXP-SW2 
RouteXP-SW2 > enable
RouteXP-SW2 # configure terminal
RouteXP-SW2 (config)# spanning-tree vlan 200 root primary
RouteXP-SW2 (config)# spanning-tree vlan 100 root secondary
RouteXP-SW2 (config)# spanning-tree vlan 200 priority 2100
RouteXP-SW2 (config)# spanning-tree vlan 100 priority 3100
RouteXP-SW2 (config)# end