A 1 Gb port costs 4, not 20,000: one short path-cost table for the spanning tree #1600
No reviewers
Labels
No labels
blocked-on-build
bug
device
device-request
enhancement
from-github
needs-datasheet
needs-info
needs-triage
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
jaylouisw/packetforge!1600
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "rev/1116-0400"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
A port's default spanning-tree path cost: the short method the switch actually defaults to, in one table.
The engine charged the 32-bit costs under a comment that called them the 16-bit ones:
Cisco's short method - the default on Catalyst and NX-OS - charges 10M 100, 100M 19, 1G 4, 10G 2,
25G/40G/100G 1. So a Fast Ethernet cable cost 200,000 (ten times a gigabit) in the election while the file's
own
portCost()charged 200, and the 40 Gb row disagreed between the two copies (400 vs 500).computeStp()built the election from the simulator's copy whileportCost()used the library's, so one portcould carry two costs. Both now call
costForSpeedMbps()inengine/stp.js;speedToCostwas exported and callednowhere else, so it goes.
The behaviour this changes
show spanning-treereports roles and states, not costs, so the visible effect is which port blocks. A bridgewith one 100 Mb hop to the root (19) against a five-hop 1 Gb chain (5 x 4 = 20) now roots through the 100 Mb port
and blocks the chain; under the old numbers the chain cost 100,000 against 200,000, so it blocked the faster path
and forwarded the slower one.
Inferred, and said so
A rate with no published row (2.5G, 5G; anything above 100G) takes the next slower documented row's cost, so
every value returned is one the vendor publishes and cost never rises with speed. Asserted as an inference.
Sources
research/stp-path-cost.md: Catalyst 9200 and 9500 Layer 2 config guides 17.2, NX-OS 10.4 Rapid PVST+ (Table 4,short vs long out to 400G), and the CBS-250/350 CLI guide - the small-business line defaults to long, the one
place "Cisco defaults to short" is not true.
Tests
test/stp-path-cost.test.js(21 assertions): the published rows, interpolation, monotonic rule, the election thatflips, and simulator/library charging the same cost for the same cable at 1 Gb and forced 100 Mb.
test/stp.test.js's "default port cost is 20000" now expects 4.Full suite: 264 suites, 9,569 assertions, 0 failed.
node scripts/syntax-check.js: 334 files OK.Left unresolved
Port-channel cost (this engine divides by member count; Cisco derives it from the bundle's speed) and per-VLAN
cost/priority (PVST/RPVST adds the VLAN id, so VLAN 1 is 32769). Both are features, not fidelity fixes.
`show spanning-tree` reports roles and states, so a wrong path cost is not a wrong number on the page - it is the wrong port blocked. The engine charged the 32-bit costs under a comment that called them the 16-bit ones, and it kept two copies of the table that disagreed with each other. engine/stp.js DEFAULT_PORT_COST = 20000 // "802.1D short cost for a 1G link" SPEED_COST = {10: 2000000, 100: 200000, 1000: 20000, ...} engine/simulator.js speedToCost() - no row for 100 Mb, and 40 Gb as 400 Every number there is the *long* method; Cisco's short method - the default on Catalyst and NX-OS - charges 100 / 19 / 4 / 2 / 1 for 10M / 100M / 1G / 10G / 25G and above. A Fast Ethernet cable therefore cost 200,000 (ten times a gigabit) in the election and 200 in the file's own `portCost()`. `computeStp()` built the election from the simulator's copy while `portCost()` used the library's, so one port could carry two costs. Both now call `costForSpeedMbps()` in engine/stp.js: the published table, with a rate that has no row of its own taking the next slower row's cost (2.5G and 5G cost 4) so every value returned is one the vendor publishes and cost never rises with speed. `speedToCost` was exported and called nowhere else, so it goes. The ring this changes: a bridge with one 100 Mb hop to the root (19) against a five-hop 1 Gb chain (5 x 4 = 20) roots through the 100 Mb port and blocks the chain. Under the old numbers the chain cost 100,000 against 200,000, so the bridge blocked the faster path and forwarded the slower one. Sources in research/stp-path-cost.md (Catalyst 9200/9500 L2 guides, NX-OS 10.4 Rapid PVST+, CBS-350 CLI - the small-business line defaults to long, which is the one place "Cisco defaults to short" is not true). test/stp-path-cost.test.js pins the published rows, the interpolation, the monotonic rule, the election that flips, and that the simulator and the library charge the same cost for the same cable at 1 Gb and at a forced 100 Mb. test/stp.test.js's "default port cost is 20000" now expects 4. Full suite: 264 suites, 9,569 assertions, 0 failed.240d0324acf383b4e78f