In any switch other than the Root Switch, has to find a Root Port, from its available traunk ports, which is that Switch's Port to reach the Root Bridge (Switch). The Root Port is calculated in every Switch, other than the Root Switch, by using the lowest accumulated Path Cost Value to reach the Root Bridge (Switch).
The Spanning Tree Cost Value is inversely proportional to the associated bandwidth of the path and therefore a path with a low cost value is more preferable than a path with high cost value.
The following table lists the Port Cost value for different bandwidths.
|Link Speed||Cost Value|
As we can see from the above diagram, Switch 4 has two paths to reach the Root Switch (Switch 1). The accumulated Spanning Tree Path Cost Value via the left path is 23 (19 + 4) and the accumulated Spanning Tree Path Cost Value via the right path is 8 (4 + 4).
There for the best path to reach the Switch 1 (Root Switch) from Switch 4 is via right path (because of lowest cost) and the port in Switch 4 connected to the right path is selected as the Root Port.
Spanning Tree Path Cost value can be defined as the accumulated port costs from a Switch (other than the Root Bridge (Switch)) to reach the Root Switch. When a switch receives a Bridge Protocol Data Unit (BPDU) in its port, it increments the path cost with the cost of the incoming port. Path costs are incremented when a Bridge Protocol Data Unit (BPDU) reaches a port.