All interfaces on the root bridge are put in the forwarding state
For other devices that are not the root bridge, the port that is closest to the root bridge is put in the forwarding state.
The bridge with the lowesr administrative distance to the root bridge is called the designated bridge. The ethernet interface on the designated bridge is called hte designated port. That port is put into forwarding state.
The root bridge is elected based on bridge ID(usually the MAC address) and a priority.
By default all priorities are the same so, by default the switch with the lowest MAC address will become the root bridge.
Calculating the lowest administrative cost to the root bridge is based on the speed of the links across the LAN, to get to that root bridge. STP uses default port costs to calculate this. These port costs can be overridden by an administrator.
When a new switch is introduced to the network, the algorithm and port states are recalculated to prevent a new loop.
Switches communicate with a BPDU(Bridge Protocol Data Unit) every 2 seconds. If the remote switch doesnt respond, it is assumed that that switch(and it’s links) are down and the Spanning Tree Algorithm is recalculated.
The STP Port states are:
Blocking – does not receive any frames but still receives BPDU’s from other switches.
Listening – Same as blocking but it is beginning its transition to forwarding frames. Unlike blocking, in Listening mode, the port will send BPDU’s.
Learning – The second state in the transition to frame forwarding. In this state the switch receives MAC address information from devices on this switch port.
Forwarding – Transmits and receives frames. This is the normal state for a port.
Disabled – This means that the switch port is administratively down or disabled.
STP is protocol 802.1d
STP works on Ethernet LAN’s