# Trusted Energy-Aware Hierarchical Routing (TEAHR) for Wireless Sensor Networks
## 3 Proposed Studies
### Proposed Algorithm
Lines 19-29: If a new member is added for each new Nodenode in network N if the new Nodenode meets or exceeds the trust threshold T_threshold, fully integrate the Nodenode into the network with standard privileges. If the new Node fails to meet the trust threshold T_threshold: If probation is needed, extend the probation period for the Node. Otherwise, the Node can be removed from the network based on security policies. Lines 30-34 Periodically recalculate the trust thresholds. Recalculate T_threshold during significant network events, such as node failures or attack detection. Use adaptive algorithms to set thresholds based on predictive analytics of network conditions and node behavior patterns. Lines 35-42 manage the malicious behavior; if the overall trust score falls below T_threshold and the Node shows signs of malicious behavior, then isolate and remove xi from critical communication routes and broadcast alerts. Line 43 is the end of the loop. ```
1:\(\text{x}_{\text{i}}\) represents the normal Node, and CH represents a Cluster-Head node. 2:\(\text{Output}\): Cluster head selection
3:function cluster_head_selection(N, CH)
4:for each \(\text{x}_{\text{i}}\) in CH's cluster do
5:if xi in CH.T then
6:\(\text{T\_energy(x_{\text{i}})}\Leftarrow\text{E\_res(x_{\text{i}})}/\text{E\_max}\)
7:\(\text{T\_forward(x_{\text{i}})}\Leftarrow\text{P\_forward(x_{\text{i}})}/ \text{P\_received(x_{\text{i}})}\)
8:\(\text{T\_consistency(x_{\text{i}})}\Leftarrow\text{P\_consistent(x_{\text{i}})}/ \text{P\_forward(x_{\text{i}})}\)
9:\(\text{T\_behavior(x_{\text{i}})}\Leftarrow\text{evaluate\_behavior(x_{\text{i}})}\)
10:\(\text{T\_overall(x_{\text{i}})}\Leftarrow\text{w1}^{*}\text{T\_energy(x_{ \text{i}})}+\text{w2}^{*}\text{T\_forward(x_{\text{i}})}+\text{w3}^{*} \text{T\_consistency(x_{\text{i}})}+\text{w4}^{*}\text{T\_behavior(x_{\text{i}})}\)
11:\(\text{T\_threshold}\Leftarrow\text{set\_dynamic\_trust\_threshold()}\)
12:if\(\text{T\_overall(x_{\text{i}})}<\text{T\_threshold}\)then
13:if\(\text{is\_malicious(x_{\text{i}})}\) then
14:\(\text{broadcast\_alert(x_{\text{i}})}\)
15:\(\text{block\_node(x_{\text{i}})}\)
16:else
17:\(\text{flag\_for\_re\_evaluation(x_{\text{i}})}\)
18:\(\text{update\_trust\_level(CH.T, x_{\text{i}})}\)
19:endif
20:else
21:\(\text{confirm\_participation(x_{\text{i}})}\)
22:\(\text{update\_trust\_level(CH.T, x_{\text{i}})}\)
23:endif if
24:endif for
25:endif function
```  
**Algorithm 1**Cluster Head Selection  
Algorithm 3 is Trust-based hierarchical routing oversees the routing process through trust assessments and energy factors. This method invokes method 1 (cluster_head_selection(N and CH)) to pick cluster heads based on Trust and employs the dynamic trust thresholds established by just previous algorithm for routing decisions. Establishes a hierarchical routing mechanism that is energy-efficient and trust-centric, guaranteeing adequate and secure data transmission across the network. In this algorithm, trust-based routing, data transmission, dynamic trust management, and secure data transmission functions are used to create hierarchical routing. ```
**Algorithm 2**Setup Dynamic Trust Thresholds
```
1:Input: xi represents a normal node, and CH denotes a cluster-head node managing a cluster of nodes.