State
The remembered condition of the protocol endpoint right now. A client in the wrong state must reject some events.
Build and test the state, event, guard, action, timer, and context pattern behind IoT protocol behaviour
State machines are not just diagrams. They are the rules an IoT client uses to decide which event is legal, which timer is running, what packet must be sent, and what context must be remembered before the next step.
The remembered condition of the protocol endpoint right now. A client in the wrong state must reject some events.
A packet, timer, API call, or link failure that asks the model to move. The same event can be valid in one state and invalid in another.
The guard checks whether the transition is allowed. The action updates context, sends packets, starts timers, or reports an error.
Real implementations keep IDs, retry counts, credit, timers, and pending acknowledgements. Without context, the diagram is incomplete.
Choose a protocol lens, run a guided event path, then test what happens when an invalid or timeout event arrives.
A simplified teaching model for connection and one QoS 1 publish. MQTT QoS packet state is separate from the TCP connection lifecycle.
The diagram is simplified to teach the state-machine pattern. It is not a complete normative state diagram for every packet and error in the specifications.
MQTT connection state, subscription state, session state, and QoS packet state should not be collapsed into one state variable in a real client.
CoAP Message ID handles duplicate detection while Token matches request and response. AMQP uses nested endpoints and settlement state, not one flat connection state.
Run the normal path. Say the current state, event, guard, action, and next state out loud before stepping.
Switch to Timeout. Watch which timer fires and which context value changes. Explain why retry is an action, not a state by itself.
Use Try invalid from each protocol lens. Identify whether the client should ignore, reject, close, or surface the event to application code.
Use this fundamentals page first, then move into the more specific protocol state-machine pages.
Compare timers, errors, state variables, and implementation notes across protocols.
Trigger valid and invalid events and watch event history across MQTT, CoAP, and AMQP.
Explore clickable protocol diagrams and detailed transition explanations.
The model uses simplified teaching paths, with terminology cross-checked against the protocol specifications below.