1 Introduction

Mobile ad hoc networks are devices that communicate through access points to the network and the base station. The complicated field of MANET embraces power and trustworthiness compared to other networks. The energy constraint of the nodes reduces the packet delivery ratio to the destination. For applications such as battlefields and emergencies, power resources are most important. The efficient use of energy resources is critical in any network since changing or recharging batteries is time-consuming [1].

The clustering process used sensors with comparable capabilities and strengths to construct clusters. Additionally, one of the nodes with better qualities selected as the cluster head, with the other nodes referred to as members. The elected leader is responsible for storing all information to be delivered and routing it to the appropriate destination. In MANETs, the optimization of energy utilization depends on the existence of the wireless nodes. Therefore, transmitting power, receiving power, residual power, and the energy consumption is managed to better energy utilization.

Typically, the MANETs are dependent on wireless communication techniques, in which secure data transfer technique plays an important role to protect the secrecy of data. Furthermore, as no central or administration node exists in MANETs, it is more important to secure the data packets secure transmission in ad hoc networks to detect or prevent security vulnerabilities and breaches or inconsistencies. Further, the literature exhibit that procedures are adequate to protect the network. However, when they are collectively layered, they are beneficial for secure routing in the network.

The clustering method proposed to utilize bandwidth and power in temporary mobile networks to overcome these limitations. Based on existing studies, it is clear that the clustering methods are suitable to solve these problems. The cluster heads can manage the entire network effectively and use intrusion detection on MANETs. Cluster approaches on the MANET divide the total nodes into smaller synchronous groups (cluster). A node acts as an organizer for controlling others in a cluster head (CH) in each group. It is not easy to maintain the members (the nodes) of clusters because of the node mobility in MANETs.

In MANET, when ineffective cluster heads are elected, they may act incorrectly due to power instability. It makes the routing failure because the elected cluster heads cannot control its member nodes and transmit their information. Thus, it affects the routing process and other network operations of the MANET. Contributions and novelty of the work are as follows:

  • In the proposed research, energy management is achieved through a self-configurable cluster method with the k-means protocol.

  • For identifying the unstable cluster heads in MANETs, a self-configurable cluster method was developed with the k-means protocol and cluster heads elected and designated effectively.

  • A self-configurable cluster method with the k-means protocol will replace the incapable nodes with high configuration nodes.

  • Trust management systems for successful packet delivery among MANET nodes are achieved through the proposed trust management algorithm.

  • The proposed research work also reduces the transmission failures by detecting cluster head failure earlier.

The above section presents the challenging fields of MANET, such as power management, trust management, contemporary techniques to cope with the limitations of MANET, and the novelty of the work. Section 2 reviews previous studies of various authors. Sections 3 and 4 explain the proposed system, the trust management framework, and algorithm, k-means protocol to reduce energy consumption in MANETs. Section 5 deals with the evaluation part of the proposed work, outcomes, and comparisons discussed. Finally, Sect. 6 provides the conclusion of the research work presented.

2 Related Works

An energy-efficient routing in MANET requires MANET nodes should have an auto-organizing ability with dynamic architecture. For providing secure routing across MANET nodes, trust is necessary. The sender and recipient node's connection is characterized as trust. MANET nodes basic trust features include dynamicity, non-transitivity, asymmetric subjectivity, and context-dependency. Maintaining a high degree of trust across nodes requires trust management. The data was transmitted without any data loss if the trustworthy nodes are used.

In MANETs, the data packets are routed between sources and destinations via intermediate nodes. As a result, intermediary nodes must ensure trust. The nodes must authenticate each other before exchanging data between them. Calculating the path with the highest trust value yields the trust value. It's the recently discovered data transfer route. The routing decision is the foundation of the trust model. [2, 3].

Due to the complexity of MANETs, many techniques for energy management have limits. Easy routing, authentication, obtaining the right of the entrance to control, intrusion detection, and key management are some of the trust management approaches established for specific objectives [4]. In MANET, few authors concentrated on topics such as cooperative approaches. Collisions, limited transmission power, and node partial dropping are problems with current approaches. The methods were defined, mainly in terms of their design or model [5,6,7,8].

