Spanning-Tree Protocols · Topic 1 of 3
STP and RSTP, Port Roles, States and BPDUs
Learn STP and RSTP on MX routers for JNCIS-SP JN0-364: root bridge election, port roles and states, BPDU contents, timers and RSTP configuration.
- 5 min
- Lowest bridge ID (priority, then MAC) is root; default priority 32768, steps of 4096.
- Root port: lowest root path cost; designated port: best on each segment.
- Default costs: 1 Gbps 20,000; 10 Gbps 2000. Port priority default 128.
What it is
Redundant Layer 2 links give resilience, but Ethernet has no TTL, so a loop lets broadcast frames circle forever and melt the network. The Spanning Tree Protocol (STP, IEEE 802.1D) blocks just enough ports to leave one loop-free path between any two points.
Rapid Spanning Tree Protocol (RSTP, IEEE 802.1w, now part of 802.1D-2004) keeps the same tree logic but converges in seconds instead of up to 50 seconds. On MX Series routers you configure it under protocols rstp, and classic STP runs as RSTP forced to the old version.
How it works
Electing the root and choosing ports
- Root bridge. The bridge with the lowest bridge ID wins. The bridge ID is the bridge priority followed by the MAC address. The Junos default priority is 32768 (
32k), set in steps of 4096 (4k). - Root port. Every other bridge picks the one port with the lowest root path cost, the sum of port costs toward the root.
- Designated port. On each segment, the port that offers the lowest cost to the root forwards for that segment. All ports on the root bridge are designated.
- Everything else is blocked (STP) or discarding (RSTP).
Ties are broken by the lowest sender bridge ID, then the lowest sender port ID. The port ID is the port priority (default 128) followed by the port number.
By default the port cost is based on link speed: a 1-Gigabit Ethernet port has cost 20,000 and a 10-Gigabit Ethernet port 2000. Lower cost is better.
Port roles and states
| Role | Meaning | Forwarding? |
|---|---|---|
| Root | The bridge's best path to the root; one per non-root bridge | Yes |
| Designated | The best port toward the root on its segment | Yes |
| Alternate | RSTP: a backup path to the root through another bridge (a blocked port in STP) | No |
| Backup | RSTP: a backup for a designated port on a segment the bridge already reaches (a blocked port in STP) | No |
| Disabled | Administratively down or not in spanning tree | No |
| STP state | RSTP state | Learns MACs | Forwards |
|---|---|---|---|
| Disabled, Blocking, Listening | Discarding | No | No |
| Learning | Learning | Yes | No |
| Forwarding | Forwarding | Yes | Yes |
In STP a port moves through Listening and Learning for one forward delay each, 15 seconds by default, before it forwards.
BPDUs
Bridges exchange bridge protocol data units (BPDUs), sent to the multicast MAC address 01:80:C2:00:00:00.
| BPDU | Sent by | Purpose |
|---|---|---|
| Configuration BPDU | STP, from the root outward | Root ID, root path cost, sender bridge ID, sender port ID and timers |
| TCN BPDU | STP, toward the root | Reports a topology change |
| RST BPDU (version 2) | RSTP, every bridge on every designated port | Same fields plus flags for port role, proposal, agreement and topology change |
| MST BPDU (version 3) | MSTP | RST BPDU plus MSTI records |
Timers are set by the root and copied by every bridge. The Junos defaults are hello time 2 seconds, max age 20 seconds and forward delay 15 seconds.
What RSTP changes
- Every bridge sends BPDUs every hello time, not only relays the root's. A neighbor is considered lost after three missed hellos, 6 seconds by default.
- Edge ports, facing hosts, go straight to forwarding.
- On point-to-point links, a proposal and agreement handshake moves a new designated port to forwarding without waiting for timers.
- Alternate and backup ports are precomputed, so a failed root port is replaced at once.
Configuring RSTP on the MX
user@mx# set protocols rstp bridge-priority 4k
user@mx# set protocols rstp interface ge-1/0/0
user@mx# set protocols rstp interface ge-1/0/1 cost 10000
user@mx# set protocols rstp interface ge-1/0/1 mode p2p
user@mx# set protocols rstp interface ge-1/0/5 edge
The interface mode statement takes p2p or shared. Timers are set with hello-time, max-age and forward-delay under protocols rstp. To run classic 802.1D STP for older bridges, add set protocols rstp force-version stp.
To make an MX the root, lower its bridge-priority, for example to 4k or 0. Never rely on the MAC address tie-break, because the bridge with the oldest, lowest MAC often wins by accident.
Monitoring
user@mx> show spanning-tree bridge
user@mx> show spanning-tree interface
show spanning-tree bridge shows the root bridge ID, root cost, root port, and the local bridge ID and timers. show spanning-tree interface lists each port with its port ID, designated bridge, cost, state (such as FWD or BLK) and role (ROOT, DESG, ALT, BKUP, DIS).
Common mistakes
Picking the highest priority as root. The lowest bridge ID wins; priority is compared first, then MAC.
Confusing alternate and backup. An alternate port backs up the root port with a path through another bridge. A backup port backs up a designated port on a segment the bridge already reaches.
Thinking blocked ports send nothing. A blocked or discarding port still receives BPDUs; it just does not forward user frames or learn MACs.
On the root bridge there is no root port; every active port is designated. An exam output with a ROOT port therefore cannot be from the root bridge.
What to remember for the exam
- Lowest bridge ID (priority, then MAC) is root; default priority 32768, steps of 4096.
- Root port: lowest root path cost; designated port: best on each segment.
- Default costs: 1 Gbps 20,000; 10 Gbps 2000. Port priority default 128.
- STP states: blocking, listening, learning, forwarding, disabled; RSTP: discarding, learning, forwarding.
- RSTP roles add alternate and backup.
- BPDUs go to 01:80:C2:00:00:00; RSTP is version 2, MSTP version 3.
- Defaults: hello 2 s, max age 20 s, forward delay 15 s.
- MX:
protocols rstp,edge,mode p2p,force-version stp.
Check yourself
Bridge A has priority 32768 and MAC 00:aa..., bridge B has priority 4096 and MAC 00:01.... Which is root?
Bridge B, because priority is compared before the MAC address and 4096 is lower.
Which RSTP port role is a ready replacement for the root port?
The alternate port, which receives better BPDUs from another bridge and can take over at once.
How do you run classic 802.1D STP on an MX?
Configure
protocols rstpwithforce-version stp.
Topic 1 of 3 in Spanning-Tree Protocols
Test yourself on Spanning-Tree Protocols
The full Juniper JNCIS-SP JN0-364 question bank has 860 questions, with timed practice exams and an explanation for every answer.
This study guide is independent and is not affiliated with, endorsed by, or sponsored by Juniper. Vendor names, certification names and exam codes are trademarks of their respective owners and are used for identification only.