# Federated Learning-Based Security Attack Detection for Multi-Controller Software-Defined Networks
## 3 The Proposed Methodology
### Hybrid Heuristic-Based Feature Selection  
In the SDN, the network traffic data comprise numerous features in different categories, such as the basic, content, and traffic categories-based 41 features in the NSL-KDD dataset. Owing to the vast number of features that describe different aspects of network traffic, superfluous, irrelevant, or noisy features increase the computational cost and overfitting. Moreover, the significance of each feature and the interrelationship between a set of features varies in the network traffic data. Accordingly, with the awareness of the interrelationship among the features, feature selection is imperative [26] for the hybrid learning-based traffic classification. To optimally select the features in the feature-rich network dataset, FedSec initially applies the hybrid heuristic algorithm [27], namely Mayflies-Harmony Search (MA-HS). By modeling the feature selection algorithm as the binary optimization problem, the proposed approach applies the wrapper-based method that selects whether an individual feature in a feature subset contributes to an accurate attack detection or not. In the FedSec, instead of utilizing the global flight experience of all mayflies (g), the global experience gained only from the mayflies (b) that are highly associated with the corresponding mayfly (f) in achieving higher local fitness function. In this context, mayfly refers to the features in the network traffic dataset, and the fitness function implies the classification accuracy. Instead of selecting the features that highly impact the accurate attack classification, the proposed approach focuses on selecting the features with the global impact of classification accuracy improvement as well as the association among the features in improving the classification accuracy. \[\text{gbest}(\text{b})_{a}^{f}= \begin{cases}\text{x}_{\text{b}}^{+1}(\text{a })\\ \text{if fitness}(\text{a},\text{b})^{f}>fitness(\text{a},\text{g})^{f}\end{cases}  \tag{4}\]  
As modeled in Equation (4), the enhanced MA-HS selects a set of globally experienced mayflies (b) based on the fitness score of any global mayfly with ith mayfly. Suppose the bth mayfly obtains a higher fitness score than the gth mayfly. The enhanced MA-HF selects that bth mayfly as the associative combination for the ath mayfly and updates the position of the ith mayfly to the bth mayfly through dynamic interactions. Accordingly, the feature is retained in a final feature subset based on the influence on all the attack classes; hence, the fitness score is validated across multiple classes. \[\text{Fitness Function}(f)=\frac{\left|(\rho)_{t_{\text{s}}}\right|}{\left| \varphi_{t_{\text{s}}}\right|},\text{where}\big{|}\varphi_{t_{\text{s}}} \big{|}=|\text{N}_{\text{f}}|/|\text{N}_{\text{F}}| \tag{5}\]  
In the enhanced MA-HS, the fitness function consists of accuracy and the number of features with the feature threshold of iterating the validation of the feature subset in the global search space, formulated in Equation (5). To avoid the compromise between the error and the number of selected features, the proposed approach contemplates the accuracy with the direct relationship between the number of selected features and the feature threshold. As formulated, the fitness function needs to be increased with the increase in accuracy (\((\rho)_{t_{\text{s}}}\)) as well as the decrease in the number of features (fs); in particular, the ratio (\(|\varphi_{t_{\text{s}}}|\)) between the number of reduced features and the total number of features. The proposed approach initially aims to maintain 50% of network features to represent patterns on various attack classes. Hence, it selects the features to obtain better accuracy if the feature threshold (\(\left|\varphi_{t_{6}}\right|\)) is above 0.5; otherwise, the proposed approach selects an optimal set of features until reaching an improved accuracy over the accuracy on the entire feature set or feature set in its previous iteration.