UAT 105 Digital Technology and Networks
Worksheet 4 A battery-reporting system for a drone fleet
Objective
Build an MQTT system that reports several drones, knows data freshness, detects lost drones and restricts rights per topic
Equipment and materials
- Computer with Mosquitto
- Python and paho-mqtt
- The MQTT and Mosquitto knowledge unit
Safety
- Desk work only; no flying
- Use only a local or lab broker
Steps
- Run mosquitto_sub -t "drone/#" -v and publish with mosquitto_pub; try + and #
- Write a program that simulates three drones sending battery level every second at QoS 0
- Add a retained online status and a Last Will of offline
- Write a subscriber that shows the latest value with its age, then kill one drone abruptly
- Enable TLS and an ACL and test that drone 1 cannot publish to drone 2's topics
Record of results
| Subscribed filter | Published topic | Expected to receive? | Actually received? |
|---|---|---|---|
| Time (s) | Drone | Latest battery (%) | Data age (s) | Status |
|---|---|---|---|---|
| Test | Command used | Expected result | Result obtained |
|---|---|---|---|
Questions
Does a subscriber on drone/+/battery receive a message on drone/1/status, and does one on drone/#? Explain from your Table 1 results.
After one drone was killed abruptly, how did its data age change and how quickly did the Last Will arrive? Why must the subscriber still show data age when Last Will exists?
Why should the online status be retained but the battery level not?
If your subscriber can process 2 messages per second while 3 drones each send 1 per second, how long is the queue after one minute, how long does a new message wait, and how would you fix it?
What does the ACL test prove, and how does the threat TLS stops differ from what the ACL stops?
Check before you hand in
What to hand in
- Simulated drone and subscriber code
- Last Will test record
- TLS and ACL configuration with test result