Wiki DE Start in the browser

Wiki › Protocols

Spanning tree (STP)

Redundant cables without a broadcast storm: root bridge, port roles, blocked ports and what happens without STP.

Layer
2 (Sicherung)
Standard
IEEE 802.1D, IEEE 802.3, IEEE 802.2
See an example
2 demos

The problem: loops

Two cables between switches increase resilience but form a loop. A broadcast is sent round in circles endlessly and multiplies: a broadcast storm. After seconds the network is full and the MAC tables flap back and forth.

Broadcast storm without spanning tree: frames circle endlesslyBroadcast storm without spanning tree: frames circle endlessly
Slow motion Broadcast storm without spanning tree: frames circle endlessly

The solution: a tree

The Spanning Tree Protocol turns the meshed network into a tree without loops:

  1. The switches exchange BPDUs and elect a root bridge: the switch with the smallest bridge ID (priority, then MAC address).
  2. Every other switch determines its root port: the path with the lowest cost to the root.
  3. Every link has one designated port; all other ports are blocked.

If a cable fails, the switches recompute and a blocked port takes over. With classic STP this takes until the forward delay has expired; Rapid Spanning Tree (RSTP) switches over in milliseconds.

RoleState
Root portforwards (towards the root)
Designated portforwards (away from the root)
Alternate (blocked)does not forward, only listens to BPDUs

With spanning-tree priority 4096 you make a particular switch (usually in the core) the root.

The BPDU in the frame

BPDUs do not travel in Ethernet II but in an IEEE 802.3 frame with length and LLC header (DSAP and SSAP 0x42) to the multicast address 01:80:c2:00:00:00.

IEEE 802.3Frame · IEEE 802.3, IEEE 802.2, RFC 1042
Preamble7 bytes
SFD1 bytes
Destination MAC6 bytes01:80:c2:00:00:00
Source MAC6 bytes02:00:00:00:01:06
Length2 bytes38
DSAP1 bytes0x42
SSAP1 bytes0x42
Control1 bytes0x03
OUI3 bytes
Type (SNAP)2 bytes
Payload38–1497 bytes43 Byte
FCS4 bytes0x182ad55e
Gap (IFG)12 bytes
Left to right, in the order the bytes are sent. Grey dashed: never part of a capture (layer 1 or line framing). Point at a field for an explanation.
FieldLengthExample valueMeaning
Preamble (layer 1)7 bytes10101010 × 7Seven bytes 10101010: the receiver synchronises its clock. Part of the physical layer.
SFD (layer 1)1 bytes10101011Start frame delimiter 10101011: the frame starts now.
Destination MAC6 bytes01:80:c2:00:00:00To whom? FF:FF:FF:FF:FF:FF is broadcast, a first byte with the lowest bit set is multicast.
Source MAC6 bytes02:00:00:00:01:06From whom? The MAC address of the sending interface; the switch learns it.
Length2 bytes38Length of the payload in bytes (at most 1500). This tells the receiver it is an IEEE 802.3 frame with LLC instead of Ethernet II.
DSAP1 bytes0x42Destination service access point (IEEE 802.2 LLC): for whom at the other end. 0x42 = spanning tree, 0xAA = SNAP follows.
SSAP1 bytes0x42Source service access point: from which service, usually the same as DSAP.
Control1 bytes0x03LLC control, 0x03 = unnumbered information (without acknowledgement).
OUI (optional)3 bytesOnly with SNAP (DSAP 0xAA): organisation identifier, 00-00-00 for EtherType values (RFC 1042).
Type (SNAP) (optional)2 bytesOnly with SNAP: the EtherType of the payload, e.g. 0x0800 for IPv4. This is how Wi-Fi and other LLC networks carry IP.
Payload38–1497 bytes43 ByteThe payload, e.g. a spanning tree BPDU. Shorter frames are padded to 64 bytes.
FCS4 bytes0x182ad55eFrame check sequence: CRC-32 over the whole frame from the destination MAC. If it does not match, the receiver drops the frame.
Gap (IFG) (layer 1)12 bytesAt least 12 bytes of silence before the next frame (interframe gap). Part of the physical layer.
Values: Real frame from the demo “VLAN and spanning tree” (no. 1, 64 bytes), exactly as the packet list in leyoNET shows it.

In leyoNET

Without STP the simulation detects the storm, shows a banner with the affected devices and throttles forwarding so the page stays responsive. With STP, show spanning-tree shows root, roles and states; the blocked port is marked on the canvas.

How to do it in leyoNET

The same text as in the app’s help (F1 key).

Spanning tree (STP)

Redundant cables between switches form loops. Without STP, broadcasts circulate forever: a broadcast storm that cripples the network. The simulator then shows a warning and the affected devices.

With STP the switches elect a root bridge and block some ports until a path fails. Enable it on the switch under «Spanning tree». For faster failover: Rapid Spanning Tree (RSTP).

See an example

  • Demo “VLAN and spanning tree” in leyoNETDemo “VLAN and spanning tree” in leyoNET
    Slow motion This is how it looks in the simulation: every dot is a frame on the cable.
    VLAN and spanning tree

    Three switches in a ring, two VLANs over trunks.

    STP blocks one port (orange), then the office reaches its second computer over the trunk with an 802.1Q tag.

    Watch live Project file

  • Broadcast storm

    Three switches in a ring, but without spanning tree.

    The very first ARP request circles endlessly and multiplies. Then enable STP and compare.

    Watch live Project file

“Watch live” opens the network in leyoNET, the simulation runs in a loop. In the app you find it under File → Demo networks, ready to present.

Practise

  • ★★★☆☆ A loop without a storm · 3 goals · Worksheet (German)
  • ★★★★☆ UE11 Network design: collapsed core · 5 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

What leyoNET simplifies

ProtocolLayerSimplification in the simulation
STP2Shortened timers; ports to end devices forward immediately (like PortFast)

Standards

  • IEEE 802.1D – Media Access Control (MAC) Bridges (current edition: IEEE 802.1D-2004)
  • IEEE 802.3 – IEEE Standard for Ethernet (current edition: IEEE 802.3-2022)
  • IEEE 802.2 – Logical Link Control (ISO/IEC 8802-2) (current edition: ISO/IEC 8802-2:1998 (IEEE 802.2-1998))

Read on

Found a mistake or have an idea? Source of this page on GitHub.