IOT device communication protocol MQTT

Hello everyone! The author's company is doing business related to IOT equipment recently. Based on this opportunity, I searched and learned about the content related to the IOT communication protocol. Finally, I chose to use the MQTT protocol in the technical selection and combined with the upper-layer MQTT middle of EMQ. In this round of blog posts, we will discuss and learn about the relevant characteristics of IOT devices and the nature of the MQTT protocol.

attach:

Meow's blog: w-blog.cn

MQTT official: https://github.com/mqtt/mqtt.github.io

List of service middleware: https://github.com/mqtt/mqtt.github.io/wiki/servers

List of clients: https://github.com/mqtt/mqtt.github.io/wiki/libraries

1. Characteristics of IoT devices

When discussing the title of this question, we need to first figure out what an IOT device is, and what is the difference between an IOT device and a traditional smart device. The IOT device summarized by the author has the following characteristics:

  • Poor hardware capability (storage capacity is basically only a few MB, CPU frequency is low, even using HTTP requests is a luxury)
  • Systems vary widely (Brillo, mbedOS, RIOT, etc.)
  • If the battery is used for power supply, the power consumption is sensitive
  • If it is a small device with a large device base, it needs to maintain a large number of online links
  • The network situation is unstable, the mobile network network tariff is expensive, and it is necessary to minimize the overhead and stabilize

In the above harsh scenarios, many technologies commonly used in smart device solutions are prohibitive. To sum up, we mainly face the following three problems:

  • socket.io, websocket? Different systems may not be able to use HTTP, and device resources may be extravagant to use HTTP
  • TCP/IP custom protocol? Although you don't need to care about the system, how can custom packets solve the problem of network overhead?
  • The cost of independent research and development is high, and the use of third-party IOT platforms is easy to be bound by technology or hardware

2. Why is MQTT suitable for IoT scenarios?

MQTT (Message Queuing Telemetry Transport, Message Queuing Telemetry Transport) is an instant messaging protocol developed by IBM. It is used in a similar way to queue software such as RabbitMQ. It uses a publish/subscribe method to provide communication between each other. MQTT is used for computing power. A protocol designed to communicate with remote sensors and control equipment that is limited and works on low-bandwidth, unreliable networks. It has the following main characteristics:

  • The protocol supports all platforms and can connect almost all networked items to the outside world

  • There are three message publishing qualities of service

      - “至多一次”,消息发布完全依赖底层 TCP/IP 网络。会发生消息丢失或重复。这一级别可用于如下情况,环境传感器数据,丢失一次读记录无所谓,因为不久后还会有第二次发送。
      - “至少一次”,确保消息到达,但消息重复可能会发生。
      - “只有一次”,确保消息到达一次。这一级别可用于如下情况,在计费系统中,消息重复或丢失会导致不正确的结果。
    
  • Small transfers with little overhead (fixed-length headers are 2 bytes), and protocol switching is minimized to reduce network traffic;

  • Mechanisms for notifying interested parties of abnormal client outages using the Last Will and Testament features;

In addition to the protocol characteristics of MQTT, there are some objective reasons:

  • Language friendly and mainstream language clients have
  • Most hardware solutions are natively supported
  • Dozens of MQTT server-side programs to choose from
  • The community's mature solutions are widely used, and it is convenient to seek help when encountering problems

The above is basically the reason why we also choose MQTT as the IOT protocol. For more information or to check whether the client supports or not and the server implementation, please refer to the official github:

MQTT official: https://github.com/mqtt/mqtt.github.io

List of service middleware: https://github.com/mqtt/mqtt.github.io/wiki/servers

List of clients: https://github.com/mqtt/mqtt.github.io/wiki/libraries

3 Summary

The explanation about MQTT is just the beginning. The next chapter will talk about our protagonist, EMQ, the million-level MQTT message service. Thank you so much for your attention. We will see you in the next section...

Note: The author has limited ability and I hope that everyone can point out the wrong places, and I hope to communicate more!

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324392222&siteId=291194637