UAT 105 Digital Technology and Networks

Worksheet 4 A battery-reporting system for a drone fleet

Lab 6 hAssesses CLO3

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

  1. Run mosquitto_sub -t "drone/#" -v and publish with mosquitto_pub; try + and #
  2. Write a program that simulates three drones sending battery level every second at QoS 0
  3. Add a retained online status and a Last Will of offline
  4. Write a subscriber that shows the latest value with its age, then kill one drone abruptly
  5. Enable TLS and an ACL and test that drone 1 cannot publish to drone 2's topics

Record of results

Table 1 Wildcard tests with mosquitto_sub and mosquitto_pub
Subscribed filterPublished topicExpected to receive?Actually received?
Table 2 Subscriber display before and after one drone is killed
Time (s)DroneLatest battery (%)Data age (s)Status
Table 3 TLS and ACL test results
TestCommand usedExpected resultResult obtained

Questions

  1. Does a subscriber on drone/+/battery receive a message on drone/1/status, and does one on drone/#? Explain from your Table 1 results.

  2. 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?

  3. Why should the online status be retained but the battery level not?

  4. 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?

  5. 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

CLO3 Explain IoT architecture and publish/subscribe messaging. (CLOs are a web-team draft; the course owner sets the final ones.)

Instructors: answers and teaching notes for this worksheet are in the teaching pack