What it does

The Spanning Tree Protocol (STP) and its rapid successor (RSTP, the Rapid Spanning Tree Protocol) keep a switched network with redundant links free of loops: the switches elect one root bridge, every other switch keeps its best port towards the root, every segment keeps one port that forwards towards it, and every port left over stops forwarding. The election is fixed by comparisons anyone can do on paper, and this calculator does them for a small network you describe in a few lines, in two modes:

  • Election. For 2 to 16 bridges and the links between their ports: the root bridge, the root port of every other bridge, the designated port of every segment, and the ports left as alternate or backup ports, each with the comparison that decided it, in the order the course "LAN Switch Operations and Maintenance" teaches it in chapter 2.4 (elect the root, assign path costs, find the designated bridge of each segment, identify root and designated ports, block the rest).
  • Cost by speed. For a link speed: the long (32-bit) and short (16-bit) port path costs that the documents read for the tool give, which documents give them, and each vendor's documented default method and the command that changes it.

Everything is computed in your browser.

Election: the topology

One statement per line; a # starts a comment, blank lines are ignored, and keywords and bridge names are read without regard to case.

bridge B1 32768 00-00-5E-00-53-01
bridge B2 32768 00-00-5E-00-53-02 short
link B1:1 B2:1 1G
link B1:2 B2:2 cost 4000
port B1:2 priority 64
vlan 10
priority-format 802.1d
  • bridge: a name (a letter, then up to 15 letters, digits, dots, hyphens or underscores), a bridge priority and a MAC (media access control) address with colons or hyphens, in three dotted groups, or as twelve hexadecimal digits. Ending the line with short or long gives that bridge its own path cost method; otherwise it uses the method chosen above the box.
  • link: two ports written as bridge:port, then a speed (10M, 100M, 1G, 10G, 25G, 40G, 50G, 100G, 1T or 10T, also spelled 1 Gb/s or 1gbps) or the word cost and a number. Three or more ports on one line make a shared segment, as through a hub; two ports of the same bridge on one line are a cable looped between them.
  • port: a port already on a link, then priority and a value, cost and a value, or both.
  • vlan: the VLAN whose tree you are computing; its ID is added to every bridge priority as the system ID extension.
  • priority-format 802.1d: the 16-bit bridge priorities of 802.1D-1998, for bridges that accept any value from 0 to 65535.

The tool reads up to 16 bridges, 32 links, 8 ports on one segment, 128 ports in all, 80 lines and 4000 characters. A port's path cost comes, in this order, from a port line, from a cost typed on its link, or from its link's speed and its own bridge's method.

Election: the rules it applies

Identifiers. A bridge ID is "a manageable priority in the four most-significant bits, a system ID extension in the next 12 bits, and the Bridge Address in the remaining 48 bits" (IEEE 802.1Q RSTP YANG module, revision 2025-02-04), so on bridges that follow 802.1t or 802.1w the priority's "permissible values are 0-61440, in steps of 4096" (RFC 4188, dot1dStpPriority; the same in the IEEE's spanning tree MIB). Cisco's per-VLAN trees put the VLAN in the extension, "a 12-bit extended system ID value equal to the VLAN ID" (Cisco, Catalyst 9300, IOS XE 17.18), and Arista's manual gives the VLAN number for Rapid-PVST, the instance number for MST and 0 for a single RSTP tree (Arista EOS 4.37.0F). A port ID is "a priority in the four most-significant bits, and a twelve-bit Bridge Port number" (IEEE YANG module), so port priorities are 0 to 240 in steps of 16 (RFC 4188, dot1dStpPortPriority). The page prints IDs the way switches do: 32778.00-00-5E-00-53-01 for a bridge ID, 128.4 for a port ID.

