IoT is all about a group of devices communicating with each other and the cloud through the internet, but how is this even possible? Data that is generated by a device has to be sent to the cloud through a medium – the internet. The rules that are followed to exchange this data are called the messaging protocols.
The IoT devices use these messaging protocols at various levels for communication. There is a wide variety of protocols to choose from, in this article we will look at four of the most used protocols in today’s world namely MQTT, DDS, XMPP and HTTP. The choice of messaging protocols depends mainly on your use case. Here we will compare the protocols on the basis of a few key parameters relevant to IoT.
Contents
Protocols in Brief
MQTT
MQTT is a messaging protocol that stands for Message Queue Telemetry Transport. This messaging protocol is a publish-subscribe based messaging protocol and is extremely simple to use. It is usually used to connect a huge number of IoT devices together. This protocol is one of the most commonly used in the industry. MQTT is a message centric protocol. MQTT is known for its low power consumption and hence can save battery on IoT devices. It also sends very few data packets and hence has low network usage.
DDS
Another frequently used messaging protocol is DDS. DDS stands for Data Distribution Service. It enables scalable, real-time, reliable, high performance and interoperable data exchanges between publishers and subscribers. DDS is also a data centric protocol. DDS is also one of the only protocols that is both data centric and provides extensive support for QoS (Quality of Service).
XMPP
XMPP itself is very robust and powerful, owing mostly to its standardized and decentralized nature. It stands for Extensible Messaging and Presence Protocol. This messaging protocol is based on the Extensible Markup Language (XML). XMPP is a Message Centric protocol. It also has no provision for Quality of Service (QoS). XMPP is also extendable and adaptable, allowing for the creation of bots in the lines of IRC bots.
HTTP
HTTP stands for Hyper Text Transfer Protocol. It has been extensively used to maintain connection between a client and web-server. It sends data over in the ASCII format and hence the message sizes are comparatively bigger. HTTP is also a document centric transfer protocol.
Factors of Comparison
Here is a brief description for the factors considered in the comparison of the previously mentioned protocols.
Centricity
Centricity of a protocol defines the broad purpose and use case of that protocol. It is mainly of three types – Data Centric, Message Centric and Document Centric.
- Data Centric
In a data centric system the focus is mainly on the data defined by the user. The unit of exchange in this type of system is the data.
- Message Centric
A message centric system requires the users to share data through the exchange of messages. This makes message centric systems a little harder to maintain as it requires the user to spend time writing message handling logic
- Document Centric –
A document centric system is that system in which the major data type that gets transferred is documents. HTTP has for long been used to transfer HTML documents around the web. Essentially HTTP was built keeping in mind the transfer of documents rather than messages or data (which is important for IoT).
Quality of Service (QoS)
The Quality of Service (QoS) is an agreement between the sender of a message and the receiver of a message that defines the guarantee of delivery for a specific message. Here we will compare whether each of the protocols has a provision to support QoS software.
Transport
Software at the transport layer is responsible for establishing temporary communication sessions between two application programs, and delivering data as requested by those applications.
The Transmission Control Protocol (TCP) is used for applications in which reliable connections between hosts are necessary. TCP checks for transmission errors, lost packets, packets out of order, etc
The User Datagram Protocol (UDP), is an unreliable transport protocol with no sessions or flow control and optional error checking. UDP just sends packets as soon as requested and forgets about them. However, it is faster than TCP
In this comparison we will figure out what transfer protocols are being used in each of the protocols.
Security
IoT relies majorly on communication of data and wherever there is communication there is a requirement for security. However, the extent of this requirement can vary from one use case to another. In this article we will see how secure each of the protocols performs.
Real Time
This factor depends heavily on your use case and level of optimization that you prefer in your IoT project. Real time data (in most cases) tends to take up more space in the data base that you are storing the data in and can consume more power. Yet real time data is essential in certain cases. In this comparison we will look into whether each of these protocols supports real time data transfer.
Architecture
The architecture of a messaging protocol in IoT builds its fundamental principles; this principle describes how a protocol works and behaves under different situations. It also tells us the best way to use a particular protocol. Here we will mention the architecture of each of the protocols so that it can help you choose the best one for your use case.
Performance
The performance of a protocol can be judged by the approximate number of messages per second per subscriber or the number of requests per second (in the case of HTTP). This can be a major factor in choosing what protocol best suits your need.
Conclusion
In conclusion, we can never really pick the single best messaging protocol for all use cases. Each of them has its own unique set of pros and cons. You will have to carefully go through its features and decide what’s best for you. However, in my opinion MQTT and DDS are 2 of the best available messaging protocols. MQTT is the most used in the industry at the moment and hence has a lot of support. However DDS is known for its speed and security which is useful most often.
This article is my attempt at making the decision making process simpler. I hope this article helped you choose the right protocol for your project.