I am trying to implement IEEE 802.1D. I know how the root bridge id is elected. Initially, every switch will advertise that they are the root bridge. Next, it will check whether the bridge ID received in BPDU is lower than it's bridge ID or not. Based on which has a lower bridge Id, it will either forward or stop advertising the root bridge ID. I can implement this part in Python. However, I am unsure when will I know when the election is over. Like, how will I know that each device knows the root bridge ID in the network? Once it is completed, I can assign ports block, forwarding based on root path cost.