A malicious traffic detection method based on multi-sparsity analysis
By constructing a multi-sparseness analysis framework and combining DBSCAN, KMeans, and IFOreest models, the problem of insufficient accuracy of single anomaly analysis mechanisms in existing technologies is solved, achieving high-precision and low-false-report malicious traffic detection, which is suitable for large-scale SDN network environments.
Patent Information
- Application Number
- CN202611323726.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-28
- Publication Date
- 2026-11-27
AI Technical Summary
Most existing intrusion detection systems rely on a single anomaly analysis mechanism, resulting in limited accuracy in identifying anomalies in the feature space, a high false alarm rate, and difficulty in effectively identifying unknown attacks.
A multi-sparseness analysis-based approach is adopted, combining three unsupervised anomaly detection models: DBSCAN, KMeans, and IFOrest, to construct a multi-sparseness analysis framework for comprehensive evaluation of network flow anomalies. Data collection and feature extraction are performed through a distributed controller cluster and a producer-consumer concurrent processing mechanism. Sliding window analysis is used to analyze network flow behavior and calculate a comprehensive anomaly score for malicious traffic detection.
It improves the accuracy of malicious traffic detection and reduces the false alarm rate, is suitable for large-scale SDN network environments, and achieves high-precision detection of unknown attacks.
Smart Images

