At differnet layers, IoT and connected devices uses different communication and messaging protocols. While developing an IoT device, the selection of the protocol largely depends on the type, layer and function to be performed by the device.
In today’s time, networking with smart devices and IoT is increasing largely due to the ongoing technological revolution across the globe. People are increasingly using IoT and connected devices to automate industrial operations, control city traffic, track health, control home appliances, manage the fleet of vehicles, etc. Smart devices like phones, wearable devices, kiosks, appliances, and automobiles use the internet to connect with other devices and exchange information and data with servers to perform different operations.
There are two ways these devices can connect to the internet. Some devices may connect through a gateway, while others may have network capability built into the devices itself. It is interesting to note here that for establishing the connection with the internet, these devices use messaging and communication protocols at each layer of the Open Systems Interconnection (OSI) model. Depending on the function of the device, the communication protocol at each layer varies.
When it comes to selecting a protocol for the application layer of the IoT system, there are several protocols available. However, the most common types of IoT application protocols include, MQTT, XMPP, DDS, AMQP, and CoAP.
MQTT (Message Queue Telemetry Transport)
MQTT is a machine-to-machine (M2M) protocol. It is a publish-subscribe-based messaging protocol, used to communicate device data to the servers. The main purpose of MQTT is to manage IoT devices remotely. It is mainly used when a huge network of small devices needs to be monitored or managed via Internet i.e. parking sensors, underwater lines, energy grid, etc.
It should be noted that not all control packets have the variable headers and payload. A payload can be up to 256 MB. The small header overhead in MQTT makes this protocol appropriate for IoT.
- Lightweight for constrained networks
- Flexibility to choose Quality of Services with the given functionality
- Standardized by OASIS Technical Committee
- Easy and quick to implement
- High power consumption due to the TCP-based connection
- Lack of encryption
A parking lot where there are a number of parking sensors installed to identify the number and location of empty or vacant parking spots.
XMPP (Extensible Messaging and Presence Protocol)
XMPP was originally developed as a messaging protocol known as Jabber. It uses an XML format for messaging. The main feature of this protocol is its addressing mechanism. It identifies the devices/nodes in the IoT network using the address known as Jabber ID (JID). JID follows the standard i.e. [email protected] This addressing mechanism enables two nodes to exchange information, regardless of how far the nodes are in the network.
XMPP messages are usually transmitted over the underlying TCP connection. It uses a polling mechanism to identify the destination of the message. XMPP is implemented using a client-server architecture. The client starts an XML stream by sending an opening <stream> tag. The server then replies with an XML stream back to the client. Since XMPP is an open protocol, anyone can have their own XMPP server in their network without necessarily connecting to the internet.
- Addressing scheme to identify devices on the network
- Client-server architecture
- Text-based messaging, no end-to-end encryption provision
- No Quality of Service provision
- A smart thermostat that can be accessed from a smartphone via a web server.
- A gaming console with instant messaging between the two online players.
DDS (Data Distribution Service)
DDS is also based on a publish-subscribe model. DDS connects the devices directly, unlike MQTT, which connects them to the server. This is why DDS is faster than MQTT. Apparently, it can deliver millions of messages to a number of different receivers in seconds as it eliminates the communication with the server. DDS can be utilized for providing device-to-device communication over the data bus.
It provides detailed Quality of Service and reliability.
- Based on a simple “publish-subscribe” communication paradigm
- Flexible and adaptable architecture that supports “auto-discovery” of new or stale endpoint applications
- Low overhead — can be used with high-performance systems
- Deterministic data delivery
- Dynamically scalable
- Efficient use of transport bandwidth
Military systems, wind farms, hospital integration, medical imaging, asset-tracking systems and automotive test and safety.
AMQP (Advanced Message Queuing Protocol)
Advanced Message Queuing Protocol (AMQP) is an open standard application layer protocol for sending transactional messages between servers. As a message-centric middleware, it can process thousands of reliable queued transactions.
AMQP is focused on not losing messages as messages can be transferred using TCP or UDP. The use of TCP provides a reliable point-to-point connection. Further, endpoints must acknowledge the acceptance of each message. The standard also describes an optional transaction mode with a formal multiphase commit sequence. True to its origins in the banking industry, AMQP focuses on tracking messages and ensuring each message is delivered as intended, regardless of failures or reboots.
- Messages can be sent over TCP and UDP
- Provides end-to-end encryption
- Relatively high resource utilization i.e. power and memory usage
AMQP is mostly used in business messaging. It usually defines devices like mobile handsets, communicating with back-office data centers.
CoAP (Constrained Application Protocol)
CoAP is an application layer protocol with a client-server architecture. It is a document transfer protocol, which runs over UDP (User Datagram Protocol). It is specifically developed for the resource-constrained devices. Clients and servers communicate through connectionless datagrams. It is useful in low power application as it uses minimal resources. DTLS (derivation of SSL protocol) can be used for security of the messages.
- Use of DTLS for security
- Fast device-to-device communication
- Smaller packet size
- Well-designed protocol
- No broadcast message facility as it is a one-to-one protocol
- Reliability is application’s responsibility
Smart energy grids and smart homes.
All the above-listed protocols are uniquely applicable to different operating scenarios. Any protocol can be handpicked based on their pros and cons for IoT application development. The main factors to consider while choosing any one of them for your application is quality of service, security, and reliability your application requires.