Bird
Raised Fist0
IOT Protocolsdevops~20 mins

Topics and topic hierarchy in IOT Protocols - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
MQTT Topic Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding MQTT Topic Hierarchy

In MQTT, topics are structured in a hierarchy separated by slashes. Which of the following represents a valid topic hierarchy for a smart home system?

Ahome.livingroom.temperature
Bhome/livingroom/temperature
Chome\livingroom\temperature
Dhome-livingroom-temperature
Attempts:
2 left
💡 Hint

Think about how MQTT topics use slashes to separate levels.

💻 Command Output
intermediate
2:00remaining
MQTT Topic Subscription Wildcards Output

What topics will a client receive if it subscribes to home/+/temperature?

Ahome/livingroom/temperature and home/kitchen/temperature
Bhome/livingroom/temperature only
Chome/livingroom/humidity and home/kitchen/temperature
Dhome/livingroom/temperature and home/livingroom/humidity
Attempts:
2 left
💡 Hint

The '+' wildcard matches exactly one level in the topic hierarchy.

❓ Configuration
advanced
3:00remaining
Configuring MQTT Broker Topic Access Control

You want to restrict clients so they can only publish to topics under devices/ and subscribe to topics under sensors/. Which configuration snippet correctly enforces this in a typical MQTT broker ACL file?

A
user client
publish devices/
subscribe sensors/
B
user client
publish sensors/#
subscribe devices/#
C
user client
publish #
subscribe #
D
user client
publish devices/#
subscribe sensors/#
Attempts:
2 left
💡 Hint

Remember that '#' matches all subtopics and the ACL syntax requires specifying publish and subscribe permissions.

❓ Troubleshoot
advanced
3:00remaining
Troubleshooting MQTT Topic Subscription Failure

A client subscribes to home/+/temperature but does not receive messages published to home/livingroom/humidity. What is the most likely cause?

AThe client is publishing to <code>home/livingroom/humidity</code> instead of <code>home/livingroom/temperature</code>
BThe MQTT broker does not support the '+' wildcard
CThe client subscribed to <code>home/#</code> instead of <code>home/+/temperature</code>
DThe client subscribed with QoS 0 but messages are published with QoS 2
Attempts:
2 left
💡 Hint

Check if the published topic matches the subscribed topic pattern exactly.

🔀 Workflow
expert
5:00remaining
Designing a Topic Hierarchy for Scalable IoT Deployment

You are designing an MQTT topic hierarchy for a city-wide sensor network with multiple sensor types in many locations. Which topic hierarchy design best supports easy filtering by location and sensor type?

Asensor_type/city/location/sensor_id
Bcity/sensor_type/location/sensor_id
Ccity/location/sensor_type/sensor_id
Dsensor_id/city/location/sensor_type
Attempts:
2 left
💡 Hint

Consider which topic levels you want to filter on first when subscribing.

Practice

(1/5)
1. What is the main purpose of topics in IoT protocols like MQTT?
easy
A. To encrypt messages for security
B. To store device firmware
C. To organize messages in a clear, folder-like structure
D. To control device power settings

Solution

  1. Step 1: Understand the role of topics

    Topics act like folders to organize messages so devices know where to send or receive data.
  2. Step 2: Compare options with topic function

    Only organizing messages matches the purpose of topics; encryption and firmware storage are unrelated.
  3. Final Answer:

    To organize messages in a clear, folder-like structure -> Option C
  4. Quick Check:

    Topics organize messages = B [OK]
Hint: Topics are like folders for messages [OK]
Common Mistakes:
  • Confusing topics with security features
  • Thinking topics store device data
  • Mixing topics with device settings
2. Which of the following is the correct way to write a topic with three levels?
easy
A. home-kitchen-temperature
B. home.kitchen.temperature
C. home\kitchen\temperature
D. home/kitchen/temperature

Solution

  1. Step 1: Recall topic level separator

    Topics use slashes (/) to separate levels, like folders in a path.
  2. Step 2: Check each option's separator

    Only home/kitchen/temperature uses slashes correctly; others use dots, backslashes, or dashes which are incorrect.
  3. Final Answer:

    home/kitchen/temperature -> Option D
  4. Quick Check:

    Topic levels separated by '/' = A [OK]
Hint: Use slashes (/) to separate topic levels [OK]
Common Mistakes:
  • Using dots instead of slashes
  • Using backslashes which are invalid
  • Using dashes instead of separators
3. Given the topic building1/floor2/room3/sensor, which part represents the third level?
medium
A. room3
B. floor2
C. building1
D. sensor

Solution

  1. Step 1: Split the topic by slashes

    Splitting 'building1/floor2/room3/sensor' by '/' gives ['building1', 'floor2', 'room3', 'sensor'].
  2. Step 2: Identify the third element

    The third element (index 2) is 'room3'.
  3. Final Answer:

    room3 -> Option A
  4. Quick Check:

    Third level = room3 = C [OK]
Hint: Count levels separated by '/' to find position [OK]
Common Mistakes:
  • Counting from zero incorrectly
  • Choosing first or second level by mistake
  • Confusing last level with third
4. Identify the error in this topic string: home//livingroom/temperature
medium
A. Double slash creates an empty level
B. Missing slash between 'home' and 'livingroom'
C. Topic levels must use dots, not slashes
D. Topic cannot contain the word 'temperature'

Solution

  1. Step 1: Analyze the topic string

    The string 'home//livingroom/temperature' has two slashes together, meaning an empty level between them.
  2. Step 2: Understand topic level rules

    Empty levels are invalid because each level should have a name; double slashes cause this error.
  3. Final Answer:

    Double slash creates an empty level -> Option A
  4. Quick Check:

    Double slash = empty level error = A [OK]
Hint: Avoid double slashes to prevent empty topic levels [OK]
Common Mistakes:
  • Ignoring empty levels caused by double slashes
  • Thinking dots are required separators
  • Believing certain words are forbidden in topics
5. You want to subscribe to all sensors in any room on floor 1 of building 2 using MQTT topics. Which subscription topic should you use?
hard
A. building2/floor1/*/sensor
B. building2/floor1/+/sensor
C. building2/floor1/room1/sensor
D. building2/floor1/#/sensor

Solution

  1. Step 1: Understand MQTT wildcards

    The '+' wildcard matches exactly one level, while '#' matches all remaining levels.
  2. Step 2: Analyze the subscription needs

    We want any room on floor1, so '+' replaces the room level. '#' would match too many levels, and '*' is invalid in MQTT.
  3. Final Answer:

    building2/floor1/+/sensor -> Option B
  4. Quick Check:

    '+' wildcard for one level = D [OK]
Hint: Use '+' for single-level wildcard in MQTT topics [OK]
Common Mistakes:
  • Using '#' when only one level is needed
  • Using '*' which is not a valid MQTT wildcard
  • Specifying exact room instead of wildcard
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard