## 5 Collision Calculation Through Packet Error Rate
\[\mathrm{P}(C_{N_{n}^{1,2}}^{\prime})=1-\mathrm{P}(C_{N_{n}^{1,2}}^{\prime})=1- e^{\phi G(N_{n}^{1,2})} \tag{20}\]  
Also considering that at least one LoRa device is transmitting in areas of gateway 1, \(N_{n}^{1}\), and gateway number 2, \(N_{n}^{2}\), probability can be represented as follows:  
\[\mathrm{P}(C_{N_{n}^{1}}^{\prime}\cap C_{N_{n}^{2}}^{\prime})=(1-\mathrm{P}(C _{N_{n}^{1}}^{\prime}))(1-\mathrm{P}(C_{N_{n}^{2}}^{\prime}))=(1-e^{\phi G(N_ {n}^{1})})(1-e^{\phi G(N_{n}^{2})}) \tag{21}\]  
Now, the delivery ratio incorporating both events and also considering probability of regions from where LoRa devices are transmitting, same can be deduced as given in Equation (22). \[D_{n}=1-\mathrm{P}(C_{N_{n}^{1,2}}^{\prime}\cup(C_{N_{n}^{1}}^{\prime}\cap C_ {N_{n}^{2}}^{\prime}))=e^{-\phi G(N_{n}^{1,2})}.[e^{-\phi G(N_{n}^{1})}+e^{- \phi G(N_{n}^{2})}-e^{-\phi G(N_{n}^{1}\cup N_{n}^{1})}] \tag{22}\]  
In order to estimate collisions in a smart city environment with multiple gateways, regions, and hundreds of LoRa devices, let us consider a set \(N_{n}^{1,2}\) covering a region of two gateways, \(N_{n}^{1}\), and \(N_{n}^{2}\). Let the area covered be given as \(A\), thus the successful reception of packets based on [PERSON]'s law will be given as following. \[PER=1-\mathrm{P}(\prod\limits_{i=1}^{|A|}(\prod\limits_{N_{n}^{k}\in A_{i}}C_{ N_{n}^{k}}^{\prime}))=\prod\limits_{i=1}^{|A|}1-\prod\limits_{N_{n}^{k}\in A_{i}}(1-e^{ \phi G(N_{n}^{k})}) \tag{23}\]  
Applying long distance path loss as given in Equations (15) and (17) and a set of interfering nodes represented by \(l_{n}^{k},\forall k\in\{1,2,\ldots k\}\), Equations (22) and (23) will be same for value of \(k=1\), path loss given in Equation (17) for a node \(n\) and a LoRa device transmitting at same time represented as \(j\) is \(K_{i}^{r}=a_{i}+Y_{i}\) where \(i\in\{n,j\}\) and \(Y_{i}=N(0,\sigma\
eq 0)\). For successful reception, power at LoRa device \(n\) should be greater than power at interfering device \(j\), i.e., \(\ Power_{n}^{r}-Pwr_{j}^{r}<SIR_{s,s^{\prime}}\). Simplifying \(n=1,j=2\) and \(SIR_{s,s^{\prime}}=b\), taking zero mean normal deviation \(X_{1}-X_{2}<b-(a_{1}-a_{2})\). The probability density function (PDF) will be \(f(X_{3})=\frac{1}{2\sigma\sqrt{2\pi}}e^{-\frac{\pi^{2}}{8\sigma^{2}}}\). Outage probability is also affected by the fading environment, and thus the final delivery rate for LoRa device \(n\) will be \(D_{n}=(1-P_{C})(1-P_{O})\), where \(P_{C}\) is the probability of collision and \(P_{O}\) is probability of outage. Based on the a/m scenario, \(P_{C}\) and \(P_{O}\) are presented in Equation (24) and Equation (25), respectively. \[P_{C}=\prod_{i=1}^{|s|}(1-(\prod_{R_{n}^{k}}\in s_{i}(1-\prod_{j\in R_{n}^{k}} P(C_{\{j\}}^{\prime}\cap C_{j}^{k})))) \tag{24}\]  
\[S=-174+10\text{log}_{10}BW+NF+SNR \tag{16}\]0  
Probability of collision \(P_{C}\) guides on the number of collisions that might occur in the \(n\) LoRa device scenario with \(k\) gateways, where \(j\) LoRa devices are considered interfering devices; \(P_{O}\) gives guidance on the probability of the received power at the LoRa node and also the sensitivity for successful reception. Together, both are useful in determining successful reception and complete loss of packets. We can rewrite the equation for delivery ratio as follows:  
\[S=-174+10\text{log}_{10}BW+NF+SNR \tag{16}\]1  
Beyond the value of delivery ratio \(D_{n}\), outage probability \(P_{O}\), and collision probability \(P_{C}\), the calculation of the re-transmission ratio \((RT)\) based upon number of LoRa packets re-transmitted after collision will guide on the success of Algorithm 2. \[S=-174+10\text{log}_{10}BW+NF+SNR \tag{16}\]2