## 3 The Proposed Intelligent Mixed Approach
### The Mixed Frequency Hopping Spread Spectrum and Smart Clustering Algorithm
#### 3.2.2 The Proposed Energy Efficient and Scalable Clustering and Network Coding Approach
The above considerations, lead to a maximum transmission range \(d_{th}\)  
\[d_{th}=\frac{K\times(MAX(d_{n})+MIN(d_{n}))}{2}, \tag{10}\]  
where \(K=\frac{RSSI_{avg}}{RT_{avg}}\), \(RSSI_{avg}\) is the average RSSI value, and \(RP_{avg}\) is the average residual power as observed by the BS after the broadcasting of interest messages during network deployment. Our proposed approach opts for the use of the threshold transmission distance to form the different network clusters. Considering the set of all nodes denoted as \(N\), the set of neighbour nodes of node \(n\) denoted as \(N_{b}\) can be computed as follows  
\[N_{b}=\sum_{b\in N,b\
eq n}d(b,n)<d_{max}, \tag{11}\]  
where \(d(b,n)\) is the Euclidean distance between NB-IoT nodes \(b\) and \(n\). This approach comes with the advantage that it avoids the chaining issue. * Step 2: For every node \(n\), all the distances with the neighbors in its cluster is computed as follows \[d_{sum}=\sum_{b\in N_{b}}d(n,b).\] (12)
* Step 3: The average residual energy of each cluster \(i\) denoted as \(RE_{CH_{i}}\) is computed as follows, \[RE_{CH_{i}}=\frac{1}{sizeof(N_{b})}\times\sum_{b\in N_{b}}RE_{ni}\] (13) where \(RE_{ni}\) represents the residual energy of node \(n\) belonging to cluster \(i\). * Step 4: For each formed cluster \(i\), the BS computes as a mixed residual energy and signal strength aware cluster head selection gradient \(SG_{ni}\) as follows, \[SG_{ni}=\alpha\times(\frac{RE_{ni}}{RI_{ni}})+\beta\times(RSSI_{ni}),\] (14) where \(RI_{ni}\) is the initial energy level of node \(n\) in cluster \(i\) and \(RSSI_{ni}\) is the RSSI value of node \(n\) in cluster \(i\) with respect to the BS. \(RSSI_{ni}\) is computed as per Equation (5). On the other hand, the parameters \(\alpha\) and \(\beta\) are the cost weights of the residual energy consideration and the reliability of communication aspect respectively. The cost weights \(\alpha\) and \(\beta\) are selected in each cluster \(i\) based on the following criteria, \[ \begin{cases}\alpha+\beta=1\\ \frac{RE_{CHi}}{RSSI_{Chi}}=\frac{\alpha}{\beta}\end{cases} \] (15) The criteria in Equation (15) express the fact that, the sum of cost weights (\(\alpha\) and \(\beta\)) is equal to unity and the higher the average residual energy in a cluster \(i\) (\(RE_{CHi}\)) as compared to the average \(RSSI\) of nodes in cluster \(i\) (\(RSSI_{Chi}\)), the higher the weight cost \(\alpha\) of the residual energy consideration in the definition of the CH selection gradient as compared to the weight cost of the RSSI consideration \(\beta\) and vice-versa. * Step 5: In each cluster \(i\), the node with the highest selection gradient \(S_{Gn}\) within a cluster, is selected to be the CH. * Step 6: Each time a CH receives data packets form various member nodes in its cluster, it applies Random Linear Network Coding (RLNC) (data aggregation) before transmitting it to the BS. In the typical two-hops clustering approach as considered by this study, the focus of this study is mainly on the global network coding approaches as the data aggregation point is the CH after which the aggregated data is immediately forwarded to the BS where its decoding occurs. Furthermore, the proposed network coding approach is an intersession network coding scheme in which data packets form various member nodes within the network are aggregated together before being transmitted as a single packet to the BS. The \(m\) independent data packets (\(d_{i}\)) from the \(m\) member nodes of the network cluster \(i\) are linearly combined by means of \(m\) random coefficients (\(C_{i}\)) from the GF of order \(2^{S}\). The value \(S\) is a positive number equal to the size of a single NB-IoT packet. The \(m\) packets are combined to form a single aggregated packet of the same size \(S\) as each one of them. A GF as generated by each CH is also made know to the BS for the sake of the decoding process.