Figure CN123184898A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer network security, specifically involving a malicious traffic detection method based on multi-sparseness analysis. Background Technology
[0002] Malicious traffic is an abnormal data stream in the network initiated by attackers with the purpose of destruction or theft. It includes distributed denial-of-service attack traffic, port scanning, and malicious penetration testing. This type of traffic can consume network bandwidth, steal user privacy and business data, disrupt normal server services, bypass security access controls, and cause system paralysis or information leakage. It has five-tuple characteristics, message interaction patterns, and transmission behavior patterns that are different from normal business traffic, and is a key target for intrusion detection systems to identify and intercept.
[0003] Software-Defined Networking (SDN) completely decouples the tightly coupled control plane and data forwarding plane in traditional network devices. A dedicated, centralized controller manages the entire network topology and provides a global network view. Leveraging southbound protocols like OpenFlow, it distributes flow table rules to lower-level switches that are solely responsible for traffic forwarding. Upper-layer applications then flexibly invoke controller capabilities via northbound APIs to achieve network programmability. Compared to the independent operation of traditional network devices, SDN controllers can simultaneously perceive and manage a large number of switching nodes in the network, acquire real-time network status information, and dynamically adjust forwarding behavior based on network policies. Therefore, SDN demonstrates significant advantages in network resource scheduling, traffic engineering, fault recovery, and security management, and has become a crucial supporting technology for data center networks and cloud computing environments.
[0004] Sparsity analysis is an anomaly detection method based on the distribution characteristics of samples in a feature space. Its basic idea is that normal network traffic typically exhibits similar behavioral patterns, forming relatively dense clusters in the feature space; while malicious traffic, due to significant differences in behavioral patterns from normal traffic, is usually distributed in low-density areas or far from the cluster centers of normal samples, exhibiting obvious sparsity and outlier characteristics. Therefore, by analyzing the sparsity characteristics of network flows in the feature space, the degree of anomaly of the network flows can be assessed, thereby enabling the identification of malicious traffic.
[0005] This invention proposes a malicious traffic detection method based on multi-sparseness analysis, enabling malicious traffic detection within an SDN environment. The method first collects flow statistics reported by switches from an SDN distributed controller cluster. Based on preset matching rules for network flow source IP addresses, network flows are divided into different controller instances. A producer-consumer concurrent processing mechanism based on thread pools is then used to asynchronously collect and process flow statistics. Subsequently, a flow state context is established for each network flow, flow increment information is calculated, and byte rate, packet rate, and their statistical characteristics are extracted using a sliding window to construct a standardized network flow behavior feature vector. Finally, the feature vector is input into a DBSCAN model to calculate anomaly scores based on local density; into a KMeans model to calculate anomaly scores based on global distance; and into an IFOres model to calculate anomaly scores based on sample isolation. All anomaly scores are standardized, and a comprehensive anomaly score is obtained through root mean square fusion. Finally, a threshold is used to determine malicious traffic. Summary of the Invention
[0006] To address the limitation of existing intrusion detection systems that largely rely on a single anomaly analysis mechanism, resulting in limited accuracy in identifying anomalies in the feature space and a high false positive rate, this invention proposes a malicious traffic detection method based on multi-sparseness analysis. This method integrates three unsupervised anomaly detection models—DBSCAN, KMeans, and IFOres—to construct a multi-sparseness analysis framework, comprehensively evaluating the degree of network flow anomalies to achieve malicious traffic detection. This method features high detection accuracy and a low false positive rate, effectively identifying unknown attacks and is applicable to malicious traffic detection in large-scale SDN network environments.
[0007] The technical solution adopted by the present invention to achieve the above objectives mainly includes three steps: data acquisition, feature extraction, and anomaly detection.
[0008] 1. Data Acquisition: Based on the distributed controller cluster, network flow statistics reported by the switches are obtained. The load balancing of network flows is achieved through source IP address matching rules. The producer-consumer concurrent processing mechanism is used to asynchronously receive, parse, cache and maintain the status of flow statistics.
[0009] 2. Feature Extraction: The collected network flow statistics data are organized and statistically analyzed over time. By establishing the network flow state context, calculating incremental statistical information, and analyzing network flow behavior using a sliding window, multidimensional statistical features that can characterize the temporal changes of network flow are extracted, and a standardized network flow behavior feature vector is constructed.
[0010] 3. Anomaly Detection: The network flow is input as a feature vector into the multi-sparseness analysis framework. The DBSCAN model, KMeans model and IFOreest model are used to calculate the anomaly score of the network flow. The anomaly scores are standardized and fused to obtain a comprehensive anomaly score. Malicious traffic is identified based on the comparison between the comprehensive anomaly score and the threshold. Beneficial effects
[0011] This invention achieves load-balanced collection of network flow statistics through a distributed controller cluster and a traffic partitioning mechanism based on source IP addresses. Combined with a producer-consumer concurrent processing architecture, it improves the efficiency of flow statistics collection and system throughput in large-scale SDN network environments, effectively reducing the computational pressure and processing latency of a single controller. By constructing a sliding window-based network flow behavior feature extraction method, it performs time-series analysis on flow statistics, extracting byte rate, packet rate, and their statistical features, which more accurately characterizes the dynamic behavior of network flows and improves feature representation capabilities. Furthermore, it utilizes the DBSCAN model to evaluate the degree of network flow anomalies from the perspective of local density, the KMeans model from the perspective of global distance, and the IFOres model from the perspective of sample isolation. Through anomaly score standardization and fusion mechanisms, it reduces the detection bias of a single model, achieving high-precision detection of unknown attacks without the need for attack samples and attack feature libraries. It boasts advantages such as high detection accuracy and low false positive rate, making it suitable for malicious traffic detection in large-scale SDN environments. Attached Figure Description
[0012] Figure 1 This is a flowchart of data acquisition.
[0013] Figure 2 This is a flowchart for feature extraction.
[0014] Figure 3 This is a flowchart for anomaly detection.
[0015] Figure 4 This is a flowchart of a malicious traffic detection method based on multi-sparseness analysis. The execution process is as follows: First, network flows are mapped to corresponding controller instances based on their source IP addresses. The controller then obtains switch flow statistics through an active polling mechanism and performs asynchronous concurrent processing of flow statistics using a producer-consumer model. Second, a network flow state context is established for the collected flow statistics, and network flow behavioral features are extracted using a sliding window to construct a behavioral feature vector. Finally, the behavioral feature vector is input into the multi-sparseness analysis framework to calculate the anomaly scores for the three detection models: DBSCAN, KMeans, and IFOrest. After standardization and fusion, a comprehensive anomaly score is obtained, and malicious traffic is determined based on the detection threshold. Detailed Implementation
[0016] The invention will be further described below with reference to the accompanying drawings.
[0017] like Figure 4 As shown, the method of the present invention mainly includes three steps: data acquisition, feature extraction, and anomaly detection.
[0018] 1. Data collection. Figure 1 The flowchart for data acquisition is as follows: This module obtains network flow statistics reported by the switch and performs load balancing and concurrent processing on the statistics, specifically including:
[0019] 1.1 Based on preset matching rules for the source IP addresses of network flows, the network flows reported by the switch are classified, and different network flows are assigned to corresponding controller instances. Specifically, a suffix-based partitioning method is used, based on the lowest suffix of the source IP address. The controller classifies traffic by bit, and the flow space it is responsible for can be represented as: Network flows with the same suffix are managed by the same controller to achieve balanced distribution of network flows.
[0020] 1.2 Each controller sends a flow statistics request to the switch it manages every 0.5s according to the preset sampling period, receives the flow statistics information returned by the switch, and obtains statistical information such as the number of bytes, the number of data packets, and the duration of each network flow.
[0021] 1.3 A producer-consumer model is introduced to build a high-concurrency data processing framework. The producer is responsible for sending statistical requests to the switch and receiving response messages. It continuously acquires stream statistics and completes basic parsing, then encapsulates the parsed stream statistics records into a unified data object and writes it to a shared buffer queue.
[0022] The shared buffer queue is located between the producer and consumer, and its main function is to implement data caching and task scheduling. When a large number of statistical messages arrive in a short period of time, the buffer queue can temporarily store tasks to be processed, thereby preventing the producer from being blocked due to insufficient consumer processing capacity. When the traffic returns to normal, the consumer thread will then process the backlog of tasks step by step, achieving dynamic balancing of system load.
[0023] Multiple worker threads in the thread pool act as consumers, continuously retrieving tasks to be processed from the shared queue and executing subsequent analysis processes, including stream state updates, traffic increment calculations, sliding window maintenance, feature extraction, and anomaly detection task submission.
[0024] 2. Feature extraction. Figure 2The flowchart shows the feature extraction process. This module extracts features from the collected network flow statistics, establishes a flow state context for each network flow, and records statistical information such as the number of bytes, the number of packets, and the flow duration. It also calculates the increment of the number of bytes and the increment of the number of packets based on the statistical values of two adjacent sampling periods.
[0025] The incremental statistical data obtained from continuous sampling of each network flow are used to construct a step-sliding window according to the window length and sliding step size. When the number of samples in the window reaches the window length, statistical analysis is performed on each sampling point in the window. The byte rate and data packet rate corresponding to each sampling point are calculated according to the sampling period, and windows containing a large number of zero-rate samples are filtered to reduce the impact of idle network flow on subsequent detection results.
[0026] Statistical calculations are performed on the byte rate and data packet rate within the sliding window, and behavioral features such as mean, maximum, minimum, standard deviation and coefficient of variation are extracted. These behavioral features are then combined to form a network flow behavioral feature vector.
[0027] 3. Anomaly detection. Figure 3 The flowchart for anomaly detection is as follows: This module treats network flows as feature vectors and inputs them into a multi-sparseness analysis framework. It calculates anomaly scores from three dimensions: local density, global distance, and sample isolation. The anomaly scores are then standardized and fused. Based on the fusion result, it determines whether the network flow is malicious traffic. Specifically, this includes:
[0028] 3.1 Input the network flow as a feature vector into the DBSCAN model to calculate the anomaly score from the dimension of local density; input it into the KMeans model to calculate the anomaly score from the dimension of global distance; input it into the IFOreest model to calculate the anomaly score from the dimension of sample isolation.
[0029] The DBSCAN model calculates density anomaly scores based on the distance between a sample and the core normal flow samples. The specific calculation formula is as follows: in, This is the sample to be tested. These are the most recent core samples. This represents the L2 norm. This distance reflects the degree to which a sample deviates from the normal density region. If a sample is located within a normal cluster, its distance from the core samples is small; conversely, when a sample is far from the normal flow cluster area, its corresponding distance will increase significantly. Therefore, The larger the value, the more likely the traffic is to be abnormal.
[0030] The KMeans model calculates a distance anomaly score based on the distance between a sample and its nearest cluster center. The specific calculation formula is as follows: in, This is the sample to be tested. It is the most recent cluster center. This represents the L2 norm. This metric indicates the distance of a sample to its nearest cluster center, measuring how far it deviates from the center of normal flow. Geometrically, normal flow typically clusters around centers, while abnormal flow tends to move further away. Therefore, the greater the sample's distance from its nearest cluster center, the higher its probability of being abnormal.
[0031] The IForest model calculates the isolated outlier score based on the average path length of a sample across multiple isolated trees. The specific calculation formula is as follows: The higher the anomaly score, the more likely the sample is to be isolated, and the higher its degree of anomaly.
[0032] 3.2 Based on the mean and standard deviation of the anomaly scores of each anomaly detection model obtained from the normal traffic training set, the density anomaly score, distance anomaly score, and isolated anomaly score are standardized to obtain the corresponding standardized anomaly scores. Then, the root mean square fusion method is used to fuse the three standardized anomaly scores to obtain the comprehensive anomaly score of the network flow. The calculation formula is as follows: in, , and These are the standardized density anomaly scores, distance anomaly scores, and isolated anomaly scores, respectively.
[0033] 3.3 Based on the actual detection results, a threshold T is set to 3.5. The comprehensive anomaly score is compared with this threshold. When the comprehensive anomaly score is greater than or equal to the threshold, the corresponding network flow is judged as malicious traffic; otherwise, it is judged as normal traffic, thereby realizing malicious traffic detection based on multi-sparseness analysis.
Claims
1. A malicious traffic detection method based on multi-sparseness analysis, characterized in that, By integrating three sparsity analysis methods—DBSCAN, KMeans, and IFOrest—this method assesses traffic anomalies from multiple dimensions, including density, distance, and isolation, to achieve robust detection of malicious traffic. The method includes the following steps: Step 1: Data Acquisition: Obtain network flow statistics reported by the switch, and perform load balancing and concurrent processing on the statistics. Specifically, this includes: Step 1.1: Classify network flows using the OpenFlow flow table matching mechanism. Divide the network flows into categories based on preset source IP address prefix or suffix matching rules. Each of the following subsets is a non-overlapping subset. Corresponding to the The processing scope of each controller is determined by this mapping relationship, and different network streams are sent to the corresponding controller instances. Step 1.2: Each controller sends a flow statistics request to the switch it manages at a preset sampling period of 0.5s, receives the flow statistics information returned by the switch, and obtains statistical information such as the cumulative number of bytes, the cumulative number of data packets, and the duration corresponding to each network flow. Step 1.3: Encapsulate the received stream statistics into a unified data object and write it into a shared buffer queue. The consumer thread in the thread pool then asynchronously reads the stream statistics from the shared buffer queue. Step 2, Feature Extraction: Feature extraction is performed on the collected network flow statistics, specifically including: Step 2.1: Establish a flow state context for each network flow, record statistical information such as the number of bytes, the number of packets, and the flow duration, and calculate the increment of the number of bytes and the increment of the number of packets between adjacent sampling periods; Step 2.2: Use a sliding window to organize the continuous sampled data in time sequence, and statistically calculate the mean, maximum, minimum, standard deviation, and coefficient of variation of the byte rate and packet rate within the window to construct a network flow behavior feature vector; Step 3, Anomaly Detection: The network flow as a feature vector is input into a multi-sparseness analysis framework. Anomaly scores are calculated from three dimensions: local density, global distance, and sample isolation. The anomaly scores are standardized and fused, and the network flow is determined as malicious traffic based on the fusion result. This includes: Step 3.1: Input the network flow behavior feature vector into the DBSCAN model, KMeans model and IFOreest model to perform multidimensional anomaly analysis on the network flow behavior features. Calculate the density anomaly score according to the DBSCAN model, the distance anomaly score according to the KMeans model and the isolation anomaly score according to the IFOreest model. Step 3.2: Based on the normal traffic training set, obtain the mean and standard deviation of the anomaly scores corresponding to each anomaly detection model. Standardize the anomaly scores output by the three models to eliminate the differences in numerical range and units between the output results of different models. Step 3.3: Combine the three standardized outlier scores to obtain the comprehensive outlier score for the network flow. : in, , and These are the standardized density anomaly scores, distance anomaly scores, and isolated anomaly scores, respectively. Step 3.4: Based on the actual detection results, set the threshold T to 3.5 and compare it with the comprehensive anomaly score. When the comprehensive anomaly score is greater than or equal to the threshold, the corresponding network flow is judged as malicious traffic; otherwise, it is judged as normal traffic, thereby realizing malicious traffic detection based on multi-sparseness analysis.
2. The malicious traffic detection method according to claim 1, characterized in that, Step 1.3 employs a producer-consumer model to construct a high-concurrency data processing framework. The acquisition thread responsible for sending statistical requests to the switch and receiving response messages is defined as the producer. It continuously acquires stream statistics and completes basic parsing work, then encapsulates the parsed stream statistics into a unified data object and writes it to a shared buffer queue. The shared buffer queue, located between the producer and consumer, is primarily responsible for data caching and task scheduling. Multiple worker threads in the thread pool act as consumers, continuously acquiring tasks to be processed from the shared queue and executing subsequent analysis processes, including stream state updates, incremental traffic calculations, sliding window maintenance, feature extraction, and anomaly detection task submission.
3. The malicious traffic detection method according to claim 1, characterized in that, In step 3.2, the mean and standard deviation of the outlier scores output by the DBSCAN, KMeans, and IFOrest models are calculated using the normal traffic training set. Then, the outlier scores of the network flow to be detected in each model are Z-score standardized to calculate their deviation from the normal traffic distribution. Finally, the outlier intensity less than zero in the standardized results is set to zero, and only the outlier deviation values higher than the normal traffic distribution are retained as the standardized outlier scores of the corresponding models to unify the numerical scale of the outlier scores of different models.
