home≈ 10 KiB RAMport 1883home/+/temphome/kitchen/temp = 21.521.5 °CQoS 1 · PUBACKretained: 21.5silent 90 s → "offline"water: wethome/basement/leakGET /temp · UDP 5683TLS · 8883own password
Coloured: the parts the current step is about; the rest wait in whiteEnvelope: one MQTT or CoAP message (pink seal), a Zigbee frame (coral seal)Small envelope: a short reply or ping (teal seal)Dotted lines: IP links to the broker · dashed: the Zigbee radio linkSmall devices publish to topics on an MQTT broker instead of talking to each app: the sensor sends one 26-byte PUBLISH to home/kitchen/temp, and the broker sends a copy to every subscription that matches. QoS sets how sure delivery is, retained messages give new subscribers the last value, and keep-alive with a last will tells everyone when a device goes silent. A gateway turns Zigbee into MQTT; CoAP is the brokerless UDP alternative. IANA ports: 1883/tcp mqtt, 8883/tcp secure-mqtt, 5683/udp coap, 5684/udp coaps. Addresses use the private home range 192.168.1.0/24 (RFC 1918).

Small devices

  1. An IoT (Internet of Things) device is a small computer, often on a battery. This temperature sensor has about 10 KiB of memory; a phone has hundreds of thousands of times more. It wakes, sends a few bytes, then sleeps. Its protocols must be tiny.

Publish / subscribe

Reliability

Gateways and CoAP

Security

On the wire, in numbers

;; step 1/12 · tiny-device · local
;; at temp sensor
temperature sensor (battery, Wi-Fi)
  address   192.168.1.50 on the home LAN 192.168.1.0/24
  memory    about 10 KiB RAM, 100 KiB flash: an RFC 7228 "Class 1" device
  a phone   about 8,388,608 KiB (8 GiB): 838,861 times more
RFC 7228 classes of constrained devices
  Class 0   RAM << 10 KiB  flash << 100 KiB
  Class 1   RAM ~ 10 KiB   flash ~ 100 KiB
  Class 2   RAM ~ 50 KiB   flash ~ 250 KiB
a constrained device cannot afford big protocols, long messages, or keeping its radio on

If the broker receives no packet for 1.5 × the keep-alive (90 s here), it must close the connection (MQTT 5.0 §3.1.2.10). MQTT 5.0 also lets a client delay its will with a Will Delay Interval. Device classes from RFC 7228: Class 0 well under 10 KiB of RAM, Class 1 about 10 KiB, Class 2 about 50 KiB. The sizes are rough guides, not hard limits.