directory

HTTP and Websocket

2, XMPP

3, COAP

4. MQTT protocol

5, DDS


For the Internet of Things, the most important thing is the communication between devices in the Internet. The common communication protocols of the Internet of Things include HTTP, WebSocket, XMPP, COAP and MQTT

HTTP and Websocket

In the Internet era, TCP/IP protocol has become the dominant protocol, and the current communication architecture of the Internet of Things is also built on the traditional Internet infrastructure. Among the current Internet communication protocols, HTTP occupies almost the majority of the market due to its low development cost and high openness. Therefore, many manufacturers also develop the Internet of Things system based on HTTP. The Google-led Physic Web project, among others, aims to build protocols for the Internet of Things on top of traditional Web technologies.

HTTP protocol is a typical CS communication mode. The client initiates the connection and requests XML or JSON data to the server. The protocol was originally designed for Internet browsing with Web browsers, and is widely used on terminals such as PCS, mobile phones, and pads. However, it does not apply to the Internet of Things. There are three disadvantages in the Internet of Things scenario:

1. The device must actively send data to the server, so it is difficult to actively push data to the device. It is barely applicable to a single data collection scene, but for frequent control scenes, it can only be pulled by the device on a regular basis, which greatly reduces the implementation cost and real-time performance.

2. Low security. The web is notoriously insecure. HTTP is a plaintext protocol, and if you don’t do a lot of security preparation (such as HTTPS, etc.) in many Internet of Things scenarios that require high security, the consequences will be disastrous…

3. Different from user interaction terminals such as PC and mobile phone, devices in the Internet of Things scenario are diversified. For devices with limited computing and storage resources, the implementation of HTTP protocol and parsing of XML/JSON data format are “Mission Impossible”.

The interaction between the HTTP client and the server is in request/reply mode. When the client requests, an HTTP connection is established and a request message is sent. The server sends a reply message and the connection is closed. (Later HTTP1.1 supports persistent connections.) Because establishing a TCP connection is expensive, it is even more expensive if SSL/TLS is used.

In a browser, a web page contains many resources, including HTML, CSS, JavaScript, images, etc., so loading a web page requires opening multiple connections to the same server at the same time.

HTTP header issues. Today’s clients send a large number of HTTP headers, and since a web page may require 50-100 requests, there is a considerable amount of header data.

HTTP communication mode problems, HTTP request/reply mode sessions are initiated by the client, lack of server notification mechanism, in the context of notification, such as chat rooms, games, client applications need to constantly poll the server.

Of course, there are still many manufacturers who choose the Internet of Things system based on HTTP protocol framework for the convenience of development. Under the condition of equipment resources, how to avoid the problem of low real-time data push mentioned above?

Websocket is a viable solution. Websocket is a protocol standard proposed by HTML5 that can support full-duplex communication based on TCP. Its design basically follows the idea of HTTP, and it is a good supplement to the Internet of Things system based on HTTP protocol.

But the problem is: HTTP + Websocket, protocol overhead is too high. If let a single chip microcomputer to achieve such a protocol, performance will be very difficult.

 

2, XMPP

As the communication mode of Internet of Things devices is very similar to that of instant messaging applications in the Internet, instant messaging protocols commonly used in the Internet are also widely used in the construction of Internet of Things systems, among which XMPP is a typical example.

XMPP is a protocol based on XML. Due to its openness and ease of use, it is widely used in Internet instant communication applications. Compared with HTTP, XMPP is more suitable for the Internet of Things system in terms of the business process of communication. Developers do not need to spend too much effort to solve the business process of device communication, and the development cost will be lower. But HTTP protocol security and computing resource consumption has not been essentially resolved. Some time ago, the TCL washing machine, which was easily cracked by hackers, is XMPP protocol.

Whether HTTP, websocket or XMPP, when the design is based on Internet application scenario design, although many manufacturers put their application in the system of Internet of things, but will not, the common fault of these agreements is not for the diversity of Internet equipment, unable to apply a lot of things networking equipment demand for low power consumption, low cost, It is difficult to apply in iot devices with very low resources. Can there be protocols that can borrow design ideas from Web technologies and adapt to the harsh operating environment of iot devices?

