# Multi-Mobile Agent Trust Framework for Mitigating Internal Attacks and Augmenting RPL Security
## 3 Proposed Framework
### Cluster Builder Module  
In this module, the underlying network found by the topology finder module is divided into independent clusters. In RPL, the absence of load balancing results in an uneven allocation of network traffic and reduces network efficiency. The proposed framework utilizes cluster-tree RPL, which was used in [41] for selecting the cluster head and setting routes using the Euclidean distance. It also utilizes fuzzy \(C\)-means clustering (FCM) to evaluate the geographical location and energy level of each node. Clustering techniques that employ FCM are among the most frequently used soft clustering algorithms. Other types of clustering, such as \(k\)-means, can be inferior to FCM. For example, in the \(k\)-means algorithm, there is a probability that a data point can belong to many clusters. For overlapping data sets, FCM clustering yields superior results [40]. FCM determines an anticipated number when generating a cluster. It provides the centroid value of such clusters by utilizing the node membership value [42]. The cluster builder module calculates clusters periodically or on discovering changes to the network topology. The value of the membership node \(D(pq)\) depends on the Euclidean distances from all the cluster centroids:  
\[D(pq)=\left[\sum_{k=1}^{M}\frac{d_{pq}^{2}}{d_{pk}^{2}}\right]^{-1},\quad p=1, 2,3\ldots N,\quad q=1,2,3\ldots M \tag{1}\]  
where \(p\) and \(q\) are two nodes and \(d\) is the Euclidean distance between them. Here, \(N\) and \(M\) are the number of nodes in the sensor field and the number of nodes in the available clusters, respectively. The Euclidean distances are measured by each node in the network [36]. The distance \(ED(pq)\) is computed for two nodes:  
\[ED(pq)=\sqrt{(p_{m}-p_{l})^{2}+(q_{m}-q_{l})^{2}} \tag{2}\]  
where \(l\) and \(m\) are two points with coordinates \((p_{l},q_{l})\) and \((p_{m},q_{m})\), respectively. The distance matrix:  
\[Distance= \begin{bmatrix}0&Distance(1,2)&\ldots&Distance(1,n)\\ \vdots&0&\ldots&\vdots\\ Distance(n,1)&Distance(n,2)&\ldots&0\end{bmatrix}  \tag{3}\]  
The centroid is computed as follows:  
\[\text{Centroid}((p_{l}-q_{l}),(p_{m}-q_{m}))=\left(\frac{p_{l}+p_{m}}{2}, \frac{q_{l}+q_{m}}{2}\right) \tag{4}\]  
At the start, the centroid point has the coordinates of the first node. The distance \(ED(pq)\) between that node and the other node is calculated by CT-RPL [41], and the centroid of the two nodes is also found. If the centroid falls within distance \(ED(pq)\), the node is added to the cluster. Otherwise, it is added to a distant cluster. The number of clusters is calculated as follows:  
\[N_{\text{(clusters)}}= \begin{cases}\text{Centroid}(p_{l},q_{m})\pm\text{ Distance},&\text{for the same cluster},\\ \text{Distant cluster},&\text{otherwise}\end{cases}  \tag{5}\]The total number of clusters:  
\[N=\sum_{i=1}^{n}=\text{Count}(\text{Centroid}(p_{l},q_{l})) \tag{6}\]  
where \(n\) is the number of nodes in a cluster. A node with the maximum value is added to the respective cluster. The FCM algorithm provides authentic clustering via OF minimization:  
\[obj(f)=\sum_{k=1}^{N}\sum_{j=1}^{n}D_{(kj)}^{/m}d_{(kj)}^{2} \tag{7}\]  
The fuzziness parameter is \(fm\), which is a very important parameter in clustering, and its value is always greater than 1. In our case, its value is \(\frac{1}{4}\), which is also used in normal circumstances. In short, the initial step after deploying RPL-Topology is to create clusters in that topology. Then, the FCM is used to cluster the nodes, as illustrated in Algorithm 1. It uses seven steps to complete the tasks:  
```
1:parameters: \(p,n,N,fm,p_{l},p_{m},D^{/m},d\)
2:initialize: \(p,n,N,fm,p_{l},p_{m},D^{/m},d\)
3: randomly initialize the membership matrix: \[Distance= \begin{bmatrix}0&Distance(1,2)&\dots&Distance(1,n)\\ \vdots&0&\dots&\vdots\\ Distance(n,1)&Distance(n,2)&\dots&0\end{bmatrix}