When the root bridge has been elected for the spanning tree instance, the STA starts the process of determining the best paths to the root bridge from all destinations in the broadcast domain. The path information is determined by summing up the individual port costs along the path from the destination to the root bridge. Each “destination” is actually a switch port.
The default port costs are defined by the speed at which the port operates. As shown in Figure 1, 10 Gb/s Ethernet ports have a port cost of 2, 1 Gb/s Ethernet ports have a port cost of 4, 100 Mb/s Fast Ethernet ports have a port cost of 19, and 10 Mb/s Ethernet ports have a port cost of 100.
Note: As newer, faster Ethernet technologies enter the marketplace, the path cost values may change to accommodate the different speeds available. The non-linear numbers in the table accommodate some improvements to the older Ethernet standard. The values have already been changed to accommodate the 10 Gb/s Ethernet standard. To illustrate the continued change associated with high-speed networking, Catalyst 4500 and 6500 switches support a longer path cost method; for example, 10 Gb/s has a 2000 path cost, 100 Gb/s has a 200 path cost, and 1 Tb/s has a 20 path cost.
Although switch ports have a default port cost associated with them, the port cost is configurable. The ability to configure individual port costs gives the administrator the flexibility to manually control the spanning tree paths to the root bridge.
To configure the port cost of an interface (Figure 2), enter the spanning-tree cost value command in interface configuration mode. The value can be between 1 and 200,000,000.
In the example, switch port F0/1 has been configured with a port cost of 25 using the spanning-tree cost 25 interface configuration mode command on the F0/1 interface.
To restore the port cost back to the default value of 19, enter the no spanning-tree cost interface configuration mode command.
The path cost is equal to the sum of all the port costs along the path to the root bridge (Figure 3). Paths with the lowest cost become preferred, and all other redundant paths are blocked. In the example, the path cost from S2 to the root bridge S1, over path 1 is 19 (based on the IEEE-specified individual port cost), while the path cost over path 2 is 38. Because path 1 has a lower overall path cost to the root bridge, it is the preferred path. STP then configures the redundant path to be blocked, preventing a loop from occurring.
To verify the port and path cost to the root bridge, enter the show spanning-tree command (Figure 4). The Cost field near the top of the output is the total path cost to the root bridge. This value changes depending on how many switch ports must be traversed to get to the root bridge. In the output, each interface is also identified with an individual port cost of 19.