Analyzing MQTT vs CoAP

August 8th, 2016

Protocols are very important and have a significant role in standardization. Two most promising IoT standard protocols applicable for small devices are MQTT (Message Queue Telemetry Transport) and CoAP (Constrained Application Protocol). MQTT vs CoAP, both being open standards with a large number of implementations, suit to constrained environments, support asynchronous communication and run on IP.

The discussion revolves around these IoT protocols (CoAP – MQTT) along with conflicting arguments and discussions on MQTT vs CoAP.

MQTT – An Overview:

  • A machine-to-machine/IoT connectivity protocol
  • Supports publish/subscribe messaging for lightweight communications
  • Utile for remote connections where there is premium network bandwidth or small code footprint is required

MQTT Protocol Architecture:

MQTT Protocol Architecture is a client-server architecture, where every sensor is a client and connects to a MQTT server named broker over TCP. It is message oriented, that is, every message (a discrete chunk of data opaque to the broker) is published to an address, known as a topic. MQTT Clients can subscribe to multiple topics to receive every message published to the topic.

mqtt

In the above figure of MQTT Protocol Architecture, each subscriber can subscribe to only one topic of their interest to start listening. Publisher publishes the messages to the MQTT broker who in turn forwards the messages to the listening subscriber.

MQTT Protocol Stack:

  • Transport: TCP
  • Messaging: Publish/Subscribe, Request/Response
  • Network: IPv6/RPL
  • Adaptation: 6LoWPAN
  • MAC: IEEE 802.15.4
  • Physical: IEEE 802.15.4

MQTT Security:

The MQTT brokers need username-password authentication from clients to connect. The TCP connection is encrypted with MQTT SSL/TLS to ensure privacy. Every client supports TCP and holds a connection open to the broker.

CoAP – An Overview:

  • A specialized web transfer protocol for use with constrained nodes and constrained networks in IoT
  • Utile for machine-to-machine (M2M) applications

CoAP Protocol Architecture:

CoAP is based on REST architecture (a general design for accessing Internet resources). It optimizes the length of datagram and provides reliable communication to overcome the shortcomings of constrained resource. On one hand, the IoT protocol offers URI, REST method such as GET, POST, PUT and DELETE, whereas on the other hand, it allows IP multicasting to achieve group communication. To counterbalance the unreliability of UDP protocol, the IoT standard defines a retransmission and resource discovery mechanism with resource description.

mqtt

 

CoAP Protocol Stack:

  • Transport: UDP
  • Messaging: Request/Response
  • Network: IPv6/RPL
  • Adaptation: 6LoWPAN
  • MAC: IEEE 802.15.4
  • Physical: IEEE 802.15.4

CoAP Security:

Built on top of UDP, CoAP cannot rely on SSL/TLS (available with TCP/IP) to provide security capabilities. In case of UDP, Datagram Transport Layer Security (DTLS) provides the same assurances as TCP.

Final Recommendation – MQTT vs CoAP:

MQTT vs CoAP


Follow Us

facebook twitter linkedin google plus youtube Glassdoor

Category

Recent Tweets & Comments

Tweets by @AltenCalsoftLabs