1. The root bridge. "The bridge with the lowest bridge ID is elected as the root bridge. If the bridge priorities are equal or if the bridge priority is not configured, the bridge with the lowest MAC address is elected the root bridge" (Juniper, spanning tree overview). The page lists every bridge in bridge ID order and says whether the priority or the MAC address decided. When every bridge has the same priority it warns that the root was chosen by accident: the course's advice is to lower the intended root's priority on purpose.

2. Root path costs and root ports. The root's root path cost is 0; every other bridge's is "the sum of the Port Path Costs on the least-cost path to the Root Bridge", each bridge adding the cost of the port a message arrives on to the cost its neighbour advertises (MikroTik RouterOS 7.24, STP guide). A bridge's root port is chosen by the "lowest Root port path cost, lowest bridge identifier, and lowest bridge port ID in this particular order", where the bridge identifier and the port ID are those of the upstream device that sent the BPDU (bridge protocol data unit) (MikroTik, as above). One more comparison exists for a bridge with two ports on a shared segment that hear the same upstream port: then the receiving ports' own IDs decide, which Cisco states as "the interface with the lowest interface number" (Cisco, as above) and Arista as "the port with the lower interface number". The page gives each bridge's root port, its cost and the comparison that decided it, with a sentence naming both candidates.

3. Designated ports. On every segment, the port whose bridge has the lowest root path cost is designated; "If two bridges have the same path cost to the root bridge, the bridge with the lowest bridge ID becomes the designated bridge" (Juniper, as above); and between two ports of that bridge on the segment, the lower port ID, which Cisco describes as "the port priority and port ID are added together, and spanning tree disables the link with the highest value". The root bridge's own ports are therefore designated, unless two of them share a segment.

4. Everything else. A port that is neither root nor designated hears a better BPDU than it would send. If that BPDU comes from another bridge, it is an alternate port, a ready second path to the root; if it comes from another port of its own bridge on the same segment, it is a backup port, and "A backup port can exist only where two or more bridge ports connect to the same LAN for which the bridge serves as the designated bridge" (Juniper, as above). Both are "placed in the discarding state" in RSTP (Juniper), which the original 802.1D calls blocking (RFC 4188, dot1dStpPortState). The four roles are those of the IEEE YANG module's port-role enumeration.

The page shows the four steps in that order, then a table of every port with its port ID, its cost and where the cost came from, and its role and state.

Path costs: long and short

Two scales are in use. The long values are the 32-bit ones of 802.1t, kept in 802.1D-2004, from 1 to 200,000,000 (RFC 4188, dot1dStpPortPathCost32); the short values are the 16-bit ones of 802.1D-1998, from 1 to 65,535 (dot1dStpPortPathCost). Both are chosen "in inverse proportion to the speed of the attached LAN" (RFC 4188). The IEEE standards themselves are not freely readable, so the tool uses the values the vendors' documents give, and names them:

Speed Long Documented by Short Documented by
10 Mb/s 2000000 Extreme Switch Engine, MikroTik, Cisco, HPE Aruba 100 Extreme (ExtremeXOS 11.5 and earlier), MikroTik, Cisco Press
100 Mb/s 200000 the same four 19 the same three
1 Gb/s 20000 the same four, Arista and Huawei 4 the same three and Huawei
2.5 Gb/s 8000 Huawei 3 Huawei
10 Gb/s 2000 the same four, Arista and Huawei 2 the same three and Huawei
25 Gb/s 800 MikroTik 1 MikroTik
40 Gb/s 500 MikroTik, Cisco, Huawei 1 MikroTik, Huawei
50 Gb/s 400 MikroTik 1 MikroTik
100 Gb/s 200 MikroTik, Cisco, HPE Aruba 1 MikroTik
1 Tb/s 20 Cisco, HPE Aruba none read
10 Tb/s 2 Cisco none read

A speed no document gives a value for (5 Gb/s, 400 Gb/s) is refused, and so is a short cost at 1 Tb/s or 10 Tb/s: type the cost your switches use instead. The tool never estimates a cost.

