Skip to content
CS-803 (C) · Internet of Things/Quick Revision Short Notes

Internet of Things (CS-803 (C)) - Unit 4 Short Notes

How unit 4 is examined

This unit covers the IoT messaging protocols MQTT, SMQTT, CoAP, XMPP and AMQP; MQTT (14 marks) carries the marks, with AMQP (7 marks) next.

MQTT and its methods and components

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">High weight</span>

Definition. <mark>MQTT (Message Queuing Telemetry Transport) is a lightweight, publish-subscribe messaging protocol that runs over TCP/IP and lets constrained IoT devices exchange messages through a central broker.</mark>

Diagram.

<figure class="ds-fig" style="margin:1.4rem 0;overflow-x:auto"><svg xmlns="http://www.w3.org/2000/svg" id="dsfig-u4-01" viewBox="0 0 424 252" width="424" height="252" role="img" aria-label="MQTT publish-subscribe. Pub = publisher (sensor), Brk = broker, S1 and S2 = subscribers, all linked by a topic."><style>#dsfig-u4-01 .e{stroke:#454C5A;stroke-width:1.4;fill:none}#dsfig-u4-01 .e.hi{stroke:#2340B8;stroke-width:2.6}#dsfig-u4-01 .n{fill:#FFFFFF;stroke:#16181D;stroke-width:1.4}#dsfig-u4-01 .n.hi{fill:#E3E9FC;stroke:#2340B8;stroke-width:2.2}#dsfig-u4-01 .n.rb-b{fill:#16181D;stroke:#16181D}#dsfig-u4-01 .n.rb-r{fill:#BD3227;stroke:#BD3227}#dsfig-u4-01 text{font-family:"JetBrains Mono",ui-monospace,Menlo,Consolas,monospace;font-size:13px}#dsfig-u4-01 .t{fill:#16181D;font-weight:500}#dsfig-u4-01 .t.inv{fill:#FFFFFF;font-weight:700}#dsfig-u4-01 .kd{stroke:#16181D;stroke-width:1.2}#dsfig-u4-01 .dot{fill:#16181D}#dsfig-u4-01 .ann{fill:#2340B8;font-size:11px;font-weight:700}#dsfig-u4-01 .lbl{fill:#6F7787;font-family:system-ui,-apple-system,sans-serif;font-size:12px;font-weight:700}#dsfig-u4-01 .ptr{fill:#2340B8;font-size:12px;font-weight:700}#dsfig-u4-01 .ah{fill:#454C5A}#dsfig-u4-01 .ah.hi{fill:#2340B8}#dsfig-u4-01 .wl rect{fill:#FFFFFF;stroke:#DCE0E7}#dsfig-u4-01 .wl .t{font-size:12px;font-weight:700}#dsfig-u4-01 .wl.hi rect{fill:#2340B8;stroke:#2340B8}#dsfig-u4-01 .wl.hi .t{fill:#FFFFFF}html.dark #dsfig-u4-01 .e{stroke:#B1B7C3}html.dark #dsfig-u4-01 .e.hi{stroke:#8FA3FF}html.dark #dsfig-u4-01 .n{fill:#161920;stroke:#E6E8ED}html.dark #dsfig-u4-01 .n.hi{fill:#1E2748;stroke:#8FA3FF}html.dark #dsfig-u4-01 .n.rb-b{fill:#E6E8ED;stroke:#E6E8ED}html.dark #dsfig-u4-01 .n.rb-r{fill:#FF7E71;stroke:#FF7E71}html.dark #dsfig-u4-01 .t{fill:#E6E8ED}html.dark #dsfig-u4-01 .t.inv{fill:#0F1115}html.dark #dsfig-u4-01 .kd{stroke:#E6E8ED}html.dark #dsfig-u4-01 .dot{fill:#E6E8ED}html.dark #dsfig-u4-01 .ann{fill:#8FA3FF}html.dark #dsfig-u4-01 .lbl{fill:#858D9C}html.dark #dsfig-u4-01 .ptr{fill:#8FA3FF}html.dark #dsfig-u4-01 .ah{fill:#B1B7C3}html.dark #dsfig-u4-01 .ah.hi{fill:#8FA3FF}html.dark #dsfig-u4-01 .wl rect{fill:#161920;stroke:#2A2E37}html.dark #dsfig-u4-01 .wl.hi rect{fill:#8FA3FF;stroke:#8FA3FF}html.dark #dsfig-u4-01 .wl.hi .t{fill:#0F1115}</style><defs><marker id="ah6" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah" d="M0,1 L9,5 L0,9 z"/></marker><marker id="ahh6" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path class="ah hi" d="M0,1 L9,5 L0,9 z"/></marker></defs><path class="e" d="M59,126 L191,126" marker-end="url(#ah6)"/><path class="e" d="M229,117.5 L365.2,49.4" marker-end="url(#ah6)"/><path class="e" d="M229,134.5 L365.2,202.6" marker-end="url(#ah6)"/><g class="wl"><rect x="95.3" y="117" width="61.5" height="18" rx="9"/><text class="t" x="126" y="126" dy=".35em" text-anchor="middle">PUBLISH</text></g><g class="wl"><rect x="281.2" y="74" width="33.6" height="18" rx="9"/><text class="t" x="298" y="83" dy=".35em" text-anchor="middle">msg</text></g><g class="wl"><rect x="281.2" y="160" width="33.6" height="18" rx="9"/><text class="t" x="298" y="169" dy=".35em" text-anchor="middle">msg</text></g><circle class="n" cx="40" cy="126" r="18"/><text class="t" x="40" y="126" dy=".35em" text-anchor="middle">Pub</text><circle class="n" cx="212" cy="126" r="18"/><text class="t" x="212" y="126" dy=".35em" text-anchor="middle">Brk</text><circle class="n" cx="384" cy="40" r="18"/><text class="t" x="384" y="40" dy=".35em" text-anchor="middle">S1</text><circle class="n" cx="384" cy="212" r="18"/><text class="t" x="384" y="212" dy=".35em" text-anchor="middle">S2</text></svg><figcaption style="font-size:.82em;opacity:.72;margin-top:.45rem">MQTT publish-subscribe. Pub = publisher (sensor), Brk = broker, S1 and S2 = subscribers, all linked by a topic.</figcaption></figure>

