The technological growth and advances in the internet led to the generation of huge volume of data that networks must be capable of transmitting. Providing security to this data is a challenging task. The development in the internet attracts several vulnerable attacks. The researchers in the literature proposed several machine learning, Deep learning and ANN based approaches for efficient attack detection. However, these approaches are prone to high false alarm rates and exhibits poor performance for diversified incoming traffic, because these methodologies relay on the packet level or transaction level features. The performance is inversely proposal to the diversity ratio of packet level features. To handle this, we introduced a combination of high-performed evolutionary algorithms and neural networks for attack classification at flow level with low false alarm rates and high detection accuracy. A unique set of flow features are defined to handle the traffic at flow level and optimal feature selection using whale Optimization Algorithm (WOA). The gravitational search (GS), and particle swarm optimization (PSO) combinations are used in attack detection phase to train the ANN and results proposed model as GSPSO-ANN with WOA. The performance of the proposed model is evaluated with NSL-KDD and CSE-CIC-IDS2018 datasets. The results are compared with other ANN based conventional methods. The results inferred that the proposed GSPSO-ANN with WOA attained maximum detection accuracy with low false alarm rates and processing time and also maintained consistency in the performance for diversified traffic.