# HCLE: Hybrid Clustering Approach for Extending WBAN Lifetime
## 4 Materials and Methods
### HCEL Routing Protocol
#### 4.2.2 Parent Node Selection  
After the sink node receives the necessary information from the sensor nodes, it employs a cost function to select the parent nodes. The cost function considers factors such as the distance between a sensor node and the sink, the current residual energy level of the node, and the RSSI value from a sensor node to the sink. The distance between the sink and the sensor node is calculated using the Euclidean formula, while the residual energy is determined as discussed in Section 3.2. The RSSI value, which follows a log-normal distribution, further discussed in Section 5.1, is updated for each transmission. Hence, the cost function, denoted as \(CF(i)\) for the sensor node \(i\), is calculated as Equation (7), where \(d\) represents the distance between node \(i\) and the sink, \(RE(i)\) is the residual energy, and \(RSSI(i)\) indicates the RSSI value of node \(i\). \[CF(i)=\frac{d\times RSSI(i)}{RE(i)} \tag{7}\]  
By incorporating distance, the cost function considers the physical proximity of each sensor node to the sink node. Including residual energy in the cost function is significant for energy efficiency. Nodes with higher residual energy levels are given high scores, indicating their ability to handle data-forwarding tasks. Additionally, the cost function incorporates RSSI values, which reflect the signal quality between the nodes and the sink. The algorithm prioritizes nodes with stronger and more reliable communication links by considering RSSI. This balanced distribution of responsibilities helps prevent energy imbalance among nodes and contributes to the network's longevity. In particular, the sink node selects the parent node based on several criteria, including shorter distance, higher RSSI value, and greater residual energy. Once the cost function is computed for all two-hop sensor nodes, the sink node selects the parent node with the maximum cost function value. However, there is a constraint on the number of nodes that a parent node can serve (\(\tau\)). This constraint ensures optimal utilization of resources within the network. The selection of parent nodes is an ongoing process that adapts to the changing energy levels of the sensor nodes. When the energy of a selected parent node reaches a threshold value (\(Th\)), the sink stops using this node for forwarding packets. At that time, another node has been selected as a parent node, as previously explained. Once the residual energy of all two-hop sensor nodes reaches the threshold (\(Th\)), a new round of parent node selection is initiated. In this case, all two-hop sensor nodes can serve as parent nodes. This approach ensures that the flow of traffic and data routing within the WBAN remains efficient and well-balanced. After selecting the parent nodes, their identifiers are broadcast to all two-hop sensor nodes, enabling them to establish a communication link with their designated parent node. It is important to note that reaching the energy threshold value (\(Th\)) is an alarm, signaling the network management system to replace or recharge the node. By selecting the parent nodes based on the maximum cost function value, the threshold energy value (\(Th\)), and the limitation in the number of nodes that the parent node can serve (\(\tau\)), the algorithm redistributes the data traffic among the sensor nodes. This strategy prevents any single node from becoming overwhelmed with excessive data forwarding responsibilities, promoting a greater utilization of network resources. In this scenario, the lifetime of all sensor nodes is extended, and the energy consumption is more evenly distributed throughout the network.