60Figure 15 A schematic diagram of designated bridges and designated portsPath costPath cost is a reference value used for link selection in STP. By calculating path costs, STP selects relativelyrobust links and blocks redundant links, and finally prunes the network into a loop-free tree.How STP worksSTP has the following workflow:1. Initial stateUpon initialization of a device, each port generates a BPDU with itself as the root bridge, in which theroot path cost is 0, designated bridge ID is the device ID, and the designated port is the port itself.2. Selection of the root bridgeInitially, each STP device on the network assumes itself to be the root bridge, with its own device ID as theroot bridge ID. By exchanging configuration BPDUs, the devices compare their root bridge IDs to electthe device with the smallest root bridge ID as the root bridge.3. Selection of the root port and designated portsTable 8 describes the process of selecting the root port and designated ports.Table 8 Selection of the root port and designated portsStep Description1 A non-root device regards the port on which it received the optimum configuration BPDU asthe root port. For the selection of the optimum configuration BPDUs, see Table 9.2Based on the configuration BPDU and the path cost of the root port, the device calculates adesignated port configuration BPDU for each of the rest ports.• The root bridge ID is replaced with that of the configuration BPDU of the root port.• The root path cost is replaced with that of the configuration BPDU of the root port plus thepath cost of the root port.• The designated bridge ID is replaced with the ID of this device.• The designated port ID is replaced with the ID of this port.3 The device compares the calculated configuration BPDU with the configuration BPDU on theport whose port role is to be defined, and acts depending on the comparison result: