MQTT is based on TCP/IP which guarantees data delivery but messages can be lost if a TCP connection breaks down. Every communication protocol must ensure a quality of service (QoS) and MQTT defines three levels for message delivery on top of TCP. From level 0 to level 2, the server increases the effort to ensure that messages are delivered to subscribers but with higher QoS there are greater bandwidth consumption and latency. Quality of Service levels are the following: