STP/ RSTP/ PVSTP

STP (Spanning Tree Protocol) 802.1D

STP is used to prevent L2 loops and at the same time provide redundancy. STP prevents loops in the network by assigning either the blocking or forwarding state on the ports. Hence with these two states STP provide redundancy as well as preventing loops in the network. This mechanism guarantees that there is one and only one active path between two network devices.


 

BPDU

BPDU are the messages which are exchanged between two switches. They are used to identify loops in the network as well as help in preventing them. Two types of BPDU are available configuration and topology change notification (TCN) BPDU. So when switch is in the election process it uses configuration BPDU, and TCN when there is a change occurs in the network. The default BPDU timer is 2 sec.


 

Bridge ID

Bridge ID has two parts BRIDGE PRIORITY & MAC Address. Bridge priority is a 2 Byte value ranges from 0-65535 and has the default value of 32768.


 

STP Timers:

STP uses 3 types of timers

  • Hello: The time taken by Root Bridge to send configuration BPDU. Default Hello timer is 2 Sec.
  • Forward delay: Time between the different port states of STP. Default Forward Delay timer is 15 Sec.
  • Max Age: Time for which the switch will keep the information received from the root in its memory. Default Max Age timer is 20 Sec.


 

STP works

When a switch first power up it assumes that it is the Root Bridge itself and switch begins by sending out BPDUs with a Root Bridge ID and Sender ID equal to its own Bridge ID. As the BPDU goes out through the network, each switch compares its own BPDU with the one that switch receives from the neighbours. The comparison is done on bridge ID. When a switch hears of a better Root Bridge (lower bridge ID), it replaces its own Root Bridge ID with the Root Bridge ID announced in the BPDU although it still identifies itself as the Sender Bridge ID. After sometime the switch with the lowest bridge ID in the network wins this Root Bridge election process.

  • STP Rule 1: All ports of the root bridge will be in forwarding mode.
    • Next, each switch determines the best path to get to the root. The switches determine this path based on Root Path Cost. This value is the cumulative cost of all the links leading to the Root Bridge. The switch uses the port with the least Root Path Cost in the BPDU in order to get to the root switch; the port with the least Root Path Cost in the BPDU is the root port.
  • STP Rule 2: The root port must be set to forwarding mode.
    • In addition, the switches on each LAN segment communicate with each other to determine which switch is best to use in order to move data from that segment to the root bridge and this determination is based on the lowest cumulative Root Path Cost to the Root Bridge. And the port is called the designated port.
  • STP Rule 3: The designated port must be set to forwarding mode.
  • STP Rule 4: All the other ports in all the switches must be placed in blocking mode.


 

If two or more links might identical Root Path Costs then that will results in a tie condition. All tiebreaking STP decisions are based on the following sequence of four conditions:

  • Lowest Root Bridge ID
  • Lowest Root Path Cost to Root Bridge
  • Lowest Sender Bridge ID
  • Lowest Sender Port ID


 

STP PORT STATE:

  • Blocking:

    All the port by default on a switch will be in the blocking state. In blocking state we are only allowed to receive BPDU. We can't build our MAC Table at this state.

  • Listening:

    If the port on the switch is administratively enabled it move to listening state. At this state it can receive and transmit BPDU. Hence it involved in the election of Root Bridge. This state has a timer enabled which has to be elapsed before getting to the next state. This timer is called as forward delay timer and its default value is 15sec.

  • Learning:

    At this state port can receive and transmit BPDU and also can start building MAC table. But it can't receive or transmit data frames at this state. This state also has forward delay timer and the default value of the timer is 15sec.

  • Forwarding:

    At this state port can receive and transmit BPDU & DATA Frames and also we will continue to build our MAC table.


 

STP PORT ROLE

  • Root port

    The most trusted port on the non root bridge is designed as root port. This port is closed to the root bridge.

  • Designated port

    Designated port is the port that has the most trusted information or we can say designated port transmits the most trusted BPDU. Designated port sends BPDU to the root port.

  • Blocking port
    • Alternate port

      This port receives the better BPDU from another bridge.

    • Backup port

      This port receives the better BPDU from the same bridge.


 

RSTP (Rapid Spanning Tree Protocol) 802.1w

It has bundled 802.1d with some additional features which are used to speed up the boot up time of the switch. The additional features are uplink fast, backbone fast, port fast.


 

PORT STATE                PORT ROLE

Discarding                Root

Learning                Designated

Forwarding                Blocking (Alternate, Back-up)


 

