MQTT¶
MQTT(Message Queuing Telemetry Transport) uses a pub-sub method to get messages from client to client, more on that in the chapter MQTT workings.
Running MQTT¶
before running anything the following ASSUMPTIONS are made here:
- MQTT is installed as per the IPSC manual
- you have four raspberries configured as per the setup chapter
- the repository has been downloaded
Now setting up the first MQTT roundtrip is very easy:
sh <techpush-sourcedir>/demonstrators/ComparedToOtherProtocols/MQTT/RoundTrip/Python/ipc/run.sh
now the local roundtrip is being setup up and run. Be sure to run cleanup.sh after cancelling the script. note: Some of the shell scripts automatically run cleanup.sh when ctrl-c is pressed
running the other MQTT setups is just as easy. For example the isc version of the roundtrpp:
sh <techpush-sourcedir>/demonstrators/ComparedToOtherProtocols/MQTT/RoundTrip/Python/isc/run.sh
or for both the bandwith programs:
sh <techpush-sourcedir>/demonstrators/ComparedToOtherProtocols/MQTT/Bandwidth/Python/ipc/run.sh
sh <techpush-sourcedir>/demonstrators/ComparedToOtherProtocols/MQTT/Bandwidth/Python/isc/run.sh
The MQTT.py program takes command line inputs in the following order:
Receiving topic Sending topic MQTT broker IP a 1 or 0 for being a master or hub respectively QOS quality of service
so for example:
python3 MQTT.py ReceivingTopic SendingTopic 192.168.0.202 1 0
In the example a master(1) is started which sends to SendTopic, receives on ReceiveTopic, works with a broker on 192.168.0.202 and uses a QOS of 0.
MQTT workings¶
MQTT works by sending a message to a central broker which then distributes the message to everybody thats listening in. It looks something like:
In the context of the roundtrip this looks like:
In the context of a roundtrip this method might seem a bit inefficients as every message has to go throught the broker. Also there is a sinle point of failure. However if the message needs to go to multiple hubs it costs almost nothing extra for the whole system. Speed should remain the same. This can be useful if for example there is a system where one sensor input needs to go to several different actuators. There are many more downsides and upsides however i will not discuss them here, there are many websites that discuss them like this one: http://portals.omg.org/dds/features-benefits/