How RSTP works

Just like STP, RSTP creates a topology database of the network. To prevent loops, some interfaces on switches are placed in forwarding state and other interfaces in discarding state. How does RSTP decides in which state the port will be placed? A couple of criteria exist:

1. all switches in a network elect a root switch. All working interfaces on the root switch are placed in forwarding state.
2. all other switches, called nonroot switches, determine the best path to get to the root switch. The port used to reach the root switch (root port) is placed in forwarding state.
3. on the shared Ethernet segments, the switch with the best path to reach the root switch is placed in forwarding state. That switch is called the designated switch and its port is known as the designated port.
4. all other interfaces are placed in discarding state and will not forward frames.

NOTE
RSTP is backwards-compatible with STP and they both can be used in the same network.

 

Consider the following example:

How RTSP works

Let’s say that SW1 is elected as the root switch. All ports on SW1 are placed in forwarding state. SW2 and SW3 choose ports with the lowest cost to reach the root switch to be the root ports. These ports are also placed in forwarding state. On the shared Ethernet segment between SW2 and SW3, port Fa0/1 on SW2 has the lowest cost to reach the root switch. This port is placed in forwarding state. To prevent loops, port Fa0/1 on SW3 is placed in discarding state. If the root port on SW3 fails, this alternate port will quickly take over and become the root port.

NOTE
RSTP also introduces a concept of backup port. This port serves as a replacement for the designated port inside the same collision domain. This can only occur when using hubs in your network.