MQTT介绍 - xyfancy/qcloud-iot-sdk-embedded-c GitHub Wiki

MQTT文档

MQTTv5.0:https://docs.oasis-open.org/mqtt/mqtt/v5.0/mqtt-v5.0.pdf

MQTTv3.1.1:http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/mqtt-v3.1.1.pdf

MQTT简介

MQTT is a Client Server publish/subscribe messaging transport protocol. It is light weight, open, simple, and designed to be easy to implement. These characteristics make it ideal for use in many situations, including constrained environments such as for communication in Machine to Machine (M2M) and Internet of Things (IoT) contexts where a small code footprint is required and/or network bandwidth is at a premium.

MQTT(Message Queuing Telemetry Transport),即消息队列遥测传输协议,是一种基于发布/订阅的消息传输协议。其轻量、开放、简洁和易实现的特点能够适用于要求代码量小、网络带宽资源匮乏的情景,如机器间通信(M2M)、物联网等。

The protocol runs over TCP/IP, or over other network protocols that provide ordered, lossless, bidirectional connections. Its features include:

• Use of the publish/subscribe message pattern which provides one-to-many message distribution and decoupling of applications.

• A messaging transport that is agnostic to the content of the payload.

• Three qualities of service for message delivery:

o "At most once", where messages are delivered according to the best efforts of the operating environment. Message loss can occur. This level could be used, for example, with ambient sensor data where it does not matter if an individual reading is lost as the next one will be published soon after.

o "At least once", where messages are assured to arrive but duplicates can occur.

o "Exactly once", where messages are assured to arrive exactly once. This level could be used, for example, with billing systems where duplicate or lost messages could lead to incorrect charges being applied. • A small transport overhead and protocol exchanges minimized to reduce network traffic.

• A mechanism to notify interested parties when an abnormal disconnection occurs.

MQTT构建在TCP/IP协议簇或者其他能够提供有序、无损和双向通信的网络协议之上。特性如下:

  • 使用发布/订阅消息模式,提供一对多的消息发布,实现应用程序的解耦合。
  • 对负载内容屏蔽的消息传输。
  • 三种不同的消息发布服务质量:
    • 至多一次:消息传输完全取决于底层的环境,消息会丢失,环境监测等只需要最新鲜数据的场景。
    • 至少一次:确保消息到达,但是可能会产生消息重复。
    • 只有一次:确保消息只到达一次,要求准确性,比如支付等场景。
  • 传输开销小,协议转换的代价低,能够有效减少网络流量。
  • 异常断线通知机制。