Protocol State Machine Playground
Trigger protocol events and watch MQTT, CoAP, and BLE state machines respond
Protocol State Machine Playground
Trigger protocol events and watch the state diagram, message trace, retry counters, and diagnosis update. The aim is to see why robust protocols define legal transitions instead of relying on ad hoc if/else behavior.
Goal
Learn how protocol state machines accept valid events, reject illegal ones, and recover from loss.
Try First
Run MQTT QoS 1 Publish. Step through CONNECT, CONNACK, PUBLISH, timeout, retransmit, and PUBACK.
Watch
The active node, highlighted transition, message log, retry counter, and diagnosis change together.
Why It Matters
State machines prevent stuck connections, unsafe retries, duplicate confusion, and undefined recovery paths.
State Diagram
Nodes are states. Arrows are legal transitions. The orange marker shows the most recent movement.
State Detail
Select or step through a state to see its purpose and valid events.
Message Trace
The trace records packets, timeouts, retransmissions, and rejected events.
Recovery Diagnosis
The model is ready for the first event.
Beginner Ramp
A state machine has one active state, a set of events, and transition rules. If an event is not valid from the current state, the implementation should reject or ignore it deliberately.
Teaching Model
This playground simplifies full specifications. Real implementations also manage packet identifiers, inflight windows, timers, authentication, session storage, and library-specific callbacks.
MQTT Accuracy
QoS 1 uses PUBLISH and PUBACK for at-least-once delivery. QoS 2 uses PUBLISH, PUBREC, PUBREL, and PUBCOMP to avoid duplicate application delivery.
CoAP Accuracy
CoAP confirmable messages use Message IDs, ACKs, and retransmission timers over UDP. A separate response may acknowledge first and deliver the response later.
BLE Accuracy
BLE roles are asymmetric: peripherals advertise and centrals scan and initiate. This model shows the link-establishment story, not every controller substate.
Debugging Rule
When a protocol gets stuck, ask: current state, expected event, received event, timer status, retry count, and whether a transition is missing or illegal.
Practice 1
Run MQTT QoS 1 Publish and trigger an illegal SUBACK before SUBSCRIBE. What protects the state machine?
Practice 2
Run CoAP Retry. Use timeout and retransmit until failure. Why is a retry limit necessary?
Practice 3
Run BLE Connection and trigger supervision timeout. Which side can initiate the original connection?