An application identification method for encrypted traffic of mobile terminals
By collecting and cleaning network traffic on the Android platform, combined with the deep learning model of CNN, LSTM and attention mechanism layer, the problem of poor identification of encrypted traffic on mobile terminals is solved, and efficient identification of domestic applications is achieved, especially on Taobao. The recognition accuracy of applications such as Toutiao and Toutiao has been significantly improved.
Patent Information
- Application Number
- CN202211369734.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-03
- Publication Date
- 2024-09-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing network traffic identification technology is not effective when facing encrypted traffic from mobile terminals. Port-based identification is invalid, load-based identification is not applicable due to data encryption, machine learning-based identification is costly, and the identification effect of deep learning is yet to be achieved. improve.
The PCAPdroid tool based on the Android platform is used to collect network traffic, and a feature matrix is generated through cleaning and data labeling. It combines a deep learning model with two layers of CNN, LSTM and attention mechanism layers for application identification, and uses a batch normalization layer and a dropout layer to prevent overfitting. , improve model training speed and recognition accuracy.
The encrypted traffic recognition effect for commonly used domestic applications is better than that of a simple deep learning model, and the recognition accuracy and model training speed are improved. In particular, the recognition accuracy of applications such as Taobao and Toutiao is significantly improved.
Smart Images

