<span style="font-family: 'Times New Roman',serif; font-size: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 宋体; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;" lang="EN-US">An Quality of Service(QOS) secure routing algorithm based on ant colony optimization is put forward to solve a variety of security problems in wireless sensor networks. The algorithm combines the ant colony optimization algorithm with the cr</span><span style="font-family: 'Times New Roman',serif; font-size: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: DE; mso-bidi-language: AR-SA;" lang="EN-US">edit evaluation mechanism, and introduces the node 's credit as the control factor to obtain better security performance. The algorithm first cuts the network topology according to the QOS requirements, kicks out the nodes that do not meet the QOS requirements, and then quickly converges the route to the optimal route according to the ant colony optimization method. Finally, the security analysis of the algorithm is carried out from various aspects of network layer attack.</span><span style="font-family: 'Times New Roman',serif; font-size: 10pt; mso-ansi-language: EN-US; mso-fareast-font-family: 宋体; mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA;" lang="EN-US"> The experimental results show that the algorithm has very good performance in wireless sensor networks. As a result, it is concluded that it can be widely applied in wireless sensor networks.</span>