Non-root bridges place various ports into their proper roles by
listening to BPDUs as they come in on all ports. Receiving BPDUs on multiple
ports indicates a redundant path to the root bridge.
The switch looks at
these components in the BPDU to determine which switch ports will forward data
and which switch ports will block data:

- Lowest path cost
- Lowest Sender BID
- Lowest Local port ID
The switch looks at the path cost first to determine which port is
receiving the lowest cost path. The path is calculated based on the link speed
and the number of links the BPDU traversed. If a port has the lowest cost, that
port is eligible to be placed in forwarding mode. All other ports that are
receiving BPDUs continue in blocking mode.
If the path cost and Sender
BID are equal, as with parallel links between two switches, the switch goes to
the port ID as a "tiebreaker." The port with the lowest port ID
forwards data frames, and all other ports continue to block data frames.
Path Cost
The spanning tree path cost is a value advertised in
the BPDU by each bridge. This is a value representing the cumulative cost of
all the links from the root bridge to the switch sending the BPDU. Path cost
value is used by the receiving switch to determine the best path to the root
bridge. The lowest cost is considered to be the best path.

Post cost values per link are shown above under the Revised IEEE Spec with
the lower values being associated with higher bandwidth, and therefore being
the more desirable paths. This new specification uses a nonlinear scale with
port cost values as shown. In the previous IEEE specification, the cost value
was calculated based on Gigabit Ethernet being the maximum Ethernet bandwidth,
with an associated value of 1, from which all other values were derived in a
linear manner.
Selecting the Root Port
Switch Y receives a
BPDU from the root bridge (switch X) on its switch port on the Fast Ethernet
segment and another BPDU on its switch port on the Ethernet segment. The root
path cost in both cases is zero. The local path cost on the Fast Ethernet
switch port is 19, while the local path cost on the Ethernet switch port is
100. As a result, the switch port on the Fast Ethernet segment has the lowest
path cost to the root bridge and is elected the root port for switch Y.

Selecting the Designated Port
STP selects one designated port per
segment to forward traffic. Other switch ports on the segment become
nondesignated ports and continue blocking. The nondesignated ports receive
BPDUs but do not forward data traffic to prevent loops. The switch port on the
segment with the lowest path cost to the root bridge is elected the designated
port. If multiple switch ports on the same segment have the same cost, the
switch port with the lowest port ID becomes the designated port.

Because
ports on the root bridge all have a root path cost of zero, all ports on the
root bridge are designated ports.