Efficient federated learning intrusion detection method based on dynamic adaptive compression

By optimizing the communication and computational resource allocation of federated learning through sparse ternary compression and adaptive strategies, the problem of high communication overhead in intrusion detection by federated learning is solved, and efficient detection results are achieved in bandwidth-constrained environments.

CN122069059APending Publication Date: 2026-05-19TIANJIN UNIVERSITY OF TECHNOLOGY
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TIANJIN UNIVERSITY OF TECHNOLOGY
Filing Date
2026-01-05
Publication Date
2026-05-19

AI Technical Summary

Technical Problem

Existing federated learning methods suffer from high communication overhead in intrusion detection, especially in bandwidth-constrained environments, and fail to effectively adjust training strategies to optimize resource utilization, resulting in computational redundancy.

Method used

A sparse ternary compression algorithm is used to quantize and encode the gradients uploaded by the client, and an adaptive strategy is combined to dynamically adjust the compression ratio, optimize the allocation of communication and computing resources, and adjust the training strategy according to the client's performance through an adaptive mechanism.

Benefits of technology

It significantly reduces communication volume, improves detection efficiency and accuracy in bandwidth-constrained environments, balances communication costs and model performance, and is suitable for bandwidth-constrained device scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122069059A_ABST
    Figure CN122069059A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of flow detection, in particular to an efficient federated learning intrusion detection method based on dynamic adaptive compression, which comprises the following steps: S1, initializing a global model and a first training parameter; s2, the server side distributes the global model and the first training parameters to all clients; s3, the client performs this round of training on the local model based on the corresponding training set to obtain a second local parameter; s4, the client obtains the gradient of the local model based on the first local parameter and the second local parameter and uploads the gradient to the server after compression; s5, the server side updates the first training parameter based on the gradient of the local model, issues the updated first training parameter to all the clients and judges whether the next round of training needs to be carried out or not; s6, if the next round of training is needed, the server side determines clients participating in the next round of training; and S7, if the next round of training is not needed, detecting the flow to be detected.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of traffic detection technology, and more specifically to an efficient federated learning intrusion detection method based on dynamic adaptive compression. Background Technology

[0002] Federated Learning (FL), due to its data privacy protection features, has been widely used in fields such as the Internet of Things (IoT) and in intrusion detection in various edge intelligence scenarios. However, it generally suffers from high communication overhead, which is particularly evident in large-scale edge devices or bandwidth-constrained environments. Existing compression methods often focus on uplink communication (clients uploading parameters to the server) while neglecting downlink compression (server distributing the model), and some compression mechanisms lack stability in non-independent identically distributed (Non-IID) scenarios. Furthermore, many existing methods do not consider the dynamic characteristics of model updates at different training stages and cannot self-adjust based on performance during training, such as the amount of training data and the number of participating clients, leading to resource waste and computational redundancy.

[0003] Therefore, there is an urgent need for a strategy that can simultaneously compress uplink and downlink communication and adaptively adjust federated learning training strategies to further improve communication and computing efficiency. Summary of the Invention

[0004] To address the aforementioned issues, the present invention aims to provide an efficient federated learning intrusion detection method based on dynamic adaptive compression. This method combines dynamic adaptation with an efficient communication method that utilizes compression mechanisms to detect network attacks. The method significantly reduces the communication volume per round by quantizing and encoding model updates uploaded by the client and distributed by the server. Simultaneously, it attempts to dynamically adjust the computational load using adaptive strategies, including modifying the compression ratio based on the client's training performance, to enable deployment in real-world scenarios with limited bandwidth, thereby minimizing the training overhead of the FL-based intrusion detection model.

[0005] This invention is an efficient federated learning intrusion detection method based on dynamic adaptive compression. The detection method is performed on both the server and a corresponding client. The detection method includes the following steps: Step S1: The server initializes the global model and the first training parameters. Before this, step S0 is required to preprocess the dataset used. Each client corresponds to a training set and a test set, and the server corresponds to a validation set.

[0006] The preprocessing in step S0 includes the following steps: S0.1: Extract the key features of the sample to obtain the feature vector of the sample; S0.2: Normalize the feature vectors of the samples; S0.3: Fill the feature vectors of the normalized samples with a fixed length; S0.4: Shuffle and save the index of the samples to form standardized samples.

