STP is the loop detection mechanism on the switches as you know. But STP has a brother whose name is PVST ( Per VLAN Spanning Tree ) !
Per-VLAN Spanning Tree (PVST) maintains a spanning tree instance for each VLAN configured in the network. It uses ISL Trunking and allows a VLAN trunk to be forwarding for some VLANs while blocking for other VLANs. Since PVST treats each VLAN as a separate network, it has the ability to load balance traffic (at layer-2) by forwarding some VLANs on one trunk and other Vlans on another trunk without causing a Spanning Tree loop.
One root bridge is elected for per VLAN. In PVST header there is a priority value which is “priority + VLAN number”. Default priority value is 32768 + 1 = 32769.
SWITCH_A(conf)#spanning-tree VLAN ... root primary SWITCH_A(conf)#spanning-tree VLAN ... root secondary SWITCH_A(conf)#spanning-tree VLAN ... priority X
PVST config is made as you can see above. You select the primary and secondary VLAN and a priority number and hard code it into the switch.
Let’s verify the SWITCH_A spanning – tree configuration via show command.
SWITCH_A(conf)#show spanning-tree Root ID Priority 32769 Address 000b:5f00:9880 Port 1 (Fa0/1)
**** These values above are the informations of the root bridge.
Bridge ID Priority 32769 Address 000c:854b:ee80
**** These values above are the informations of the SWITCH_A
Interface Role Sts Cost f0/1 Root Fwd 19 f0/2 Altnt Blk 19 f0/24 Desig Fwd 19