Muthu Raj Kumar et al. introduced a unique and safest routing mechanism called Cluster-based Energy Efficient Secure Routing Algorithm to develop a secure and energy-efficient routing algorithm, utilizing intelligent agents to make appropriate routing decisions. The routing algorithm substantially reduces service rejections. According to trials done using the trust-based secure routing mechanism, the proposed routing protocol enhances security to reduce energy consumption and routing delays [9].

Y. Hamzaoui et al. proposed an OLSR routing protocol using k-means clustering in MANETs. The author discussed QoS progress on MANETs and presented a clustering technique based on the new movement measure and the k-means approach to distributing nodes among various clusters [10].

Suyambu Karthick et al. introduced a new secure and energy-efficient routing protocol for WSN. The Trust-Distrust Protocol (TDP) routing is completed in four phases according to the suggested protocol. The most secure routing path is established in the last stage based on the quality criteria. NS2 is used to test the proposed protocol on one of the most critical types of SONs (Self-Organizing Networks), such as the WSN. Finally, the protocol suggests looping in SON, which overrides the efficacy of the present routing protocol [11].

Rao et al. proposed a hierarchical KF-MAC routing protocol for determining the energy efficiency standard and quality of services on MANETs in work. The newly introduced KF-MAC (k-means cluster generation refers to MAC routing based on Firefly cluster head selection) minimizes the deliberation of Quality of Service elements while transmitting data from a source to a destination. In the beginning, the network is clustered into nodes using the k-means clustering approach. Then, to discover cluster heads, the Firefly Optimization Technique is used to classify and up-gradation of clustered nodes. At last, the data is transmitted within the network nodes through the TDMA- MAC routing protocol. The KF-MAC algorithm works on Quality of Service parameters like bandwidth, latency, error rate, and jitter. Furthermore, the KF-MAC method allows for conflict-free data transfer while minimizing energy consumption [12].

Maitreyi Ponguwala et al. discussed the unsupervised machine learning method. At first, the Secure Certificate-based Group Formation (SCGF) method used to construct the entire network. Then, using the recommendation filtering by the k-means method, the dependability of each group is calculated. HMAC-AES technique combines hash and cryptography capabilities. In a network simulator-3 environment, the proposed methodology achieves optimum results in terms of pocket distribution rate (96.3 percent), performance (135 kbps), latency (3.26 m), detection rate (99 percent), and power consumption (8.5 percent). Methods such as team development and trust screening help to protect the MANET-IoT network. The cryptographic function also assures data security, while the hash function maintains data integrity [13].

In wireless sensor networks, security vulnerabilities are a massive issue in data finding and dissemination. These weaknesses allow a rival to insert erroneous values into a system, remove incorrect variables, or execute DoS attacks [14, 15]. In addition, WSNs can be used to track and manage environmental factors.

The author has developed a distance-vector technique that can be implemented on computers with suitable configurations. The Direct Sequence Distance Vector (DSDV), which includes nodes, may consist of the critical paths for limited communication. It reduces memory requirements, eliminates unnecessary duplications, responds quickly to network connection failures, preserves static routes [16].

Sirisala S et al. proposed characteristics like energy, bandwidth, topological changes, continuous movement, processing power, transmission time, and channel state to evaluate trustworthiness [17]. In MANETs, trust helps nodes to deal with unpredictability and malicious nodes. However, trust calculations and management are problematic in MANET due to computing complexity limitations and many independent nodes. As a result, the data quality and reliability are impacted by such untrustworthy nodes [18].

The quality of service metrics of each multimedia stream, such as latency, bandwidth, jitter, and packet loss, was investigated as a source for the construction of sensor clusters and a link between Quality of Service for each multimedia stream in wireless sensor networks. According to the testing findings, the technique performed better in various video and audio circumstances [19].

Jose M. et al. presented energy usage in antennas during transmission from public wireless networks. Based on their findings, a new Open flow protocol extension for Software-Defined Networking networks was designed to govern the system and enhance network performance while consuming the least amount of power [20].

3 Trust Management Framework

