I'm looking online for definitions of each, but I'm confused as some websites say STP uses only two types of flags; while others refer to TCN, TC, and TCA flags. Are they three separate types of flags? What is the use of each in STP?
802.1D STP has configuration BPDUs sent by the root bridge. The designated bridges relay these BPDUs on their designated ports. All BPDUs flow from the root. With 802.1D, a port going up or down will generate a topology change, unless portfast has been configured on the port.
When a switch detects a topology change it will generate a TCN BPDU, which is a special BPDU. This BPDU is sent on root port. This BPDU must be acknowledged by the upstream switch until the TCN eventually reaches the root.
After the TCN BPDU has reached the root bridge, the root bridge will send out configuration BPDU with TC bit set. The root does this for MaxAge + FWD_DELAY seconds which is 20 + 15 seconds by default, for a total of 35 seconds.
When the switches receive this BPDU with TC set, they will shorten the timeout of the MAC address table to flush out stale entries. The timeout is then set to 15 seconds, so stale entries will be removed but active flows will be relearned through the now active ports.
If using 802.1w then there is a synchronization process through a proposal and agreement mechanism. With RSTP, only ports moving to forwarding can create topology changes. This makes sense since only adding connectivity should be of concern.
With a RSTP switch, when it detects a change it will set the TC bit in its BPDUs, the switch receiving this BPDU will then flush all MACs learned except for the port on where the BPDU was received. This will repeat throughout the network until the topology has converged.
There are some more details in some of my blog posts: