## 3 Proposed Solution
### Trust Calculation in Proposed Methodology
The characteristics to detect a greyhole node are:  
```
Input :Set of nodes \(N\), G, Avg, TPP, TPL, TEC Output :Potential blackhole nodes
1 for each node \(m\) in \(N\)do
2 Gini index value \(\leftarrow\) Gini index value of node \(m\);
3 packet loss rate \(\leftarrow\) packet loss rate of node \(m\);
4 latency \(\leftarrow\) latency of node \(m\);
5 energy consumption \(\leftarrow\) energy consumption of node \(m\);
6 foreach node \(n\) in \(N\)do
7 if\(n\) has abnormal traffic distributionthen
8 TrafficDistribution \(\leftarrow\) true;
9
10 ifGini index value is significantly different from Avgthen
11 PotentialBlackholeNodes \(\leftarrow\) PotentialBlackholeNodes \(\cup\)\(m\);
12
13 ifpacket loss rate \(>\) TPPthen
14 PotentialBlackholeNodes \(\leftarrow\) PotentialBlackholeNodes \(\cup\)\(m\);
15
16 iflatency \(>\) TPLthen
17 PotentialBlackholeNodes \(\leftarrow\) PotentialBlackholeNodes \(\cup\)\(m\);
18
19 ifenergy consumption \(>\) TECthen
20 PotentialBlackholeNodes \(\leftarrow\) PotentialBlackholeNodes \(\cup\)\(m\);
21
22 ifTrafficDistribution then
23 PotentialBlackholeNodes \(\leftarrow\) PotentialBlackholeNodes \(\cup\)\(m\);
24
25 returnPotentialBlackholeNodes;
```  
**Algorithm 2**Detection of blackhole nodes. Gini index deviation: The Gini index deviation for node \(m\) at time \(t\) can be defined as described in Equation (6): \[Gini\_Deviation_{m}(T)=|G_{m}(T)-G\overline{(}T)|\] (6) \[\text{Packet loss: The condition to detect potential greyhole nodes based on packet loss can be expressed as described in Equation (7): \[P_{m}(T)>\theta_{P}\] (7) \[\text{Latency: The condition to detect potential greyhole nodes based on latency can be expressed as described in Equation (8): \[L_{m}(T)>\theta_{L}\] (8) \[\text{Energy consumption: The condition to detect potential greyhole nodes based on energy consumption can be expressed as described in Equation (9): \[EC_{m}(T)>\theta_{E}C\] (9) \[\text{Throughput: The condition to detect potential greyhole nodes based on throughput can be expressed as described in Equation (10): \[Th_{m}(T)<\theta_{T}h\] (10) The Gini index deviation captures the deviation of a node's Gini index from the average. At the same time, the packet loss, latency, and throughput characteristics help identify nodes with abnormal behavior in terms of packet loss rate, latency, and data transfer rates, respectively. The pseudo-code for the detection of greyhole nodes using the Gini index is depicted in Algorithm 3. The time complexity of the algorithm is O(n), while the space complexity is also O(nlogn). 4. Trust Update A key component of assuring the network's dependability and security in CPS networks is trust updating. Based on the behaviors and interactions within the network, individual nodes' given trust ratings are evaluated and updated. There are two basic ways trust updates may occur: routine/periodic updates and reactive updates brought on by modifications in node behavior. 1. Routine: Routine trust updating is carried out at predetermined intervals, usually as part of a routine maintenance operation. This method ensures that trust values are always up-to-date and represent the nodes' current behavior. Network managers may identify potential deviations or anomalies in node activity by periodically analyzing their trustworthiness. 2. Reactive: When a node's behavior changes significantly or displays questionable behavior, reactive trust updating takes place. These adjustments may take the form of abrupt increases in data loss, unforeseen communication delays, or departures from established behavioral norms. When these anomalies are found, a reactive action is taken to adjust the node in question's trust value. For a CPS network to remain trustworthy, both routine and reactive trust-update measures are essential. The routine updates offer a methodical and proactive way to monitor the network, ensuring that trust values are consistently evaluated and modified.