The proposed trust management framework has three major components: gathering the information, calculating the trust level, and trust-based setup. It interacts through each node to generate trustworthy network relationships. After that, the packets are sent to the source, and the reply begins using suggestions from network clients or nodes. The neighbors of a node monitor and log all of its activity. Neighboring nodes are requested to provide their perspectives. A node is regarded as malicious if it does not reply after gathering all associate assessments. As a result, the proposed method might be precious in creating a secure wireless connection.

To identify a malicious node in this system, the CH uses a direct and indirect observer approach to send an inquiring message to the node (Fig. 1). The viewer node receives indirect observation from the nodes around it. By integrating several trust models, we can get appropriate trust values, resulting in the efficiency of the proposed methodology.

Fig. 1
figure 1

Trust management framework

3.1 Path Discovery and Route Manager

Every route controls the routing manager in a network, tracking the route by the list, table, and path unit (Fig. 2). The path discovery method is used for determining the shortest path and the shortest path discovered by sending a route request packet to every node in the network. The routing database was updated to incorporate routes, which was commonly called pathfinding.

Fig. 2
figure 2

Route discovery

3.2 Energy Management Through k-means Protocol

This research identifies the unstable cluster heads in MANETs through a self-configurable cluster method developed with the k-means protocol. Our approach assesses each cluster node and broadcasts the popularity levels of other CH candidates based on their activities. After that, every node collects the reputation values of all CH candidates. Cluster head arrangement is also made to accomplish speed in data transfer in groups and speed allocation in subgroups, with the possibility of selecting a leader at the end. Thus, cluster heads are selected and designated effectively through the proposed approach. When Cluster Head is not chosen in few rounds, the k-means protocol consumes substantial energy. By using a self-configurable cluster method with the k-means protocol, it can be avoided. The various steps involved in eliminating the hacker node during secure cluster head selection are shown in Fig. 3.

Fig. 3
figure 3

Elimination of hackers node

4 Trust Calculation Through Trust Management Algorithm

In general, wireless networks are most vulnerable to attacks. Therefore, mobile ad hoc networks require trust management and authentication system for successful packet delivery among MANET nodes. The two primary security challenges that emerge while obtaining security statistics are confidentiality and data integrity. Confidentiality confirms that the data was secure and not anywhere else, and Data Integrity ensures that the sent message has not made any changes while transmitting. The Trust Management algorithm is proposed to detect and prevent vulnerabilities in MANET. The normalized local trust value in the algorithm makes the CH (Cluster Head) decide whether the node is a trusted or malicious node. If the node is malicious, then discard it through the trust management system. The following algorithm describes the calculation of the normalized local trust value.

Algorithm 1: (Normalized local trust value calculation)

Sx, y stands for the sum of ratings of individual transactions

N x, y Normalized local trust value

Lx stands for Local Trust value

ST (x, y) stands for Satisfactory Transactions

US (x, y) stands for Unsatisfactory Transactions

Start

Allocate parameters for Local trust value, Satisfactory Transactions, and Unsatisfactory Transactions.

Let,

For calculating S x, y by Eq. 1, calculate the Lx between the node x, y

Node x receives a data packet from node y. If the received data packet is good, then the Lx is 1, and if the received data packet contains any harmful data, then its Lx value is 0.

$$ S_{x,y} = \sum {L(x,y)} $$
(1)

By Eq. 2,

$$ S_{x,y} = ST(x,y) - US(x,y) $$
(2)

Normalize the local trust value,

$$ N_{x,y} = \frac{{\max (S_{x,y} ,0)}}{{\sum {S_{x,y} ,0} }} $$
(3)

End

In the given algorithm Sx, y is the sum of the ratings of individual transactions (Satisfactory Transactions and Unsatisfactory Transactions), calculates the reputation index. S x, y was calculated either by Eq. 1 or by Eq. 2. Normalized local trust value (N x, y) is calculated by Eq. 3. This normalized local trust value and trust management framework is used to detect vulnerabilities in MANET and solve it by taking necessary actions (e.g., if the node is malicious, discard the node from the network). Thus, the proposed algorithm efficiently supports with trust management framework and provides secure communication in MANETs.

5 Results

