# Communication Protocols of an Industrial Internet of Things Environment: A Comparative Study
## 4 Comparison between IoT Protocols  
A performance comparison between HTTP and MQTT is conducted in [46] on required network resources for IoT, while the payload was fixed to zero bytes and the topic names were varied. In addition, a performance analysis of MQTT, HTTP, and CoAP was performed in [47] for IoT-based monitoring of a smart home. The authors of [48] discussed and analyzed the efficiency, usage, and requirements of MQTT and CoAP. Moreover, the authors of [49] compared AMQP and MQTT over mobile networks, and the authors of [50] emulated a quantitative performance assessment of CoAP in comparison with HTTP. In this section, the main differences between HTTP, CoAP, MQTT, AMQP, XMPP, and MODBUS TCP protocols are discussed from various telecommunication aspects. Then, a protocol is chosen that fulfills the requirements of the IIoT environment. Accordingly, Table 2 summarizes these differences from different communication aspects including infrastructure, architecture, mechanism, model, messaging pattern, methodology, and transmission paradigm. These protocols use the client-server communication architecture. HTTP uses the request-response model and is a document-oriented protocol, whereas MQTT uses the publish-subscribe model and is message-oriented. Thus, MQTT is one-to-many, and HTTP is one-to-one (peer-to-peer). CoAP uses a specific infrastructure--namely, 6 LoWPAN (IEEE 802.15.4)--which employs IPv6 in the network layer. Both MQTT and HTTP use an inexpensive and available communication infrastructure, which is Internet or Intranet in wire mode (Ethernet--IEEE 802.3) or wireless mode (Wi-Fi--IEEE 802.11)--which may employ either IPv4 or IPv6 in the network layer. In the transport layer, MQTT and HTTP protocols use TCP port numbers 1883 and 80, respectively. However, CoAP uses UDP port number 5683. Given that MQTT is event-based, it is a message-oriented protocol. Thus, CoAP mimics HTTP in using polling-based messaging, but in a shorter time and smaller frame-size. Figure 3: Relationship between the number of bytes and the number of registers of the MODBUS function code (FC) “read/write multiple registers” (0x17). CoAP is an application layer protocol, dedicated to communication with constrained devices in IPv6-based IoT infrastructures. Two communication patterns are used by CoAP, i.e., publish-subscribe and request-response [51]. The CoAP messaging pattern is based on the exchange of messages between endpoints and uses a short fixed-length binary header that may be followed by a compact binary option and a payload. Compared to HTTP, as shown in Figure 4, CoAP runs over the connectionless UDP in the transport layer, whereas in the network layer, CoAP uses either IPv6 or 6 LoWPAN. When CoAP uses IPv6, it is necessary for it to use Ethernet or Wi-Fi for the data link and physical layers, respectively. When CoAP uses 6 LoWPAN, it employs IEEE 802.15.4e for the data link and physical layers. The content (payload) of HTTP may vary according to the type of transferred data, called content-type, which could be plain text, HTML, XML, GIF image, PDF application, or audio. For the exchange of data using HTTP, XML is used, which handles verbose plain text for solving interoperability issues. However, for CoAP, the efficient XML interchange (EXI) [52] is used, which encodes verbose XML documents in binary format, if interoperability is considered. This is normally used for constrained devices to increase the performance and decrease the consumed power. Hence, CoAP is suitable for constrained devices in IoT-based wireless sensor networks that employ IPv6-based infrastructure. However, it needs a gateway to exchange data over the Internet.