Got it

Understanding of STP - STP Topology Calculation Highlighted

Latest reply: Aug 8, 2021 13:33:24 679 28 27 0 4

OBJECTIVE


The purpose of this post is to present an introduction to the STP Topology Calculation.


After all devices on the network are enabled with STP, each device considers itself the root bridge. Each device only transmits and receives BPDUs but does not forward user traffic. All ports are in the Listening state. After exchanging configuration BPDUs, all devices participate in the selection of the root bridge, root port, and designated port.


BPDU Exchange


As shown in Figure 1, the quadruple marked with {} indicates a set of ordered vectors: root BID (S1_MAC and S2_MAC indicates the BIDs of two devices), total path costs, sender BID, and Port ID. Configuration BPDUs are sent at intervals set by the Hello timer.


08

Figure 1 - Exchange of initialization messages


STP algorithm imlementation


1. Initialization


As each bridge considers itself the root bridge, the value of the root BID field in the BPDU sent by each port is recorded as its BID. The value of the Root Path Cost field is the accumulative cost of all links to the root bridge; the sender BID is the ID of the local bridge; the Port ID is the PID of the local bridge port that sends the BPDU.


2. Root bridge selection


During network initialization, every device considers itself as the root bridge and the root bridge ID as the device ID. Devices exchange configuration BPDUs to compare the root bridge IDs. The device with the smallest BID is elected as the root bridge.


3. Root port and designated port selection


Table 1 lists the process of selecting the root port and designated port.


No.Procedure
1

The non-bridge device uses the port that receives the optimal configuration BPDU as the root port. Table 2 lists the process of selecting the optimal configuration BPDU.

2

The device calculates a BPDU for each designated port based on the BPDU and path

cost of the root port.


  • The root bridge ID is replaced with the root bridge ID of the BPDU on the root interface.


  • The root path cost is replaced with the root path cost in the BPDU on the root interface plus the path cost of the root interface.


  • The sender BID is replaced with the device ID.


  • The designated port ID is replaced with the port ID.

3

The device compares the calculated BPDU with the BPDU on the port:


  • If the calculated BPDU is of higher priority, the port is selected as the designated port and its BPDU is replaced by the calculated BPDU. The port periodically sends the calculated BPDU.


  • If the BPDU of the port is of higher priority, the BPDU on the port is not updated and the port is blocked. The port only receives BPDUs, and does not forward data or send BPDUs.


Table 1 - lists the process of selecting the root port and designated port


No.Procedure
1

Each port compares the received BPDU with its BPDU:


  • If the received BPDU has a lower priority, the port discards the received BPDU and does not process its BPDU.


  • If the received BPDU has a higher priority, the port replaces its BPDU with the received BPDU.

2

The device compares BPDUs on all the ports and selects the optimal BPDU.

Table 2 - Selecting the optimal BPDU


STP Calculation Example


When the root bridge, root port, and designated port are selected successfully, the whole tree

topology is set up. The following example describes STP calculation.


09


Figure 2 - STP networking and topology after


As shown in Figure 2, priorities of DeviceA, DeviceB, and DeviceC are 0, 1, and 2, and the path costs between DeviceA and DeviceB, between DeviceA and DeviceC, and between DeviceB and DeviceC are 5, 10, and 4 respectively.


1. Initial state of each device


Table 3 lists the initial state of each device.


DevicePort NameBPDU
DeviceAPORT A1{0, 0, 0, Port A1}
PORT A2 {0, 0, 0, Port A2}
DeviceBPORT B1{1, 0, 1, Port B1}
PORT B2{1, 0, 1, Port B2}
DeviceCPORT C1{2, 0, 2, Port C1}
PORT C2{2, 0, 2, Port C2}


Table 3 - Initial state of each device


2. Comparison and result


Table 4 lists the comparison and result.


i_f42.gifThe fields in the BPDU represent {root bridge ID, accumulative root path cost, sender BID, transmit port ID PID}.


