28Calculation process of the STP algorithmThe STP algorithm uses the following calculation process:1. Initial stateUpon initialization of a router, each port generates a BPDU with the router as the root bridge, inwhich the root path cost is 0, designated bridge ID is the device ID, and the designated port is theport itself.2. Selection of the root bridgeInitially, each STP-enabled router on the network assumes itself to be the root bridge, with the rootbridge ID being its own device ID. By exchanging configuration BPDUs, the routers compare theirroot bridge IDs to elect the router with the smallest root bridge ID as the root bridge.3. Selection of the root port and designated ports on a non-root routerTable 2 describes the process of selecting the root port and designated ports.Table 2 Selection of the root port and designated portsStep Description1 A non-root-bridge router regards the port on which it received the optimum configuration BPDU asthe root port. Table 3 describes how the optimum configuration BPDU is selected.2Based on the configuration BPDU and the path cost of the root port, the router 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 the pathcost of the root port.• The designated bridge ID is replaced with the ID of this router.• The designated port ID is replaced with the ID of this port.3The router compares the calculated configuration BPDU with the configuration BPDU on the portwhose port role is to be determined:• If the calculated configuration BPDU is superior, the router considers this port as the designatedport, replaces the configuration BPDU on the port with the calculated configuration BPDU, andperiodically sends out the calculated configuration BPDU.• If the configuration BPDU on the port is superior, the router blocks this port without updating itsconfiguration BPDU. The blocked port can receive BPDUs, but cannot send BPDUs or forwarddata traffic.NOTE:When the network topology is stable, only the root port and designated ports forward user traffic, whileother ports are all in the blocked state to receive BPDUs but not forward BPDUs or user traffic.Table 3 Selection of the optimum configuration BPDUStep Actions1Upon receiving a configuration BPDU on a port, the router compares the priority of the receivedconfiguration BPDU with that of the configuration BPDU generated by the port, and:• If the former priority is lower, the router discards the received configuration BPDU and does notprocess the configuration BPDU of this port.• If the former priority is higher, the router replaces the content of the configuration BPDUgenerated by the port with the content of the received configuration BPDU.