ENHANCEMENT

  • Non-root Bridge can generate BPDU

    In RSTP non-root port are allowed to generate the BPDU and they generate the BPDU on every hello second which is by default sets to 2sec. we use this method to enable fast aging process i.e. if a switch misses the 3 hello BPDU from the non root-bridge it will remove all the path learned via that switch.

  • Back-bone fast (inferior BPDU)

    If the link between any two switches fails, and they don't have any other link to reach out. In such case they use inferior BPDU. So as soon as a switch sees that my best BPDU is not receiving it switches its path from best one to inferior one. And allow network to convergence fast.

  • Port-fast

    In this switch is defined by two additional ports edge & point-to-point port.

    • Edge-port is a port which doesn't have any L2 device connected to it. It means it can have a PC connecting to it. So, in such the port will move directly from blocking state to forwarding and hence preventing listing and learning state i.e. saving 30secs. And whenever a port fast port receives a BPDU, the port fast feature will get disabled and normal STP process will take place.
    • Point-to-point link is a link which has only 2 switch connected, even in such situation we can skip listing and learning stage and can save 30secs. The switch will identify the Point-to-point link if their ports are in full-duplex mode.
  • Uplink fast

In this method if switch root port gets down then we can use alternate port to reach to the destination. Hence we can speed up the conversation.


 

Loop Guard

The loop guard is intended to provide additional protection against L2 forwarding loops (STP loops). An STP loop is created when an STP blocking port in a redundant topology erroneously transitions to forwarding state. This usually happens because one of the ports of a physically redundant topology (not necessarily the STP blocking port) stopped receiving STP BPDUs.

In its operation, STP relies on continuous reception or transmission of BPDUs, depending on the port role (designated port transmits, non-designated port receives BPDUs).

When one of the ports in a physically redundant topology stops receiving BPDUs, the STP conceives the topology as loop free. Eventually, the blocking port from the alternate or backup port becomes designated, and moves to forwarding state, thus creating a loop.

With the loop guard, an additional check is made. If BPDUs are not received any more on a non-designated port and the loop guard is enabled, that port will be moved into the STP loop-inconsistent blocking state instead of moving to the forwarding state. Without the loop guard, the port would assume the designated port role and move to STP forwarding state, and thus create a loop.

Loop guard should be enabled on the non-designated & blocking ports (more precisely, on root and alternate ports) for all possible combinations of active topologies.


 

Root guard

The root guard feature is used to enforce the root bridge placement in the network.

The root guard ensures that the port on which root guard is enabled is the designated port. If the bridge receives superior STP Bridge Protocol Data Units (BPDUs) on a root guard-enabled port, root guard moves this port to a root-inconsistent STP state. This root-inconsistent state is effectively equal to a listening state. No traffic is forwarded across this port. In this way, the root guard enforces the position of the root bridge.

Whenever the root guard feature is enabled, no traffic passes through the root-inconsistent STP port in this state. After device ceases to send superior BPDUs, the port is unblocked again. Via STP, the port goes from the listening state to the learning state, and eventually transitions to the forwarding state. Recovery is automatic; no human intervention is necessary.

You must enable root guard on all ports where the root bridge should not appear. In a way, you can configure a perimeter around the part of the network where the STP root is able to be located.


 

BPDU Guard

Whenever we have a port fast feature enabled, the port will directly go in forwarding state from blocking but when it encounters a BPDU on that port it will loose its port fast feature and will start working as normal STP. But if we have BPDU Guard enabled on that interface the port will not disabled port fast where as it will shut down that port for further communication.


 

PVST (Per-VLAN Spanning Tree)

Per-VLAN Spanning Tree (PVST) is a CISCO proprietary version of STP and maintains a spanning tree instance for each VLAN configured in the network. It uses ISL Trunking and allows a VLAN trunk to be forwarding for some VLANs while blocking for other VLANs. Since PVST treats each VLAN as a separate network, it has the ability to load balance traffic (at layer-2) by forwarding some VLANs on one trunk and other VLANs on another trunk without causing a Spanning Tree loop.


 

PVST+ (Per-VLAN Spanning Tree Plus)

Per-VLAN Spanning Tree Plus is a proprietary version of STP that allows devices to interoperate with both PVST and CST. In networks where PVST and CST coexist, interoperability problems occur because each requires a different trunking method, so BPDUs are never exchanged between STP types and CST.

To do this, PVST+ acts as a translator between groups of CST switches and groups of PVST switches. PVST+ can communicate directly with PVST by using ISL trunks. To communicate with CST, however, PVST+ exchanges BPDUs with CST as untagged frames over the native VLAN.

0 comments: