# Reducing Detrimental Communication Failure Impacts in Microgrids by Using Deep Learning Techniques
## 5 Communication Protocol and Latency
### Messaging Protocol  
There are different application layer protocols that can be utilized for such applications. The more famous ones are hypertext transfer protocol (HTTP), message queuing telemetry transport (MQTT), and constrained application protocol (CoAP) [38]. MQTT, which is the selected messaging protocol in our aforementioned MG architecture, is considered to be a better candidate for device-to-device (D2D) applications due to its publish/subscribe methodology and simpler frame structuring which means smaller headers sizes than the HTTP protocol [39]. This provides the light-weight feature of MQTT. It is necessary to mention that in our proposed structure IEEE 802.11 (WiFi) is utilized as the physical layer protocol.  
Figure 9: LSTM-RNN short-term PV-generation forecasting: 200 hidden units, 1000 epoch #. (**a**) Updated with observed values. (**b**) Updated with predicted values.  
MQTT frames consist of a fixed header (minimum one and maximum two bytes), a variable header and payload that can theoretically be as large as 260 MB. The formatting of MQTT messages are comprehensively explained in reference [39]. It is important to mention that, while binary messages are also possible, normally the payload bytes are formed by UTF-8 encoded strings in MQTT protocol. In other words, if the messages are going to grow in size due to adding supplementary information _\"at least one byte\"_ will be added to the payload for each character. The effects of this phenomenon is investigated in terms of latency increase, due to larger frames, and possible medium access control (MAC) layer collisions in the next subsection.  
Since the idea of this article is related to transmission link failures it is important to provide a brief discussion about the failure rate or the reliability of the utilized communication framework. This is required to be discussed from two different points of view which are MQTT reliability as the messaging protocol and the rest of the transmission architecture that is conceptualized as the OSI stack:  
* The reliability of the MQTT messaging protocol depends on the level of quality of service (QoS) selected. Generally, a larger level of QoS translates to higher reliability and QoS 1 and QoS 2 ensure the delivery of messages while increasing the latency as a consequence of adding the number of transmissions and redundancy [2].
* MQTT works on top of TCP/IP and a compatible physical layer protocol, which in this case is WiFi. The failure rate of this combination is totally case sensitive and depends on lots of factors such as the size of the network, congestion issues, security level, and power availability/stability [40].  
Based on the points addressed above, it can be argued that failure rates or reliability of a communication architecture such as MQTT depend on different factors regarding the specific application. However, it can be stated that using higher MQTT QoS levels removes packet loss possibilities from the application layer. Then, further down the OSI stack, employing a stable and standard network such as WiFi can greatly contribute to higher reliability.  
In the case of the tests conducted for this study, as expected, no unintentional packet losses or link failures were observed since MQTT QoS 1 was employed, limited users were connected to the LAN, and also the very robust and high bandwidth IEEE 802.11 ac was employed for the link and physical layer. All the failures, that will be introduced in the following sections were intentional to emulate poor network scenarios.