Figure CN115766522B
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of network traffic identification, and in particular relates to an application identification method for encrypted traffic of a mobile terminal. Background Art
[0002] Network traffic classification is an important part of the network monitoring system. Its function is to identify the upper-layer services, applications, and user actions of network traffic. The results of network traffic classification are of great significance to network monitoring, network security services, and personal information protection. In order to effectively identify traffic, different classification technologies based on ports, loads, machine learning, and deep learning have emerged. They all identify and classify traffic based on traffic characteristics. However, these technologies are not all applicable at present. The application of technologies such as port forwarding makes port-based identification no longer effective; data encryption technology makes load-based identification technology no longer applicable; the variability of traffic characteristics also makes machine learning-based identification require huge manpower costs; deep learning technology is more widely used, but the identification effect needs to be improved. Summary of the invention
[0003] The purpose of the present invention is to provide an application identification method for encrypted traffic of a mobile terminal.
[0004] A method for identifying an application of encrypted traffic on a mobile terminal comprises the following steps:
[0005] 1) Use the PCAPdroid tool on the Android platform to collect the network traffic pcap files generated by the applications to be identified. During the collection process, only one application's traffic is captured at a time to ensure that the traffic and the application can correspond one to one;
[0006] 2) Clean the collected network traffic pcap files to remove background traffic, non-encrypted traffic, abnormal traffic and zero-load traffic;
[0007] 3) Mark the data according to the application information csv file generated by PCAPdroid, and store the traffic of different applications in different directories;
[0008] 4) Select the source port, destination port, packet payload length, TCP window size, packet direction, and time interval between packets as the data features for classification and generate a csv file;
[0009] 5) Extract characteristic information from the network traffic obtained after cleaning, and intercept and fill the traffic of different lengths. The data packet characteristic data obtained after processing is in the form of a two-dimensional matrix, which contains data packet information and time series information between different data packets;
[0010] 6) Training application recognition model based on attention mechanism;
[0011] The application recognition model based on the attention mechanism includes two layers of CNN, one LSTM layer, an attention mechanism layer, a batch normalization layer and a dropout layer; the input of the CNN layer is a feature matrix, and the output is a multi-dimensional matrix containing data space features. In order to hand over the matrix to the LSTM for processing, the multi-dimensional matrix needs to be transformed and expanded in dimensions other than the time dimension, so as to obtain a two-dimensional feature matrix based on the time series;
[0012] The input of the LSTM layer is a two-dimensional feature matrix based on the time series, and the LSTM layer extracts a one-dimensional matrix of the features of the time series;
[0013] The input of the attention mechanism layer is the one-dimensional matrix extracted by the LSTM layer. The attention layer identifies the data nodes that have a greater impact on the classification results, and realizes the allocation of classification weights for different traffic information.
[0014] The batch normalization layer is used to normalize the input features. The processed information contains data information and has a unified data specification, which makes the model converge faster and improves the speed of model training.
[0015] The dropout layer is used to prevent overfitting. During training, the output of some neurons is randomly discarded, which is equivalent to suspending the neurons in the model with a certain probability. By randomly discarding, the model is prevented from being too dependent on some local features of the data and causing overfitting.
[0016] 7) Use the trained model to identify application traffic.
[0017] The beneficial effects of the present invention are:
[0018] The present invention relates to a network traffic identification scenario, and proposes an application identification method for mobile terminal encrypted traffic based on deep learning and attention mechanism for the most widely used mobile terminal applications and encrypted network traffic. At present, based on the deep learning model, different numbers of CNNs and LSTMs are used to identify traffic in parallel or serially, and the identification object is a foreign application data set for encrypted traffic, which is not suitable for domestic application environments and the identification effect needs to be improved. The data set used in the present invention is collected and accurately marked for commonly used domestic applications, and the attention mechanism is used for application identification based on CNN and LSTM, which can effectively identify domestic applications, and the identification effect is better than that of a simple deep learning model. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] Figure 1This is an application recognition model diagram based on CNN and LSTM.
[0020] Figure 2 It is the deep learning model structure and parameter diagram of the attention mechanism.
[0021] Figure 3 This is a diagram of the recognition effect of the deep learning model.
[0022] Figure 4 This is the performance indicator chart of the CNN_2_LSTM_2 model.
[0023] Figure 5 This is the confusion matrix diagram of the CNN_2_LSTM_2 model.
[0024] Figure 6 This is a performance comparison chart of CNN_2_LSTM_2 and AttNet.
[0025] Figure 7 It is the performance indicator diagram of AttNet model.
[0026] Figure 8 This is the confusion matrix diagram of the AttNet model. DETAILED DESCRIPTION
[0027] The present invention is further described below in conjunction with the accompanying drawings.
[0028] The present invention collects encrypted traffic data sets for commonly used domestic applications, and proposes an encrypted application recognition model based on deep learning and attention mechanism. At present, based on deep learning models, different numbers of CNNs and LSTMs are used to identify traffic in parallel or serially, and the identification object is a foreign application data set for encrypted traffic, which is not suitable for domestic application environments and the recognition effect needs to be improved. The data set used in the present invention is collected and accurately marked for commonly used domestic applications, and the attention mechanism is used for application recognition based on CNN and LSTM, which can effectively identify domestic applications, and the recognition effect is better than that of a simple deep learning model.
[0029] 1) Encrypted traffic collection: Use the PCAPdroid tool on the Android platform to collect the network traffic (pcap files) generated by the applications to be identified. During the collection process, only the traffic of one application is captured at a time to ensure that the traffic and the application can correspond one to one.
[0030] 2) Traffic cleaning: Use Python's Scapy and dpdk network library to develop a traffic cleaning program, which cleans the collected traffic (pcap file) to remove traffic that is not relevant to the classification (background traffic, non-encrypted traffic, abnormal traffic, and zero-load traffic).
[0031] 3) Data marking: Data is marked according to the application information csv file generated by PCAPdroid, and the traffic of different applications is stored in different directories.
[0032] 4) Traffic analysis: Analyze the traffic data, analyze the traffic characteristics and model input information, select six features of the data packet source port, destination port, data packet payload length, TCP window size, data packet direction and time interval between data packets as data features for classification, and generate a csv file.
[0033] 5) Traffic feature extraction: extract the feature information required by the model from the original traffic, and intercept and fill the flows of different lengths. After processing, the final data packet feature data obtained is in the form of a two-dimensional matrix, which contains the data packet information and the time series information between different data packets.
[0034] 6) Application identification model construction, the application identification model based on the attention mechanism proposed in the present invention is constructed for application identification. This model uses two layers of CNN, one layer of LSTM and one layer of Attention. The input of the CNN layer is a feature matrix, and the data only needs to be fed into the model. Its output is a multi-dimensional matrix containing the spatial features of the data. In order to hand over the matrix to the LSTM for processing, the matrix needs to be transformed and expanded in dimensions other than the time dimension to obtain a two-dimensional feature matrix based on the time series. The matrix can be used as the input of the LSTM layer to extract a one-dimensional matrix of the features of the time series. The data is used as the input of the attention layer, and the data nodes that have a greater impact on the classification results are identified through the attention layer, so that the classification weights of different traffic information can be allocated. In addition to the above-mentioned neural network layers, the final application identification model also uses some additional neural network layers: batch normalization layer and dropout layer. The role of the batch normalization layer is to normalize the input features. The processed information has a unified data specification while containing data information, which can make the model converge faster, thereby greatly improving the speed of model training. The dropout layer is a common method used to prevent overfitting in neural network training. The idea of this method is to randomly discard the output of some neurons during training, which is equivalent to suspending the neurons in the model with a certain probability. Random discarding can prevent the model from being too dependent on certain local features of the data and causing overfitting. In addition, a model based solely on the CNN and LSTM layers in deep learning is built to compare application recognition performance.
[0035] 7) Local model training.
[0036] 8) Repeat step 7 until the model converges.
[0037] 9) Use the trained model to identify 20 types of application traffic.
[0038] Application recognition model design based on deep learning Figure 1 As shown in the figure, Conv(x,y,z,m) represents a convolutional layer with x convolution kernels, where y and z represent the height and width of the convolution kernel calculation window, respectively, with a step size of m and full zero padding; BN represents a batch normalization layer; LSTM(x) represents a long short-term memory network layer, where x represents the dimension of the output space; DR(x) represents a dropout layer, and the dropout coefficient is equal to x. In the training process of all models, the training rounds are 100 times. Except for the last layer using softmax activation, all activation functions use rectified linear units (ReLU). The loss function is Softmax Cross Entropy, and the optimizer is Adam's batch stochastic gradient descent (SGD). For Model 1 and Model 2, they both first perform feature extraction based on a layer of CNN, and then use LSTM for time series feature recognition. The difference is that Model 2 uses one more LSTM layer to extract sequence features than Model 1; Model 3 uses one more layer of CNN for feature extraction than Model 1; Model 4 uses one more layer of CNN and one more layer of LSTM for feature extraction than Model 1.
[0039] Application recognition models based on attention mechanism Figure 2 As shown, this model is Figure 1 The difference between the CNN_2_LSTM_2 model in the above example is that the 7th LSTM layer is changed to an attention layer. In order to determine the feasibility of the model based on the attention mechanism, we first use a simple deep learning model to perform application recognition on the collected data set. The application recognition results of different models are shown in Figure 2. Figure 3 As shown in the figure, it can be seen that the application recognition models based on deep learning can reach or even exceed 90% recognition accuracy. Among them, the recognition accuracy of the CNN_1+LSTM_2 model reaches 92.6%, which is the best performing model.
[0040] In order to conduct a detailed analysis of the application performance of the model, the CNN_2+LSTM_2 model with the best recognition effect is selected for detailed analysis. The recognition accuracy, recall rate and F1 value of different applications in this model are as follows: Figure 4 As shown, the confusion matrix is Figure 5 As shown in the figure, it can be seen that Zhihu has the highest recognition accuracy, reaching 97.9%, and most of the incorrect classifications are confused with Taobao and Kuaishou applications; Douyin has the second highest recognition accuracy, reaching 97.1%, and this application has the highest degree of confusion with Toutiao. Taobao has the worst classification, with an accuracy of 81.5%, because many other applications are mistakenly classified as Taobao.
[0041] The comparison between the model with attention mechanism and the CNN_1+LSTM_2 model is as follows: Figure 6 As shown in Figure 2, it can be seen that the model with attention mechanism can improve the recognition accuracy by about 3%. The performance and confusion matrix of the model based on attention mechanism in different applications are shown in Figure 2. Figure 7 and Figure 8 As shown in the figure, Taobao has the largest improvement in recognition accuracy, with a 10.4% increase in recognition accuracy. From the confusion matrix, we can see that the number of apps that are misclassified as Taobao apps has been greatly reduced. For example, the confusion between Ctrip, Fliggy and Toutiao and Taobao apps has been greatly improved. Secondly, the recognition accuracy of Dianping, Toutiao and Tencent News has increased by more than 6%, and the other 10 apps, a total of 14 apps, have improved in accuracy. However, the accuracy of NetEase News has only increased by 0.1%, with almost no change. The other five apps, Zhihu, Vipshop, Ele.me, Ctrip and JD.com, have a certain degree of decline in recognition accuracy, among which Zhihu's recognition accuracy has decreased by 2.5%, and the decline of the other four apps is within 1%.
[0042] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
Claims
1. A method for identifying application of encrypted traffic of mobile terminals, characterized in that: The following steps are involved: 1) Use the PCAPdroid tool on the Android platform to collect the network traffic pcap files generated by the applications to be identified. During the collection process, only one application's traffic is captured at a time to ensure that the traffic and the application can correspond one to one; 2) Clean the collected network traffic pcap files to remove background traffic, non-encrypted traffic, abnormal traffic and zero-load traffic; 3) Mark the data according to the application information csv file generated by PCAPdroid, and store the traffic of different applications in different directories; 4) Select the source port, destination port, packet payload length, TCP window size, packet direction, and time interval between packets as the data features for classification and generate a csv file; 5) Extract characteristic information from the network traffic obtained after cleaning, and intercept and fill the traffic of different lengths. The data packet characteristic data obtained after processing is in the form of a two-dimensional matrix, which contains data packet information and time series information between different data packets; 6) Training application recognition model based on attention mechanism; The application recognition model based on the attention mechanism includes two layers of CNN, one LSTM layer, an attention mechanism layer, a batch normalization layer and a dropout layer; the input of the CNN layer is a feature matrix, and the output is a multi-dimensional matrix containing data space features. In order to hand over the matrix to the LSTM for processing, the multi-dimensional matrix needs to be transformed and expanded in dimensions other than the time dimension, so as to obtain a two-dimensional feature matrix based on the time series; The input of the LSTM layer is a two-dimensional feature matrix based on the time series, and the LSTM layer extracts a one-dimensional matrix of the features of the time series; The input of the attention mechanism layer is the one-dimensional matrix extracted by the LSTM layer. The attention layer identifies the data nodes that have a greater impact on the classification results, and realizes the allocation of classification weights for different traffic information. The batch normalization layer is used to normalize the input features. The processed information contains data information and has a unified data specification, which makes the model converge faster and improves the speed of model training. The dropout layer is used to prevent overfitting. During training, the output of some neurons is randomly discarded, which is equivalent to suspending the neurons in the model with a certain probability. By randomly discarding, the model is prevented from being too dependent on some local features of the data and causing overfitting. 7) Use the trained model to identify application traffic.