Mixing the two scales. A switch on short costs advertises a root path cost thousands of times smaller than a neighbour on long costs, so paths through it look cheapest whatever their speed. Extreme warns that "an 802.1D-1998 compliant bridge could become the most favorable transit path" (Extreme, configure stpd ports cost), and Cisco's document 225591 describes a root inconsistency in which "Switch 3 was integrated into the network utilizing the path cost method designated as 'short'" while the others used long, solved with spanning-tree pathcost method long (Cisco, document 225591). The page warns whenever the bridges' speeds are costed with both methods; the Mixed cost methods sample shows an access switch whose root port goes through an old bridge's 100 Mb/s uplink rather than a newer bridge's 10 Gb/s one.

Each vendor's default

The vendors chapter 2.4 of the course covers, with what their documents say on 8 November 2026:

  • Extreme Switch Engine 33.7.1: the long values by default since ExtremeXOS 11.6 (2,000,000 for a 10 Mbps port down to 2,000 for 10 Gb/s), the short ones (100, 19, 4 and 2) in ExtremeXOS 11.5 and earlier; no method switch, and to match an 802.1D-1998 bridge the advice is to type the old value on the port. Per port: configure stpd <stpd> ports cost [auto | <cost>] <ports>.
  • Extreme Fabric Engine 9.4: spanning-tree mstp pathcost-type <bits16 | bits32>, and "The default is 32 bits" (Fabric Engine 9.4 User Guide).
  • Cisco IOS XE 17.18 and 26.x (Catalyst 9300): the documents disagree. The command reference gives spanning-tree pathcost method a "Command Default" of short in both releases (17.18, 26.x), and the configuration guides and the IOS XE 17 STP guide (updated 17 July 2026) say "The short path cost method is the default STP path cost method used"; yet the guides' default configuration tables list "1 Gbps: 20000" and the other long values, and the command reference's own show spanning-tree summary example prints "Configured Pathcost method used is long" beside a port path cost of 20000. show spanning-tree summary tells you which method a switch is using. Pin the method on every switch with spanning-tree pathcost method long, the command of document 225591. Per port: spanning-tree cost, "the range is 1 to 200000000".
  • HPE Aruba Networking AOS-CX 10.16: the long values by speed, from "10 Mbps link speed equals a path cost of 2,000,000" to "1 Tbps link speed equals a path cost of 20"; the page read gives no command to change the method. Per port: spanning-tree cost, 1 to 200,000,000 (AOS-CX 10.16, spanning-tree cost).
  • Juniper Junos OS: "The link cost is determined by the link speed" (Junos CLI reference, cost), with no method statement in the pages read; the example output of show spanning-tree interface prints 20000 on a ge- interface and 2000 on xe- interfaces. Per port: set protocols rstp interface <name> cost <cost>.
  • MikroTik RouterOS 7.24: port-cost-mode on the bridge, long or short, "Default: long" (RouterOS 7.24, Bridging and Switching); "RouterOS versions prior to 7.13 do not change port path cost based on the link speed" (RouterOS 7.24, Spanning Tree Protocol).
  • Arista EOS 4.37.0F: "1 gigabit interfaces have a default cost of 20000" and "10 gigabit interfaces have a default cost of 2000"; no method setting appears in the manual read. Per port: spanning-tree cost.
  • Huawei VRP (S5700 and S6700 V200R025C00): "By default, the IEEE 802.1t is used to calculate the path cost", that is the long values. stp pathcost-standard { dot1d-1998 | dot1t | legacy } switches to the short values or to Huawei's own legacy scale (20 for 1 Gb/s, 2 for 10 Gb/s), and changing it puts every port's typed cost back to the default. Huawei's table gives 8000 long and 3 short for 2.5 Gb/s, one less for full duplex at 10 and 100 Mb/s (1,999,999 and 199,999 long, 99 and 18 short) and lower costs for aggregated links, so a Huawei port at those speeds can differ from the table above. Per port: stp [ instance <id> ] cost <cost>, 1 to 200,000,000 under 802.1t (Huawei, STP/RSTP/MSTP/VBST Configuration Commands, read in a browser: the site refuses automated reads).

