MQTT over TLS (MQTTS) in IOT Protocols - Time & Space Complexity
We want to understand how the time to send messages changes when using MQTT over TLS.
Specifically, how does adding TLS affect the work done as message size grows?
Analyze the time complexity of the following MQTT over TLS message send process.
connect_to_broker_tls() {
establish_tls_handshake()
authenticate()
}
send_message_tls(message) {
encrypt_message(message)
send_over_network(message)
wait_for_ack()
}
This code shows connecting securely and sending a message with encryption and acknowledgment.
Look for repeated steps that take time as input grows.
- Primary operation: encrypting the message before sending
- How many times: once per message, processing each byte
As the message size grows, encryption and sending take longer.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 bytes | 10 encryption steps + network send |
| 100 bytes | 100 encryption steps + network send |
| 1000 bytes | 1000 encryption steps + network send |
Pattern observation: The work grows directly with message size.
Time Complexity: O(n)
This means the time to send a message grows in direct proportion to its size.
[X] Wrong: "TLS encryption time is constant no matter message size."
[OK] Correct: Encryption processes each byte, so bigger messages take more time.
Understanding how encryption affects message sending time helps you explain secure communication delays clearly.
"What if we batch multiple small messages before encrypting and sending? How would the time complexity change?"