In 2023, Statista estimated that 15.14 billion Internet of Things (IoT) devices existed worldwide, to become 29.4 billion in 2030 [1]. These IoT devices find applications across many domains, performing a range of critical tasks such as patient monitoring, forest fire control, and search and rescue missions. As they have become prevalent in our daily lives, there is a growing demand for developers to create and implement software systems for these IoT devices. These IoT applications run on devices or cloud servers communicating via different protocols. The two prominent protocols for IoT communication are the Constrained Application Protocol (CoAP) [2] and Message Queuing Telemetry Transport (MQTT) [3], which are designed for IoT devices with limited capabilities [4], such as limited battery and processing resources.

CoAP and MQTT are two standards, RFC7252 [2] and ISO/IEC 20922 [5], that have been implemented by different organisations in different programming languages, both as closed and open source. For example, the Eclipse Foundation [6] provides Californium and Paho MQTT open-source libraries in Java of CoAP and MQTT, respectively. The IBM Watson IoT Platform Message Gateway[7] provides an implementation of MQTT.

By Mar. 1st, 2023, there were 35 reported libraries of CoAP [8] and 40 of MQTT [9], with different characteristics, like levels of completeness and runtime performances. We studied and finally selected the four libraries: Californium [11], java-coap [12], HiveMQ MQTT Client [13], Paho MQTT [14].

We Collected, devised, and implemented scenarios using the chosen libraries. We Collected static metrics (LOC, CBO, CC, LCOM) on the implemented senders and receivers. We analysed packet sizes theoretically and practically. In addition, we collected runtime performances (goodput, throughput, overhead) when running the scenarios.

Finally, HiveMQ MQTT Client performs well in our static metrics. In addition, we found that in our experiment, java-coap uses the least packet size, but the Californium library is actively maintained, we concluded that the libraries of CoAP in our experiment use less packet size, and run faster. But we recommend HiveMQ MQTT Client for the ease of its usage.


[1] Statista. Number of Internet of Things (IoT) connected devices worldwide from 2019 to 2030(in billions), 2022.

[2] Shelby, Zach and Hartke, Klaus and Bormann, Carsten. The constrained application protocol (CoAP), 2014.

[3] MQTT: The Standard for IoT Messaging, 2022.

[4] Marwa O. Al Enany, Hany M. Harb, and Gamal A. Attiya. Comparative analysis of MQTT and IoT application protocols. International Conference on Electronic Engineering (ICEEM), pages 1–6, 2021. IEEE CS Press.

[5], as of March 1st, 2023

[6], as of March 1st, 2023

[7], as of March 1st, 2023

[8], as of March 1st, 2023

[9], as of March 1st, 2023

[10], as of March 1st, 2023

[11], as of March 1st, 2023

[12], as of March 1st, 2023

[13], as of March 1st, 2023

[14], as of March 1st, 2023