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.
IoT devices work by fetching data from users, either through input devices such as touch screens or sensors used for motion detection, temperature, humidity, pressure, etc. This data is then sent to the data servers for storage and processing, and the resulting information is provided to the end user devices for analysis and control.
To understand this, let us consider an example of a Smart Home setup. A typical smart home consists of devices like thermostat, door sensor, smart bulbs, smart refrigerator, smart TV, surveillance systems, etc. These devices are connected to the internet directly or to the gateway, which is further connected to the end user’s smartphone, mobile application or data center and vice-versa.
IoT Protocol Stack
There are many protocols used in an IoT ecosystem at different layers of an OSI Model. However, the usage of a protocol is based on the type of application and its functionality. Usually, it is preferred to use low-powered protocols like 6LoWPAN, Bluetooth BLE, ZigBee, etc. Another deciding factor in choosing a protocol is the distance range for the communication of the IoT devices i.e. in inches or meters or miles.
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.
DOWNLOAD CASE STUDY
Enabling Remote Monitoring & Predictive Maintenance of Warehouse Equipment
The MQTT messages are sent asynchronously through publish-subscribe architecture. The messages are encapsulated in several defined control packets, which are designed to minimize the network footprint. Listed below are a few MQTT protocol control packets:
An MQTT control packet is formed as shown in the figure below.
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. firstname.lastname@example.org. 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.
Below is an example of a typical message from an XMPP client wrapped in XML:
- 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.
DOWNLOAD CASE STUDY
Collision Awareness System for Manufacturing and Assembly Plant
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.
Most of these protocols run on top of TCP. Although TCP is reliable, it becomes a bottleneck when there is a slow end-user input. DDS has an edge over other protocols in terms of QoS because of the device-to-device communication architecture. XMPP excels in providing a device-addressing mechanism and enables easy identification of the destination. However, it is slow and does not handle large payloads. AMQP, MQTT, and CoAP work well with a server-to-server and server-to-device connection in the network.
Overall, everything comes down to the application usage. All the protocols follow different architectures and provide different capabilities. It is up to the application developer to decide which protocol is the best fit for the required use case.
eInfochips has developed an intelligent IoT Gateway Framework that provides flexibility to connect any IoT devices over edge and cloud with the support for various protocols like MQTT, XMPP, AMQP, CoMP, Bluetooth, ZigBee, Thread, Z-wave and more. Download the brochure to know more.