What it refuses, and why

  • A priority that is not a multiple of 4096 from 0 to 61440, unless the topology says priority-format 802.1d, where any 16-bit value is read; a priority that is not a number.
  • Two bridges with the same MAC address, which would also give them the same bridge ID at equal priorities: the bridge address is "used by this bridge when it must be referred to in a unique fashion" (RFC 4188, dot1dBaseBridgeAddress). Two bridges with the same name.
  • A link to a bridge no line declares, a port on two links, a port number outside 1 to 4095 (1 to 255 with priority-format 802.1d), a link with fewer than two or more than eight ports, and a link without a speed or a cost.
  • A disconnected topology: each separate part would elect its own root, so the tool says which bridges cannot reach which and computes one connected network at a time.
  • A speed no document gives a cost for, a short cost above 100 Gb/s, a cost outside 1 to 200,000,000, and a cost above 65,535 on a bridge that uses short costs (Extreme: "the path cost range setting is 1 to 65,535" on 802.1D-1998 bridges).
  • A port priority that is not a multiple of 16 from 0 to 240, a vlan outside 1 to 4094 or with priority-format 802.1d, any statement the tool does not read, and the bounds above.

Every refusal names the line and says what the line needs. A MAC address with the group bit set is computed, with a warning: "If it is zero, the MAC address is unicast" (RFC 9542, section 2.1.1), and a bridge's own address is a unicast one.

Worked examples

  • The Example is the worked example of chapter 2.4 of the open course LAN Switch Operations and Maintenance, slide 259: six bridges with the IDs 80-00:1 to 80-00:6 (priority 32768, MAC addresses rising from 1 to 6, here in the documentation range 00-00-5E-00-53-00 to 00-00-5E-00-53-FF of RFC 9542), equal path costs (every link at 1 Gb/s, 20000), and two links between Bridge 3 and Bridge 6. B1 is the root, chosen by its MAC address. B5 reaches the root at 40000 through B2 and through B4; the BPDU from B2 has the lower bridge ID, so B5:1 is its root port and B5:2 is an alternate port. B6 hears B3 twice and B5 once, all at 60000: B3 has the lower bridge ID than B5, and between B3's two ports the lower sender port ID, 128.2 against 128.3, makes B6:1 the root port, so B6:2 and B6:3 are alternate ports, exactly the three blocked ports of the slide.
  • Learn lab, short costs: the square with one diagonal of the article's lab, with B-D at 100 Mb/s (cost 19): A is the root, C's root port is direct, and D reaches the root through C at 8 rather than through B at 23.
  • Backup port on a hub: SW1 is the root by priority and has two ports on one shared segment: SW1:2 is designated by its lower port ID, SW1:3 is a backup port and SW2:2, which reaches the root more cheaply over its 10 Gb/s link, is an alternate port.
  • Mixed cost methods: ROOT reaches OLD over 100 Mb/s and NEW over 10 Gb/s; OLD uses short costs. ACC's root port goes through OLD (19 + 20000 = 20019) instead of NEW (2000 + 20000 = 22000); with OLD on long costs (200000), ACC would choose NEW.
  • VLAN 10, root on purpose: the Example's network with B5 at 4096 and a vlan 10 line: every priority field gains 10 (4106 for B5, 32778 for the others), and B5 becomes the root.
  • Cost by speed: 1 Gb/s gives 20000 long and 4 short, the 20000 the course's slide 266 shows on ge.2.1 and ge.2.4.

What it does not do

