Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Networking experimental devices: MQTT #99

Closed
eugeneia opened this issue Jun 11, 2020 · 1 comment
Closed

Networking experimental devices: MQTT #99

eugeneia opened this issue Jun 11, 2020 · 1 comment

Comments

@eugeneia
Copy link

This issue serves to extend on #54 and #24. Quartiq devices will be managed/interconnected over a network, how should that be implemented?

@jordens suggested MQTT as a suitable protocol. I’ve investigated that option a bit and will compare it with what we currently have. I’ll try to summarize the approaches, and distill features/requirements/use-cases served by aspects of those approaches. Please fill in whatever I miss.

Status-quo

Yeet JSON to a TCP port. This is what stabilizer supports currently.

  • I can telnet/netcat to the port, type in my JSON and that’ll work.
  • I can vendor smoltcp and a ubiquitous JSON encoder/decoder crate and call it a day
  • I can probably read it in Wireshark
  • Can be described with JSON schemas, flexible extensible
  • Question: is JSON is a desirable wire format? Debatable.

MQTT

MQTT is a message bus protocol that facilitates N to N connectivity (hub and spoke). It acts as a transport substrate on top of TCP and implements support for application level features such as QoS (unreliable, at least once / only-once delivery), N-to-N broadcasting, and some more. Classic request-response patterns are re-implemented on top of more generic MQTT constructs.

I’ve implemented a minimal MQTT client that can publish/subscribe (QoS=0) to a topic in ~200LoC. Running ejabberd as a broker was fairly straightforward.

  • What MQTT would give us is a well defined way to control/orchestrate N devices on a network—instead of having one concurrent connection per device we’d have all devices connect to the broker, and one or more controller/orchestrator clients that connects to the broker to perform the experiment.
  • (We could go for a zero-conf setup and use e.g. DHCP/mDNS to have our devices automatically connect to local broker on startup, and implement a scheme to have automatic discovery of active devices)
  • The devices could also interact with each other without establishing connections (meshing) with each other
  • We could control auxiliary protocols like high-bandwidth sample streaming via MQTT (E.g., sending a MQTT message dump:10.10.0.7:4567 to stabilizer_XYZ could trigger it to attempt to open a TCP socket to 10.10.0.7:4567 and stream samples over that socket)
  • We’d have a clear interface (the broker) to extract low-bandwidth time series data for historic analysis
  • Caveat: you need a MQTT broker to talk to your devices (us implementing a client subset seems like reasonable effort, maintaining an MQTT broker would possibly be overkill—we’d rely on a third party providing a working broker)
  • MQTT doesn’t define a wire format for payloads (and as mentioned request/response patterns are implemented ad-hoc), we’d do our status-quo or an alternative protocol over MQTT instead of plain TCP. I.e., MQTT does not supersede any functionality that is currently implemented.
  • I can maybe still read our protocol on top of MQTT in Wireshark

Cc @ryan-summers @jordens @cjbe

@jordens
Copy link
Member

jordens commented Oct 13, 2020

We've settled this in favor of going for MQTT. Forking individual issues arrising from it.

@jordens jordens closed this as completed Oct 13, 2020
This was referenced Oct 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants