Loop Prevention - MicahKezar/MicahKezar GitHub Wiki

What Is a Bridging Loop?

Let's say we have two switches connected over two ports. If PC A (on port 1) sends a broadcast frame to Switch 1, the switch will copy the frame and send it to Switch 2 over both ports. The port on switch 2 getting the frame from switch 1 will also associate that port with PC A. Switch 2 takes that frame and continues to flood it back to switch 1. Switch 1 is going to see that PC A moved ports (which it didn't.)

PC A will lose connection, and both switches are rapidly changing their MAC Address Tables. This will eventually overload the CPU.

Introduction to Rapid Spanning-Tree

Originally introduced in 2001 as IEEE 802.1w standard. They then upgraded it to IEEE 802.1d in 2004. Usually called CST (Common Spanning Tree). With Spanning Tree, there is no redundancy in traffic paths for frames.

How RSTP Works

The 'tree' in Rapid Spanning Tree means that you take a topology with switches or bridges that's highly redundant. There's lots of ways two points in a network can talk to each other. With this redundancy though, you risk bridging loops. It takes the highly redundant network, trims off the redundancy, and creates a tree-like structure.

There's only one path between any two points. In order for this to work, you need to elect a switch as the "root bridge."

The next step, all other switches that aren't the root bridge have to elect a root port.

Then on every cable connecting two switches together or a cable going to a host, they have to be elected as a designated port. Everything that's non-designated gets blocked.

Root Bridge Election

  • Switch with lowest Bridge ID in the network becomes the Root Bridge.

Spanning Tree is preemptive. At any point in time, a new bridge or switch can be introduced to a nice stable network, and if that new switch is technically better than the existing root bridge, the new switch can take over that role. There are optional security measures to put in place to prevent that, but it can happen.

When a switch detects one or more of its interfaces have come up, the switch will start advertising itself as the root bridge. It sends out BPDU's saying its name and that it's ready to be a root bridge. If there's another switch that is already the root bridge, an election process will take place.

The bridge ID Contains:

  • Bridge Priority (Default: 32768)
    • range 0 to 61440 in increments of 4096.
  • System ID Extension take the 16-bit priority and add a system ID extension of:
    • 0-4095
  • MAC Address

Your Bridge ID and System ID are a combined value. The System ID is typically your VLAN number. Since it's taking up the first 4095 bits, your Bridge Priority is forced to go in increments of 4096. The only thing you can change/influence is the Bridge Priority. The System ID Extension cannot be manually changed, nor can your MAC Address.

All of those values will be combined into your Bridge ID.

The Bridge Protocol Data Unit

BPDU = Bridge Protocol Data Unit Required to determine and maintain STP topology.

image

Protocol Identifier = 0 (indicating spanning tree)
Protocol Version: 2 (Rapid Spanning Tree)
Message Type: 00 (Config BPDU to figure out the root bridge)
Flags:
Root ID: Bridge ID of the Root Switch Bridge ID: Sending Bridge ID (The current switch Bridge ID being sent out. Root ID and Bridge ID will be the same if the current switch is root)

RSTP needs special port roles and port states.

Port Roles

A port role indicated "what's my job or responsibility in regard to STP? Do I send you a BPDU? Do I receive a BPDU and forward it?" That's what a port role does.

Designated Port:

  • A port that is the closest port to root bridge. The root bridge's interfaces will always be designated ports. They deliver BPDUs.
  • Port State: Forwarding. You are allowed to transmit and receive data on these interfaces.

Root Port:

  • A port that only receives BPDU's. The other side of a root port is ALWAYS a designated port. Then to send this newly received BPDU, the next interface will then have to be a Designated Port. Dp (in+out), Rp (only input).
  • Port State: Forwarding.

Edge Port:

  • A port that is connected to a host device. By default, a switch doesn't know when an interface comes up if it's connected to another switch, router, or host. On this port, you need to add additional configuration to tell RSTP that this port is an edge port. An Edge port is ALSO a Designated Port.
  • Port State: Forwarding.

Alternate Port:

  • A port that
  • Port State: Discarding

Backup Port:

  • A port that
  • Port State: Discarding

Port States

If user data comes in, what am I going to do with that information?