[0007] Step S2: The server distributes the global model and the first training parameters to all clients; all clients receive the global model distributed by the server and load the first training parameters to form a local model and the first local parameters; the server determines the clients participating in this round of training. Step S3: The client participating in this round of training performs this round of training on the local model based on the corresponding training set and updates the first local parameters after completion. The updated first training parameters are marked as the second local parameters. Step S4: The clients participating in this training round obtain the gradient of their local model based on the first and second local parameters. Simultaneously, based on the accuracy and standard deviation obtained from the training of each client in this round, a compression ratio is set for each client, and compression is performed. After compression, the first local parameters are uploaded to the server. Specifically, the gradient of the local model is compressed into the form {-1, 0, +1} using a ternary compression algorithm, then positionally encoded, and uploaded to the server. Because the compression is bidirectional, this compression method is called BiASCT-FL. Step S4.1: The client subtracts the first local parameter from the second local parameter element by element to obtain the local gradient, which is used as the only update in this round of upload; Step S4.2: Flatten the local gradients from step S4.1 into vectors. T According to the formula ),in p To achieve sparsity, select the k elements with the largest absolute values ​​and set the rest to 0 to obtain the mask vector T. masked ; Step S4.3: Based on the mask vector T in step S4.2 masked Calculate the average absolute value of the non-zero terms. μ Generate a ternary vector T ; Step S4.4: First, based on the ternary vector T from step S4.3... Extract the set of non-zero indices and their symbols to obtain S and to S Lossless positional coding is used to further reduce communication volume, forming the parameters uploaded in this round of training. payload In addition, participating clients evaluate the accuracy and standard deviation (STD) of the current local model on a local test set to obtain the evaluation results. a c and with payloadUpload them together to the server; Step S4.5: The server processes the parameters uploaded in step S4.4. a c The arithmetic mean is obtained. a μ Then, the compression rate of the clients participating in this round of training is adaptively set. p .

