Model-Based Testing IoT Communication via Active Automata Learning

Martin Tappler, Bernhard K. Aichernig, Roderick BloemarXiv 2019

Abstract

Testing reactive systems like IoT message brokers is challenging due to the lack of formal models. This paper presents a semi-automated approach using active automata learning to infer state machine models of MQTT broker implementations. By performing differential testing on these learned models, the authors identified 18 bugs across multiple open-source brokers, demonstrating a lower-effort alternative to traditional model-based testing.

Introduction

Testing reactive systems—such as network servers or IoT message brokers—is notoriously difficult. Traditional Model-Based Testing (MBT) requires engineers to manually translate natural-language specifications into formal, mathematical models to generate tests. This process is labor-intensive, error-prone, and often skipped in practice.

This study addresses the challenge of verifying black-box implementations of the MQTT protocol without a pre-existing formal reference model. The researchers overcome practical hurdles of network testing, including massive input spaces and asynchronous communication, by leveraging automated learning techniques.

Methodology: Active Automata Learning and Differential Testing

The core methodology relies on Active Automata Learning (specifically the TTT algorithm from the LearnLib library) and Differential Testing. Instead of manually drafting a model, the researchers use an algorithm to infer one by interacting with the system.

Overview of the learning-based bug discovery workflow.

The process follows four key stages:

  1. Abstraction via Mappers: Because network protocols have near-infinite input possibilities, "mappers" translate a small set of abstract inputs into concrete network packets and vice versa.
  2. Learning Mealy Machines: The learning algorithm interacts with a target broker to infer a deterministic Mealy machine—a state machine that produces outputs for every state transition.
  3. Equivalence Checking: Once models are learned for multiple brokers, an "on-the-fly" bisimulation check compares pairs of models to find traces where implementations produce different outputs.
  4. Manual Verification: Any trace causing a disagreement is flagged as a counterexample. A human then checks this trace against the official MQTT specification to determine which broker is at fault.

Experimental Setup

The researchers evaluated five actively developed, open-source MQTT (v3.1.1) brokers: Apache ActiveMQ, emqttd, HBMQTT, Mosquitto, and VerneMQ. To prevent state space explosion, they divided the protocol into functional subsets (e.g., basic pub/sub vs. retained messages) and learned smaller, targeted models for each. Network quiescence was handled by implementing strict timeouts; if no packet was received, the mapper recorded an "Empty" output.

Key Results and Insights

The approach successfully uncovered 18 bugs across four of the five brokers. Mosquitto was the only implementation that exhibited no faulty behavior during the tests.

Comparison of learned models for Mosquitto (a) and HBMQTT (b), highlighting behavioral differences.

Differential testing proved highly effective at bypassing the "oracle problem." If multiple implementations of the same standard disagree, at least one is likely wrong. For example, the learned models revealed that HBMQTT failed to disconnect a client that sent a second CONNECT packet, which is a strict protocol violation.

However, the study also highlighted runtime bottlenecks. Active learning over a network is slow; learning even a simple 18-state model for ActiveMQ took over 110 minutes because the system had to wait for timeouts to confirm "Empty" responses.

Conclusion and Future Work

Active automata learning combined with differential testing is a powerful, lower-effort alternative to traditional MBT for black-box reactive systems. While successful, the approach is currently limited by assumptions of system determinism and the manual effort required for final counterexample analysis.

Future work will explore algorithms capable of learning non-deterministic or timed automata to better handle real-world network unreliability. Additionally, the authors propose automating the clustering of counterexamples to further reduce the manual effort required during the debugging phase.

Summary updated

BibTeX
@misc{tappler2019model,
  author = {Martin Tappler and Bernhard K. Aichernig and Roderick Bloem},
  title = {{Model-Based Testing IoT Communication via Active Automata Learning}},
  year = {2019},
  eprint = {1904.07075},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1904.07075},
}
Figure