It computes the stable result every bridge agrees on, not how the network gets there. It does not model timers and convergence, the proposal and agreement handshake, edge ports, link types, topology changes, MSTP (Multiple Spanning Tree Protocol) regions and instances, PVST+ (per-VLAN spanning tree plus) beyond one VLAN's tree, failed links, or BPDU Guard, Root Guard and Loop Guard. It does not talk to any switch. To practise the same rules on a new network every day, play the Spanning Tree puzzle; the article Spanning tree in one article explains the protocol and has a lab with four switches.

Share results

Under the verdict, Share results builds a link to this page, only when you press it, that carries the mode and the fields of the mode shown, as typed, after the #: mode (election or cost); in Election mode method (long or short) and topology, the lines as typed; in Cost by speed mode speed. The other mode's fields are not carried. In Election mode the popover adds a caution: bridge names and MAC addresses can describe a real network, so read them before you send the link.

RFC 3986 (section 3.5, read 2026-11-08) describes the fragment as the part of a reference that is used only after the document is retrieved: "the fragment identifier is not used in the scheme-specific processing of a URI; instead, the fragment identifier is separated from the rest of the URI prior to a dereference". These values are therefore not sent to the server when the link is opened; they stay in the address bar and the history of whoever opens it, and anyone who has the link can read them.

  • How long. A link carries at most 16,384 characters, the bound the site uses for every value after the #; a topology is at most 4000.
  • Opening a link. The mode and its fields are set as typing would set them (a link without method means long), the other mode keeps its values, and the page computes. A link with an unknown mode or method, a field of the other mode, a missing or blank required field, a topology longer than 4000 characters, or a speed on two lines or longer than 24 characters is ignored. Accepted or not, the values then leave the page's own address at once, without a request.

Provenance

The engine is a shortest-path pass and three sorts, with no clock, no network and no randomness. It ships 178 golden vectors (set stp-election-calculator-golden-2026-11-08b): 78 elections (the Example, the four samples, fourteen variations and sixty seeded random topologies, which together exercise every tie-break: the root by priority and by MAC address; root ports by cost, the sender's bridge ID, the sender's port ID and the receiving port's ID; designated ports by cost, bridge ID and port ID; 22 backup ports), 22 cost lookups, and 78 written out (sentences, spellings, the API and 59 refusals). Every expected root, role, cost and root port was derived by a separate implementation, not by running this engine: a Python program that reads its cost tables from the saved documents and elects by passing messages between ports until no bridge changes its mind, then assigns each port's role by comparing what it would send with what it hears. Four deliberate faults put into the engine (the last two tie-breaks swapped, the sending port's cost added instead of the receiving port's, the designated comparison reordered, the backup role removed) each made between 3 and 21 vectors fail.

API

The same engine answers /api/v1/stp-election-calculator on the site's HTTP API; the contract is on the API page, which also says whether this site serves the API.

  • Request. A JSON object. Election: {"mode": "election", "method": "long", "topology": "bridge B1 32768 00-00-5E-00-53-01\nbridge B2 32768 00-00-5E-00-53-02\nlink B1:1 B2:1 1G"}, with method optional (long by default). Cost: {"mode": "cost", "speed": "1G"}.
  • Response, election. mode, method, methodDefault, priorityFormat, vlan, bridges (each: index, name, priority, extension, priorityField, mac, bridgeId, bridgeIdHex, method, methodSet, rank, isRoot, rootPathCost, rootPort), ports (each: index, bridge, bridgeName, number, priority, portId, portIdValue, segment, cost, costSource, speed, role, forwarding, designatedPort), segments, root, rootStep, rootPortSteps (with every candidate), designatedSteps (with every candidate), blockedSteps, counts, verdictText, warnings and notes.
  • Response, cost. mode, speed (id, mbps, label, long and short, each with value and sources, or null), table (every speed), vendors (each: id, platform, defaultMethod, change, perPort, sources, valueAtSpeed, text), verdictText and notes.
  • Errors. HTTP 400, invalid_input, with the engine's message, for example Line 1: A: priority 32769 is not a multiple of 4096 from 0 to 61440. ....

Sources