[0008] Furthermore, step S4.5 includes for poorly performing clients ( a c < a μ For clients that perform well, a smaller compression ratio is used to retain more parameters; for clients that still participate in subsequent training rounds, a larger compression ratio is used for corresponding adjustments. Step S5: The server updates the first training parameters based on the gradient of the compressed local model, sends the updated first training parameters to all clients, and determines whether the next round of training is needed. Step S6: If a next round of training is required, the server determines the clients to participate in the next round of training; the clients participating in the next round of training perform the next round of training based on the updated first training parameters; Step S7: If no further training is required, the traffic to be detected is detected based on the global model on the server side and the updated first training parameters on the server side.

[0009] Moreover, step S0 includes: constructing a dataset and preprocessing the samples in the dataset; allocating a validation set to the server based on the constructed dataset, and allocating different training and test sets to each client.

[0010] Furthermore, in step S3, the client participating in this round of training evaluates the performance of the local model based on the test set and the second local parameters, obtains the evaluation results of the client participating in this round of training, and uploads the evaluation results of the client participating in this round of training to the server. In step S6, the server determines the clients to participate in the next round of training based on the evaluation results of the clients participating in this round of training.

[0011] Furthermore, in step S4, the gradient of the local model is compressed into the form of {-1, 0, +1} using a ternary compression algorithm, then positionally encoded, and finally uploaded to the server.

[0012] Furthermore, step S5 includes the following steps: Step S5.1: The server receives the gradients of the compressed local model from the client participating in this round of training; Step S5.2: The server decodes the gradient of the local model compressed by the client participating in this round of training based on the position encoding to obtain the gradient of the local model decoded by the client participating in this round of training; Step S5.3: Based on the aggregation algorithm and the sample size of the training set corresponding to the clients participating in this round of training, the server performs a weighted average of the gradients of the local models of the clients participating in this round of training to obtain the updated first training parameters. Step S5.4: The server compresses the updated first training parameters and sends them to all clients; Step S5.5: The server determines whether the next round of training is needed.

[0013] Furthermore, in step S6, the server compares the evaluation results of the clients participating in this round of training with a preset comparison threshold; if the evaluation result of the client participating in this round of training is lower than the comparison threshold, the client participating in this round of training will participate in the next round of training; if the evaluation result of the client participating in this round of training is higher than the comparison threshold, the client participating in this round of training will no longer participate in the next round of training.

[0014] Furthermore, the comparison threshold is determined based on the average level of the clients participating in this round of training.

[0015] Furthermore, in step S5, the server determines whether the client needs to perform the next round of training based on the performance of the global model; if the performance of the global model is stable, the next round of training will not be performed; if the performance of the global model is unstable, the next round of training will be performed.

[0016] The beneficial effects of this invention are: 1. This invention significantly reduces the communication burden during model training by introducing a sparse ternary compression (STC) mechanism into a traditional federated learning-based traffic detection framework. This method sparsifies and quantizes the uploaded gradients locally on the client side, retaining only the updates with the largest gradients, and transmits them through positional encoding, thereby greatly reducing the amount of communication data per round. Compared to uncompressed federated learning frameworks, this invention effectively reduces the total amount of uplink and downlink communication, improving the practicality and efficiency of deployment in bandwidth-constrained scenarios.

[0017] 2. This invention optimizes communication while maintaining the accuracy and convergence of model training, ensuring stable detection performance. Combined with an adaptive training strategy, it dynamically adjusts participation and resource allocation based on the client's local performance, enabling the system to balance communication costs and model performance, thus demonstrating strong engineering feasibility. Attached Figure Description

[0018] Figure 1 This is a flowchart of the present invention. Detailed Implementation

[0019] This invention provides an efficient federated learning intrusion detection method based on dynamic adaptive compression, combining compression mechanisms to detect network attacks. This method significantly reduces the amount of communication per round by quantizing and encoding model updates uploaded by the client and distributed by the server; simultaneously, it attempts to dynamically adjust the computational load using adaptive strategies, enabling deployment in real-world scenarios with limited bandwidth.

[0020] This invention discloses a communication-efficient federated learning framework suitable for distributed network intrusion detection systems. This framework combines a sparse ternary compression algorithm with an adaptive mechanism, effectively alleviating the problem of high communication overhead in federated learning environments. Specifically, the sparse ternary compression algorithm converts the parameters uploaded by the client into a sparse three-state representation, significantly reducing the transmission volume without a significant decrease in accuracy. Simultaneously, the adaptive training mechanism dynamically adjusts the local training process based on the performance indicators of each participating client, improving resource utilization and overall training efficiency. Preliminary experiments in DDoS intrusion detection tasks demonstrate that this invention maintains good classification performance while reducing communication overhead, making it suitable for learning scenarios with limited bandwidth and insufficient device computing power.

[0021] This invention discloses an efficient federated learning intrusion detection method based on dynamic adaptive compression. The method is implemented using a bidirectional adaptive federated learning (FL) system (BiASTC-FL), which has at least one server and multiple clients. Preferably, the global model is a neural network model, such as a multilayer sensor machine (MLP). Figure 1 As shown, it includes the following steps: Step S0: Construct the dataset and preprocess the samples in the dataset. After preprocessing, allocate a validation set to the server based on the constructed dataset, and allocate different training and test sets to each client, so that each server corresponds to a validation set. Each client corresponds to a local dataset (training and test sets). The sample size of the training set for each client is inconsistent.

[0022] The dataset can use existing datasets or network traffic captured in real time using network analysis and monitoring tools (such as Wireshark / PyShark, Packet Tracer, etc.). Traffic attributes include, but are not limited to, source / destination IP, port, protocol type, timestamp, etc. The dataset includes multiple samples, divided into normal traffic samples and attack traffic samples according to a certain ratio; the attack traffic samples contain various attack types. The dataset can be divided into training, test, and validation sets. To further improve the generalization ability and evaluation performance of the global model, this invention attempts to add a dynamic partitioning method based on traffic feature statistics, building upon traditional random data partitioning. Specifically, before partitioning, the distribution of various attack samples in the entire dataset is statistically analyzed. During partitioning, stratified sampling and group sampling are used to ensure that the distribution of different attack types differs across the training, validation, and test sets, such as including attack types that are not present or have a very low proportion in the training set within the test set. This invention focuses on the global model's ability to detect unknown or rare traffic types, thereby improving the generalization performance and robustness of the global model.

[0023] After constructing the dataset, the samples in the dataset will be preprocessed to form standardized samples. The specific process is as follows: feature extraction (extracting key features from the samples in the dataset to obtain the feature vectors of the samples), normalization (normalizing the feature vectors of the samples), fixed-length padding (padding the feature vectors of the normalized samples with a fixed length (such as the size of a set time window) to adapt them to the input size of the global model), and shuffling and saving the sample indices in the dataset to form standardized samples.

[0024] The specific operation of padding the feature vectors of normalized samples to a fixed length is as follows: Set a maximum number of packets (such as the maximum length of each traffic sample), and the feature vector of each sample is padded or truncated to the maximum length; for samples that are less than the maximum length, zeros or specified values ​​are added to the end of the feature vector to make the dimension of each sample consistent, thereby ensuring that the data size of the samples remains the same for the global model.

[0025] Step S1: The server randomly initializes the global model and loads the first training parameters; the client corresponds to the training set and test set; the server corresponds to the validation set.

[0026] Step S2: The server distributes the global model and the first training parameters (global parameters) to all clients; all clients receive the global model from the server and load the first training parameters (such as epoch and step) to form a local model and first local parameters; the server determines the clients participating in this round of training; to distinguish them from the server's global model and first training parameters, the client's global model and first training parameters are referred to as the local model and first local parameters, and each client corresponds to its own local model. If this round of training is the first round of training, then all clients participate in the first round of training.

[0027] Step S3: The client participating in this round of training performs this round of training on the local model based on the corresponding training set (local training set). After this round of training is completed, the first local parameters are updated. The updated first training parameters of the local model (corresponding to...) Figure 1 The updated local parameters in the dataset are marked as the second local parameters. Each client participating in this round of training will perform local training on its local model based on its own training set. After the training is completed, the client will fine-tune and update the first local parameters of the local model according to its own training performance to obtain the second local parameters.

[0028] Step S4: The client participating in this round of training obtains the gradient of the local model based on the first local parameters and the second local parameters, and uploads it to the server after compression; The clients participating in this training round evaluate the performance of their local models based on the test set and the second local parameters, obtaining the evaluation results from the clients participating in this training round. These evaluation results, along with the gradients of the local models, are then uploaded to the server. Performance metrics include accuracy, loss, and standard deviation.

[0029] Specifically, the gradient of the local model refers to the element-wise difference between the first local parameter and the second local parameter. Then, the client participating in this training round uses the ternary compression (STC) algorithm to compress the difference into the form {-1, 0, +1}, and uses an appropriate encoding strategy for positional encoding to reduce uplink communication overhead. If the first local parameter is... The second local parameter is Then the gradient of the local model is After applying the STC algorithm, the clients participating in this round of training only retain the most significant parameter changes and quantize them as {-1, 0, +1}.

[0030] Each client participating in this round of training will compress the gradients of its local model and upload them to the server.

[0031] Step S5: The server updates the first training parameters based on the gradient of the compressed local model, compresses the updated first training parameters and sends them to all clients, and determines whether the next round of training is needed. Specifically, step S5 includes the following steps: Step S5.1: The server receives the gradients of the compressed local model from the client participating in this round of training; Step S5.2: The server decodes the gradient of the local model compressed by the client participating in this round of training based on the position encoding to obtain the gradient of the local model decoded by the client participating in this round of training; Step S5.3: Based on the aggregation algorithm and the sample size of the training set corresponding to the clients participating in this round of training, the server performs a weighted average of the gradients of the local models of the clients participating in this round of training to obtain the gradient update of the global model (the updated first training parameters).

[0032] Step S5.4: The server compresses the updated first training parameters and sends them to all clients; Step S5.5: The server determines whether to proceed with the next round of training. Whether to proceed with the next round is determined based on the global model's performance or the number of training rounds in the current iteration. The server uses a validation set to evaluate the performance of the global model (e.g., calculate the F1 score, accuracy, STD, etc.) to determine if it is stable (converged). If the performance of the global model on the validation set (e.g., the F1 score) approaches stability (i.e., the performance change is below a set threshold for several consecutive training rounds), then the next round of training will not be performed.

[0033] Alternatively, if the number of training rounds in this round has already equaled the preset maximum number of training rounds, then no further training round will be conducted.

[0034] Step S6: If a client needs to perform the next round of training, the server determines which clients will participate. The server determines this based on the evaluation results of the clients participating in the current round. Clients with lower evaluation scores are allocated more local training resources and have their compression ratio reduced, allowing them to upload more updated parameter information. Clients with higher evaluation scores have their local training resources reduced and their compression ratio increased to reduce communication overhead, while still having the opportunity to participate in model updates. Clients participating in the next round of training then re-train based on the updated first training parameters. The process for the next round of training is the same as the current round. Steps S2-S4 are then repeated.

[0035] The server compares the evaluation results of each client participating in the current training round with a preset comparison threshold. If the evaluation result is lower than the threshold, the client participates in the next training round; if the evaluation result is higher than the threshold, the client does not participate in the next training round. Through this comparison, clients performing below average are allocated more training epochs and local training steps (Batch / MBGD); conversely, high-performing clients have their training reduced or paused. The server dynamically adjusts this strategy to achieve efficient allocation of computing and communication resources.

[0036] Step S7: If no further training is required, the traffic to be detected is detected based on the global model on the server side and the updated first training parameters on the server side.

[0037] The detection method of this invention continuously optimizes the performance of the global model by performing local evaluation on the client and aggregating the global model on the server, thereby improving the accurate identification and classification of DDoS attacks and achieving effective detection and response to network attacks.

[0038] The following section explains the ternary compression algorithm involved: Ternary compression (STC) algorithm: Sparse Ternary Compression (STC) is a low-communication-cost model quantization method. Its core idea is to set the smaller gradient elements in the original data to zero, retaining only a small amount of key gradient information with large amplitudes, and limiting its values ​​to a ternary set of {-1, 0, +1}, thus achieving both sparsity and compressibility. Specifically, the STC algorithm includes the following key steps: Sparsification: Select the top-k elements with the largest absolute values ​​from the gradient and set the rest to zero to reduce the non-zero ratio of the update vector.

[0039] Ternarization: Non-zero elements are symbolized, retaining only their sign (+1 for positive, -1 for negative), further reducing communication overhead.

[0040] To give a simple example, suppose the gradient of a certain layer of the global model during training is [0.3, -0.05, 0.01, -0.25, 0.16, 0.07]. After sparsification and ternary quantization by the STC algorithm, it can be compressed into the form [1, 0, 0, -1, 1, 0].

[0041] Optional Position Encoding: This uses lossless compression methods such as Golomb encoding and Elias encoding to process the indices of non-zero elements. While preserving sparse structural information, it significantly reduces communication load. The STC algorithm is suitable for client-side uplink updates and server-side downlink broadcasts, possessing excellent communication compression capabilities and effectively improving the communication efficiency of FL. Adaptive Mechanism: This invention attempts to incorporate an adaptive mechanism into the federated learning process, dynamically adjusting computational tasks based on the client's performance on the test set. Specifically, clients with poor performance are allocated more training epochs and steps (Mini-Batch / MBGD) to improve the accuracy of their local models on local data, while clients with good performance are allocated fewer or no additional computation, saving overall computational resources and accelerating global model convergence. Specifically, after each training epoch, the server collects the local validation accuracy (or F1 score) uploaded by the clients participating in that epoch. Using the average accuracy of the clients as a benchmark, clients with accuracy below this average are considered "poorly performing," while those above are considered "well-performing." Poorly performing clients are allocated more training epochs or steps to improve their local model performance; well-performing clients are allocated fewer training resources or are given early stopping strategies to avoid resource waste, thus achieving efficient training of FL not only in environments with limited bandwidth but also limited computational resources.

[0042] The formula for calculating the F1 score is: , , , Where TP represents the number of true instances, FP represents the number of false positives, TN represents the number of false negatives, Precision represents accuracy, and Recall represents recall.

[0043] Adaptive mechanism algorithm: Filtering out the client set with low accuracy The system will assign the next training round and number of steps to each client group. Training can then be stopped for the remaining client groups that are not selected. (1) Determine the client set using the following formula : ; (2) Execute the following formula: , ; (3) For client sets Each client in the process determines its next training round number and number of steps using the following formula: , ; in, The return value is a collection of all clients. 'This represents the set of clients that did not meet the criteria selected in this training round, and the accuracy of each client on the test set.' The average accuracy is given by σ, which is the scaling / computation factor. and These represent the number of training epochs and steps (MBGD), respectively. This measures the current client sample size. Compared to the average size of all clients The overall idea of ​​this invention is to adjust the current client based on the difference between the highest and lowest accuracy rates among these clients, allocating more computing resources to clients with lower accuracy rates to improve their performance. Furthermore, for high-performing users, early-stopping strategies are applied to reduce computational load.

[0044] To further verify the present invention, the experimental examples of the present invention are as follows: The experimental dataset used was CIC-DDoS2019, released in 2019 by the University of New Brunswick in Canada. It includes normal traffic and 13 different types of DDoS attacks. Each traffic packet was parsed into a fixed-length array of 11 fields (such as packet length and protocol characteristics). The captured traffic data was in PCAP format and processed using Wireshark, an open-source network packet analyzer that captures traffic from network interfaces in real time for subsequent analysis. The training, test, and validation sets were split in an 8:1:1 ratio within the dataset.

[0045] To simulate the characteristics of experimental data under Non-IID federated learning, in addition to the unbalanced nature (i.e., the traffic scale held by different clients is inconsistent), it also includes the case where each client holds only one specific attack type.

[0046] The local models used for training were an MLP (Multilayer Perceptron) and a ResNet-8, with 4,000+ and 32,000+ parameters respectively. The compression ratio was set to ρ=0.1, meaning only 10% of the model parameters were non-zero. The optimizer used was Adam, with a fixed value of 0.01.

[0047] To verify the effectiveness of the method of this invention, the experiment included the FedAvg clustering method as a baseline. The server selected a subset of clients for local training, and then weighted the parameters of these clients according to the number of samples to obtain a new global model. Specifically, in each round of federated training, the server received model parameter updates from each participating client, decoded them into sparse floating-point vectors, and then aggregated them to generate new global model parameters. The server weighted all model parameters or gradients uploaded by clients according to the number of samples in the client's local training data: that is, the weight of each client's uploaded parameter = its local sample count / the sum of the sample counts of all participating clients. This represents the sum of the training results of all participating clients in this round of training. The larger the amount of data in each client's local dataset, the greater the influence of its local model on the global model. These global model parameters are then distributed to each client as the initial parameters for the next round of local training.

[0048] In this application, the F1 score is used for metric evaluation. The F1 score is determined by the harmonic mean of precision and recall. Precision (P) is the proportion of traffic samples predicted as attacks that are actually attack traffic; recall (R) is the proportion of all real attack traffic samples that are correctly identified as attacks.

[0049] Traffic classification capability refers to the global model's ability to determine whether an input traffic sample belongs to normal traffic or attack traffic (such as DDoS, WebDDoS, LDAP, etc.). Its effectiveness is reflected in whether the global model can effectively distinguish and identify various network traffic types, thereby enabling the detection and early warning of network intrusion behavior.

[0050] Regarding the compression mechanism, since it is bidirectional quantization, the total communication volume includes uplink and downlink, and the unit is MB.

[0051] Experiment 1 involved 5 clients, each holding a local dataset (training and test sets) containing approximately 5,500 traffic entries of various types: WebDDoS, LDAP, Portmap, DNS, and Benign (normal traffic). An MLP model was used, primarily to verify Non-IID compliance. Table 1 shows the results for the 5 clients. The FedAvg baseline had Epoch=1 and Batch=50.

[0052] Table 1

[0053] Experiment 2 involved 15 clients, with files of corresponding formats randomly generated from several segments of CIC-DDoS2019. The traffic type held by each client was no longer specific, but mostly UDP (User Datagram Protocol) traffic. The data size of each client ranged from 300 to 1500, focusing on unbalanced performance. Table 2 shows the results of the 15 clients in the first 30 rounds, where the F1 score with the STC mechanism was close to that without the addition.

[0054] Table 2

[0055] Conclusions: In Experiment 1, with five clients each holding a traffic category, the total uplink and downlink communication volume was reduced by over 64% and 70%, respectively, compared to the benchmark FedAvg method and the adaptive-only mechanism, through sparse ternary compression and an adaptive training mechanism. Experiment 2 expanded the number of clients to 15, further increasing the traffic volume and resulting in a significantly uneven data distribution. The F1 score decreased slightly, and the total communication volume was reduced by over 72%. Furthermore, this invention significantly improved communication while validating the effectiveness of network attack detection through metrics such as the F1 score. Experimental results show that even with significant communication volume compression, the global model can still accurately identify network attacks such as DDoS, balancing communication efficiency and detection performance.

[0056] An F1 score above 0.9 indicates that the global model has a high level of attack detection capability and can effectively detect and intercept intrusions in real-world cybersecurity scenarios; an F1 score in the range of 0.8-0.9 is considered excellent; and an F1 score below 0.7 indicates relatively average performance, suggesting that the global model's recognition capability needs improvement.

[0057] In the experimental examples of this invention, the F1 value is close to the uncompressed baseline (FedAvg), indicating that even with a significant reduction in communication overhead, the global model still maintains a high accuracy and stability in network attack detection, and has certain practical application value.

[0058] Two small-scale experiments conducted on the CIC-DDoS2019 dataset demonstrate that this method possesses high communication efficiency and relatively reliable detection performance under high heterogeneity.

Claims

1. A highly efficient federated learning intrusion detection method based on dynamic adaptive compression, characterized in that, The detection method is based on a server and several clients, with each client corresponding to a training set and a test set; the server corresponds to a validation set; the detection method includes the following steps: Step S1: The server initializes the global model and the first training parameters; Step S2: The server distributes the global model and the first training parameters to all clients; all clients receive the global model distributed by the server and load the first training parameters to form a local model and the first local parameters; the server determines the clients participating in this round of training. Step S3: The client participating in this round of training performs this round of training on the local model based on the corresponding training set and updates the first local parameters after completion. The updated first training parameters are marked as the second local parameters. Step S4: The client participating in this round of training obtains the gradient of the local model based on the first local parameters and the second local parameters, and uploads it to the server after compression; Step S5: The server updates the first training parameters based on the gradient of the compressed local model, sends the updated first training parameters to all clients, and determines whether the next round of training is needed. Step S6: If a next round of training is required, the server determines the clients to participate in the next round of training; the clients participating in the next round of training perform the next round of training based on the updated first training parameters; Step S7: If no further training is required, the traffic to be detected is detected based on the global model on the server side and the updated first training parameters on the server side.

2. The efficient federated learning intrusion detection method based on dynamic adaptive compression according to claim 1, characterized in that, It also includes step S0; step S0: constructing a dataset and preprocessing the samples in the dataset; assigning a validation set to the server based on the constructed dataset, and assigning different training and test sets to each client.

3. The efficient federated learning intrusion detection method based on dynamic adaptive compression according to claim 2, characterized in that, In step S3, the client participating in this round of training evaluates the performance of the local model based on the test set and the second local parameters, obtains the evaluation results of the client participating in this round of training, and uploads the evaluation results of the client participating in this round of training to the server. In step S6, the server determines the clients to participate in the next round of training based on the evaluation results of the clients participating in this round of training.

4. The efficient federated learning intrusion detection method based on dynamic adaptive compression according to claim 2, characterized in that, Preprocessing includes the following steps: Step S0.1: Extract the key features of the sample to obtain the feature vector of the sample; Step S0.2: Normalize the feature vectors of the samples; Step S0.3: Fill the feature vectors of the normalized samples with a fixed length; Step S0.4: Shuffle and save the index of the sample to form a standardized sample.

5. The efficient federated learning intrusion detection method based on dynamic adaptive compression according to claim 1, characterized in that, In step S4, the gradient of the local model is compressed into the form of {-1, 0, +1} using a ternary compression algorithm, then positionally encoded, and finally uploaded to the server.

6. The efficient federated learning intrusion detection method based on dynamic adaptive compression according to claim 5, characterized in that, Step S5 includes the following steps: Step S5.1: The server receives the gradients of the compressed local model from the client participating in this round of training; Step S5.2: The server decodes the gradient of the local model compressed by the client participating in this round of training based on the position encoding to obtain the gradient of the local model decoded by the client participating in this round of training; Step S5.3: Based on the aggregation algorithm and the sample size of the training set corresponding to the clients participating in this round of training, the server performs a weighted average of the gradients of the local models of the clients participating in this round of training to obtain the updated first training parameters. Step S5.4: The server compresses the updated first training parameters and sends them to all clients; Step S5.5: The server determines whether the next round of training is needed.

7. The efficient federated learning intrusion detection method based on dynamic adaptive compression according to claim 3, characterized in that, In step S6, the server compares the evaluation results of the clients participating in this round of training with a preset comparison threshold. If the evaluation result of the client participating in this round of training is lower than the comparison threshold, the client participating in this round of training will participate in the next round of training. If the evaluation result of a client participating in this round of training is higher than the comparison threshold, then the client participating in this round of training will not participate in the next round of training.

8. The efficient federated learning intrusion detection method based on dynamic adaptive compression according to claim 7, characterized in that, The comparison threshold is determined based on the average level of the clients participating in this round of training.

9. The efficient federated learning intrusion detection method based on dynamic adaptive compression according to claim 6, characterized in that, In step S5, the server determines whether the client needs to perform the next round of training based on the performance of the global model; If the performance of the global model is stable, then no further training will be performed; If the performance of the global model is unstable, proceed to the next round of training.