1 of 10

CSE 122 / 222C ; WES 269MQTT

Pat Pannuto, UC San Diego

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell

2 of 10

MQTT Goals

  • Quick primer on a very commonly used, lightweight protocol for data

2

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell

3 of 10

Outline

  • MQTT Primer

3

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell

4 of 10

MQTT Origins & Design Goals

  • First use: Monitoring for ”highly remote” oil pipelines
    • Very limited (and costly) communications infrastructure 🡪 minimal protocol

  • MQTT doesn’t stand for anything
    • It is not a “Message Queue”

  • Base case is still very simple/minimal, but there are lots of expansions now
    • Security enhancements as well as MQTT-SN most relevant to you
    • https://mqtt.org/mqtt-specification/

4

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell

5 of 10

MQTT is a “pub/sub” protocol�An answer to the “where do you send data” question

5

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell

6 of 10

MQTT Roles

  • Broker
    • Server that distributes information

  • Client
    • Any device connected to the Broker

6

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell

7 of 10

Pub/Sub Architecture

  • Topic
    • String that names the data being sent

  • Publish
    • Sends data with an associated Topic to Broker

  • Subscribe
    • Inform Broker of which Topics you want data from
    • ALL subscribed Clients get copies of the data

7

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell

8 of 10

MQTT Access Control

  • Nothing is required by default
    • Which is its own concern

  • Can require a password to communicate with Broker
    • Which by default is sent in the clear, over the Internet [use MQTTS instead]

  • Can make access control lists on a per-topic basis
    • Each user with a given password can only access certain topics

8

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell

9 of 10

Value of MQTT

  • And that’s pretty much everything there is to MQTT
    • MQTT is very simple, and that’s a benefit
    • Packets are sent over TCP, so the reliability is already handled sufficiently
      • Variants can function over UDP instead

  • How is data formatted?
    • However you want. It’s just bytes attached to a Topic string
    • Could be an array of data bytes, JSON blob, image data, whatever
      • Up to MB of data in a single payload

    • Application-level probably knows how to decode

9

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell

10 of 10

Next Up: Longer-Range Technologies

10

CSE 122/222C ; WES 269 [WI25]

CC BY-NC-ND Pat Pannuto – Content developed in coordination with Branden Ghena and Brad Campbell