Key points.

  1. In the publish-subscribe model the publisher and subscriber never talk directly, so they are decoupled in space, time and synchronisation.
  2. The broker is the central server that receives every message, filters it by topic and forwards it to all subscribers of that topic.
  3. A publisher is a device (such as a temperature sensor) that sends a message on a topic; a subscriber is a client that registers interest in topics.
  4. A topic is a hierarchical UTF-8 string such as home/room1/temp, and it acts as the routing key.
  5. MQTT methods (packet types) are CONNECT, CONNACK, PUBLISH, PUBACK, PUBREC, PUBREL, PUBCOMP, SUBSCRIBE, SUBACK, UNSUBSCRIBE, UNSUBACK, PINGREQ, PINGRESP and DISCONNECT.
  6. QoS 0 (at most once) sends PUBLISH once with no acknowledgement; QoS 1 (at least once) uses PUBLISH then PUBACK and may duplicate; QoS 2 (exactly once) uses the four-step PUBLISH, PUBREC, PUBREL, PUBCOMP handshake.
  7. Features: a tiny 2-byte minimum header, low bandwidth and power use, keep-alive pings, Last Will and Testament, and retained messages.
  8. Advantages are simplicity, scalability to many devices and reliability on poor networks; applications are smart homes, healthcare monitoring, industrial telemetry and Facebook Messenger. Default ports are 1883 (plain) and 8883 (TLS).

Example. A sensor publishes 23 on home/room1/temp with QoS 1; the broker forwards it to the phone app subscribed to that topic and the sensor receives a PUBACK.

Answer frame. Open with the definition and the publish-subscribe idea; draw the publisher, broker and subscribers figure; then develop points 1-4 (architecture), 5-6 (packets and QoS flow) and 7-8 (features, advantages, applications); close with one line that MQTT suits low-power, unreliable IoT networks.

Pitfall: Do not say the broker sends PUBACK for QoS 0; only QoS 1 and 2 have acknowledgements.

Asked: [14 marks] (May 2023) Explain in detail about MQTT protocol.

MQTT communication, topics and applications

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>MQTT communication is a client connecting to a broker, subscribing to topic filters and publishing messages that the broker routes by topic.</mark>

Key points.

  1. A client first sends CONNECT and the broker replies CONNACK; after that it can SUBSCRIBE (SUBACK) or PUBLISH.
  2. Topic levels are separated by /; the wildcard + matches one level and # matches all remaining levels.
  3. Topics beginning with $ are reserved for the broker's system information.
  4. Applications include smart homes, agriculture, healthcare, vehicle tracking and industrial monitoring.

SMQTT

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>SMQTT (Secure MQTT) is an extension of MQTT that adds lightweight encryption, based on attribute-based encryption, to protect messages.</mark>

