Spanning tree port costs
By stretch | Friday, September 5, 2008 at 7:37 a.m. UTC
Anyone familiar with STP will likely have most of this table memorized:
The costs in the table are recommended by the IEEE in section 8.10.2 the 802.1D standard published in 1998 (available for free at the IEEE website). However, the standard apparently makes no mention of the formula used to arrive at these costs; if anyone can shed some light on this, please leave a comment. The 1998 standard allows for a 16-bit path cost value (held in software), 1 to 65535, and a 32-bit root path cost (the cost which is advertised in a BPDU field).
Its successor, 802.1D-2004, increases the path cost to a 32-bit value, providing far more granularity in assigning costs, and enabling the use of a static scale. Section 17.14 includes the following table:
The following excerpt provides some insight:
The recommended values for any intermediate link speed can be calculated as 20,000,000,000/(Link Speed in Kb/s). Limiting the range of the Path Cost parameter to 1-200,000,000 ensures that the accumulated Path Cost cannot exceed 32 bits over a concatenation of 20 hops.
By expanding the range of port costs, the 2004 standard allows for a simple inverse scale of bandwidth to cost (e.g. a port with ten times the bandwidth of another has one-tenth its cost). As per the standard, we can see the ceiling of the configurable port cost has been raised from 65,535 to 200,000,000 in more recent IOS releases:
Switch(config-if)# spanning-tree vlan 1 cost ? <1-200000000> Change an interface's per VLAN spanning tree path cost
About the Author
Jeremy Stretch is a network engineer living in the Raleigh-Durham, North Carolina area. He is known for his blog and cheat sheets here at Packet Life. You can reach him by email or follow him on Twitter.
Posted in Switching
August 7, 2013 at 4:12 p.m. UTC
Excellent! Exactly what I was looking for.
March 24, 2015 at 2:43 p.m. UTC
802.1D STP Link Cost from O'reilly JunOS Enterprise switching pg 325 Link Cost = 1,000 / Data Rate (Mbps) 1,000 / 4 Mbps = 250 1,000 / 10 Mbps = 100 etc...
Nice right up. Cheers
March 24, 2015 at 2:59 p.m. UTC
HA So after 16Mbps this formula I referenced does not work
from the book I referenced same page: "However the ieee 802.1 committee soon realized the lan speeds were steadily increasing past 1gpbs. Therefore in 1998 they recommended a non linear relationship between Data rates and link costs while maintaining backwards compatibility with the original specification"
July 21, 2016 at 9:14 a.m. UTC
real short question if you have 2 switches with different link speeds one fast-ethernet (19)and the other gigabit-ethernet (4).... attached to each other in a STP topology what is the cost the link to elect the Root port in my case...is it 4 or 19..?