{"id":180,"date":"2022-11-29T22:31:13","date_gmt":"2022-11-29T21:31:13","guid":{"rendered":"https:\/\/mokrane-assam.com\/?p=180"},"modified":"2026-11-29T22:36:29","modified_gmt":"2026-11-29T21:36:29","slug":"spanning-tree-basics-root-bridges-port-roles-and-rstp","status":"publish","type":"post","link":"https:\/\/mokrane-assam.com\/index.php\/2022\/11\/29\/spanning-tree-basics-root-bridges-port-roles-and-rstp\/","title":{"rendered":"Spanning Tree Basics: Root Bridges, Port Roles, and RSTP"},"content":{"rendered":"<p class=\"wp-block-paragraph\">Spanning Tree is the protocol that keeps a looped Layer-2 network from destroying itself. Ethernet frames have no TTL, so a single bridging loop does not slow a network down \u2014 it melts it, in seconds. STP&#8217;s job is to find every redundant path and deliberately block it, leaving exactly one loop-free tree, then unblock a backup the moment the active path fails. This walk-through goes from why the loop is fatal to RSTP and the guards that keep the tree where you put it.<\/p><h2 class=\"wp-block-heading\">1. Why a Layer-2 loop is fatal<\/h2><p class=\"wp-block-paragraph\">An IP packet has a TTL that decrements at each hop and eventually dies. An Ethernet frame has none. Put two switches in a loop and a single broadcast circulates forever, multiplied at every switch, until the links saturate \u2014 a <strong>broadcast storm<\/strong>. Worse, the same source MAC arrives on two ports, so the MAC table <strong>flaps<\/strong> and unicast forwarding breaks too. There is no self-healing; the loop must be prevented, not survived.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 230\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"Why a Layer-2 loop is fatal\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"230\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">Why a Layer-2 loop is fatal<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"250\" y=\"90\" width=\"150\" height=\"50\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"325\" y=\"120\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Switch A<\/text><rect x=\"520\" y=\"90\" width=\"150\" height=\"50\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"595\" y=\"120\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Switch B<\/text><line x1=\"400\" y1=\"105\" x2=\"520\" y2=\"105\" stroke=\"#C8102E\" stroke-width=\"2.5\" marker-end=\"url(#ar)\"\/><line x1=\"520\" y1=\"125\" x2=\"400\" y2=\"125\" stroke=\"#C8102E\" stroke-width=\"2.5\" marker-end=\"url(#ar)\"\/><text x=\"460\" y=\"165\" text-anchor=\"middle\" fill=\"#9f1239\" font-size=\"12\" font-weight=\"700\">one broadcast loops forever (no TTL) -> storm<\/text><text x=\"460\" y=\"195\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"11\">MAC table also flaps as the same source appears on both ports<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">2. Electing the root bridge<\/h2><p class=\"wp-block-paragraph\">STP builds a tree rooted at one switch. Every switch starts claiming to be root and advertises its <strong>Bridge ID<\/strong> \u2014 a 2-byte priority (default 32768) plus its MAC address \u2014 in <strong>BPDUs<\/strong>. The switch with the <strong>lowest Bridge ID<\/strong> wins; since priorities are usually equal, the lowest MAC wins by default \u2014 which is why you set priority explicitly rather than letting the oldest switch become root by accident.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 230\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"Root bridge election\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"230\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">Root bridge election<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"360\" y=\"86\" width=\"200\" height=\"56\" rx=\"10\" fill=\"#dcfce7\" stroke=\"#166534\" stroke-width=\"1.5\"\/><text x=\"460\" y=\"108\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"12\" font-weight=\"700\">ROOT (lowest Bridge ID)<\/text><text x=\"460\" y=\"128\" text-anchor=\"middle\" fill=\"#334155\" font-size=\"10.5\">priority 4096<\/text><rect x=\"120\" y=\"180\" width=\"180\" height=\"50\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"210\" y=\"205\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"11.5\">Switch (prio 32768)<\/text><rect x=\"370\" y=\"180\" width=\"180\" height=\"50\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"460\" y=\"205\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"11.5\">Switch (prio 32768)<\/text><rect x=\"620\" y=\"180\" width=\"180\" height=\"50\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"710\" y=\"205\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"11.5\">Switch (prio 32768)<\/text><line x1=\"420\" y1=\"142\" x2=\"250\" y2=\"180\" stroke=\"#166534\" stroke-width=\"2\"\/><line x1=\"460\" y1=\"142\" x2=\"460\" y2=\"180\" stroke=\"#166534\" stroke-width=\"2\"\/><line x1=\"500\" y1=\"142\" x2=\"700\" y2=\"180\" stroke=\"#166534\" stroke-width=\"2\"\/><text x=\"460\" y=\"252\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"11\">Bridge ID = priority (2 bytes) + MAC. Equal priority -> lowest MAC wins.<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">3. Each switch picks a root port<\/h2><p class=\"wp-block-paragraph\">Once the root is known, every non-root switch chooses one <strong>root port<\/strong> \u2014 its best path back to the root, the one with the lowest cumulative <strong>root path cost<\/strong>. Cost accumulates per link by speed, so a switch compares the total cost over each of its uplinks and keeps the cheapest. Ties break on the neighbor&#8217;s Bridge ID, then its port ID.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 230\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"Root port selection\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"230\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">Root port selection<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"360\" y=\"86\" width=\"200\" height=\"46\" rx=\"10\" fill=\"#dcfce7\" stroke=\"#166534\"\/><text x=\"460\" y=\"114\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"12\" font-weight=\"700\">ROOT<\/text><rect x=\"360\" y=\"190\" width=\"200\" height=\"50\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"460\" y=\"220\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Switch X<\/text><line x1=\"420\" y1=\"132\" x2=\"420\" y2=\"190\" stroke=\"#166534\" stroke-width=\"2.5\"\/><text x=\"360\" y=\"165\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"11\" font-weight=\"700\">cost 4 (1G)<\/text><text x=\"380\" y=\"182\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"10\">ROOT PORT<\/text><line x1=\"500\" y1=\"132\" x2=\"640\" y2=\"160\" stroke=\"#cbd5e1\" stroke-width=\"2\"\/><rect x=\"620\" y=\"150\" width=\"150\" height=\"46\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"695\" y=\"178\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"11\">Switch Y<\/text><line x1=\"560\" y1=\"210\" x2=\"640\" y2=\"190\" stroke=\"#C8102E\" stroke-width=\"2\" stroke-dasharray=\"5 3\"\/><text x=\"600\" y=\"228\" text-anchor=\"middle\" fill=\"#9f1239\" font-size=\"10.5\">via Y: cost 8 (worse)<\/text><text x=\"460\" y=\"256\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"11\">Root port = lowest total cost to root; the pricier path is not chosen<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">4. Each segment picks a designated port<\/h2><p class=\"wp-block-paragraph\">Every link segment also needs exactly one <strong>designated port<\/strong> \u2014 the port responsible for forwarding toward the root on that segment, chosen as the one advertising the lowest cost. All of the root bridge&#8217;s ports are designated. Any port that is neither a root port nor a designated port is put into <strong>blocking<\/strong> \u2014 that is the port STP shuts down to break the loop.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 220\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"Designated ports and blocking\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"220\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">Designated ports and blocking<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"120\" y=\"86\" width=\"160\" height=\"46\" rx=\"10\" fill=\"#dcfce7\" stroke=\"#166534\"\/><text x=\"200\" y=\"114\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"12\" font-weight=\"700\">ROOT<\/text><rect x=\"120\" y=\"170\" width=\"160\" height=\"46\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"200\" y=\"198\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\">Switch A<\/text><rect x=\"640\" y=\"170\" width=\"160\" height=\"46\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"720\" y=\"198\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\">Switch B<\/text><line x1=\"200\" y1=\"132\" x2=\"200\" y2=\"170\" stroke=\"#166534\" stroke-width=\"2.5\"\/><text x=\"200\" y=\"155\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"9\">RP<\/text><line x1=\"280\" y1=\"100\" x2=\"720\" y2=\"170\" stroke=\"#166534\" stroke-width=\"2.5\"\/><text x=\"500\" y=\"128\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"9\">RP (B)<\/text><line x1=\"280\" y1=\"193\" x2=\"640\" y2=\"193\" stroke=\"#0A66C2\" stroke-width=\"2\"\/><rect x=\"300\" y=\"182\" width=\"36\" height=\"22\" rx=\"4\" fill=\"#dcfce7\"\/><text x=\"318\" y=\"198\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"9\">DP<\/text><rect x=\"584\" y=\"182\" width=\"56\" height=\"22\" rx=\"4\" fill=\"#fee2e2\"\/><text x=\"612\" y=\"198\" text-anchor=\"middle\" fill=\"#9f1239\" font-size=\"9\">BLOCK<\/text><text x=\"460\" y=\"214\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"11\">One designated port per segment; the loser is blocked<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">5. Port states and the slow timers<\/h2><p class=\"wp-block-paragraph\">Classic STP does not forward immediately. A port climbs through <strong>Blocking \u2192 Listening \u2192 Learning \u2192 Forwarding<\/strong>, spending a <strong>forward delay<\/strong> (15 s) in each of listening and learning so it cannot create a transient loop while the topology settles. With a hello of 2 s and a max-age of 20 s, a failure can take <strong>30\u201350 seconds<\/strong> to recover \u2014 glacial by modern standards, and the reason RSTP exists.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 200\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"STP port states\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"200\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">STP port states<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"40\" y=\"110\" width=\"150\" height=\"46\" rx=\"9\" fill=\"#fee2e2\" stroke=\"#C8102E\"\/><text x=\"115\" y=\"138\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"11.5\" font-weight=\"600\">Blocking<\/text><rect x=\"225\" y=\"110\" width=\"150\" height=\"46\" rx=\"9\" fill=\"#fff7ed\" stroke=\"#f59e0b\"\/><text x=\"300\" y=\"138\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"11.5\" font-weight=\"600\">Listening<\/text><rect x=\"410\" y=\"110\" width=\"150\" height=\"46\" rx=\"9\" fill=\"#fff7ed\" stroke=\"#f59e0b\"\/><text x=\"485\" y=\"138\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"11.5\" font-weight=\"600\">Learning<\/text><rect x=\"595\" y=\"110\" width=\"150\" height=\"46\" rx=\"9\" fill=\"#dcfce7\" stroke=\"#166534\"\/><text x=\"670\" y=\"138\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"11.5\" font-weight=\"600\">Forwarding<\/text><line x1=\"190\" y1=\"133\" x2=\"225\" y2=\"133\" stroke=\"#64748b\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"375\" y1=\"133\" x2=\"410\" y2=\"133\" stroke=\"#64748b\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><line x1=\"560\" y1=\"133\" x2=\"595\" y2=\"133\" stroke=\"#64748b\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><text x=\"460\" y=\"180\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"11\">hello 2s \u00b7 forward delay 15s each (listen+learn) \u00b7 max-age 20s -> ~30-50s recovery<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">6. RSTP \u2014 convergence in milliseconds<\/h2><p class=\"wp-block-paragraph\">Rapid STP (802.1w) keeps the same tree math but replaces the timers with a handshake. It adds <strong>alternate<\/strong> and <strong>backup<\/strong> port roles \u2014 a pre-computed backup to the root port and to a designated port \u2014 so a failover is a role switch, not a 30-second wait. A <strong>proposal\/agreement<\/strong> exchange lets two switches agree to forward instantly, and <strong>edge ports<\/strong> (host-facing) forward immediately. Convergence drops from tens of seconds to sub-second.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 220\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"RSTP proposal and agreement\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"220\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">RSTP proposal and agreement<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"120\" y=\"100\" width=\"190\" height=\"56\" rx=\"10\" fill=\"#dcfce7\" stroke=\"#166534\"\/><text x=\"215\" y=\"132\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"12\" font-weight=\"700\">Switch 1<\/text><rect x=\"610\" y=\"100\" width=\"190\" height=\"56\" rx=\"10\" fill=\"#fff\" stroke=\"#0A66C2\"\/><text x=\"705\" y=\"132\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"600\">Switch 2<\/text><line x1=\"310\" y1=\"118\" x2=\"610\" y2=\"118\" stroke=\"#0A66C2\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><text x=\"460\" y=\"110\" text-anchor=\"middle\" fill=\"#0A66C2\" font-size=\"11\">Proposal<\/text><line x1=\"610\" y1=\"140\" x2=\"310\" y2=\"140\" stroke=\"#166534\" stroke-width=\"2\" marker-end=\"url(#ar)\"\/><text x=\"460\" y=\"158\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"11\">Agreement -> both forward now<\/text><text x=\"460\" y=\"194\" text-anchor=\"middle\" fill=\"#64748b\" font-size=\"11\">Roles: Root \u00b7 Designated \u00b7 Alternate (backup to root) \u00b7 Backup \u00b7 Edge<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">7. Path cost \u2014 the table that decides the tree<\/h2><p class=\"wp-block-paragraph\">Because the whole tree hangs on cumulative cost, knowing the per-link values is what lets you predict and shape it. The legacy (short) scale tops out low, so modern links collapse together; the <strong>long<\/strong> path-cost method spreads them out. Set costs deliberately on key links rather than accepting defaults that may send traffic the long way round.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 230\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"STP path cost\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"230\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">STP path cost<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"30\" y=\"80\" width=\"860\" height=\"30\" rx=\"6\" fill=\"#0f172a\"\/><text x=\"200\" y=\"100\" text-anchor=\"middle\" fill=\"#fff\" font-size=\"11\" font-weight=\"700\">Link speed<\/text><text x=\"500\" y=\"100\" text-anchor=\"middle\" fill=\"#fff\" font-size=\"11\" font-weight=\"700\">Short (legacy) cost<\/text><text x=\"760\" y=\"100\" text-anchor=\"middle\" fill=\"#fff\" font-size=\"11\" font-weight=\"700\">Long cost<\/text><rect x=\"30\" y=\"110\" width=\"860\" height=\"30\" fill=\"#ffffff\" stroke=\"#e2e8f0\"\/><text x=\"200\" y=\"130\" text-anchor=\"middle\" fill=\"#334155\" font-size=\"11\">10 Mbps<\/text><text x=\"500\" y=\"130\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"11\" font-weight=\"600\">100<\/text><text x=\"760\" y=\"130\" text-anchor=\"middle\" fill=\"#0A66C2\" font-size=\"11\" font-weight=\"600\">2,000,000<\/text><rect x=\"30\" y=\"140\" width=\"860\" height=\"30\" fill=\"#f1f5f9\" stroke=\"#e2e8f0\"\/><text x=\"200\" y=\"160\" text-anchor=\"middle\" fill=\"#334155\" font-size=\"11\">100 Mbps<\/text><text x=\"500\" y=\"160\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"11\" font-weight=\"600\">19<\/text><text x=\"760\" y=\"160\" text-anchor=\"middle\" fill=\"#0A66C2\" font-size=\"11\" font-weight=\"600\">200,000<\/text><rect x=\"30\" y=\"170\" width=\"860\" height=\"30\" fill=\"#ffffff\" stroke=\"#e2e8f0\"\/><text x=\"200\" y=\"190\" text-anchor=\"middle\" fill=\"#334155\" font-size=\"11\">1 Gbps<\/text><text x=\"500\" y=\"190\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"11\" font-weight=\"600\">4<\/text><text x=\"760\" y=\"190\" text-anchor=\"middle\" fill=\"#0A66C2\" font-size=\"11\" font-weight=\"600\">20,000<\/text><rect x=\"30\" y=\"200\" width=\"860\" height=\"30\" fill=\"#f1f5f9\" stroke=\"#e2e8f0\"\/><text x=\"200\" y=\"220\" text-anchor=\"middle\" fill=\"#334155\" font-size=\"11\">10 Gbps<\/text><text x=\"500\" y=\"220\" text-anchor=\"middle\" fill=\"#C8102E\" font-size=\"11\" font-weight=\"600\">2<\/text><text x=\"760\" y=\"220\" text-anchor=\"middle\" fill=\"#0A66C2\" font-size=\"11\" font-weight=\"600\">2,000<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">8. Guarding the tree<\/h2><p class=\"wp-block-paragraph\">A correct tree can still be broken by a misbehaving or malicious switch, so STP ships with protections. <strong>PortFast<\/strong> forwards edge ports immediately; <strong>BPDU Guard<\/strong> err-disables a PortFast port the instant it hears a BPDU (someone plugged a switch into an access port); <strong>Root Guard<\/strong> rejects a superior BPDU on a port so a rogue switch cannot steal the root role; <strong>Loop Guard<\/strong> keeps a port blocking if BPDUs mysteriously stop, rather than letting it drift to forwarding and form a loop.<\/p><figure class=\"mkz-diagram\" style=\"margin:24px auto;max-width:920px\"><svg style=\"width:100%;height:auto;display:block;margin:0 auto\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 920 210\" font-family=\"'Segoe UI',Roboto,Helvetica,Arial,sans-serif\" role=\"img\" aria-label=\"STP protections\"><defs><linearGradient id=\"hg\" x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\"><stop offset=\"0\" stop-color=\"#17263f\"\/><stop offset=\"1\" stop-color=\"#0f172a\"\/><\/linearGradient><marker id=\"ar\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\"><path d=\"M0 0L10 5L0 10z\" fill=\"#0A66C2\"\/><\/marker><\/defs><rect x=\"0\" y=\"0\" width=\"920\" height=\"210\" rx=\"14\" fill=\"#f8fafc\" stroke=\"#e2e8f0\"\/><rect x=\"0\" y=\"0\" width=\"920\" height=\"60\" rx=\"14\" fill=\"url(#hg)\"\/><rect x=\"0\" y=\"40\" width=\"920\" height=\"20\" fill=\"#0f172a\"\/><text x=\"28\" y=\"37\" fill=\"#ffffff\" font-size=\"19\" font-weight=\"700\">STP protections<\/text><text x=\"892\" y=\"37\" text-anchor=\"end\" fill=\"#38bdf8\" font-size=\"13\" font-weight=\"600\" letter-spacing=\"1\">NET BY ME<\/text><rect x=\"30\" y=\"90\" width=\"210\" height=\"90\" rx=\"10\" fill=\"#e0f2fe\" stroke=\"#0A66C2\"\/><text x=\"135\" y=\"118\" text-anchor=\"middle\" fill=\"#0f172a\" font-size=\"12\" font-weight=\"700\">PortFast<\/text><text x=\"135\" y=\"140\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"10.5\">edge ports forward now<\/text><text x=\"135\" y=\"158\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"10.5\">hosts, not switches<\/text><rect x=\"255\" y=\"90\" width=\"210\" height=\"90\" rx=\"10\" fill=\"#fef2f2\" stroke=\"#C8102E\"\/><text x=\"360\" y=\"118\" text-anchor=\"middle\" fill=\"#9f1239\" font-size=\"12\" font-weight=\"700\">BPDU Guard<\/text><text x=\"360\" y=\"140\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"10.5\">BPDU on edge -> err-disable<\/text><text x=\"360\" y=\"158\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"10.5\">stops rogue switches<\/text><rect x=\"480\" y=\"90\" width=\"210\" height=\"90\" rx=\"10\" fill=\"#fff7ed\" stroke=\"#f59e0b\"\/><text x=\"585\" y=\"118\" text-anchor=\"middle\" fill=\"#9a3412\" font-size=\"12\" font-weight=\"700\">Root Guard<\/text><text x=\"585\" y=\"140\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"10.5\">reject superior BPDU<\/text><text x=\"585\" y=\"158\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"10.5\">protects root placement<\/text><rect x=\"705\" y=\"90\" width=\"185\" height=\"90\" rx=\"10\" fill=\"#ecfdf5\" stroke=\"#166534\"\/><text x=\"797\" y=\"118\" text-anchor=\"middle\" fill=\"#166534\" font-size=\"12\" font-weight=\"700\">Loop Guard<\/text><text x=\"797\" y=\"140\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"10.5\">BPDUs stop -> stay blocking<\/text><text x=\"797\" y=\"158\" text-anchor=\"middle\" fill=\"#475569\" font-size=\"10.5\">prevents silent loops<\/text><\/svg><\/figure><h2 class=\"wp-block-heading\">Takeaways<\/h2><p class=\"wp-block-paragraph\">Spanning Tree is one idea applied relentlessly: pick a root, measure the cost to it, keep one path, block the rest, and switch to a backup on failure. RSTP makes the switch fast; the guards make sure the tree stays where you designed it. Understand the Bridge ID, the cost table, and the port roles, and nothing STP does will surprise you.<\/p><p class=\"wp-block-paragraph\"><em>Generic, vendor-neutral fundamentals from my own study and lab work. No client- or employer-specific configuration.<\/em><\/p>","protected":false},"excerpt":{"rendered":"<p>Spanning Tree is the protocol that keeps a looped Layer-2 network from destroying itself. Ethernet frames have no TTL, so a single bridging loop does not slow a network down \u2014 it melts it, in seconds. STP&#8217;s job is to find every redundant path and deliberately block it, leaving exactly one loop-free tree, then unblock<\/p><\/div>\n<div class=\"blog-btn\"><a href=\"https:\/\/mokrane-assam.com\/index.php\/2022\/11\/29\/spanning-tree-basics-root-bridges-port-roles-and-rstp\/\" class=\"home-blog-btn\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[24],"tags":[],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-basic"],"_links":{"self":[{"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/comments?post=180"}],"version-history":[{"count":1,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":181,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/posts\/180\/revisions\/181"}],"wp:attachment":[{"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/media?parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/categories?post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mokrane-assam.com\/index.php\/wp-json\/wp\/v2\/tags?post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}