## 11 Conclusions  
This research undertook an in-depth study of the related work to identify the research gaps in the existing trust-based techniques to detect and mitigate blackhole and greyhole attacks in a CPS. The study considered the utilization of the Gini index and blockchain technology as an opportunity to enhance the security of CPS networks further. The Gini index can improve the accuracy of attack detection in trust-based schemes, whereas blockchain enhances the immutability of the trust database. The proposed framework calculates trust scores based on carefully selected significant trust parameters, including the packet drop ratio, energy consumption, end-to-end delay, and latency. The blockchain technology has been implemented as a database in the form of a smart contract to make the global trust list immutable. The trust calculation and implementation of smart contracts in the fog layer have improved the detection and mitigation of attacks, as observed during the simulations.  
This research work proposes a thorough strategy for preventing blackhole and greyhole attacks in smart healthcare CPSs using the Gini index and blockchain. The suggested approach shows its usefulness in a range of CPS security and performance characteristics when implemented in the device layer and fog layer. When comparing the GBG-RPL mechanism to the BCPS-RPL mechanism, evaluations of several characteristics, including the attack-detection rate, average residual energy, packet loss ratio, energy consumption, number of nodes, and end-to-end delay, provide insightful information. In terms of attack-detection rate/time, energy efficiency, packet loss ratio, and transmission efficiency, the GBG-RPL method produces favorable outcomes. To validate and improve the suggested technique for real-world CPS deployments, nevertheless, more analysis and application in the field are needed. These research findings support ongoing efforts to increase the security and resistance of CPSs to complex attacks.  
\begin{table}
\begin{tabular}{l c c c} \hline \hline
**Metric** & **GBG-RPL** & **BCPS-RPL** & **\% Improvement** \\ \hline Packet Loss Ratio & 0.375 & 0.404 & 7.18\% \\ Residual Energy & 0.635 & 0.559 & 11.97\% \\ Energy Consumption & 0.04768 & 0.0591 & 19.27\% \\ Attack-Detection Rate & 0.77 & 0.688 & 10.65\% \\ Avg. Attack-Detection Time (30 nodes) & 14.33 & 17.67 & 18.88\% \\ Message Overhead & 9435 & 12050 & 21.65\% \\ End-to-End Delay (30 nodes) & 0.907 & 1.267 & 28.34\% \\ \hline \hline \end{tabular}
\end{table}
Table 12: Performance comparison of GBG-RPL and BCPS-RPL.  
**Author Contributions:** Conceptualization, M.J. and N.T.; Methodology, M.J. and N.T.; Software, M.J.; Validation, N.T., M.A. ([PERSON]), F.A.K., M.A. ([PERSON]) and M.I.; Formal analysis, M.J. and M.A. ([PERSON]); Investigation, M.J., N.T., F.A.K. and M.A. ([PERSON]); Resources, M.A. ([PERSON]), F.A.K. and M.I.; Writing--original draft, M.J. and N.T.; Writing--review & editing, M.A. ([PERSON]), F.A.K., M.A. ([PERSON]) and M.I.; Visualization, F.A.K., M.A. ([PERSON]) and M.I.; Supervision, N.T.; Project administration, M.A. ([PERSON]); Funding acquisition, F.A.K. All authors have read and agreed to the published version of the manuscript.  
**Funding:** This research was funded by the Deputyship for Research and Innovation, Ministry of Education in Saudi Arabia (IFKSUOR3-507).  
**Institutional Review Board Statement:** Not applicable.  
**Informed Consent Statement:** Not applicable.  
**Data Availability Statement:** Data sharing not applicable.  
**Acknowledgments:** The authors extend their appreciation to the Deputyship for Research and Innovation, Ministry of Education in Saudi Arabia for funding this research (IFKSUOR3-507).  
**Conflicts of Interest:** The authors declare no conflict of interest.  
List of abbreviations:  
**Abbreviation**  
**A1**  
**A2**  
**B**C**PS-RPL **B**L**