STP Path Cost: When the Short Table Ties and the Long Formula Does Not
A spanning-tree path cost is the sum of the port costs toward the root, not a hop count. Faster links are supposed to look cheaper. Whether they actually do depends on which cost method you are using. The STP Path Cost Calculator applies either the long formula or the short table, then compares two paths. Long formula versus short table The long method, as implemented by the calculator, is:…
A spanning-tree path cost is determined by the sum of the port costs leading to the root, rather than a simple hop count. The speed at which a link operates influences its cost, with faster links appearing cheaper. However, this depends on the cost method being used: the long formula or the short table.
The long formula calculates the cost by dividing 2e10 (20000000000) by the product of the link's speed in Mbps and 1000. It then rounds the result and clamps it between 1 and 200000000. The short table, on the other hand, uses a pre-defined cost table and rejects any speeds not listed.
For example, a 100 Gbit/s port is valid in the long method but results in an error in the short method. Also, the short table cannot rank speeds above 10 Gbit/s, which can cause two paths with different physical speeds to appear equal in cost.
The long method was demonstrated with two 10 Gbit/s hops versus one 1 Gbit/s hop. The long method calculated a total cost of 4000 for the faster path and 20000 for the slower path, resulting in a clear winner. However, the short method reported a tie for both paths, highlighting the difference between the two cost calculation methods.
Common mistakes to avoid include comparing short-table totals with long-formula totals, expecting the short table to accept high speeds, mistyping speeds, and treating a tie as operationally identical paths. Remember, port priority and bridge ID are not considered by this calculator. Also, do not count hops instead of adding up port costs, as faster hops can sometimes offset slower ones.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.