DeviceComparisonBPDU After Comparison
DeviceA
  • Port A1 receives the BPDU {1, 0, 1, Port B1} from Port B1 and finds that its BPDU {0, 0, 0, Port A1} has higher priority than the BPDU {1, 0, 1, Port B1} from Port B1 , so Port A1 discards the BPDU {1, 0, 1, Port B1}.


  • Port A2 receives the BPDU {2, 0, 2, Port C1} from Port C1 and finds that its BPDU {0, 0, 0, Port A2} has higher priority than the BPDU {2, 0, 2, Port C1} than so Port A2 discards the BPDU {2, 0, 2, Port C1}.


  • After finding that both the root and the designated switches are itself in the BPDU on each port, DeviceA considers itself as the root. Switch A then sends BPDUs from each port periodically without modifying the BPDUs.

  • Port A1: {0, 0, 0, Port A1}


  • Port A2: {0, 0, 0, Port A2}

DeviceB
  • Port B1 receives the BPDU {0, 0, 0, Port A1} from Port A1 and finds that its BPDU {0, 0, 0, Port A1} has higher priority than the BPDU {1, 0, 1, Port B1}, so Port B1 updates its BPDU.


  • Port B2 receives the BPDU {2, 0, 2, Port C2} from Port C2 and finds that its BPDU {1, 0, 1, Port B2} has higher priority than the BPDU {2, 0, 2, Port C2}, so Port B2 discards the BPDU {2, 0, 2, Port C2}.

  • Port B1: {0, 0, 0, Port A1}


  • Port B2: {1, 0, 1, Port B2}

  • DeviceB compares the BPDU on each port and finds that the BPDU on Port B1 has the highest priority, so Port B1 is used as the root port and the BPDU on Port B1 remains unchanged.



  • DeviceB calculates the BPDU {0, 5, 1, Port B2} for Port B2 based on the BPDU and path cost of the root port, and compares the BPDU {0, 5, 1, Port B2} with its BPDU {1, 0, 1, Port B2} on Port B2. Device B finds that the calculated BPDU has higher priority, so Port B2 is used as the designated port, and its BPDU is replaced by the calculated BPDU and the calculated BPDU is sent periodically.

  • Root port (Port B1): {0, 0, 0, Port A1}


  • Designated port (Port B2): {0, 5, 1, Port B2}

DeviceC
  • Port C1 receives the BPDU {0, 0, 0, Port A2} from Port A2 and finds that the BPDU {0, 0, 0, Port A2} has higher priority than its BPDU {2, 0, 2, Port C1}, so Port C1 updates its BPDU.


  • Port C2 receives the BPDU {1, 0, 1, Port B2} from Port B2 and finds that the BPDU {1, 0, 1, Port B2} has higher priority than its BPDU {2, 0, 2, Port C2}, so Port C2 updates its BPDU.

  • Port C1: {0, 0, 0, Port A2}


  • Port C2: {1, 0, 1, Port B2}

  • DeviceC compares the BPDU on each port and finds that the BPDU on Port C1 has the highest priority, so Port C1 is used as the root port and the BPDU on Port C1 remains unchanged.


  • DeviceC calculates the BPDU {0, 10, 2, Port C2} for Port C2 based on the BPDU and path cost of the root port, and compares the BPDU {0, 10, 2, Port C2} with its BPDU {1, 0, 1, Port B2} on Port C2. DeviceC finds that the calculated BPDU has higher priority, so Port C2 is used as the designated port and its BPDU is replaced by the calculated BPDU.

  • Root port (Port C1): {0, 0, 0, Port A2}


  • Designated port (Port C2): {0, 10, 2, Port C2}

  • Port C2 receives the BPDU {0, 5, 1, Port B2} from Port B2 and finds that the BPDU {0, 5, 1, Port B2} has higher priority than its BPDU {0, 10, 2, Port C2}, so Port C2 updates its BPDU.


  • Port C1 receives the BPDU {0, 0, 0, Port A2} from Port A2 and finds that the BPDU {0, 0, 0, Port A2} is the same as its BPDU, so Port C1 discards the received BPDU.

  • Port C1: {0, 0, 0, Port A2}


  • Port C2: {0, 5, 1, Port B2}

  • DeviceC finds that the root path cost of Port C1 is larger than the root patch cost of Port C2, so the BPDU on Port C2 has higher priority than that on Port C1. Port C2 is used as the root port and its BPDU remains unchanged. The root path cost of Port C1 is 10 (root path cost 0 in the BPDU plus the link patch cost 10), and the root path cost of Port C2 is 9 (root path cost 5 in the BPDU plus the link patch cost 4).


  • DeviceC calculates the BPDU {0, 9, 2, Port C1} for Port C1 based on the BPDU and path cost of the root port, and compares the BPDU {0, 9, 2, Port C1} with its BPDU {0, 0, 0, Port A2} on Port C2. DeviceC finds that its BPDU has higher priority, so Port C1 is blocked and its BPDU remains unchanged. Port C1 does not forward data until STP recalculation is triggered. For example, when the link between DeviceB and DeviceC is Down, STP recalculation is triggered.

  • Blocked port (Port C1): {0, 0, 0, Port A2}


  • Root port (Port C2): {0, 5, 1, Port B2}