Key points.

  1. It works in four phases: setup, encryption, publish and decryption.
  2. The publisher encrypts the message with a key tied to attributes, and only subscribers holding matching attributes can decrypt it.
  3. It gives confidentiality with little extra overhead for constrained devices.
  4. Plain MQTT instead relies on TLS on port 8883.

CoAP and its message types

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>CoAP (Constrained Application Protocol) is a lightweight RESTful web transfer protocol that runs over UDP for constrained devices.</mark>

Key points.

  1. It uses methods GET, POST, PUT and DELETE like HTTP and supports resource discovery and observe.
  2. The four message types are CON (confirmable, needs an ACK), NON (non-confirmable, no ACK), ACK (acknowledgement) and RST (reset).
  3. It has a 4-byte header and default port 5683, with DTLS for security.
  4. Reliability comes from retransmission of CON messages.

CoAP request-response model

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>In CoAP's request-response model a client sends a request (method plus URI) to a server and receives a response carrying a status code.</mark>

Key points.

  1. A piggybacked response returns the reply inside the ACK for a CON request.
  2. A separate response sends an empty ACK first and the reply later as a new message when the server needs time.
  3. Response codes follow HTTP style, such as 2.05 Content and 4.04 Not Found.
  4. A token matches a response to its request.

XMPP

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Not asked since 2022</span>

Definition. <mark>XMPP (Extensible Messaging and Presence Protocol) is an XML-based, decentralised protocol for near real-time messaging, presence and contact-list exchange.</mark>

Key points.

  1. Clients connect to their own server, and servers federate with each other over TCP.
  2. Data travels as XML stanzas of three kinds: message, presence and iq (info/query).
  3. Addresses are JIDs of the form user@domain/resource, and the default port is 5222.
  4. It is used for chat and IoT device control, but the XML makes it heavier than MQTT.

AMQP features and components, frame types

<span style="display:inline-block;padding:.16em .6em;border:1.5px solid currentColor;border-radius:999px;font-size:.68em;font-weight:700;letter-spacing:.06em;text-transform:uppercase;opacity:.75">Low weight</span>

Definition. <mark>AMQP (Advanced Message Queuing Protocol) is an open, binary, wire-level application protocol for reliable, secure and interoperable message-oriented middleware.</mark>

Key points.

  1. Features are reliability (acknowledgements and persistence), flexible routing, security (TLS and SASL) and interoperability across vendors.
  2. Components are the broker, exchanges, queues and bindings; a publisher sends to an exchange, which routes by binding rules to queues, from which consumers read.
  3. Exchange types are direct, fanout, topic and headers.
  4. Frame types are Open, Begin, Attach, Transfer, Disposition, Detach, End and Close.
  5. Compared with MQTT, AMQP is heavier with richer routing, suiting enterprise messaging, while MQTT suits constrained devices.

Asked: [7 marks] (May 2023) What are the AMQP features and components explain in detail.

Last-minute revision

  • MQTT is publish-subscribe over TCP with a central broker; ports 1883 and 8883 (TLS).
  • QoS 0 is at most once, QoS 1 at least once, QoS 2 exactly once.
  • QoS 1 flow is PUBLISH, PUBACK; QoS 2 flow is PUBLISH, PUBREC, PUBREL, PUBCOMP.
  • MQTT has 14 packet types, starting with CONNECT and CONNACK.
  • Wildcards are + (one level) and # (many levels).
  • SMQTT adds attribute-based encryption to MQTT.
  • CoAP runs over UDP, port 5683, with CON, NON, ACK and RST messages.
  • CoAP responses are piggybacked or separate.
  • XMPP uses XML stanzas (message, presence, iq) and JIDs, port 5222.
  • AMQP components are exchange, queue, binding and broker.

Memory hooks

  • Pub, Broker, Sub: "the post office sits in the middle".
  • QoS 0-1-2 means "zero, once or more, exactly once".
  • CoAP is "HTTP on a diet over UDP"; CON, NON, ACK, RST.
  • XMPP = XML plus presence, like chat; AMQP = queues with exchanges and bindings.

Coverage checklist

  • MQTT, MQTT methods and components: Q1 (14 marks, May 2023).
  • MQTT communication, topics and applications: covered, none asked.
  • SMQTT: covered, none asked.
  • CoAP, CoAP message types: covered, none asked.
  • CoAP Request-Response model: covered, none asked.
  • XMPP: covered, none asked.
  • AMQP features and components, AMQP frame types: Q2 (7 marks, May 2023).
Go to where you left off?

Quick Add to Notes

Save questions, your own notes and screenshots into notes filed by unit. It takes a free account.

Create free account

Have an account? Log in