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 :
Picture taken from http://www.tcpipguide.com/free/t_TCPOperationalOverviewandtheTCPFiniteStateMachineF-2.htmÂ
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 :
http://www.ieee802.org/1/files/public/docs2000/1wProposedStateDiagrams041.pdf