Table 4 - Topology calculation and result


After the topology becomes stable, the root bridge still sends configuration BPDUs at intervals set by the Hello timer. Each non-root bridge forwards the received configuration BPDUs by using its designated port. If the priority of the received BPDU is higher than that on the non-root bridge, the non-root bridge updates its own BPDU based on the information carried in the received BPDU.


STP Topology Changes


Figure 3 shows the packet transmission process after the STP topology changes.


10


Figure 3 - Diagram of packet transmission after the topology changes


  1. After the network topology changes, a downstream device continuously sends TCN BPDUs to an upstream device.


  2. After the upstream device receives TCN BPDUs from the downstream device, only the designated port processes them. The other ports may receive TCN BPDUs but do not process them.


  3. The upstream device sets the TCA bit of the Flags field in the configuration BPDUs to 1 and returns the configuration BPDUs to instruct the downstream device to stop sending TCN BPDUs.


  4. The upstream device sends a copy of the TCN BPDUs to the root bridge.


  5. Steps 1, 2, 3 and 4 are repeated until the root bridge receives the TCN BPDUs.


  6. The root bridge sets the TC bit of the Flags field in the configuration BPDUs to 1 to instruct the downstream device to delete MAC address entries.


i_f42.gif

  • TCN BPDUs are used to inform the upstream device and root bridge of topology changes.

  • Configuration BPDUs with the TCA bit being set to 1 are used by the upstream device to inform the downstream device that the topology changes are known and instruct the downstream device to stop sending TCN BPDUs.

  • Configuration BPDUs with the TC bit being set to 1 are used by the upstream device to inform the downstream device of topology changes and instruct the downstream device to delete MAC address entries. In this manner, fast network convergence is achieved



--- End

Nice
View more
  • x
  • convention:

Awesome material.
Very complex.
It's favorited to read again
View more
  • x
  • convention:

andersoncf1
andersoncf1 Created May 1, 2021 18:01:43 (0) (0)
Thanks bro  

very nice, thanks for sharing!

View more
  • x
  • convention:

Thanks for sharing
View more
  • x
  • convention:

To be highlighted, that's great
View more
  • x
  • convention:

EL.BODO
EL.BODO Created May 8, 2021 20:47:33 (0) (0)
✌  
Interesting to know.
View more
  • x
  • convention:

andersoncf1
andersoncf1 Created May 1, 2021 18:02:10 (0) (0)
Thanks dear  
Thanks for sharing my friend!
Show!
View more
  • x
  • convention:

GOOD JOB
View more
  • x
  • convention:

EL.BODO
EL.BODO Created May 8, 2021 20:48:02 (0) (0)
✌  
nice
View more
  • x
  • convention:

123
Back to list

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.