Spanning Tree Protocol Operation
The Spanning Tree Protocol is used to create a loop-free topology in Layer 2 networks. It is a Layer 2 protocol that calculates the best path through a switched network that contains redundant paths.
It allows bridges to communicate with each other for the purpose of discovering physical loops in the network. When physical loops are found, the protocol specifies an algorithm that bridges can use to create a loop-free logical topology. Blocking loops reduces flooding in the network. The STP algorithm computes a tree structure of loop-free leaves and branches that spans the entire Layer 2 network.
Various Layer 2 STP control protocols take care of resolving the forwarding loops in a Layer 2 network. L2CPD is the Junos OS process responsible for all of the various STP versions in the Junos operating system.
Figure 1 shows a typical Layer 2 network in which broadcast loops can occur.
Figure 1: Flat Topology of Layer 2 Loops

In this example, STP is not enabled. Host A sends a frame to Host B to the broadcast MAC address (ff-ff-ff-ff-ff-ff). Router R2 (operating as a switch) receives the frame and sends it out to Router R1 and Router R3. When Router R1 and Router R3 receive the frame, they forward the frame to the Layer 2 switch connected to Host B. The Layer 2 switch then forwards the packet to the other router and to Host B. When Router R1 and Router R3 receive the frame, they forward the frame to Router R2. Router R2 forwards the frame to Host A, Router R1, and Router R2. Thus creating a forwarding loop.
Looping in Layer 2 Ethernet frame formats is handled differently than it is in IP headers. An IP header has a time-to-live (TTL) field that is set by the original host and is decremented at each router, allowing the router to prevent looped datagrams by discarding packets that reach TTL=0. This feature is not available for Layer 2 Ethernet frames.
Therefore, after a Layer 2 frame starts to loop in the network shown in Figure 1, it continues looping forever until one of these events occurs:
- One of the bridges is turned off.
- A link is broken.
- A bridge is rebooted.
Bridging tables that are not configured with STP can be corrupted by the looping created by a broadcast storm. Looping can also be created by unicast traffic.
There are four Ethernet frame formats, each illustrated in Table 1, Table 2, Table 3, and Table 4:
Table 1: Ethernet (Ethernet II) Frame Format
Dst | Src | Type | Data |
|---|---|---|---|
<-- 6 --> | <-- 6 --> | <-- 2 --> | <– 46-1500 –> |
Table 2: IEEE 802.3 Frame Format
Dst | Src | Length | Data |
|---|---|---|---|
<-- 6 --> | <-- 6 --> | <-- 2 --> | <– 46-1500 –> |
Table 3: IEEE 802.2 (IEEE 802.3 with IEEE 802.2 header) Frame Format
Dst | Src | Length | DSAP | SSAP | Control | Data |
|---|---|---|---|---|---|---|
<-- 1 --> | <-- 1 --> | <-- 1 --> | <– 43-1497 –> |
Table 4: SNAP (IEEE 802.3 with IEEE 802.2 and SNAP headers) Frame Format
Dst | Src | Length | 0xAA | 0xAA | 0x03 | Org Code | Type | Data |
|---|---|---|---|---|---|---|---|---|
<-- 3 --> | <-- 2 --> | <– 38-1492 –> |
Related Topics
- Decision Sequence for a Loop-Free STP Topology
- Key Concepts in Spanning Tree Protocols
- Multiple Spanning Tree Protocol
- Overview of Spanning Tree Protocol on Juniper Networks MX Series 3D Universal Edge Routers
- Port Roles in STP
- Rapid Spanning Tree Protocol Port States and Port Roles
- Restrictions and Cautions for Implementing STP
- Spanning Tree Protocol States
- STP Scaling and Performance on Juniper Networks MX Series 3D Universal Edge Routers
- VLAN Spanning Tree Protocol
Hide Navigation Pane
Show Navigation Pane
Download
SHA1