# An Energy-Saving Forwarding Mechanism Based on Clustering for Opportunistic Networks
## 4 Architecture Overview
### Detailed Design  
Our mechanism comprises nodes with the highest energy level values to forward messages and avoid network resource loss. Additionally, eGPDMI focused on situations of gathering nodes by similar interests. We applied two clustering phases to enable decision-making:  
1. [label=()]
2. the first phase clusters the nodes by energy level;
3. the second phase clusters the nodes according to the interest profile. For building clusters, we analyzed two well-known clustering methods:  
Figure 1: Impact of the scenario density and battery range on the delivery probability of messages. EM (expect-maximization) is a clustering technique based on a statistics model called \"finite mixtures\". A finite mixture is a set of k distribution probabilities representing k clusters and the values that define each cluster. EM is a method to find the maximum likelihood for a group of parameters:  
1. Step 1 (expect step): It calculates the likelihood of the dataset by associating each object \(x_{i}\) to the cluster \(C_{k}\) by applying Equation (2). \[P(x_{i}\in C_{k})=p\frac{C_{k}}{x_{i}}=\frac{p(C_{k})p(x_{i}/C_{k})}{p(x_{i})}\] (2)
2. Step 2 (maximization step): Applying the maximization of Equation (1), recalculating the unknown values. \[mk=\frac{1}{n}\sum_{i=1}^{n}\frac{x_{i}p(x_{i}\in C_{k})}{\Sigma_{j}p(x_{j}\in C _{j})}\] (3) EM repeats the steps above, and the algorithm ends when the maximum likelihood criteria are satisfied. * K-means: Unlike hierarchical clustering, where the clusters merge or partition at each iteration, k-means partitions the clustering into precise k groups. The aim is to find clusters as homogeneous as possible. Hence, k-means can be written as follows. 1. Each cluster \(C_{k}\) is randomly built by applying a random centroid \(\alpha_{k}k\) for each cluster;
2. For each input y, assign it to the cluster \(C_{k}\), which centroid \(\alpha_{k}\) is the closest for each input;
3. Update their centroids by using all inputs assigned for each class;
4. Calculate the error function by applying Equation (4): \[E=\sum_{k=1}^{K}\sum_{y^{\prime}\in C_{k}}||y^{(l)}-\alpha_{k}||^{2}\] (4)
5. Repeat steps 2, 3, and 4 until there is no change in any clusters. EM allows a more stable control over the characteristics of the clusters. Both yield a sub-optimal solution since there is a lack of global knowledge of the network status. Further, this solution is suitable for routing through groups in OppNets, where there is no central network infrastructure. * Cluster-based forwarding: The primary goal of our mechanism is to mitigate the unnecessary use of device resources, particularly energy level, prioritizing the message transmission from nodes with a low level of energy. We assume these nodes have a stronger trend to become selfish due to a lack of resources. Our mechanism has three main steps, (i) apply clusterization techniques to arrange neighbor nodes according to their energy levels; (ii) apply clusterization techniques to group neighbor nodes with common interests; (iii) validate the threshold of the neighbor's energy during each contact. The energy level threshold is defined as \(E=[\text{Energy}\textit{lower},\text{Energy}\textit{upper}]\), \(E\subset[0,100]\). For example, if \(E=[50,100]\), our mechanism builds a cluster with nodes with an energy level between 50% and 100%. Depending on this condition, each node taking part in a contact forwards or does not forward a message towards a node not belonging to this cluster. Our complete message forwarding mechanism is written as follows:  
1. Message creation: Each created message is classified according to the topics of interest of the source node. 2. Classification of interests: Each node is classified according to its topics of interest. Classification of energy: Each node is classified according to its energy level. * 4 Clustering: The clusters of interests are built by applying the same mechanism presented in GPDMI. Then, we carry out a new clusterization run based on the energy level. We deploy the EM technique to gather nodes by energy.