## 2 Related Concepts  
With the continuous development of science and technology, human beings are paying increasing attention to security issues. Security can be classified into two main aspects: privacy protection and trust. Although scholars at home and abroad have studied security in various fields, a truly high degree of security has not yet been achieved [12; 13; 14; 15]. Currently, many scholars are studying wireless sensor network routing algorithms, mostly in an attempt to solve the problem of limited node energy, however, they rarely consider the security issues posed by malicious nodes, and much less consider safety and energy issues simultaneously. Therefore, in this paper, to improve the energy efficiency of wireless sensor networks, a suitable trust mechanism is introduced into the routing protocol. In a practical sense, trust can be simply defined as the confidence that the nodes will behave as expected. There are two main types of trust measurements: direct and indirect [16]. To measure the trust between nodes more directly, this paper introduces the concept of the reputation value of a node and uses this variable to determine whether the node is credible or malicious; the definition of a node's reputation value is given below.  
**Definition 1** (Node Reputation Value).: _The reputation value of a node is defined as an absolute value for a specific period and environment, which is calculated using an appropriate evaluation model of the node's credibility based on a synthetic analysis of the node's historical behavior._  
It represents a comprehensive image of the node within the set of all nodes and is a summary of the overall evaluation results. Ants have features of self-organization, self-adaption, mutual communication and collaboration. Ant-colony optimization simulates their intelligent behavior and can solve many complex problem. Ant-colony optimization is proposed as a new type of simulated evolutionary algorithm in the early 1990s, which is also a very important method of cluster analysis. It has strong extensibility and robustness and can adapt to the dynamic environment, so it is suitable for the design of dynamic wireless sensor networks. Ant-colony optimization is widely applied in ad hoc networks, wireless sensor networks, etc., because of its characteristics of self-organization, self-optimization, and dynamic topology [17]. The underlying concept of ant-colony optimization is described in Definition 2. Traditional ant-colony optimization algorithms do not consider the unique characteristics of wireless sensor networks. Therefore, it is necessary to improve upon the traditional ant-colony optimization algorithms for this purpose. We integrate the reputation values, energies and time delays of the nodes into the algorithm to increase its effectiveness in solving problems involving wireless sensor networks.  
**Definition 2** (Ant-Colony Optimization).: _Ant-colony algorithms are swarm-intelligence optimization algorithms inspired by research on the behavior of ant colonies in the real world that has revealed that ants are capable of finding the shortest path between a food source and their nest._  
Ants leave pheromones along each path, and the amount of pheromones on a path indicates the number of ants that have walked along that path; the more ants that have walked along a path, the closer that path is to food. Eventually, all ants will choose the path with the most pheromones, which is the shortest path between the nest and food [18]. Ants leave pheromone on each path, the more pheromones show that more ants are on the path, and the closer the food is to the path. In the end, all ants will choose the path left by the most pheromones, which is the shortest path between the nest and the food. In our approach, we use the Ant System algorithm, which is the most basic ant colony optimization algorithm. The algorithm is simple and easy to understand, which has the advantage of robust, excellent distributed calculated mechanism, easy to combine with other methods.