IoT Protocols (MQTT, CoAP)

๐Ÿ“ก IoT Protocols: MQTT & CoAP

1. MQTT (Message Queuing Telemetry Transport)

  • Type: Publish/Subscribe messaging protocol

  • Designed for: Lightweight, low-bandwidth, unreliable networks

  • How it works:

    • Devices (clients) publish messages to a broker on specific topics.

    • Other devices subscribe to those topics to receive messages.

  • Use Cases:

    • Remote sensor monitoring

    • Home automation

    • Industrial IoT

  • Advantages:

    • Minimal overhead, ideal for constrained devices

    • Reliable message delivery with QoS levels (0,1,2)

    • Supports retained messages and last will/testament features

  • Port: Usually runs over TCP/IP on port 1883 (unencrypted) or 8883 (TLS encrypted)




2. CoAP (Constrained Application Protocol)

  • Type: Client-server protocol modeled on HTTP, but optimized for IoT

  • Designed for: Simple devices and constrained networks (low power, lossy)

  • How it works:

    • Uses RESTful architecture — devices send requests (GET, POST, PUT, DELETE) to servers.

    • Supports multicast requests and asynchronous message exchange.

  • Use Cases:

    • Smart lighting

    • Building automation

    • Sensor networks

  • Advantages:

    • Very low overhead, runs over UDP (faster, lighter than TCP)

    • Supports resource discovery and proxying

    • Easily integrates with HTTP systems via proxies

  • Port: Default UDP port 5683, secured by DTLS (Datagram Transport Layer Security)


๐Ÿ”‘ Summary Comparison

FeatureMQTTCoAP
Protocol ModelPublish/SubscribeRequest/Response (RESTful)
Transport LayerTCPUDP
Use Case FocusMessaging for telemetry and controlResource manipulation in constrained environments
SecurityTLSDTLS
OverheadLow, but higher than CoAPVery low
CommunicationAsynchronous, broker-basedSynchronous, direct client-server