# E-MQTT: End-to-End Synchronous and Asynchronous Communication Mechanisms in MQTT Protocol
## 3 E-Mqtt
### End-to-End Communication Problem of MQTT  
When a publisher seeks the moment when a query message is received by a subscriber, the MQTT protocol involves the following procedural steps, illustrated in Figure 1. To facilitate the receipt of a response message from a subscriber, the publisher must subscriber to a new topic designated as B (1). The message publishing and subscription to topic B is an additional publish-subscribe session for the exchange of a response message. Subsequently,the publisher sends the original query message with the topic A (2), which the subscriber receives (3). The message publishing and subscription to topic A is the original publish-subscribe session for the exchange of a query message. To reply to the query message, the subscriber needs to publish a new response message with the new topic B (7). Upon reception of the published response message attached to topic B, the publisher confirms that the query message has been received by a subscriber before this response message (8). As a result, MQTT needs two distinct publishing sessions and requires 18 messages exchanged among the publisher, broker, and subscriber.  
Figure 2 illustrates how the publisher confirms when n subscribers have received the query message in MQTT. This figure shows only the query and response PUBLISH messages and omits the other PUBREC, PUBREL, PUBCOMP, and subscription messages for simplicity. By receiving n PUBLISH messages with topic B (1), the publisher can check the reception by n subscribers. As the number of subscribers increases, the number of exchanged messages also increases proportionally.  
Through modifications to MQTT, E-MQTT enables publishers to verify the moment of query message reception by subscribers with only one publishing session, effectively  
Figure 1: End-to-end confirmation process of query reception by one subscriber in MQTT (QoS 2).  
Figure 2: End-to-end confirmation process of query reception by n subscribers in MQTT (QoS 2).  
mitigating communication overhead. As shown in Figure 3, E-MQTT introduces a mechanism that permits publishers to check the moment when the query message is received by subscribers upon the receipt of a PUBREC packet (4), thus streamlining the necessary actions. In MQTT, the occurrence of a PUBREC packet ((4) in Figure 1) denotes the broker's reception of the published message, not that of a subscriber. On the other hand, in E-MQTT, the PUBREC packet implies that one or more subscribers have received the published query message. In E-MQTT, the number of exchanged messages is reduced to 9 and the broker forwards the PUBLISH and PUBREC packets to the final target after additional processing for the end-to-end communication.  
Figure 4 illustrates how the publisher confirms when n subscribers have received the query message in E-MQTT. This figure shows only the query PUBLISH and response PUBREC messages and omits the other PUBREL, PUBCOMP, and subscription messages for simplicity. When the publisher sends the query PUBLISH message, it also designates n responses that it will wait for (1). As the broker collects n PUBREC messages from subscribers (2), the publisher can check the reception by n subscribers by receiving one PUBREC message (3). Therefore, it also reduces the number of exchanged messages between the publisher and broker. We describe details of E-MQTT in the following sub-sections.