Abstract :

Wireless Sensor Networks (WSNs) are widely used in mission-critical domains such as environmental monitoring, industrial automation, and defense. However, they face two major challenges: vulnerability to malicious node attacks and high energy consumption, both of which degrade network performance and shorten operational lifespan. This study aims to develop a unified framework that simultaneously addresses security and energy efficiency in WSNs. The novelty lies in integrating Capsule Neural Networks (CapsNets) with the Enhanced Animal Migration Optimization (EAMO) algorithm—a combination not explored in existing methods. Unlike conventional intrusion detection models that rely on CNNs or shallow classifiers, CapsNets preserve spatial relationships in features through vector-based representation and dynamic routing, improving detection accuracy and reducing false positives. Simultaneously, EAMO—enhanced with birth–death processes—optimizes LEACH-based routing by selecting energy-aware cluster heads and secure paths, reducing latency and energy drain. Using Z-Score Normalization for preprocessing, Fuzzy C-Means clustering, and the NSL-KDD dataset, the framework is evaluated in NS2 simulations. Results show superior packet delivery ratio, detection accuracy, and energy efficiency compared to ASNGSRA, DMCNN, and FRCSROD protocols. This integrated deep learning–metaheuristic approach offers a robust, scalable solution for secure, energy-aware WSNs, with potential future work focusing on adaptive defenses against evolving cyber threats.