The Internet of Things (IoT) and the number of deployed IoT devices are growing exponentially nowadays. These devices play a pivotal role in diverse domains, including smart homes and connected health, undertaking vital functions like monitoring indoor pollutants. Given their constrained processing and memory capacities, IoT devices engage in communication with each other, as well as with edge devices and cloud servers, through specialized protocols.
The two main protocols for communications among IoT devices are the Constrained Application Protocol (CoAP) and Message Queuing Telemetry Transport (MQTT). Many organizations have implemented these protocols in different programming languages, different libraries/frameworks, as closed or open source. By March 1, 2023, there were 35 public libraries of CoAP and 40 of MQTT. These libraries have different characteristics, like levels of completeness and runtime performances.
In an era marked by the rapid expansion of demands across diverse IoT domains, the need for IoT applications increases correspondingly. Because of diverse and complex user requirements in different domains, it is impractical to assume that all software applications uniformly adhere to the same protocol. Consequently, developers tasked with programming software for IoT devices encounter the challenge of selecting the suitable protocol, such as MQTT or CoAP, and determining its libraries (e.g., Californium, java-coap, Paho MQTT, or HiveMQ MQTT Client). To the best of our knowledge, comprehensive and clear comparisons of the API and performance of these existing protocols and their implementations are lacking, leaving developers without the necessary insights to make well-informed choices.
In this thesis, we implement multiple IoT scenarios by employing the CoAP and MQTT protocols along with various implementations, subsequently subjecting them to a comprehensive comparative analysis in terms of API and performance metrics encompassing both static metrics, packet size, and runtime metrics evaluation. Our findings reveal that among the four libraries, HiveMQ MQTT Client demonstrates superior performance in static metrics, while java-coap exhibits the smallest packet size. Drawing upon our examination of the two protocols and their respective implementations, we conclude that CoAP and its java-coap implementation is faster than MQTT.
We thus provide developers software for IoT devices with evidence of the CoAP and MQTT protocols and their libraries. Moving forward, our aspiration is to broaden the scope of this research to encompass additional communication protocols and IoT frameworks, while also exploring diverse software characteristics and metrics.