Online drift detection and self-adaptive sustainable network traffic classification method
Through online drift detection and adaptive network traffic classification methods, Beta distribution is used to detect data drift and perform model updates, which solves the problem of performance degradation of the traffic classification model and achieves rapid adaptation and high-performance maintenance of the model.
Patent Information
- Application Number
- CN202410782700.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2044-06-18
AI Technical Summary
Existing technologies are difficult to effectively detect and deal with the drift problem of network traffic data, resulting in degraded performance of traffic classification models and inability to keep up with the pace of dynamic changes in applications.
Adopt online drift detection and adaptive sustainable network traffic classification methods, by building original models, drift detection, training data integration and model update, using improved Beta distribution to detect data drift, and model through old knowledge distillation and bias correction methods Fine-tuning ensures that the model maintains high performance when the data distribution changes.
It realizes real-time monitoring of network traffic data changes, timely detection of data drift and model updates, ensuring that the model quickly adapts to new data distribution, maintains good performance, and reduces resource waste and reduced real-time performance.
Smart Images

Figure CN118764439A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of network traffic analysis, and in particular to an online drift detection and adaptive sustainable network traffic classification method. Background Art
[0002] As an important means of network management and security, network traffic classification (TC) has received great attention from academia and industry since the late 1990s, and has been well applied in QoS / QoE management, network resource optimization, congestion control, intrusion detection, etc. With the rapid development of new generation network technologies (B5G / 6G, Internet of Things, integrated space-ground network, etc.), network technology is developing towards a highly autonomous direction of "self-healing, self-management, self-optimization and self-protection". As one of the decision-making means for network business and security management, network traffic classification technology plays a key role. Many studies have applied AI technology to network traffic classification, and the classification performance has been greatly improved compared to traditional machine learning.
[0003] With the ubiquitous access of massive heterogeneous terminals, the network presents a high degree of "dynamics", "heterogeneity" and "complexity", which brings a series of new challenges to network traffic classification technology. In particular, the frequent upgrades of active applications, the continuous emergence of new applications, and the continuous removal of silent applications have always hindered the implementation of AI technology in traffic classification, which can easily cause data drift problems, resulting in the performance of traffic classification models to decline and unable to keep up with the pace of dynamic changes in applications. Therefore, there is an urgent need to study the problem of drift in network traffic data distribution and provide effective drift detection and response methods so that the model can quickly adapt to the new data distribution and maintain good performance. Summary of the invention
[0004] The problem to be solved by the present invention is to provide an online drift detection and adaptive sustainable network traffic classification method to solve the problem of lack of effective drift detection and processing methods for network traffic data, monitor the changes of network traffic data in real time, discover the occurrence of data drift in time, and use appropriate update strategies to quickly adapt to new data distribution.
[0005] The present invention adopts the following technical solution: an online drift detection and adaptive sustainable network traffic classification method, characterized in that it includes the following steps:
[0006] S1. Build the original model: Based on the input network traffic data, perform data processing to complete traffic data engineering and traffic feature engineering; and use the processed traffic data to train the classification model to obtain the original model that identifies the application category to which the traffic data belongs;
[0007] S2, drift detection: Based on the trained original model, the continuously input network traffic is identified and classified; the drift detector is used to detect whether the network traffic data drifts. If the data drifts, the model update is started;
[0008] S3, training data integration: after detecting data drift, collect the changed network traffic as new data, repeat step S1 to obtain a new training data set, and use the last training data as old data samples, perform sample selection on the old data samples, select representative samples and retain them as the old training set, merge them with the new training set for model update;
[0009] S4, model update: Use the training data set obtained in step S3 to update the model, adjust the model by fine-tuning, use improved old knowledge distillation and bias correction methods to perform continuous learning after data drift; replace the old model with the adjusted new model to perform traffic identification, and repeat step S2 to continue drift detection, and complete automatic detection and update of the model after network traffic data drift.
[0010] Specifically, in step S1, the flow data engineering includes: flow collection, preprocessing and flow labeling;
[0011] The traffic collection collects network traffic data in the served network, including header information and payload of data packets;
[0012] The preprocessing includes flow purification and flow reassembly, removing noise data in the flow data, filtering packets irrelevant to flow feature extraction, and forming complete TCP / UDP flows and session flows;
[0013] The traffic annotation marks the traffic data as specific applications or services, which are used as the real labels of the flow data for model training.
[0014] Specifically, in step S1, the traffic feature engineering includes: feature extraction, selection, expression and compression;
[0015] Extract features from the original grouping to form a key feature set containing multiple bidirectional flows. Use the automatic encoder and principal component analysis dimensionality reduction method to compress the key features and reduce the original model parameters. Use feature expression to form a feature set that can be used for original model training. Train the CNN classification model to obtain the original model and effectively identify the application category to which the traffic belongs.
[0016] The key features include: packet-level features, flow-level features, and statistical features; the feature expressions include: two-dimensional vectors, images, byte sequences, and graphs.
[0017] In particular, step S1 also divides two types of data storage in the original model, namely short-term memory S and long-term memory L, to store network traffic data; the short-term memory S stores traffic data instances obtained in the last time interval, and the long-term memory L stores traffic data samples of each category so far, which are used to train and update the original model.
[0018] Specifically, the drift detector in step S2 is based on drift detection of improved Beta distribution, uses a distance function to quantify the difference between the historical data distribution and the new data distribution, and detects drift by detecting changes in the model confidence distribution, including the following sub-steps:
[0019] S2.1. For a new data sample i, obtain the feature vector X i , calculate the confidence s of the current model for data sample i i , will s i Add to the short-term memory S, where S uses a sliding window and N represents the current length of S;
[0020] S2.2, set the parameter Δ, and for each data k from Δ to N-Δ in S, divide S into two sub-windows S a and S b , S a The latest data is in (s1﹕s k ) is S b ,(s k+1 ﹕s N ) is S a ;
[0021] When the drift detection trigger calculation condition is reached, calculate S a and S b The average values of confidence are m a and m b ; When m a ≤λ×m b When , we search for the change point, and λ represents the sensitivity to the change;
[0022] S2.3. Estimate S a and S b The Beta distribution parameter (α a ,β a ) and (α b ,β b ), calculate the sum of the absolute values of the log-likelihood ratios P k , the formula is as follows:
[0023]
[0024] Among them, s i∈S, α, β>0, are the two shape parameters of Beta distribution. α represents the shape of the distribution and determines the changing trend of the probability density function; β represents the range of the distribution and determines the width of the probability density function.
[0025] Function f(s i |α,β) is the probability density function, and the formula is as follows:
[0026]
[0027] Function B(α,β) is the Beta function, which is used for normalization to ensure that the total probability is 1. The formula is as follows:
[0028]
[0029] Among them, the function Γ represents the Gamma function, ds i For i The integral representation of .
[0030] S2.4. For all data k within Δ≤k≤N-Δ, calculate P after the conditions for triggering drift detection calculation are met. k , take P k The maximum value P f , set the threshold T h = -log(λ), if P f >T h , it is determined that drift occurs, otherwise no drift occurs.
[0031] Specifically, in step S3, the selection of old data samples includes: applying intra-clustering and intra-cluster sampling;
[0032] According to the clustering rules, the data is clustered within the application to capture the inherent communication mode of the application and cluster all the data of each application into multiple clusters;
[0033] Perform intra-cluster sampling on each cluster, and select the sample that best represents the overall data distribution from each identified communication pattern cluster; merge the samples selected from different clusters for each application and store them as the reserved data of the application, and discard the rest of the data to reduce redundant storage;
[0034] The clustering rule is: clustering network flow data with the same {destination IP, destination port, protocol} tuple into one cluster.
[0035] Specifically, the method of selecting samples in the cluster is as follows: calculate the average feature vector, determine the number of samples K to be selected, and for all integers j from 1 to K, select the sample B closest to the current average feature vector j :
[0036]
[0037] Among them, argmin represents the variable value when the objective function takes the minimum value, z is the current cluster, M' represents the old model that has not been updated yet, D' represents the entire old data set, ξ is the index mapping function, and η is the average feature vector; the representative sample finally selected in cluster z is: B z = {B1, B2, ..., B k}.
[0038] Specifically, in step S4, an improved old knowledge distillation and deviation correction method is used to perform continuous learning after data drift, and the method includes the following sub-steps:
[0039] S4.1. Fine-tune the model and set the neural network model input layer and hidden layer parameters θ c Freeze, softmax layer parameters θ f Do not freeze and initialize the new model, use the bias layer to correct the classification probability score applied to the old data, and calculate the distillation loss Loss based on the classification probability d , according to Loss d Update the parameter θ f ;
[0040] S4.2. After fine-tuning, unfreeze the parameter θ c , train a new model and use cross entropy loss as the classification loss Loss c , the total loss combines the distillation loss and the classification loss, and the model parameters θ are updated according to the total loss c and θ f , the total loss formula is as follows,
[0041]
[0042] Among them, C′ is the number of old data applications, and C is the total number of new and old data applications:
[0043] Update model parameters θ c and θ f :
[0044]
[0045] S4.3. By optimizing the loss function training, a new classification model that can identify new data categories and reduce catastrophic forgetting is obtained; the adjusted new model is used to replace the old model for traffic identification, and step S2 is repeated to continuously perform automatic model detection and updating to achieve automatic model detection and updating after network traffic data drifts.
[0046] The technical solution of the present invention also provides: an electronic device, comprising:
[0047] one or more processors;
[0048] a storage device having one or more programs stored thereon;
[0049] When the one or more programs are executed by the one or more processors, the one or more processors implement any of the above-mentioned online drift detection and adaptive sustainable network traffic classification methods.
[0050] The technical solution of the present invention also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps in any of the above-mentioned online drift detection and adaptive sustainable network traffic classification methods are implemented.
[0051] Compared with the prior art, the present invention adopts the above technical solution and has the following technical effects:
[0052] The sustainable network traffic classification method proposed in the present invention can monitor the changes of network traffic data in real time, detect the occurrence of data drift in time, and use appropriate update strategies to enable the model to quickly adapt to the new data distribution and maintain good performance. At the same time, data selection and storage are taken into consideration, reducing the waste of resources caused by storing all data, and the problems of low real-time performance and sensitivity caused by using all data to update the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a flowchart of the sustainable network traffic classification method of the present invention;
[0054] Figure 2 It is a schematic diagram of the short-term memory sliding window and its partitions of the present invention;
[0055] Figure 3 The router reasoning performance monitoring and the latest real-time traffic identification information of the embodiment of the present invention;
[0056] Figure 4 The number of correctly identified and incorrectly identified instances in the embodiments of the present invention;
[0057] Figure 5 The precision, recall rate and F1 score of the traffic recognition result of the embodiment of the present invention;
[0058] Figure 6 This is the confusion matrix of the recognition results of the embodiment of the present invention. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the application is further elaborated in detail below in conjunction with the accompanying drawings. The described embodiments are only a part of the embodiments involved in the present invention. All non-innovative embodiments of other researchers in the field on this embodiment belong to the protection scope of the present invention. At the same time, for the step numbering in the embodiment of the present invention, it is only set for the convenience of explanation, and the order between the steps is not limited in any way. The execution order of each step in the embodiment can be adaptively adjusted according to the understanding of those skilled in the art.
[0060] The present invention provides an online drift detection and adaptive sustainable network traffic classification method, such as Figure 1 As shown, it includes 4 steps: original model training, drift detection, training data integration, and model update.
[0061] S1. Original model training: Based on the input network traffic data, data processing is performed to complete traffic data engineering and traffic feature engineering; and the processed data is used to train the classification model to obtain an original model that can identify the application category to which the traffic belongs. The specific implementation steps include the following:
[0062] S101: Traffic data engineering, including traffic collection, preprocessing and labeling. Collect traffic data in the served network, including the header information and payload of the data packet. Traffic collection can be achieved in different ways, such as deploying probes on network devices, installing clients on terminal devices, and using software defined network (SDN) technology at the edge or core of the network. Preprocess the collected traffic data, including traffic distilling and stream reassembly, remove background traffic, redundant packets and other noise data in the flow data, filter packets that are not related to flow feature extraction, and form complete TCP / UDP streams and session streams. Traffic labeling is to mark what kind of application or service the traffic is, which is used as the real label of the flow data for model training.
[0063] S102: Traffic feature engineering, including feature extraction, selection, representation and compression. Representative traffic features are extracted from the original group to form a set of key features containing multiple bidirectional flows, where the set FF = {ff1, ff2, ff3…ffj}.
[0064] The key features include: packet-level features, flow-level features, and statistical features.
[0065] Among them, Packet-level features: including packet payload / raw bytes, in addition to packet-level features such as pkt len, inter-arrival-time, etc.; Flow-level features: including Flow type flow category (IEC104, Modbus, etc.), flow duration, number of packets in the flow pkt counts, etc.; Statistical features: mean or std deviation of related features, etc.
[0066] According to certain principles, the most representative features with higher contribution are selected, and dimensionality reduction methods such as automatic encoding machine and principal component analysis (PCA) are used to compress the features, further reduce model parameters and reduce the complexity of model training.
[0067] After forming the traffic features that can be used for model training, select a suitable way to express the traffic feature information, including two-dimensional vectors, images, byte sequences, graphs, etc., to form a feature set (Feature Set) that can be used for model training.
[0068] In order to store the above traffic data, two types of data storage are divided in the device, short-term memory S and long-term memory L. Short-term memory S is used to store data instances obtained by the device in the last time interval. These latest data will be saved for a period of time and processed to check whether drift has occurred. Long-term memory L stores the training data samples of each category so far. This information will be saved for a long time and used to train and update the model so that the model can learn all categories.
[0069] S103: Model training and evaluation: Use the training data set formed in the above steps to input into the CNN classification model for training. Select appropriate learning and training methods, the learning methods include supervised, semi-supervised, unsupervised, weakly supervised, etc., and the training methods include centralized / distributed training, federated learning, etc. Define corresponding evaluation criteria (Performance Evaluation Metrics), including accuracy, precision, recall, F1 score, etc., to evaluate the quality of the model and ensure that a qualified original model that can effectively identify the application category to which the traffic belongs is obtained.
[0070] S2, drift detection: Based on the currently trained model, the continuously input network traffic is classified; at the same time, the drift detector detects whether the data drifts; if the detection result does not exceed the threshold, the current model parameters continue to be used for traffic identification; if it exceeds the threshold, it is determined that the data drifts and the model update is started.
[0071] Specifically, the drift detector adopts a drift detection method based on the improved Beta distribution, uses a distance function to quantify the difference between the historical data distribution and the new data distribution, and detects drift by detecting the distribution change of the confidence of the model. It does not require data labels as input. The steps are as follows:
[0072] S201: Every time there is a new data instance (X i ,y i ) is available, get its eigenvector X i , calculate the confidence s of the current model i . Use the current model to predict this sample X i is the probability of each category P(c j |X), where c j is one of all possible classes, Y = {c1, c2, ..., c m}. Take P(c j |X) is the model's confidence in the sample. i . i Add to short-term memory S, S uses a sliding window, N represents the current length of S, and sets its maximum size N max , once the maximum size of S is reached, adding a new element to S means deleting the oldest element.
[0073] S202: Set parameter Δ, where N represents the length of the current S. For each data k from Δ to N-Δ in S, divide S into two sub-windows S a and S b (S a The latest data is in (s1﹕s k ) is S b ,(s k+1 ﹕s N ) is S a ,like Figure 2 As shown. It is unnecessary to perform detection calculation every time a new confidence value is inserted, and it will cause problems such as high calculation cost, large delay, and waste of resources. Therefore, the trigger link of the calculation is set as follows:
[0074] S2021: Determine each sub-window S a and S b Do they all contain at least Δ elements to maintain the statistical properties of a distribution, that is, there are at least 2Δ elements in S; if so, proceed to the next step.
[0075] S2022: Set a random number r between (0,1) to determine Is it true? This means that the higher the confidence, the lower the possibility of performing drift detection; if so, go to the next step.
[0076] S2023: When concept drift occurs, the confidence value will decrease, so only the negative change of confidence needs to be detected. a and S b The average values of confidence are m a and m b , then when m a ≤λ×m b When , a change point is searched for and subsequent detection calculations are performed. Among them, λ is the sensitivity to change, and the size can be set as needed. The larger λ is, the more sensitive it is to negative changes in confidence.
[0077] S203: Use parameter estimation method to estimate S a and S b The parameter of the Beta distribution (a a ,β a ) and (α b ,β b ), using the parameter to calculate the sum of the absolute values of the log-likelihood ratios P k , the formula is as follows:
[0078]
[0079] Among them, f(s i |α,β) is the probability density function, s i ∈S, its calculation formula is as follows:
[0080]
[0081]
[0082] Calculate all P within Δ≤k≤N-Δ k , S a and S b The greater the difference in the probability density function, the greater the k The higher the value of is, the greater the value of is. f , k max For its corresponding k value, and set the threshold T h = -log(λ). If P f >T h , then at point k max If a change is detected at the location, the model update is started and the short-term memory S is cleared; otherwise, no drift occurs and the current model parameters are continued to be used for traffic identification.
[0083] S3, training data integration: After data drift is detected, the changed traffic is collected as new data, and the data is processed in the same way as in step 1 to obtain a new training set for model training.
[0084] The last training data of the model is used as the old data set. To prevent catastrophic forgetting of the model, the old data and new data need to be used to update the model. However, if the forgotten knowledge is regained by replaying the entire existing sample, there will be two defects: on the one hand, this is redundant work, and on the other hand, the storage space is limited and cannot fully store the increasing data samples. Therefore, sample selection is performed on the old data, and a few representative samples are selected to be retained as the old training set, which is merged with the new training set for model update.
[0085] The selection of old data samples mainly includes two key steps: applying intra-clustering and intra-cluster sampling, as follows:
[0086] S301: Intra-application clustering. Each module of an application communicates with an external server to implement its functions. This communication is usually associated with a specific network destination, such as a server IP address and port. These communication destinations tend to remain relatively stable over time, so the inherent communication patterns of these applications can be captured based on the following rules: flow data with the same {destination IP, destination port, protocol} tuples are clustered into one cluster.
[0087] According to the clustering rules, the data is clustered within the application, the minimum data size of each cluster is set to n, and all the data of each application is clustered into multiple clusters z. The cluster Z of each application is {z1, z2, ..., z m}. This step ensures that the different communication patterns inherent in each application are identified. If the number of samples in some clusters is less than n, or some samples may not be clustered, these samples are merged into a comprehensive cluster.
[0088] S302: In-cluster sampling. In-cluster sampling is performed on each cluster after clustering, and the sample that best represents its overall data distribution is selected from each identified communication pattern cluster. Finally, the samples selected by each application from different clusters are merged and stored as the reserved data of the application, and the remaining data is discarded. While retaining a subset of samples as examples, the risk of eliminating the relationship and difference between classes is minimized, and the computation and storage overhead is reduced.
[0089] For each cluster, the specific sampling steps are as follows:
[0090] S3021: In order to better obtain the characteristics of the cluster, first use the current model M' to calculate its average feature vector η:
[0091] η=mean(∑ m∈z M′(ξ(m,D′)))
[0092] Among them, z is the current cluster, M' represents the old model that has not been updated yet, D' represents the entire old data set, and ξ is the index mapping function.
[0093] Iteratively select the sample closest to the current average feature vector to ensure that the selected sample set reflects the feature distribution of the original data to the greatest extent.
[0094] S3022: To ensure fair sample selection for all applications, define K, which represents the number of representative samples selected from each cluster:
[0095]
[0096] Among them, ceil() is a mathematical function that rounds a number to the nearest integer. represents the average number of samples of this class, τ% is the sample retention rate, len() is a quantity measurement function, z is the current cluster, and c is the current category.
[0097] S3023: After determining the number of samples K to be selected, for all integers j from 1 to K, select a sample B that is closest to the current average feature vector j :
[0098]
[0099] Among them, argmin represents the variable value when the objective function takes the minimum value, and all B j After that, the representative sample B finally selected in cluster z z = {B1, B2, ..., B k}.
[0100] Finally, for the old dataset, the representative sample B selected from application c c =*B z + z∈Z . Merge representative samples of all applications, that is, select the retained part for the old data samples and merge it with the new dataset as the training dataset for the next model update.
[0101] S4, model update: Use the training data set obtained in step 3 to update the model to alleviate the problem of catastrophic forgetting of the model. However, completely retraining the model requires a lot of computing resources and time, which reduces the real-time performance and sensitivity of the model. Therefore, the model is fine-tuned, using improved old knowledge distillation and bias correction technology to ensure continuous learning after data drift. The specific steps are as follows:
[0102] S401: Assume that a CNN classification model is used, multiple convolutional layers are connected, and in order to output the prediction probability, the fully connected layer is used as the classifier layer. The parameter H′ of the old model M′ is c ,θ' f ,θ' c represents the parameters of the convolutional layer, θ' f Represents the parameters of the fully connected layer. First, freeze θ' c , without freezing θ' f , which means that during the subsequent model fine-tuning, the parameter θ′ c Will not be updated and gradients will not be calculated. The freezing formula for this parameter is: Where L is the loss function and θ is the frozen parameter.
[0103] S402: Model fine-tuning. Define the old data samples in the training set as X', the number of samples as S', and the number of old application categories included as C'; the total samples in the training set as X, the total number of samples as S, and the total number of categories included as C.
[0104] S4021: Initialize the new model M, and obtain the classification probability (i.e., prediction score) p'=M(X') for X' in the training set. Then use the bias layer to correct the score, p=A×p'+B, where A and B are the two parameter matrices of the bias layer, and p is the final classification probability obtained by the model M.
[0105] S4022: The old model automatically finds the parameters of the old application and calculates the distillation loss based on the classification probability of the old application in the new model. This distillation loss enables the neural network to retain as much knowledge about the old application in the classifier as possible.
[0106] Definition of distillation loss Loss d :
[0107]
[0108] Update model parameters θ f :
[0109]
[0110] The number of rounds of fine-tuning can be defined as needed. Once fine-tuning is completed, the neuron parameters θ' c It will be unfrozen. The unfreezing formula of this parameter is: α is the degree of thawing parameters, when α=1, thawing is completed.
[0111] S403: Model training. Use cross entropy loss as classification loss c , to ensure the classification accuracy of new classes.
[0112]
[0113] Among them, y ic is the true label of the i-th sample. If the sample belongs to category c, the value is 1, otherwise it is 0; p ic is the predicted probability that the i-th sample belongs to category c.
[0114] Finally, the total loss combines the distillation loss and the classification loss, and the formula is as follows:
[0115]
[0116] Update model parameters θ c and θ f :
[0117]
[0118] By optimizing the loss function training as described above, a new classification model is obtained that can recognize new data categories and reduce catastrophic forgetting.
[0119] Finally, the adjusted new model replaces the old model for the next traffic identification, and returns to step S2 to continue automatic model detection and updating to achieve automatic model detection and updating after network traffic data drift.
[0120] In particular, in one embodiment of the present invention, the above-mentioned sustainable network traffic classification method is deployed in a home router to identify what application category the real-time traffic data in the router belongs to, classify mobile phone applications, and pay special attention to identifying the game traffic therein for subsequent game acceleration.
[0121] Specifically, the real-time traffic data in the router is classified. First, in the stage of building the original model, PCAPDroid and Wireshark are used to capture the original network traffic by using automated scripts and manual collection. CICFlowMeter is used to extract traffic features and perform data processing for training the deep learning model. Then, the model is solidified into the router, and the packet capture and reasoning modules are started. The application category to which the traffic generated by the terminal devices connected to the router network belongs can be identified in real time, and the real-time results can be visualized on the front-end web page. At the same time, the drift detection module is started to monitor the model recognition effect. When drift is detected, the new and old training data will be integrated, and the model will be updated to ensure the accuracy of the classification. Finally, the relevant results are deployed in the Mou family router to provide acceleration services for popular applications (games, live broadcasts, videos, etc.) within the home.
[0122] The method has been verified to be able to accurately identify real-time traffic data and provide real-time monitoring of router performance to ensure that resource consumption meets demand. Figure 3-Figure 6 As shown, Figure 3 Inferring performance monitoring and up-to-date real-time traffic identification information for routers, Figure 4 is the number of correctly identified and incorrectly identified instances, Figure 5 The precision, recall and F1 score of the traffic recognition results. Figure 6 The confusion matrix of the recognition results is shown in Figure 2. The overall recognition accuracy reaches 93%, the inference resource usage is reasonable, and it can reach the quasi-commercial standard.
[0123] In an embodiment of the present invention, an electronic device is also provided, including: one or more processors; a storage device on which one or more programs are stored; when the one or more programs are executed by the one or more processors, the one or more processors implement the line drift detection and adaptive sustainable network traffic classification method described in any of the above embodiments.
[0124] In an embodiment of the present invention, a computer-readable storage medium is further provided, on which a computer program is stored. When the program is executed by a processor, the steps in any one of the line drift detection and adaptive sustainable network traffic classification methods in the above embodiments are implemented.
[0125] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. An online drift detection and adaptive sustainable network traffic classification method, characterized in that: The steps include: S1. Build the original model: Based on the input network traffic data, perform data processing to complete traffic data engineering and traffic feature engineering; and use the processed traffic data to train the classification model to obtain the original model that identifies the application category to which the traffic data belongs; S2, drift detection: Based on the trained original model, the continuously input network traffic is identified and classified; Use the drift detector to detect whether the network traffic data drifts. If the data drifts, start the model update. S3, training data integration: after detecting data drift, collect the changed network traffic as new data, repeat step S1 to obtain a new training data set, and use the last training data as old data samples, perform sample selection on the old data samples, select representative samples and retain them as the old training set, merge them with the new training set for model update; S4, model update: Update the model using the training data set obtained in step S3, adjust the model by fine-tuning, and use the improved old knowledge distillation and bias correction method to perform continuous learning after data drift; The old model is replaced by the adjusted new model to perform traffic identification, and step S2 is repeated to continuously perform drift detection. After the network traffic data drift is completed, the model is automatically detected and updated.
2. The online drift detection and adaptive sustainable network traffic classification method according to claim 1 is characterized in that: In step S1, the flow data engineering includes: flow collection, preprocessing and flow labeling; The traffic collection collects network traffic data in the served network, including header information and payload of data packets; The preprocessing includes flow purification and flow reassembly, removing noise data in the flow data, filtering packets irrelevant to flow feature extraction, and forming complete TCP / UDP flows and session flows; The traffic annotation marks the traffic data as specific applications or services, which are used as the real labels of the flow data for model training.
3. The online drift detection and adaptive sustainable network traffic classification method according to claim 1 is characterized in that: In step S1, the traffic feature engineering includes: feature extraction, selection, expression and compression; Extract features from the original grouping to form a key feature set containing multiple bidirectional flows. Use the automatic encoder and principal component analysis dimensionality reduction method to compress the key features and reduce the original model parameters. Use feature expression to form a feature set that can be used for original model training. Train the CNN classification model to obtain the original model and effectively identify the application category to which the traffic belongs. The key features include: packet-level features, flow-level features, and statistical features; the feature expressions include: two-dimensional vectors, images, byte sequences, and graphs.
4. The online drift detection and adaptive sustainable network traffic classification method according to claim 1 is characterized in that: In step S1, two types of data storage are divided in the original model, namely short-term memory S and long-term memory L, to store network traffic data; the short-term memory S stores the traffic data instances obtained in the last time interval, and the long-term memory L stores the traffic data samples of each category so far, which are used to train and update the original model.
5. The online drift detection and adaptive sustainable network traffic classification method according to claim 4 is characterized in that: The drift detector in step S2 is based on drift detection of improved Beta distribution, uses a distance function to quantify the difference between the historical data distribution and the new data distribution, and detects drift by detecting changes in the model confidence distribution, including the following sub-steps: S2.
1. For a new data sample i, obtain the feature vector X i , calculate the confidence s of the current model for data sample i i , add si to the short-term memory S, where S uses a sliding window and N represents the current length of S; S2.2, set the parameter Δ, and for each data k from Δ to N-Δ in S, divide S into two sub-windows S a and S b , S a The latest data is in (s1∶s k ) is S b ,(s k+1 :s N ) is S a ; When the drift detection trigger calculation condition is reached, calculate S a and S b The average values of confidence are m a and m b ; When m a ≤λ×m b When , we search for the change point, and λ represents the sensitivity to the change; S2.
3. Estimate S a and S b The Beta distribution parameter (α a , β a ) and (a b , β b ), calculate the sum of the absolute values of the log-likelihood ratios P k , the formula is as follows: Among them, s i ∈S, α, β>0, are the two shape parameters of Beta distribution, α represents the shape of the distribution, which determines the trend of the probability density function; β represents the range of the distribution, which determines the width of the probability density function; Function f(s i |α, β) is the probability density function, and the formula is as follows: Function B(α, β) is the Beta function, which is used for normalization to ensure that the total probability is 1. The formula is as follows: Among them, the function Γ represents the Gamma function, ds i For i The integral representation of ; S2.
4. For all data k within Δ≤k≤N-Δ, calculate P after the conditions for triggering drift detection calculation are met. k , take P k The maximum value P f , set the threshold T h = -log(λ), if P f >T h , it is determined that drift occurs, otherwise no drift occurs.
6. The online drift detection and adaptive sustainable network traffic classification method according to claim 1, characterized in that: In step S3, the selection of old data samples includes: applying intra-clustering and intra-cluster sampling; According to the clustering rules, the data is clustered within the application to capture the inherent communication mode of the application and cluster all the data of each application into multiple clusters; Perform intra-cluster sampling on each cluster, and select the sample that best represents the overall data distribution from each identified communication pattern cluster; merge the samples selected from different clusters for each application and store them as the reserved data of the application, and discard the rest of the data to reduce redundant storage; The clustering rule is: clustering network flow data with the same {destination IP, destination port, protocol} tuple into one cluster.
7. The online drift detection and adaptive sustainable network traffic classification method according to claim 6 is characterized in that: The method of selecting samples in the cluster is as follows: calculate the average feature vector, determine the number of samples K to be selected, and for all integers i from 1 to K, select the sample B closest to the current average feature vector. j : Among them, argmin represents the variable value when the objective function takes the minimum value, z is the current cluster, M′ represents the old model that has not been updated yet, D′ represents the entire old data set, ξ is the index mapping function, and η is the average feature vector; the representative sample finally selected in cluster z is: B z = {B1, B2, ..., B k }.
8. The online drift detection and adaptive sustainable network traffic classification method according to claim 1, characterized in that: In step S4, an improved old knowledge distillation and bias correction method is used to perform continuous learning after data drift, and the method includes the following sub-steps: S4.
1. Fine-tune the model and set the neural network model input layer and hidden layer parameters θ c Freeze, softmax layer parameters θ f Do not freeze and initialize the new model, use the bias layer to correct the classification probability score applied to the old data, and calculate the distillation loss Loss based on the classification probability d , according to Loss d Update the parameter θ f ; S4.
2. After fine-tuning, unfreeze the parameter θ c , train a new model and use cross entropy loss as the classification loss Loss c , the total loss combines the distillation loss and the classification loss, and the model parameters θ are updated according to the total loss c and θ f , the total loss formula is as follows, Among them, C′ is the number of old data applications, and C is the total number of new and old data applications: Update model parameters θ c and θ f : S4.
3. By optimizing the loss function training, a new classification model that can identify new data categories and reduce catastrophic forgetting is obtained; the adjusted new model is used to replace the old model for traffic identification, and step S2 is repeated to continuously perform automatic model detection and updating to achieve automatic model detection and updating after network traffic data drifts.
9. An electronic device, characterized in that: include: one or more processors; a storage device having one or more programs stored thereon; When the one or more programs are executed by the one or more processors, the one or more processors implement the online drift detection and adaptive sustainable network traffic classification method as described in any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that: A computer program is stored thereon, and when the program is executed by a processor, the steps in the online drift detection and adaptive sustainable network traffic classification method described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
Data stream anomaly detection system based on empirical features and convolution neural network
CN109284606A
Network flow concept drift solution based on batch updating
CN115604142A
Method and device for updating deep learning model in network security anomaly detection
CN116032557A
IoT botnet detection system and method capable of resisting concept drift
CN116800524A
Unknown network attack behavior drift detection method based on ensemble learning
CN116886337A
Cited By
Network abnormal flow detection method and system based on federated learning and drift detection
CN119995977A
Training method and device of border gateway protocol anomaly detection model and computer equipment
CN120768823A