3, COAP

COAP protocol is designed to achieve iot communication on low power and low speed devices. Coap, like HTTP, uses URL to mark the data that needs to be sent. In terms of protocol format design, IT basically refers to HTTP, which is very easy to understand. At the same time, the following optimization was made:

1. Use UDP instead of TCP. This eliminates the cost of establishing a TCP connection and the overhead of the protocol stack.

2. Use binary compression for packet headers to reduce the amount of data to adapt to low network rate scenarios.

3. Data can be sent and received asynchronously, improving the response speed of the device.

The COAP protocol is like an HTTP port for the Internet of Things scenario, with many of the designs keeping HTTP in mind and making it easy for developers with a Web background to get started. However, because many iot devices are hidden inside the LAN, COAP devices cannot be addressed by external devices as servers. Before the popularity of ipv6, COAP can only be used for intra-LAN communication (such as wifi), which also greatly restricts its development.

4. MQTT protocol

MQTT protocol is a good solution to the problems of COAP. MQTT protocol is an instant communication protocol developed by IBM, which is more suitable for the Internet of Things. MQTT protocol adopts publish/subscribe mode, all Internet of Things terminals are connected to the cloud through TCP, and the cloud manages the communication content concerned by each device through the way of theme, and is responsible for forwarding messages between devices.

1. Use the publish/subscribe messaging pattern to provide one-to-many messaging and decouple applications.

2. Message transmission that hides the payload.

3. Use TCP/IP to provide network connections.

4. There are three qualities of message publishing service:

“At most once”, message publishing is entirely dependent on the underlying TCP/IP network. Message loss or duplication occurs. This level can be used for environmental sensor data where the loss of a read record does not matter because a second send will follow shortly after.

“At least once” ensures that messages arrive, but message duplication may occur.

“Only once” ensures that the message arrives once. This level can be used in cases where duplicate or missing messages result in incorrect results in a billing system.

5. Small transmission, low overhead (fixed length header is 2 bytes), minimal protocol exchange to reduce network traffic.

6. Mechanisms for notifying parties of client outages using the Last Will and Testament features.

MQTT protocol design takes into account the difference of computing performance of different devices, so all protocols are encoded and decoded in binary format, and the encoding and decoding format is very easy to develop and implement. The smallest packet is only 2 bytes, which is suitable for low-power and low-speed networks. There is a very perfect QOS mechanism, according to the business scenario can choose at most once, at least once, just once three message delivery modes. It runs on TOP of TCP and supports TLS (TCP+SSL). Because all data communication is through the cloud, security is better guaranteed.

The current iot communication protocols are really a thousand flowers, and none of them can dominate the market. However, in order to realize the interconnection of iot devices (different manufacturers, platforms and architectures), the key point is not the unification of the above access protocol or communication protocol, but the unification of the upper business application layer protocol. Whether wifi, Bluetooth, MQTT or HTTP are the channels for data communication and exchange of equipment, and the format of communication is stipulated. And the unification of communication content is the key to achieve interconnection.

5, DDS

DDS (Data Distribution Service for Real-Time Systems) is a Data Distribution Service for real-time Systems. This is a protocol proposed by the well-known OMG organization, and its authority should prove the future application prospect of this protocol.

Application: Distributed high reliability, real-time transmission equipment data communication. At present, DDS has been widely used in national defense, civil aviation, industrial control and other fields.

Features: • Data-centric • Use proxy-free publish/subscribe messaging mode, point-to-point, point-to-many, many-to-many • Provide up to 21 QoS quality of service policies

• OpenDDS is an open source C++ implementation • OpenSplice DDS

DDS supports data distribution and control between devices, as well as data transmission between devices and the cloud. At the same time, THE real-time efficiency of DDS data distribution is very high, and it can simultaneously distribute millions of messages to many devices within seconds. DDS provides a lot of guarantees on quality of service (QoS), which is why it is suitable for defense, military, industrial control, such as high reliability, security applications. However, these applications all work on wired networks, and no implementation cases have been seen in wireless networks, especially under resource constraints.