Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 5 of 6 · Concept · 25 min · revision 1

Redundancy without loops: STP/RSTP, edge-port protection and LACP

Explain why Layer 2 loops trigger broadcast storms, trace STP/RSTP root-bridge election and path-cost tie-breaking, protect access and distribution ports with BPDU guard and Root guard, bundle links with LACP and diagnose duplex and MTU faults.

Contentsand lesson path

What you will learn

  • Explain how STP/RSTP elects a root bridge and blocks redundant links, and protect edge ports against loops and rogue switches.
  • Bundle links with LACP and diagnose common layer-2 faults: VLAN or native-VLAN mismatch, loops, and duplex or MTU mismatch.

01. Why it matters

Suppose you wire a second trunk between two distribution switches so a severed fibre never drops a floor—and thirty seconds later the entire campus collapses at 100% switch CPU. Or someone plugs an old spare switch into an access closet and core-to-core traffic silently detours through that 1 Gb/s spare.

Unlike IPv4 TTL or IPv6 Hop Limit, an Ethernet frame has no loop counter. Any closed physical Layer 2 loop lets broadcast and unknown-unicast frames circulate endlessly, multiplying in a broadcast storm while switches overwrite MAC tables at line rate (MAC flapping). Redundant Layer 2 topologies need Spanning Tree Protocol (STP/RSTP) to block backup loops or LACP link aggregation to merge parallel cables into one logical link.

02. How STP and RSTP elect a root bridge and protect ports

Classic STP (802.1D) and RSTP (802.1w, integrated into IEEE 802.1Q) prune any physical mesh into a loop-free tree by exchanging Bridge Protocol Data Units (BPDUs). Whereas 802.1D takes 30–50 seconds to recover a link (Max Age 20 s + Listening 15 s + Learning 15 s), RSTP converges in roughly a second on point-to-point links using direct Proposal/Agreement handshakes and three simplified states (Discarding, Learning, Forwarding).

Every switch advertises an 8-byte Bridge ID (BID) combining a configurable priority (default 32768, in multiples of 4096) and its base MAC address. Lower numbers win across four deterministic tie-breaking comparisons in strict order: (1) lowest Root BID, (2) lowest cumulative Root Path Cost, (3) lowest Sender BID, and (4) lowest Sender Port ID. Those four comparisons assign every port's role:

  1. Elect one Root Bridge (Root BID): All switches compare Root BIDs; the lowest BID becomes Root Bridge. Leaving every switch at default 32768 lets whichever switch happens to hold the lowest MAC—often the oldest spare switch in a closet—win the root election and pull cross-building traffic through itself. As a default recommendation, pin your primary core switch to priority 4096 and secondary backup to 8192.
  2. Choose each non-root switch's Root Port (cumulative Root Path Cost, then Sender BID / Port ID): Each non-root switch picks the port with the lowest cumulative root path cost back to the Root—not fewest hops. Using the legacy 16-bit short cost table (100 Mb/s = 19, 1 Gb/s = 4), if a slow 100 Mb/s direct link costs 19 while two 1 Gb/s hops via a neighbour cost 4 + 4 = 8, STP picks the two-hop path of cost 8 (modern RSTP/802.1Q defaults to 32-bit long costs—100 Mb/s = 200,000, 1 Gb/s = 20,000, 10 Gb/s = 2,000—with the exact same cumulative rule). Equal-cost ties break on lowest Sender BID, then lowest Sender Port ID.
  3. Choose one Designated Port (DP) per segment and block the rest: On each link, the switch with lower root path cost keeps its port Designated (Forwarding); if both ends have equal cost to the Root, the lower Sender BID wins DP and the peer enters Alternate (Discarding/Blocking). Only one end needs to block to break a loop.

In an equal-cost triangle where S1 is Root and S2 has a lower BID than S3, both S2 and S3 attach directly to S1 via Root Ports, and on the S2–S3 link S2 holds the Designated Port while S3's port toward S2 blocks.

Text · RSTP port roles in an equal-cost triangle (S1 Root, BID S2 < S3)
               [S1: Root Bridge]
                (DP)         (DP)
               /                 \
           (RP)                   (RP)
       [S2: lower BID] ---- [S3: higher BID]
            (DP)              (ALT/Discarding)

Protecting access and distribution edges: On a non-edge port facing an end host, RSTP receives no Proposal/Agreement reply and falls back to waiting 2 × forward delay (about 30 seconds), which can time out host DHCP. Enabling PortFast / Edge Port puts host-facing ports straight into Forwarding—but PortFast only skips the listening/learning delay, so a loop can form before STP reacts if a user plugs in an unmanaged switch with two ports patched together. Your switch's own BPDUs loop back through that unmanaged switch, and BPDU guard uses those returning BPDUs to error-disable the port at once. On distribution ports facing downstream switches that legitimately run RSTP, enable Root guard instead: it allows normal BPDUs, but puts the port into a root-inconsistent blocked state if a superior BPDU tries to claim Root Bridge. Finally, Loop guard on Alternate/Blocking uplinks stops a one-way fibre break (where BPDUs vanish) from transitioning the blocked port to Forwarding.