Network simulators and NS2 gained popularity due to their recommended multipath routing protocols, cluster-based algorithms, and other features. In this research network simulator, NS2 is used to replicate the specified procedures, and Fig. 4 shows that each node sends a single cluster head a greeting message. Other nodes are used to acquire the message from their neighbors. When every node receives the hello message in the vicinity, it enables an acknowledgment sent to each node based on its energy level.

Fig. 4
figure 4

Hello messages between nodes

In cluster construction, each node group is built and arranged as shown in (Fig. 5). Cluster formation is completed by communicating with other nodes, and it reduces the pace of transmission, separates groups into subgroups, and eventually selects a leader. Thus, clusters are formed, depend on the communicating range of nodes within the network.

Fig. 5
figure 5

Communication between nodes

The volume of data is combined into one or more aggregated outputs per minute using network aggregation. Then, it is used to go over the data verification message sent to BS and choose the most secure path (Fig. 6). As a result, the cluster head might be able to find out a secure path.

Fig. 6
figure 6

Find a secure path

Packet Delivery Ratio: As represented in Fig. 7, the proposed approach with TSQRS (Trust-based Secure QoS Routing Scheme) protocol has the highest PDR than traditional AODV(Ad Hoc On-Demand Distance Vector) and ETRS (Enhanced trusted routing scheme)protocols. When the number of malicious nodes increases to 20, there is a significantly reduced packet delivery as 45% and 25% for AODV and ETRS protocol. In contrast, the proposed TSQRS routing protocol has 80–85 percent PDR. AODV falls to more percent of reduced PDR when the percentage of hazardous components increases. Hence, the packet delivery ratio of the proposed TSQRS routing protocol improved by 10 – 30% of PDR than the ETRS and AODV protocol.

Fig. 7
figure 7

PDR versus Malicious nodes

Routing Overhead: The routing overhead of the proposed approach with the TSQRS routing protocol compared with the ETRS and AODV routing protocol, as shown in Fig. 8. we can see that the TSQRS has the lowest routing overhead at 4.96 percentage than the other existing routing approaches. When the number of malicious nodes in the network increases to 30, the routing overhead for the TSQRS routing protocol is 5.5%. On the other side, the ETRS protocol and AODV protocol routing overhead raise by a ratio between 6.5 and 9. The TSQRS routing protocol reduces routing overhead by 2–5% than ETRS and AODV protocol.

Fig. 8
figure 8

Routing overhead

Energy Consumption: From Fig. 9, the number of malicious nodes increases the energy consumption also increases gradually. For instance, when the number of malicious nodes is 30, the ETRS consumes 313 J of energy, and AODV consumes 314.25 J of energy. In contrast, the proposed approach with TSQRS consumes less energy consumption. Similarly, the proposed approach with TSQRS consumes as low as 311.11 J of energy, whereas ETRS consumes 313.13 J of the energy and AODV consumes 314.31 J of energy. The proposed approach with TSQRS routing methodology achieves 3–5 percentage of reduced energy consumption than other approaches. As a result, the proposed techniques minimize wireless node energy consumption even with a higher number of malicious nodes in the network.

Fig. 9
figure 9

Energy consumption

6 Conclusion

The complex field of MANET holds power and trustworthiness compared to other networks. The energy constraint of the nodes reduces the packet delivery ratio to the destination. This work focuses on building a power management scheme that saves energy in the MANET. Due to power instability, there is a chance that cluster heads fail and function incorrectly in cluster-based routing. As a result, instability occurs with the cluster heads while collecting data and communicating with others. This work presented about detecting the unstable cluster heads, which were replaced by other nodes implementing the envisaged self-configurable cluster mechanism. So, the self-configurable cluster mechanism with the k-means protocol approach was proposed to designate cluster heads effectively, and the Trust Management algorithm was also presented to detect and prevent vulnerabilities in MANET. Network simulator was used for its recommended multipath routing protocols, cluster-based algorithms, and other features. Finally, the proposed algorithm tested in a network simulator, and the results were observed accordingly. The experimental results showed that the proposed approach works well to minimize the energy and provide trust in MANET communication compared to other techniques. In future research, trust management can build by framing the different algorithm to overcome the real-time challenges by ensuring reputation and trustworthiness in Mobile Ad hoc Networks.