## 1 Introduction
The constraints in WSNs lead to various anomalous attacks, which further affect the regular processing of the network. Such attacks may create physical damage to sensor nodes, resulting in traffic crashes, which involve the dropping of packets, invalid transmissions, and channel jamming through radio intervention. Attacks, which attempt to disturb the routing operations in WSNs [9], can be handled using multi-hop techniques. Though conventional security-based approaches, including encryption and authentication are highly effective in alleviating some attacks, they are not ideal because of their own features [10]. Thus, an effective security-aware routing algorithm to deal with these challenges is required. Trust-based approaches are gaining attention in resolving these challenges to a greater extent. To secure the sensor nodes from malicious attacks and segregate trusted nodes from compromised nodes, trust-based security mechanisms are introduced [11]. These mechanisms aid in detecting trusted nodes, which are highly effective in identifying compromised nodes in the network, as the assessment of trust is associated with the former behavior of malicious nodes and data from neighboring reliable nodes. Due to their logical characteristics, trust-aware routing mechanisms are presented to enhance the security of the network. The selection of optimal intermediary nodes using trust values for reliable routing is a significant deliberation seen in the design of associated scenarios. Furthermore, some trust-based systems with additional factors that include the cost of energy [12], the distance from adjacent nodes to the BS [13], and hop counts [14] are utilized to support secured routing with optimal quality. However, trust-based routing mechanisms face some challenges, as listed below. 1. Some schemes compute trust based on energy and data but ignore authorization as a reliable standard for using trust values. Hence, the compromised nodes that collaborate with one another or decide to be self-centered are not discarded. 2. Smart compromised nodes are seen to be highly probable in integrating the frequency of malicious attacks with mutable intensity, thus reducing the reliability and efficacy of secure routing protocols. Some trust-based schemes do not consider these threats, though they are found to be capable of circumventing these attacks for some scenarios. 3. Some security schemes implement updating mechanisms and the maintenance of routes to generate fresh routes in case an attack is encountered. However, they fail to assess the possible reasons for the breakdown of routes that have an impact on the efficacy of the update mechanism. Hence, to overcome shortcomings of traditional cluster-based routing schemes, congestion detection and control mechanisms, and trust-based secure routing schemes, a trust-aware congestion control protocol based on cluster routing is proposed. In this paper, malicious nodes that cause network congestion are effectively identified using an optimized cluster-based routing technique. Further, the hybrid K-Harmonic Means (KHM) combined with the Gravitational Search Algorithm (GSA) is proposed for determining the trust factor, queue congestion status, distance from the BS (sink), and residual energy (RE). The major contributions of this research paper can be summarized as follows:  
1. To provide higher detection accuracy of malicious nodes, we utilize a fitness function that filters the malicious nodes from the WSN. We detect and isolate the malicious nodes from the routing path of the data by utilizing the trust concept. The parameters used in the fitness function are the trust value, link lifetime, energy, and congestion. The computed fitness function detects malicious nodes that cause network congestion and eliminates them from the network. 2. The computed fitness function is applied to the hybrid K-Harmonic Means and Gravitational Search Algorithm. The fitness function in the hybrid algorithm is responsible for the CH selection.