跳至正文
Wener Notes

MQTT (Message Queuing Telemetry Transport) Protocol

约 2 分钟阅读
标签:硬件IoTMQTTProtocols网络Go

MQTT is a lightweight, publish-subscribe network protocol that transports messages between devices. It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth is limited.

Protocol Overview

  • Architecture: Based on a Client/Broker model.
  • Transport: Typically runs over TCP/IP, but variants like MQTT-SN (for Sensor Networks) can run over UDP/Bluetooth.
  • Port: Default is 1883, while encrypted (TLS/SSL) is 8883.
  • Payload: Can carry up to 256MB of data; control headers can be as small as 2 bytes.
  • QoS (Quality of Service):
    • Level 0: At most once (Fire and forget).
    • Level 1: At least once (Acknowledged).
    • Level 2: Exactly once (Four-step handshake).

Features & Security

  • Topic System: Uses a hierarchical structure (e.g., home/living-room/temperature).
  • Retained Messages: The broker stores the last message on a topic for new subscribers.
  • Last Will and Testament (LWT): Notifies other clients when a client unexpectedly disconnects.
  • Security: Basic authentication uses plain-text usernames and passwords. TLS/SSL is highly recommended to protect against interception and tempering.

Brokers

  • Eclipse Mosquitto: a popular lightweight open-source MQTT broker.
  • EMQX: Scalable, distributed MQTT broker for IoT.

Client Libraries

Resources

关联信息

反向链接、本文链接的其他页面和外部资料。

参考资料

GitHub1 条
Wikipedia1 条
其他外链5 条
最近更新commit 906e816编辑