Great approach of understanding how the protocol or program should work is to check it’s FSM – Finite State machine.
It describes the processes of protocol, where it starts and how and where it ends.
STATE 1 -> STATE2 -> STATE3.
For example we can check the TCP FSM :
In picture above we can see the procedure of syn, synack, ack. Also we can see how connection is being closed using Fin or timeouts.
By following link below you can find an overview of RSTP state machine :