## 6 System Architecture
The value 1 can be achieved through either a uniform or an uneven distribution. As shown in Table 6, a node-rating threshold is determined using Gini logic. The main aim of these thresholds is to isolate harmful nodes from the rest of the network. Only nodes that have passed this test are allowed to take part in routing decisions. To provide more elaborate details, the different steps and processes involved in this module are described below. 1. Trust parameter collection: The trust analyzer and calculator module receives trust parameters from the trust parameter accumulator module and parent nodes at the fog layer. 2. Trust parameter normalization: Before calculating the Gini index, the trust parameters are normalized to bring them to a consistent scale. 3. Trust score calculation: A trust score is a numerical indicator of a node's reliability or trustworthiness in a network. Trust scores are essential for evaluating node behavior in the context of a CPS, especially when it comes to identifying and reducing the possibility of malicious nodes. The suggested method uses trust scores to assess nodes' credibility according to trust parameters. In a CPS network, the overall \"trustworthiness inequality\" between nodes can be evaluated using the Gini index. It offers a tool for locating potentially dangerous nodes or ones that drastically depart from the norm when paired with trust scores. Algorithm 1 explains how the suggested method calculates the trust score. 4. Gini index calculation: The Gini value for every node under observation is determined by the trust analyzer and calculator using logic based on Gini indexes. To calculate the Gini index, add up all of the trust parameter pairs' absolute differences, then divide the total by the number of pairs. The suggested method of Gini index computation is described in Algorithm 1. 5. Threshold setting for malicious behavior: After calculating the Gini value for each node, the trust analyzer and calculator sets a threshold value to distinguish between normal and malicious behavior. The threshold value is set at 0.5, but this can be adjusted based on the specific requirements and characteristics of the CPS network. 6. Node classification: Nodes with Gini values above the threshold (\(>\)0.5) are classified as exhibiting potentially malicious behavior, indicating a higher degree of parameter inequality. Nodes with Gini values below the threshold (\(<\)0.5) are considered normal nodes, exhibiting a more uniform distribution of trust parameters. 7. Formation of DODAG based on trust: To ensure the security and efficiency of the CPS network, the trust analyzer and calculator may influence the formation of the destination-oriented directed acyclic graph (DODAG) based on trust values. Nodes with lower Gini values, preferably closer to zero, are given priority in forming the DODAG, especially for critical/sensitive tasks or routing decisions. 8. Trust updates and periodic review: The trust analyzer and calculator periodically reviews the trust values based on the updated trust parameters received from the device discoverer and parent nodes. 9. Blockchain Ledger Updater for BRGTL: The blockchain ledger updater module, functioning as a smart contract in the fog layer, plays a critical role in the proposed methodology by leveraging blockchain technology to update and maintain the BRGTL. This module integrates inputs from various components, including the device discoverer module, trust parameter accumulator module, and trust analyzer and calculator module, to ensure the trustworthiness and reliability of the CPS network. The fog server implements blockchain technology to update and keep track of the BRGTL. Whena new node requests to join the network, a new entry is added here. Through the use of the sink node, the parameters of the parent node are transmitted to the fog server. A new entry is added to the blockchain if the node's information is not already included there; otherwise, the list is not updated.