## 3 Proposed Trust-CH Framework
### Trust-Based Calculation
Once ACK received for Hello packet from \(x^{i}\) at \(x^{j}\), it defines the availability of \(x^{i}\). The \(AF\) is calculated in Equation (3) [40]. \[AF\Big{(}x^{i,j}(t)\Big{)}=\frac{A\big{(}x^{i,j}(t)\big{)}}{A\big{(}x^{i,j}(t) \big{)}+AH\big{(}x^{i,j}(t)\big{)}} \tag{3}\]  
where, \(A\big{(}x^{i,j}(t)\big{)}\) denotes the number of acknowledged Hello packets and \(AH\big{(}x^{i,j}(t)\big{)}\) denotes the number of non-acknowledged Hello packets. However, a higher \(TB\big{(}x^{i}\big{)}\) value indicates greater chances of \(x^{i}\) as a legitimate WSN node. Based on the output of the \(TB\), it is determined whether the nodule is malicious, suspicious, or benign. If the \(TB\) value is within the range of the malicious node, the \(x^{i}\) node is rejected and the details of that node are reported to the rest of the CHs. Otherwise, the Trust Level (\(TL\)) value in Table (\(T\)) will be populated with the TB value only for the first time (The \(TL\) value is selected based on the \(TB\) value). The scale variable for the \(TL\) selection process is used to determine which one is in Equation (4). \[TL=\left\{ \begin{array}{ll}Malicious,&TB<\lambda\\ Suspicious,&\lambda\ \leq TB<\lambda_{1}\\ Benign,&TB>\lambda_{1}\end{array} \right. \tag{4}\]  
where \(\lambda\) and \(\lambda_{1}\) are constant values. The \(TL\) value is selected based on \(TB\) value. 2. Number of Repetitions  
If a new node is classified as benign or suspected, it remains under trial and measurement until trust is confirmed. Each time the WSN node goes to the link in another CH, it is also monitored and \(TB\) is calculated. The new \(TB\) output is added to the TL value in Table T. This operation will continue in more than one CH or the same CH. Even if the TL value reaches 1 for any of the WSN nodes, the WSN node obtains the absolute trust criterion in the cluster and processes it reliably without any future trust operations. Conversely, if the value of \(TB\) decreases, it is subtracted from the TL and the node becomes suspect until it is eventually rejected. These operations appear in Equation (5). \[TL\Big{[}x^{i}\Big{]}=\left\{ \begin{array}{ll}TL\big{[}x^{i}\big{]}-TB[x^{ i}],&TB[x^{i}]<\lambda\\ TL\big{[}x^{i}\big{]}+TB[x^{i}],&\lambda\ \leq TB[x^{i}]<\lambda_{1}\\ TL\big{[}x^{i}\big{]}+TB[x^{i}],&TB[x^{i}]>\lambda_{1}\end{array} \right. \tag{5}\]  
Likewise, it should be noted that WSN nodes with a trust value (\(TL\)) less than the threshold value (\(\lambda\)) will not exchange the T-table with them. AP is also aware of this table (T) because it will decrypt the encryptions based on the trust values of those WSN nodes. Algorithm 1 provides a summary of the Trust-building steps we discussed earlier for each WSN node. ```
1.for each \(i\in n\)do//all nodes
2.\(x^{i}\) represent the normal node
3. CH represents the Cluster-head node
4.for each \(x^{i}\in CH\)do
5. search \(x^{i}\) in CH.T // CH table
6. Find \(Px^{i}F\)()
7. Find \(AF\)(\(x^{i}\))
8. Calculate (TB(\(x^{i}\)))
9. Execute Equation (4)
10. if Tx. 'TL is malicious do
11. Broadcast a warning message to all WSN trusted nodes
12. Block the malicious node
13. goto end if/ line 21
14. elseif Tx. 'TL <> Nulldo
15. Execute Equation (5)
16. Send a message to all trusted WSN nodes and CHs
17. Do private authentication and encryption
18. else
19. T_x'.TL = TB
20. Send a message to all trusted WSN nodes and CHs
21. Do private authentication and encryption
22. endfor
23. endfor
```  
**Algorithm 1**The WSN trust-based calculation.