The IoT paradigm has brought with it a decided change in a number of areas ranging from hardware design to services offered by software companies. One of the aspects most affected by this is that of Communication Protocols.
A communication protocol can be thought of as a language that is used by two or more machines to talk to each other. It is a set of rules that are followed by the two devices in order to make sense out of the messages that they pass to each other. Communication Protocols are extremely essential in distributed systems, where different parts of the same process are carried out at more than one location, significantly distant from each other. The systems carrying out the processes may be heterogeneous in nature, warranting a common set of instructions for both systems to communicate.
The baby steps of the IoT boom are rooted in the spread of Cyber-Physical systems. The notion of physical devices connected to the Internet and passing data to and receiving data from it is the spine of a realistic implementation of an IoT solution. This added a new layer of complexity to the existing definition of Communication Protocols. The Internet.
The IoT revolution holds a lot of promise, the implications of which are only viable if there is effective machine-to-machine (M2M) communication, and to aim for real-time M2M communication over the Internet. The concept of a device being connected to the Internet was only considered to be the product of human interaction uptil this point, and not a result of an autonomous decision. Therefore, protocols considering communication with the Internet were always a tradeoff between unreliable and slow.
Another aspect of the Internet protocol architecture is the TCP/IP stack. It controls the data transfer between two computers. There is a three-way handshaking procedure involved wherein the receiver acknowledges the reception of data and sends the acknowledgements message to the sender. The second handshake is from the sender to acknowledge the acknowledgement (Yo dawg I heard you like acknowledgments) and thus close the communication channel.
This method of communication is reliable, as it accounts for all the data that is being sent, but is also slow, because of all the verification procedures.
UDP, or User Datagram Protocol, is a faster way of communication between two computers by cutting down on acknowledgement procedures. It is more of a fire anf forget alternative to the stringent processes used by TCP to ensure that the entire message reaches the destination in proper order. As a result, UDP is less reliable than TCP/IP but is much faster too. A very simplistic solution for rapid prototyping of M2M projects was considered to be UDP due to a very low overhead in terms of headers as well as delay and a simple set up routine.
The major changes with regards to protocol development in anticipation of the IoT era have happened in the Application layer of the OSI model. This layer specifies interface methods in a communication network. How a system connects to the server and how data is sent is decided by this layer.
The most popular protocol for communication over the Internet is HTTP, or Hyper Text Transfer Protocol. We use this protocol when we interact with browser based web pages. It runs on a client-server model, with the server responding to any client demands. As web pages may carry heavy content, it is necessary for this protocol to be built upon the TCP/IP stack.
MQTT or MQ Telemetry Transport is a lightweight connectivity protocol geared for IoT applications. It is based on the TCP/IP stack which uses the publish/subscribe method for transportation of data. It is open-ended and supports a high level of scaling, which makes it an ideal platform for development of Internet of Things (IoT) solutions.
MQTT hosts a number of useful features which make it suitable for IoT oriented applications. To put it in simpler terms, imagine a bulletin board where you can put up notes or posters. Whenever you have something interesting that you'd like to put up, you design a poster with your topic written in large, noticable fonts, and you post it up on the bulletin board. So, anyone who is interested in your topic can read your post.
That's pretty much how MQTT functions.
MQTT consists of two broad categories of participating devices. They are called brokers and clients. The clients are those devices which can access or modify data, and brokers are those which host and relay data.
MQTT works on a paradigm called the publish/subscribe method. A client can publish data regarding a certain parameter to the broker under a topic. Another client interested in this toopic can subscribe to this topic and receive regular updates on messages under the topic.
MQTT offers a quality of service, which from an IoT standpoint is essentially the priority attached to the message. An important message should reach the destination in any case, so it's given a better QoS, so that transmission may be slow, but delivery is guaranteed. A dynamic data source that prioritizes speed over efficiency, though, is assigned a lower QoS, so that it's more of a fire-and-forget affair, like UDP.
MQTT can retain the last good message received under a topic, which it sends to subscribers who subscribe after the chain has been set in motion. This allows asynchronous connection of subscribers within an existing network of clients and brokers. This also provides a facility to check for redundancy and data loss.
An MQTT client has a property called the Last will and testament. This property enables a client which has disconnected abruptly to send a message to the broker. An SOS call of sorts, which can be used for autonomous regeneration of a wireless sensor network, detection and debugging of stray nodes and outliers as well as a routine to ensure a faultless cycle in data flow of a wireless sensor network.
CoAP is a web transfer protocol based on the REST model. It is mainly used for lightweight M2M communication owing to its small header size. It is designed especially for constrained networks and systems withing the Internet of Things paradigm, hence the name, Constrained Application Protocol.
CoAP mimics HTTP in terms of user visibility, and from that standpoint, reading sensor values is essentially like making an HTTP request.
CoAP is considered to be a future-proof protocol in the sense that when, as the Grtner hype chart predicts, 50 billion devices will be connected to the Internet, further expansion will necessitate the development of low-cost, low-consumption lightweight devices. CoAP is designed to work on systems as basic as 10kB RAM systems.
One of the more interesting features of CoAP is the ability to discover nodes within a network. This is especially useful in case of designing low power wireless sensor networks which are autonomous and self healing. Problems regarding scalability can be overcome using CoAP for wireless sensor networks as the discovery property of nodes renders any node discovery routine redundant.
CoAP is built upon the UDP stack, which is the primary difference when compared with HTTP or MQTT. This makes it faster and more resource optimized rather than resource intensive.
However, this also makes it less reliable than HTTP or MQTT, and QoS factors remain static in case of CoAP. However, the meager 4 byte header makes it a wonderful option for continuous streaming systems such as environmental monitoring sensor networks.