# Communication Protocol Design for IoT-Enabled Energy Management in a Smart Microgrid
## 4 Error Probability Analysis
### \(k\) Odd, \(\ell\) Even  
In this case, the chances of error for the \(\bar{\ell}\)th HEMS to incorrectly decode the message at the first time slot is given as in (9). During time slot 2, the chances of error at the \(\bar{k}\)th HEMS is given by (9), with \(\bar{\ell}\) replaced by \(\bar{k}\). In time slot 3, the \(\bar{k}\)th HEMS receives the relayed message from the \(\bar{\ell}\)th HEMS, and so, the error probability can be written as in (10). Similarly, in the fourth time slot, the error probability at the \(\bar{\ell}\)th HEMS is given by (10) with \(\bar{k}\) replaced by \(\bar{\ell}\). The process continues until the \((\frac{|\ell-k|+1}{2}+1)\)th time slot. Then, similar to Lemma 3, the probability that the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS incorrectly decodes the \(k\)th HEMS's message is as follows:  
\[P_{\frac{|\ell-k|+1}{2}}\approx\sum_{a=1}^{\frac{|\ell-k|+1}{2}-k}P_{k+a-1,k+ a}\prod_{b=1,b\
eq a}^{\frac{|\ell-k|+1}{2}-k}(1-P_{k+b-1,k+b}) \tag{13}\]  
Similarly, the probability that the \((\frac{|\ell-k|+1}{2})\)th HEMS incorrectly decodes the \((\ell-1)\)th HEMS's signal can be represented as in (13), with \(k\) replaced by \(\ell-1\). The error probability for the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS decoding the \((k+1)\)th and \(\ell\)th HEMS' message can be obtained in a similar manner. After the \((\frac{|\ell-k|+1}{2}+2)\)th time slot, the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS receives the sum of the signal from the \((\frac{|\ell-k|+1}{2})\)th HEMS. Thus, the chances that the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS incorrectly estimates the message from the \(k\)th HEMS can be given as in the following lemma. **Lemma 4**. : _The probability that the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS makes an error in estimating the \(k\)th HEMS's message in the \((\frac{|\ell-k|+1}{2}+2)\)th time slot is given by the following:_  
\[ \begin{split} Pr_{\frac{|\ell-k|+1}{2}+1,k}&\approx Pr_{\frac{|\ell-k|+1}{2}+1,\frac{|\ell-k|+1}{2} }(1-Pr_{\frac{|\ell-k|+1}{2},k})(1-Pr_{\frac{|\ell-k|+1}{2},k-1})(1-Pr_{ \frac{|\ell-k|+1}{2}+1,\ell-1})\\ &+(1-Pr_{\frac{|\ell-k|+1}{2}+1,\frac{|\ell-k|+1}{2}})Pr_{\frac{ |\ell-k|+1}{2},\ell-1}(1-Pr_{\frac{|\ell-k|+1}{2},\ell-1})(1-Pr_{\frac{|\ell- k|+1}{2}+1,\ell-1})\\ &+(1-Pr_{\frac{|\ell-k|+1}{2}+1,\frac{|\ell-k|+1}{2}})(1-Pr_{ \frac{|\ell-k|+1}{2},k-1})Pr_{\frac{|\ell-k|+1}{2},\ell-1})Pr_{\frac{|\ell-k|+1 }{2}+1,\ell-1})\\ &+(1-Pr_{\frac{|\ell-k|+1}{2}+1,\frac{|\ell-k|+1}{2}})(1-Pr_{ \frac{|\ell-k|+1}{2},\ell-1})Pr_{\frac{|\ell-k|+1}{2}+1,\ell-1})\\ \end{split}  \tag{14}\]  
_Here, \(Pr_{\frac{|\ell-k|+1}{2}+1,\frac{|\ell-k|+1}{2}}\) denotes the chances of error at the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS for decoding the \((\frac{|\ell-k|+1}{2})\)th HEMS's message. The term \(P_{\frac{|\ell-k|+1}{2}+1,\ell-1}\) denotes the probability that the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS makes an error about the the \((\ell-1)\)th HEMS's message._Proof. : The \((\frac{|\ell-k|+1}{2}+1)\)th HEMS receives the \(\hat{V}_{k,\ell-1}\) from the \((\frac{|\ell-k|+1}{2})\)th HEMS. Then, it utilises the \((\ell-1)\)th HEMS's signal (which it has decoded earlier on) to extract the signal from the \(k\)th HEMS. The probability that the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS makes an error in estimating the \(k\)th HEMS's message can be described using the following scenarios. These include the following: (i) the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS makes an error in estimating the \((\frac{|\ell-k|+1}{2})\)th HEMS's message, (ii) the \((\frac{|\ell-k|+1}{2})\)th HEMS obtains an incorrect estimate of the \(k\)th HEMS's message, (iii) the \((\ell-1)\)th HEMS's message is estimated inaccurately by the \((\frac{|\ell-k|+1}{2})\)th HEMS, and (iv) the \((\ell-1)\)th HEMS's information is inaccurately obtained by the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS. Since BPSK signals are considered, the \((\frac{|\ell-k|+1}{2}+1)\)th HEMS incorrectly decodes the signal from the \(k\)th HEMS if any one or any three of these events happen at the same time.