## 4 SF-Partition-Based Clustering and Relaying (SFPCR) Scheme
### Relay LoRa Device Selection in the LSFZ  
In this paper, we considered exploiting LDs in the LSFZ as relay devices to support reliable data transmissions from source LoRa devices in the HSFZ to the GW. To achieve a reliable relay device selection policy, the SFPCR scheme uses a centralized optimal relay assignment method that iteratively allows a single best relay LoRa device (LD) among the relay candidate set of LoRa devices \(R=\{N_{1},N_{2},N_{3},\ldots,N_{i}\}\) in the LSFZ, to access the channel and assist the bidirectional transmissions of all the distant LDs (represented as CMs) through the CH in the HSFZ. The goal of our method was to devise a way to randomly select the best relay device to aid bidirectional communication between the source LDs (represented as CHs) and the GW, while taking into account two important performance parameters, namely, the link quality in terms of packet success probability and residual energy \(E_{re\_N_{i}}(t)\) of the candidate relay LoRa devices. The \(CH_{i}\) sends the relay a wake-on-radio (WOR) frame. This WOR frame wakes up the selected relay and sends packet information. The system model with \(CH_{i}\) in the HSFZ acting on behalf of the source LDs is shown schematically in Figure 4. Meanwhile, the set \(R\) of potential candidate relays in the LSFZ includes LoRa devices, that is, \(R=\{N_{1},N_{2},N_{3},\ldots,N_{i}\}\). Our method compares the metrics to determine the best relay \(N_{i}^{*}eR\). The packets collected by the \(CH_{i}\) are transmitted to \(N_{i}^{*}\) as the best relay from the candidate set because it meets the packet success probability as the primary evaluation parameter and residual energy threshold conditions for our relay device selection method. However, if any LD in the LSFZ does not meet the predefined threshold conditions, it cannot become a potential relay device. We present four main phases to specify our centralized optimal relay assignment method. With the four main phases, our method iteratively selects an optimal relay LoRa device and uses it to achieve cooperative transmission by jointly considering a LoRa device's link quality \((L_{N_{i}})\) in terms of packet success probability and remaining energy information \(E_{r_{e}\_{N_{i}}}(t)\). Initially, the residual energy of each LoRa device is critical in the relay selection process to avert excessive use of a single relay device on the appropriate channel. Thus, the concept of network fairness is not jeopardized in this way. Here, we explain the four phases in detail, respectively. **Phase 1:** To create a set of potential relay devices, we employed the harmonic mean criterion to assess the link quality [24]. According to two-hop channel information, each LoRa device estimates the integrated link quality \(L(N_{i})\) in terms of the packet success probability \((P_{suc}^{i}(loc(x))\) based on the distance between them, the SNR, and the receiver sensitivity of the device. Then, \(L(N_{i})\) can be shown in Equation (23). \[L(N_{i})=2(P_{suc}^{(S,N_{i})}(loc(x))+P_{suc}^{(N_{i}GW)}(loc(x)))^{-1} \tag{23}\]  
For all LoRa devices that pass the first criteria, a candidate set of relay devices is constituted for further scrutiny in the succeeding phases in a bid to select the best relay LD. **Phase 2:** The GW evaluates the residual energy \(E_{r_{e}\_{N_{i}}}(t)\) of each candidate relay device \(N_{i}\) at a given time (t) since its deployment in an IoT LoRa network. Assuming the total energy consumption \(E_{total\_N_{i}}(t)\) used by a LoRa device \(N_{i}\) during inactive and active modes at a particular time (t), \(E_{0}\) is the initial energy of the LD. Then, the residual energy \(E_{r_{e}\_N_{i}}(t)\) of the \(i\)th relay device is represented in Equation (24). \[E_{r_{e}\_N_{i}}(t)=E_{0}-E_{total\_N_{i}}(t) \tag{24}\]  
where \(E_{0}\) is the initial energy of the LoRa device at the initial time \((t_{0})\), \(E_{total\_N_{i}}(t)\) is the energy dissipated by the LoRa device during inactive mode at time (\(t\)) and active mode.