In the era of information technology, the new types of cyber-attacks affect the performance of the network, which is very risky and cannot be restored quickly. In pervasive computing, there are more chances for such types of attacks since the personal data of the user is closely connected to the social environment. The research is performed using SNMP-MIB dataset, and feature selection are made by using the Enhanced Salp Swarm Optimization to select the optimal features to identify the attacks by using wrapper techniques. Then, various types of attacks are appropriately distinguished with proposed classifier Gated Recurrent Unit Neural Network based on Bidirectional Weighted Feature Averaging for high detection rate and accuracy. The value of performance metrics obtained from the proposed method outperforms the existing methods in terms of 99.9% accuracy, 99.8% in precision and detection rate is 99% in classifying different types of attacks.