03. Link aggregation with LACP, Linux bridges vs OVS and Layer 2 faults

Because STP keeps backup paths idle, Link Aggregation Control Protocol (LACP, IEEE 802.1AX) negotiates parallel cables into one logical port that STP treats as a single link with zero blocking:

  • Modes and member consistency: An active port sends LACPDU negotiation probes proactively, whereas a passive port only responds when it receives LACPDUs. Either active + active or active + passive brings up a bundle, whereas passive + passive never forms a bundle. Every member port must match speed, duplex, and trunk/allowed/native VLAN configuration; pairing static mode "on" (no LACP) on one switch with LACP on the partner causes the LACP side to suspend the ports (or risks a loop if STP is disabled).
  • Configuring and verifying on Linux (Linux bonding): Create an 802.3ad bond (ip link add bond0 type bond mode 802.3ad miimon 100 xmit_hash_policy layer3+4), enslave member links (take each one down first, because the kernel refuses to enslave an interface that is up: ip link set eth1 down && ip link set eth1 master bond0, the same for eth2, then ip link set bond0 up), and inspect negotiation state with cat /proc/net/bonding/bond0 or ip -d link show bond0 (or show port-channel summary on a switch).
  • Why one TCP stream still hits one link's ceiling: LACP hashes packet headers (MACs, IPs, and TCP/UDP ports via layer3+4) so every packet of a single flow stays on one physical cable to avoid TCP out-of-order delivery. Two 10 Gb/s bundled trunks deliver ~10 Gb/s to one file transfer and ~20 Gb/s aggregate across multiple concurrent flows.

Linux bridge STP vs Open vSwitch (OVS) and when not to use STP: On Linux, ip link add br0 type bridge stp_state 1 priority 4096 enables kernel 802.1D STP (bridge link set dev <p> guard on / root_block on), whereas Open vSwitch (ovs-vsctl) adds programmable OpenFlow tables, RSTP, and LACP bonds widely used on KVM hypervisors and Containerlab OVS labs. When not to use STP at all: Multi-switch spanning trees scale poorly in large data centres because half the capacity sits blocked and broadcast faults span racks; modern leaf-spine fabrics replace STP triangles with Layer 3 ECMP routing or switch-pair MLAG (explored in IP Routing and Network Design).

Triaging duplex and MTU mismatches: Two sneaky Layer 2 faults mimic slow links without dropping link light:

  • Duplex mismatch: Forcing full duplex on one port disables auto-negotiation, so its peer falls back to half duplex. The half-duplex side logs late collisions, while the full-duplex side logs CRC errors. Restore auto-negotiation on both sides (or force both identically).
  • MTU mismatch: Because TCP MSS negotiation clamps segment sizes whenever either peer uses MTU 1500, the silent stall happens when both endpoints use MTU 9000 (negotiating an ~8,960-byte MSS) with a 1,500-byte switch port between them: small ping checks pass and CRC/collision counters stay at zero, yet large TCP transfers stall right after handshake because Layer 2 switches drop oversized frames silently instead of fragmenting them (often logging giants or oversize input error counters).

04. Check your understanding

Practice check · 3 questions

STP path cost, Root guard vs BPDU guard and MTU faults

Diagnose spanning-tree path selection, port protection and Layer 2 mismatches.

Q1. In a three-switch RSTP loop, S1 is Root Bridge. S2's direct link to S1 has path cost 19, S1's link to S3 has path cost 4, and S3's link to S2 has path cost 4. Which port becomes S2's Root Port?
Q2. A distribution port connects to a partner branch switch that legitimately runs RSTP, so you cannot block all BPDUs with BPDU guard. You still want to stop that switch from seizing Root Bridge if its priority is lowered. Which feature fits?
Q3. Two servers configured with MTU 9000 transfer files across a switch port left at MTU 1500. The link shows zero CRC errors and zero late collisions, and small `ping` checks succeed, yet SCP transfers stall immediately after the TCP handshake. Why?
Practice only: not graded, not saved, not evidence.

05. Apply it

Design the recovery test for this skill's full practice exercise: connect two vlan_filtering 1 Linux bridges (or OVS switches) with two parallel 802.1Q trunks carrying VLANs 10 and 20 plus a router-on-a-stick, enable STP (ip link set br0 type bridge stp_state 1 priority 4096), confirm with bridge -d link show which parallel link enters blocking, then set mismatched native VLAN PVIDs on one trunk end and trace the cross-VLAN leak.

From here, continue to Wireless LAN Fundamentals, Packet Capture Analysis, or Network Design to see how switched domains integrate with Wi-Fi and routed cores.

06. Review prompt

Explain the four STP tie-breaking criteria from Root BID to Sender Port ID, distinguish PortFast, BPDU guard, Root guard, and Loop guard, explain LACP active/passive negotiation and why it hashes per flow rather than per frame, and contrast duplex-mismatch counters with MTU-mismatch symptoms.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

10 questions · about 8 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check