7 每個開發人員都必須了解的基本物聯網通訊協議

地雷 十二月. 26. 2024
目錄

    What are IoT Communication Protocols?

    物聯網協定是標準或 “語言” 被機器用來相互通信, 或透過平台. 基於它們的特性和功能, 這些協議主要分為 3 類型: 傳輸協定, 通訊協議, 和行業特定協議.

    傳輸協定: used by devices for 物聯網網路 and connecting within the subnet, 包括無線網路, 藍牙, 紫蜂, 乙太網路, 近場通訊, 3G/ 4G/ 5G etc.

    Communication protocols: used for data transmission between devices, operate above the network layer and provide application layer services to users. Some of the communication protocols: MQTT, CoAP, HTTP/HTTPS, WebSocket, AMQP.

    Industry-specific protocols: standard protocols within a specific industry to ensure compatibility between the devices, 系統, platforms by different manufacturers and brands, such as JT/T 808 vehicle terminal communication protocol in China.

    7 Essential IoT Communication Protocols

    Understanding of 7 IoT Communication Protocols:

    Here you’ll find some of the communication protocols used in IoT industry, 包括:

    1. REST/HTTP

    What is REST

    REST (Representational State Transfer)is an architectural style rather than standards for designing networked applications, typically uses HTTP as its transport protocol to implement its architectural principles.

    特徵:

    • Statelessness: Each request contains all necessary information, and the server does not maintain the client’s state.
    • Resource Identification: On the server side, the application state and functionality can be divided into various resources, which are exposed to the client. Examples of resources include application objects, database records, algorithms, ETC. Each resource is assigned a unique address using a URI (Universal Resource Identifier).
    • Uniform Interface: Use standard HTTP methods to manipulate resources, such as GET, POST, PUT, DELETE

    應用:

    REST/HTTP primarily aims to simplify the system architecture of the Internet, quickly achieving loose coupling between client and server interactions, thereby reducing interaction latency. 所以, it is suitable for IoT application, enabling the exposure of IoT resources through REST, allowing services to be invoked by other applications.

    2. CoAP

    What is CoAP

    CoAP (Constrained Application Protocol) offers easy and efficient communication for constrained devices, making it ideal for operation in low-power, low-bandwidth, and high-latency environments.

    特徵:

    • Header Compression: CoAP features a compact binary header with a base of 4 位元組, followed by extended options, typically resulting in a request header of 10-20 位元組.
    • Methods and URIs: Supports GET, PUT, POST, DELETE methods, and URIs for accessing server resources.
    • Transport Layer: Built on UDP to minimize overhead and support multicast, with a simple stop-and-wait reliability mechanism.
    • Asynchronous Communication: Unlike HTTP, CoAP supports asynchronous communication, ideal for M2M applications.
    • Resource Discovery: Includes a built-in format for resource discovery, compliant with RFC 5785, using /.well-known/core for resource descriptions.
    • Caching: Supports caching of resource descriptions to enhance performance.

    應用:

    CoAP is a simplified HTTP-based RESTful API. CoAP is an application layer protocol in the 6 LoWPAN protocol stack, suitable for resource-constrained communication IP networks, such as low-power sensors and embedded systems.

    3. MQTT

    What is MQTT

    The MQTT protocol uses a publish/subscribe pattern, where IoT terminals typically connect to an MQTT broker via TCP. The broker manages the communication content through topics and is responsible for forwarding messages between devices.

    特徵:

    • Pubish/Subscribe Model: Clients can publish messages to a topic and subscribe to receive messages from specific topics. This model enables flexible message distribution.
    • Low Bandwidth: The message header is minimal, typically only 2 位元組, supporting efficient bandwidth usage and making it suitable for low-bandwidth, high-latency, and unstable networks.
    • 可靠性: MQTT offers three QoS levels for message delivery: “at most once,” “at least once,” 和 “exactly once.

    應用:

    MQTT is generally suitable for device data collection to endpoints (例如, Device -> Server) and centralized communication in a star network architecture, with the broker acting as the hub. It is widely used in IoT scenarios and has also been adopted in some mobile applications, such as Facebook Messenger (historically).

    4. DDS

    What is DDS

    DDS (Data Distribution Service) is a middleware standard created for real-time systems. It meets the strict demands of distributed applications by providing low latency, high throughput, and deterministic performance.

    特徵:

    • Data-centric
    • Brokerless Publish/Subscribe Messaging Model: Support point-to-point, point-to-multipoint, and multipoint-to-multipoint communication.
    • Offer up to 21 Quality of Service (QoS) Policies

    應用:

    Distributed, highly reliable, real-time data communication for devices. 現在, DDS is widely used in fields like civil aviation and industrial control.

    5. AMQP

    What is AMQP

    AMQP is an open-standard application layer protocol designed to ensure reliable message transmission and queuing mechanisms.

    特徵:

    • Wire-level Protocol: Transmits data across the network as a stream of bytes.
    • High compatibility due to the open standard
    • Flexible & 安全的: Supports various messaging patterns, including publish/subscribe and point-to-point. It also incorporates multiple security mechanisms, such as encryption and authentication.

    應用:

    Initially used for transaction messaging in financial systems, AMQP is now primarily utilized in IoT applications for communication and data analysis between mobile devices and backend data centers.

    6. XMPP

    What is XMPP

    As an open-standard communication protocol, XMPP (Extensible Messaging and Presence Protocol) is designed for real-time communication, such as instant messaging and presence information.

    特徵:

    • Client/Server Communication Model: Clients send requests to the server, which processes the requests and sends back the appropriate response or resource to the client.
    • Distributed Network: Multiple independent nodes form the network, eliminating single points of failure.
    • Simple Clients: Clients handle fewer tasks, with most computation done on the server side.
    • XML is used to describe data, ensuring cross-platform compatibility, though JSON has become more popular in modern applications.

    應用:

    XMPP is used in instant messaging, network management, content delivery, collaboration tools, file sharing, 賭博, remote system monitoring, 還有更多.

    7. JMS

    What is JMS

    JMS (Java Message Service) is a standard API of the Java platform for messaging in distributed applications. It allows applications to communicate through message queues, thus achieving asynchronous, 靈活的, and reliable message exchange.

    特徵:

    • Asynchronous Communication: Allows sending and receiving messages at different times, increasing system flexibility and responsiveness.
    • Message Durability: Provides message persistence, ensuring that messages are not lost in case of system failures, and enhancing reliability
    • Transaction Support: JMS provides transaction support, ensuring the atomicity of a group of message operations, meaning all operations either succeed completely or fail entirely, thereby guaranteeing data consistency.

    應用:

    JMS is ideal for distributed applications requiring asynchronous messaging, system decoupling, and high reliability, such as enterprise application integration, event-driven architecture, and real-time data processing.

    Comparisons of IoT Communication Protocols

    特徵 DDS MQTT AMQP XMPP JMS REST/HTTP CoAP
    Abstraction Pub/Sub Pub/Sub Pub/Sub Pub/Sub Request/Reply Request/Reply
    Architecture Global data space 代理人 P2P or Proxy 代理人 Through TCP guarantee P2P
    QoS 22 類型 3 類型 3 類型 3 類型 Confirm through TCP or confirmed messages 是的
    Interoperability 是的 Partially 是的 是的 是的
    Performance 100,000 msg/s/sub 1,000 msg/s/sub 1,000 msg/s/sub 1,000 msg/s/sub 100 req/s 100 req/s
    即時的 是的 是的
    Transport Layer Supports UDP and TCP 傳輸控制協定 傳輸控制協定 Not specified, usually TCP 傳輸控制協定 UDP UDP
    Subscription Filtering Message content-based and topic-based filtering Layered subscription based on topics and message content Queue and message filtering Message content and topic filtering 不支援 Supports topic and multicast
    Encoding Binary Binary Binary XML format Binary Plain text Plain text
    Dynamic Discovery 是的
    安全 Provides FSS, 傳輸層安全協定, and other security options Simple username/password, SSL data encryption SASL and TLS data encryption Provides FSS, 傳輸層安全協定, JAAS API support General support for SSL and TLS General support for SSL and TLS

     

    結論

    MQTT, DDS, AMQP, XMPP, JMS, REST, and CoAP are widely used protocols, each with multiple implementations, that claim support for real-time publish/subscribe IoT communication. 然而, when designing specific IoT system architectures, it is essential to consider the actual communication needs of the scenario—such as bandwidth limitations, latency requirements, and security—before selecting the most appropriate protocol.

    下一個: 什麼是即時定位系統? 即時定位系統綜合指南
    上一篇: LoRaWAN 與 Zigbee: 有什麼區別?