A method and device for identifying network traffic content type based on deep learning

Through the end-to-end identification method of deep learning and lightweight convolutional neural network, it solves the problems of low identification efficiency and high resource overhead in network traffic content identification technology, and achieves efficient identification and unified management of multiple traffic forms.

CN118433121BActive Publication Date: 2024-10-29NANJING UNIV OF INFORMATION SCI & TECH
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410897429.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-10-29
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

Existing network traffic content identification technology lacks a unified identification framework and is difficult to adapt to the identification of different types of traffic and dynamic changes in traffic patterns. Moreover, image-based identification methods cannot meet the needs of real-time analysis of massive network traffic, resulting in low identification efficiency and resource consumption. The cost is high.

Method used

Adopt an end-to-end identification method based on deep learning, extract key content features in network traffic through a deep neural network, and design a lightweight integer-precision one-dimensional convolutional neural network for identification, realizing the integration of plaintext, encrypted and encoded traffic. identification, and improve identification efficiency through batch processing.

Benefits of technology

It achieves unified identification of multiple forms of traffic, significantly reduces resource overhead and identification time, and improves the efficiency of network traffic analysis and the overall intelligence level of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118433121B_ABST
    Figure CN118433121B_ABST
Patent Text Reader

Abstract

The present invention provides a method and device for identifying network traffic content types based on deep learning, the method comprising: preprocessing the collected network data, extracting the uplink data packet load of each session, grouping them into data blocks according to fixed length, and sending them into a deep learning model in batches; the deep learning model extracts the features of the data blocks through a convolutional neural network, and maps them to different content types through a fully connected layer; according to the output results of the model, the content type label and confidence of each session are obtained, and output to a subsequent processing module. The present invention aggregates the network data packets and groups the load, and uses an end-to-end deep learning model to identify the content type. Compared with traditional rule-based or feature engineering methods, the present invention has the advantages of high recognition accuracy, good real-time performance, and strong scalability. The present invention can be effectively applied to network security monitoring, traffic control, protocol analysis and other fields.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of network communication technology and artificial intelligence technology, and specifically relates to a method and device for identifying network traffic content type based on deep learning. Background Art

[0002] Network traffic carries all kinds of application data, and the content types are complex and varied, including text, images, audio and video, executable programs, etc. Traditional traffic analysis methods based on rules or feature engineering are difficult to adapt to the diversity and continuous evolution of content, and there is an urgent need to introduce new methods of intelligent recognition and adaptive learning. Network traffic content recognition has a wide range of application needs in many fields such as network management, security protection, and traffic optimization. Different scenarios have different emphases on performance indicators such as recognition accuracy, real-time, and interpretability. It is necessary to build a flexible and configurable recognition framework to adapt to diverse application needs.

[0003] The prior art has attempted to use deep learning methods to classify traffic. For example, the invention "A network traffic classification method and system based on multi-scale feature attention (CN112839024B)" discloses a method for preprocessing traffic in the form of one-hot encoding, and implementing the classification of application protocols SMTP, SSH, BitTorrent, CIFS / SMB, HTTP, RDP, TLS, and Backg-TCP through the residual of the convolutional network. The invention "Deep learning traffic classification method based on the combination of spatiotemporal characteristics (CN110730140B)" discloses a method for converting traffic into a 30×30 image and then using a combined network of CNN+LSTM to classify encrypted, unencrypted, and malicious access traffic. The invention "A traffic classification method, device, equipment, and medium (CN113452810B)" discloses a method for converting data packets into n×m one-hot encoding images and implementing classification of undefined types through LSTM. The invention "A network traffic classification system and method based on deep discriminant features (CN110796196B)" discloses a method of converting traffic into 32×512 images and further scaling them to 128×128 and classifying them through CNN. These methods do not consider the following two problems:

[0004] (1) Existing network traffic content identification technologies usually design specialized processing methods for specific types of traffic (such as plain text, encrypted or encoded traffic) and lack a unified identification framework. This results in the need to process different types of traffic separately in actual network environments, making the identification links lengthy and the deployment complex. It is impossible to form an overall content-aware capability and it is difficult to adapt to the dynamic changes in traffic patterns.

[0005] (2) In the field of traffic content recognition, the mainstream method is to convert raw traffic data into image representations, such as using session matrices, star maps, etc., and then analyze them with the help of image recognition models. Although this image-based recognition paradigm can utilize mature image processing algorithms, it is difficult to meet the stringent requirements of real-time analysis of massive network traffic in terms of efficiency. The hardware resources of network devices themselves are very limited and it is difficult to afford the high computing costs of image processing models. Summary of the invention

[0006] Purpose of the invention: The technical problem to be solved by the present invention is to provide a method and device for identifying network traffic content types based on deep learning in view of the deficiencies of the prior art. This is to solve the problem of low efficiency in analyzing and processing massive traffic data in an increasingly complex network environment. This method can adaptively extract key content features in the traffic through an end-to-end recognition model, realize integrated recognition of various forms of traffic such as plain text, encryption and encoding, and significantly improve recognition efficiency and reduce resource overhead by designing a lightweight recognition network.

[0007] Technical solution: The method for identifying network traffic content type based on deep learning described in the present invention comprises the following steps:

[0008] Step 1: pre-process the collected network data, including: extracting the Xth packet of the uplink data packet for each TCP (Transmission Control Protocol) session 1 Continuous load after packets (X 1 Generally, the value is 5. TCP transmission needs to establish and confirm the connection. Extracting the data after the fifth packet can ensure that the connection establishment phase has been passed and the data transmission phase has begun. Collect 1024 bytes as a payload data block. For streams less than 1024 bytes, repeat characters to pad them to 1024 bytes. Push M payload data blocks into the stack as a batch. At the same time, create a structure containing M five-tuples corresponding to the batch, undetermined content type, and confidence probability.

[0009] Step 2: Input the batch into a deep neural network inference module for forward calculation. The deep neural network inference module is used to receive M 1024-byte inputs and output the corresponding M stream content types;

[0010] Step 3: Fill the content types of the M flows into the corresponding structure, use the maximum probability of the softmax output as the content type, use the maximum probability as the confidence, output the content type, confidence and five-tuple, group the same type of traffic together according to the type label, and clear the flow table.

[0011] Step 1 includes:

[0012] Step 1-1, capture network packets, extract TCP payload data, and construct the following tuple:

[0013] (timestamp, src_ip, src_port, dst_ip, dst_port, packet_length, payload),

[0014] Where timestamp is the capture timestamp, src_ip and dst_ip are the source IP address and destination IP address respectively, src_port and dst_port are the source port number and destination port number respectively, packet_length is the payload length, and payload is the payload content;

[0015] Step 1-2, based on the five-tuple (src_ip, src_port, dst_ip, dst_port, protocol), the network data packets are subjected to session aggregation and TCP reassembly, protocol is the transport layer protocol type, and the network data packets of the same five-tuple are divided into the same session;

[0016] Step 1-3, for each session, extract the continuous load data after the fifth packet of the uplink data packet to construct a load data block; the uplink data packet refers to the data from the source address src to the destination address dst;

[0017] Step 1-4, set the fixed length of the payload data block group to 1024 bytes. If the payload data block length L is less than 1024 bytes, extend it in the following way:

[0018] Calculate the number of repetitions T = ⌈1024 / L⌉, where ⌈·⌉ is the rounding symbol; repeat the original L-byte payload data block T times, and take the first 1024 bytes as the expanded payload data block;

[0019] Step 1-5, construct the struct Session structure based on the five-tuple information of the current session:

[0020] struct Session{

[0021] int64 timestamp;

[0022] char

[16] src_ip;

[0023] int src_port;

[0024] char

[16] dst_ip;

[0025] int dst_port;

[0026] int block_num;

[0027] char content_type;

[0028] float conf_prob;

[0029] },

[0030] Among them, int64 timestamp indicates that the data type of the session start timestamp is int64, char

[16] src_ip indicates that the data type of the source IP address is char

[16] , int src_port indicates that the data type of the source port number is int, char

[16] dst_ip indicates that the data type of the destination IP address is char

[16] , int dst_port indicates that the data type of the destination port number is int, int block_num indicates that the data type of the accumulated data blocks block_num is int; char content_type indicates that the data type of the content type content_type is char, and the content type is initially empty; float conf_prob indicates that the data type of the confidence probability conf_prob is float, and the confidence probability is initially 0;

[0031] Step 1-6, fill the payload data blocks obtained from step 1-4 into a buffer of size M × 1024 bytes as a batch, and fill the corresponding structure pointers into a batch structure pointer array of size M;

[0032] Step 1-7, if the buffer and pointer array are not full, return to step 1-2; if the buffer and pointer array are full, go to step 2.

[0033] In step 2, the deep neural network reasoning module includes an integer precision one-dimensional convolutional neural network for content type recognition, and the hierarchical structure of the convolutional neural network includes:

[0034] The input layer L1 receives an unsigned byte integer vector of size 1024, representing the original byte sequence of a data block;

[0035] The first convolutional layer L2 contains three groups of one-dimensional convolution kernels, with convolution kernel sizes of 1, 3, and 5 respectively. The number of convolution kernels in each group is 128, and the step size of all convolution kernels is 1. It outputs three groups of integer feature vectors with a size of 1024×128;

[0036] The first BN (Batch Normalization) layer L3 performs batch normalization on the output feature vectors of the first convolutional layer L2 and uses the ReLU function for activation;

[0037] The second convolutional layer L4 contains three groups of one-dimensional convolution kernels, with convolution kernel sizes of 1, 3, and 5 respectively. The number of convolution kernels in each group is 256, and the step size of all convolution kernels is 1. It outputs three groups of integer feature vectors with a size of 1024×256.

[0038] The second BN layer L5 performs batch normalization on the output feature vectors of the second convolutional layer L4 and uses the ReLU function for activation;

[0039] The third convolutional layer L6 contains three groups of one-dimensional convolution kernels with sizes of 1, 3, and 5 respectively. The number of convolution kernels in each group is 512, which is a hyperparameter. The step size of all convolution kernels is 1, and it outputs three groups of integer feature vectors with a size of 1024×512.

[0040] The third BN layer L7 performs batch normalization on the output feature vectors of the third convolutional layer L6 and uses the ReLU function for activation;

[0041] The global average pooling layer L8 performs global average pooling on the three groups of feature vectors output by the third BN layer L7 to obtain a 3×512-dimensional integer feature vector;

[0042] The fully connected layer L9 passes the output of the global average pooling layer L8 through a fully connected layer to map the 3×512-dimensional feature vector to a 12-dimensional category output vector. The weights and biases of the fully connected layer are all integers, and the category is defined as:

[0043] 0: Plain text,

[0044] 1: ciphertext,

[0045] 2: Encode Base16,

[0046] 3: Encode Base32,

[0047] 4: Encoding Based45,

[0048] 5: Encode Base64,

[0049] 6: Encode Base85,

[0050] 7: Encoding Base91,

[0051] 8: Encoding Base100,

[0052] 9: Encoding Base122,

[0053] 10: Encoding Ascii85,

[0054] 11: Unknown;

[0055] Softmax layer L10 performs Softmax normalization on the output vector of the fully connected layer L9 to obtain a 12-dimensional probability distribution vector, in which each element corresponds to the posterior probability of a content type.

[0056] Step 2 also includes: training the convolutional neural network using the following steps:

[0057] Step 2-1, construct a training data set;

[0058] Step 2-2, conduct training process;

[0059] Step 2-3, integer training;

[0060] Steps 2-4, model testing and deployment.

[0061] Step 2-1 includes:

[0062] Step 2-1-1, data collection: collect original network traffic data including plaintext traffic and encrypted traffic from various network environments, covering common application scenarios and protocol types; the plaintext data includes HTTP (Hypertext Transfer Protocol), QUIC (Quick UDP Internet Connections), SMTP (Simple Mail Transfer Protocol), FTP (File Transfer Protocol), TELNET (Telecommunication Network) that can be identified by DPI (Deep Packet Inspection), and the plaintext type of the payload content is directly marked while collecting; the encrypted data includes TLS (Transport Layer Security) and SSH (Secure Shell) that can be identified by DPI, and the encryption type of the payload content is directly marked while collecting;

[0063] Step 2-1-2, generate data: for the collected plaintext data, use encoding Base16, encoding Base32, encoding based45, encoding base64, encoding base85, encoding base91, encoding base100, encoding base122, encoding Ascii85 to generate corresponding encoding data samples, and directly annotate the corresponding encoding type at the same time to form data and label pairs;

[0064] Step 2-1-3, divide the data set, randomly divide the data and label pairs into mutually exclusive training set, validation set and test set.

[0065] Step 2-2 includes:

[0066] Step 2-2-1, design loss function: use cross entropy loss function to measure the difference between the content type distribution output by the convolutional neural network and the true label;

[0067] Step 2-2-2, parameter initialization, the weight matrices of the first convolutional layer L2, the second convolutional layer L4, the third convolutional layer L6 and the fully connected layer L9 are initialized using truncated normal distribution, and the bias vector is initialized to the zero vector;

[0068] Step 2-2-3, set hyperparameters: preset network structure parameters, batch size, and learning rate, without additional tuning; the network structure parameters include convolution kernel size and number.

[0069] Step 2-2-4, the training process includes:

[0070] Forward propagation: forward propagation is performed on each batch of data in the training set to calculate the predicted output;

[0071] Calculate loss: Use the designed cross entropy loss function to calculate the error between the predicted output and the true label;

[0072] Back propagation: The back propagation algorithm is used to calculate the gradient of the loss function relative to the weights and biases of each layer.

[0073] Update weights: Use an optimization algorithm (such as Adam) to update the network weights and biases based on the calculated gradients;

[0074] Save weights: At the end of each epoch, save the model weights obtained from the current training.

[0075] Steps 2-3 include:

[0076] Step 2-3-1, quantize the training set, labels, and model weights into 8-bit signed integers, use integer operations in forward propagation and back propagation, complete the quantization process of the model, and convert it into a quantized integer model;

[0077] Step 2-3-2, set the scaling factor for range mapping between integers and floating-point numbers to prevent quantization error accumulation; ensure accurate numerical conversion between integers and floating-point numbers in the quantized integer model.

[0078] Step 2-3-3, use the Adam optimization algorithm to convert the integer gradient into a floating point number by dividing it by the scaling factor and update the weight;

[0079] Step 2-3-4, training termination, when the performance of the validation set does not improve for consecutive epochs (epoch refers to the number of times all training samples are completely "viewed" during the training process. The completion of an epoch means that all training data has been used to update the model once. The number of epochs is set according to the training experiment when the performance no longer improves, which is a hyperparameter), stop training; ensure that the quantized integer model achieves the best performance; the trained convolutional neural network will output an M×12 output matrix for the input data (the M×12 output matrix corresponds to 12 different content types);

[0080] Steps 2-4 include:

[0081] Step 2-4-1, evaluate the content recognition accuracy and speed of the trained convolutional neural network on the test set;

[0082] Step 2-4-2, convert the trained quantized integer model into a format suitable for the deployment environment (if you want to deploy it on a mobile device, you can use TensorFlow Lite Converter to convert the model to .tflite format; if you want to deploy it on OpenVINO, you can use OpenVINO's Model Optimizer to convert the model to a format supported by OpenVINO), and provide a unified calling interface according to the M batch mode.

[0083] Step 3 includes:

[0084] Step 3-1, perform softmax operation on the M×12 output matrix row by row to obtain the normalized probability distribution;

[0085] Step 3-2, for each row of the M×12 output matrix, take the type index corresponding to the maximum probability value as the predicted type. The correspondence between the index and the type name is: {0: plaintext, 1: ciphertext, 2: encoded Base16, 3: encoded Base32, 4: encoded based45, 5: encoded base64, 6: encoded base85, 7: encoded base91, 8: encoded base100, 9: encoded base122, 10: encoded Ascii85, 11: unknown};

[0086] Step 3-3, fill the predicted type into the content type content_type field of the structure generated in step 1, fill the maximum probability value into the confidence probability conf_prob field, and output an M-tuple, each element of which is (five-tuple, content_type, conf_prob);

[0087] Step 3-4, traverse the M tuples and output the corresponding payload data blocks to the modules for the next step of processing (these modules are modules that further process different types of data blocks according to specific needs after traffic classification, which are not the main content of this article. They can include specific operations such as plaintext extraction, encoding and decoding, and encrypted traffic analysis), completing the processing of a batch;

[0088] Step 3-5: After the current batch is processed, clear the corresponding byte and five-tuple cache in the table or data structure that stores the flow information and wait for the next batch of data.

[0089] The method of the present invention further comprises step 4: determining the batch processing parameter M by executing the following steps in a deployment environment (referring to a hardware and software environment for actually running and executing the classification algorithm):

[0090] Step 4-1, count the number of new concurrent connections P per second in the training set, where P is equal to the number of SYN (Synchronize Sequence Numbers) packets of new TCP connections per second;

[0091] Step 4-2, randomly sample S sessions from a data set (an existing data set or a data set obtained through a packet capture tool), and calculate the average inter-arrival time t of uplink data packets of each session;

[0092] Step 4-3, sample the 1024-byte payload corresponding to S sessions, send it to the trained and deployed convolutional neural network obtained in step 2-4 for inference, and calculate the average inference time R;

[0093] Step 4-4, the calculation formula of M is:

[0094] M=⌈1.5×R×P / t⌉.

[0095] The present invention also provides a network traffic content type identification device based on deep learning, comprising:

[0096] The preprocessing module is used to preprocess the collected network data, including: for each TCP (Transmission Control Protocol, Transmission Control Protocol) session, extract the Xth 1 Continuous load after packets (X1 Generally, the value is 5. TCP transmission needs to establish and confirm the connection. Extracting the data after the fifth packet can ensure that the connection establishment phase has been passed and the data transmission phase has begun. Collect 1024 bytes as a payload data block. For streams less than 1024 bytes, repeat characters to pad them to 1024 bytes. Push M payload data blocks into the stack as a batch. At the same time, create a structure containing M five-tuples corresponding to the batch, undetermined content type, and confidence probability.

[0097] A neural network inference module is used to input the batches into a deep neural network inference module for forward calculation. The deep neural network inference module is used to receive M 1024-byte inputs and output the corresponding M stream content types;

[0098] The post-processing module is used to fill the content types of the M flows into the corresponding structure, use the maximum probability of the softmax output as the content type, use the maximum probability as the confidence, output the content type, confidence and quintuple, group the same type of traffic together according to the type label, and clear the flow table.

[0099] The present invention also provides a traffic content type identification device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the network traffic content type identification method when executed by the processor.

[0100] The present invention also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of the network traffic content type identification and model training method are implemented.

[0101] The present invention aims to solve the problems of the prior art, focuses on the intelligent identification of network traffic content, provides a new set of technical means for traffic analysis and application for the increasingly complex network environment, and proposes an end-to-end network traffic content intelligent identification method. Main technical features:

[0102] (1) The present invention innovatively proposes a set of end-to-end recognition methods based on deep learning, adopts a unified data representation and model structure, and realizes the integrated recognition of plaintext, encrypted and encoded traffic. It can not only greatly reduce the complexity of recognition deployment and maintenance, but also provide a unified traffic scheduling center for subsequent management and analysis, which is conducive to improving the overall intelligence level of the network system.

[0103] (2) This paper takes a different approach by directly representing traffic as a raw byte sequence and designs a customized lightweight integer-precision convolutional neural network for end-to-end recognition. Through clever data representation and model design, the fine-grained content features of traffic are fully utilized while minimizing the overhead of data preprocessing, achieving low latency and high efficiency in the recognition process.

[0104] Beneficial effects: Compared with the prior art, the present invention has the following advantages:

[0105] 1. The present invention adopts an end-to-end training method, which can simultaneously process plaintext, ciphertext and load data in various encoding formats, and covers most common application scenarios by constructing a rich training data set offline. The network model can adaptively learn key features in different data forms and has good generalization performance.

[0106] 2. The present invention designs a lightweight integer precision one-dimensional convolutional neural network, uses integer representation for network weights, and uses integer operations entirely in the forward reasoning process, which significantly reduces the computing resource overhead. In order to further improve throughput, the present invention adopts a batch processing method, adaptively determines the optimal batch size based on statistical information, and maximizes parallel computing efficiency while ensuring real-time performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0107] Figure 1 The present invention is a flowchart of the steps of the method.

[0108] Figure 2 Network traffic data preprocessing process.

[0109] Figure 3 Deep neural network architecture for network traffic content type identification.

[0110] Figure 4 The deep neural network training process of the present invention.

[0111] Figure 5 Result output and post-processing process.

[0112] Figure 6 Batch inference batch parameter setting process. DETAILED DESCRIPTION

[0113] The present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments, and the above and other advantages of the present invention will become more clear.

[0114] like Figure 1As shown, the present invention discloses a method, device, equipment and medium for identifying network traffic content types based on deep learning. The method comprises: preprocessing the collected network data, extracting the uplink data packet load of each session, grouping them into data blocks according to fixed length, and sending the batches into the deep learning model; the deep learning model extracts the features of the data blocks through a convolutional neural network, and maps them to different content types through a fully connected layer; according to the output results of the model, the content type label and confidence of each session are obtained, and output to the subsequent processing module. The specific steps include:

[0115] Step 1, preprocessing the collected network data, including: for each TCP session, extracting the continuous payload after the 5th packet of the upstream data packet, collecting 1024 bytes as a payload data block, for the stream less than 1024 bytes, padding to 1024 bytes by character duplication, pushing M=7 payload data blocks into the stack as a batch, and creating a structure containing M=7 quintuples corresponding to the batch and the undetermined content type and confidence probability;

[0116] Step 2: Input the batch to the deep neural network inference module for forward calculation. The module can receive M = 7 1024-byte inputs and output the corresponding M = 7 stream content types;

[0117] Step 3: Fill the inference result into the corresponding structure, use the maximum probability of softmax output as the content type, use the maximum probability as the confidence, output the content type, confidence and five-tuple, perform subsequent processing according to the type label, and clear the flow table.

[0118] In this embodiment, if Figure 2 As shown, step 1 specifically includes:

[0119] Step 1-1, capture network packets, extract TCP payload data, and construct the following tuple

[0120] (timestamp, src_ip, src_port, dst_ip, dst_port, packet_length, payload)

[0121] Where timestamp is the capture timestamp, src_ip and dst_ip are the source and destination IP addresses respectively, src_port and dst_port are the source and destination port numbers respectively, packet_length is the payload length, and payload is the payload content.

[0122] Step 1-2, based on the five-tuple (src_ip, src_port, dst_ip, dst_port, protocol), the data packets are aggregated and TCP is reassembled. Protocol is the transport layer protocol type. Data packets with the same five-tuple are divided into the same session.

[0123] Step 1-3, for each session, extract the continuous payload data after the 5th packet of the uplink data packet (from src to dst) and construct a payload data block.

[0124] Step 1-4, set the fixed length of the data block group to 1024 bytes. If the payload data length L is less than 1024 bytes, it is extended in the following way:

[0125] Calculate the number of repetitions T = ⌈1024 / L⌉, where ⌈·⌉ is the round-up symbol; repeat the original L-byte payload T times, and take the first 1024 bytes as the expanded data block.

[0126] Step 1-5, based on the five-tuple information of the current session, construct the following structure:

[0127] struct Session{

[0128] int64 timestamp; / / session start timestamp

[0129] char

[16] src_ip; / / Source IP address

[0130] int src_port; / / Source port number

[0131] char

[16] dst_ip; / / destination IP address

[0132] int dst_port; / / destination port number

[0133] int block_num; / / The accumulated number of data blocks

[0134] char content_type; / / Content type, initially empty

[0135] float conf_prob; / / Confidence probability, initially 0

[0136] }.

[0137] Step 1-6, fill the payload data block obtained from step 1-4 into a buffer of size M×1024 bytes as a batch, and fill the corresponding structure pointer into a batch structure pointer array of size M.

[0138] Step 1-7, if the buffer and pointer array are not full, return to step 1-2; continue to collect data blocks; if the buffer and pointer array are full, go to step 2 and send to the neural network model for processing.

[0139] Through the above step 1, the network traffic data is converted into a format suitable for neural network input.

[0140] In this embodiment, if Figure 3 As shown in the figure, the deep neural network inference module contains an integer precision one-dimensional convolutional neural network for content type recognition. The hierarchical structure of the convolutional neural network is as follows:

[0141] L1: Input layer, receiving an unsigned byte integer vector of size 1024, representing the original byte sequence of a data block;

[0142] L2: The first convolutional layer, which contains three groups of one-dimensional convolution kernels with sizes of 1, 3, and 5 respectively. The number of convolution kernels in each group is 128, and the step size of all convolution kernels is 1. It outputs three groups of integer feature vectors with a size of 1024×128.

[0143] L3: The first BN layer performs batch normalization on the output feature vectors of the first convolutional layer and uses the ReLU function for activation;

[0144] L4: The second convolutional layer, which contains three groups of one-dimensional convolution kernels with sizes of 1, 3, and 5 respectively. The number of convolution kernels in each group is 256, and the step size of all convolution kernels is 1. It outputs three groups of integer feature vectors with a size of 1024×256.

[0145] L5: The second BN layer performs batch normalization on the output feature vectors of the second convolutional layer and uses the ReLU function for activation;

[0146] L6: The third convolutional layer, which contains 3 groups of one-dimensional convolution kernels with sizes of 1, 3, and 5 respectively. The number of convolution kernels in each group is 512, which is a hyperparameter. The step size of all convolution kernels is 1, and it outputs 3 groups of integer feature vectors with a size of 1024×512.

[0147] L7: The third BN layer performs batch normalization on the output feature vectors of the third convolutional layer and uses the ReLU function for activation;

[0148] L8: Global average pooling layer: perform global average pooling on the three groups of feature vectors output by the third BN layer to obtain a 3×512-dimensional integer feature vector;

[0149] L9: Fully connected layer, the output of the global average pooling layer passes through a fully connected layer, mapping the 3×512-dimensional feature vector to a 12-dimensional category output vector. The weights and biases of the fully connected layer are all integers. The categories are defined as: 0: Plaintext, 1: Ciphertext, 2: Encoded Base16, 3: Encoded Base32, 4: Encoded Based45, 5: Encoded Base64, 6: Encoded Base85, 7: Encoded Base91, 8: Encoded Base100, 9: Encoded Base122, 10: Encoded Ascii85, 11: Unknown};

[0150] L10: Softmax layer, which performs Softmax normalization on the output vector of the fully connected layer to obtain a 12-dimensional probability distribution vector, where each element corresponds to the posterior probability of a content type.

[0151] In this embodiment, if Figure 4 As shown, the integer precision one-dimensional convolutional neural network needs to be trained through the following steps:

[0152] Step 2-1, construction of training data set

[0153] Step 2-1-1, data collection: Collect a certain amount of raw network traffic data from various network environments, covering common application scenarios and protocol types. The plaintext data is mainly HTTP, QUIC, SMTP, FTP, TELNET, etc. that can be identified by DPI, and the plaintext type of the payload content is directly marked during collection; the encrypted data is mainly TLS and SSH that can be identified by DPI, and the encryption type of the payload content is directly marked during collection.

[0154] Step 2-1-2, data generation, for the collected plaintext data, use encoding Base16, encoding Base32, encoding based45, encoding base64, encoding base85, encoding base91, encoding base100, encoding base122, encoding Ascii85 to generate corresponding encoding data samples, and directly mark the corresponding encoding type while generating.

[0155] A103 dataset partitioning randomly divides data and label pairs into mutually exclusive training, validation, and test sets.

[0156] Step 2-2, training process

[0157] Step 2-2-1, design loss function: use the cross entropy loss function to measure the difference between the content type distribution output by the neural network and the true label.

[0158] Step 2-2-2, parameter initialization, the weight matrices of the convolutional layer and the fully connected layer are initialized using truncated normal distribution, and the bias vector is initialized to a zero vector.

[0159] Step 2-2-3, hyperparameter setting, preset network structure parameters (such as convolution kernel size and number), batch size, learning rate and other hyperparameters, without additional tuning;

[0160] Step 2-2-4, the training process includes:

[0161] Forward propagation: forward propagation is performed on each batch of data in the training set to calculate the predicted output;

[0162] Calculate loss: Use the designed cross entropy loss function to calculate the error between the predicted output and the true label;

[0163] Back propagation: The back propagation algorithm is used to calculate the gradient of the loss function relative to the weights and biases of each layer.

[0164] Update weights: Use an optimization algorithm (such as Adam) to update the network weights and biases based on the calculated gradients;

[0165] Save weights: At the end of each epoch, save the model weights obtained from the current training.

[0166] Step 2-3, integer training

[0167] Step 2-3-1, quantize the input data, labels, and model weights into 8-bit signed integers, and use integer operations in forward propagation and backpropagation;

[0168] Step 2-3-2, setting the scaling factor for range mapping between integers and floating-point numbers to prevent quantization error accumulation;

[0169] Step 2-3-3, use the Adam optimization algorithm to convert the integer gradient into a floating point number by dividing it by the scaling factor and update the weight;

[0170] Step 2-3-4, training is terminated. When epoch reaches 20, training is stopped.

[0171] Steps 2-4, model testing and deployment

[0172] Step 2-4-1, evaluate the performance indicators such as content recognition accuracy and speed of the trained model on the test set;

[0173] Step 2-4-2, convert the trained quantized integer model into a format suitable for the deployment environment, and provide a unified calling interface according to the M batch mode.

[0174] The above step 2 completes the content type recognition of the preprocessed data using a neural network.

[0175] In this embodiment, if Figure 5 As shown, the result output and post-processing steps include:

[0176] Step 3-1, perform softmax operation on the M×12 output matrix row by row to obtain the normalized probability distribution;

[0177] Step 3-2, for each row, take the type index corresponding to the maximum probability value as the predicted type. The correspondence between the index and the type name is as follows: {0: plaintext, 1: ciphertext, 2: encoded Base16, 3: encoded Base32, 4: encoded based45, 5: encoded base64, 6: encoded base85, 7: encoded base91, 8: encoded base100, 9: encoded base122, 10: encoded Ascii85, 11: Unknown};

[0178] Step 3-3, fill the predicted type into the content_type field of the structure generated in step 1, fill the maximum probability value into the conf_prob field, and output an M-tuple, each element of which is (five-tuple, content_type, conf_prob);

[0179] Step 3-4, traverse M tuples and output all corresponding payload contents to the next processing module, such as plaintext extraction, encoding and decoding, encrypted traffic analysis, etc., to complete the processing of a batch;

[0180] Step 3-5: After the current batch is processed, clear the corresponding byte and five-tuple cache in the flow table and wait for the next batch of data.

[0181] The above step 3 completes the processing of the output results of the neural network, fills the inference results into the corresponding structure, and uses the results in the subsequent traffic processing module.

[0182] In this embodiment, if Figure 6 As shown, the batch parameter M is determined by executing the following steps in the deployment environment:

[0183] Step 4-1, counting the number of newly added concurrent connections P per second in the training data set, where P is equal to the number of SYN packets of newly added TCP connections per second. In this embodiment, P is 100;

[0184] Step 4-2, randomly sample S=10 sessions from the data set, and calculate the average inter-arrival time t of uplink data packets of each session. In this embodiment, the value of t is 0.046s;

[0185] Step 4-3, sample 1024 bytes of payload corresponding to S=10 sessions, send them to the trained neural network model in the deployed state for inference, and calculate the average inference time R. In this example, the value of R is 0.0021s;

[0186] Step 4-4, the calculation formula of M is M=⌈1.5×R×P / t⌉, where ⌈·⌉ is a rounding symbol, and in this embodiment, M=7.

[0187] The above step 4 determines the reasonable batch parameter M=7 in the actual deployment environment, which enables the system to efficiently process network data blocks in batches, ensuring the processing efficiency and stability of system performance.

[0188] The present invention provides a method and device for identifying network traffic content types based on deep learning. There are many methods and ways to implement the technical solution. The above is only a preferred implementation 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 principles of the present invention. These improvements and modifications should also be regarded as the protection scope of the present invention. All components not specified in this embodiment can be implemented using existing technologies.

Claims

1. A method for identifying network traffic content types based on deep learning, characterized in that: The following steps are involved: Step 1, preprocessing the collected network data, including: for each TCP transmission control protocol session, extracting the continuous payload after the X1th packet of the upstream data packet, collecting 1024 bytes as a payload data block, for the stream less than 1024 bytes, padding to 1024 bytes by character repeating, pushing M payload data blocks into a stack as a batch, and creating a structure containing M five-tuples corresponding to the batch, undetermined content type and confidence probability; Step 2: Input the batch into a deep neural network inference module for forward calculation. The deep neural network inference module is used to receive M 1024-byte inputs and output the corresponding M stream content types; Step 3: Fill the content types of the M flows into the corresponding structure, use the maximum probability output by softmax as the content type, use the maximum probability as the confidence, output the content type, confidence and five-tuple, group the same type of traffic together according to the type label, and clear the flow table; In step 2, the deep neural network reasoning module includes an integer precision one-dimensional convolutional neural network for content type recognition; Step 2 also includes: training the convolutional neural network using the following steps: Step 2-1, construct a training data set; Step 2-2, conduct training process; Step 2-3, integer training; Steps 2-4, model testing and deployment; Step 2-1 includes: Step 2-1-1, data collection: collect original network traffic data including plaintext traffic and encrypted traffic from various network environments; directly mark the plaintext type of the payload content while collecting; the encrypted data includes TLS secure transport layer protocol and SSH secure shell protocol that can be identified by DPI, and the encryption type of the payload content is directly marked while collecting; Step 2-1-2, generate data: for the collected plaintext data, use encoding Base16, encoding Base32, encoding based45, encoding base64, encoding base85, encoding base91, encoding base100, encoding base122, encoding Ascii85 to generate corresponding encoding data samples, and directly annotate the corresponding encoding type at the same time to form data and label pairs; Step 2-1-3, divide the data set, randomly divide the data and label pairs into mutually exclusive training set, validation set and test set; Step 2-2 includes: Step 2-2-1, design loss function: use cross entropy loss function to measure the difference between the content type distribution output by the convolutional neural network and the true label; Step 2-2-2, parameter initialization, the weight matrices of the first convolutional layer L2, the second convolutional layer L4, the third convolutional layer L6 and the fully connected layer L9 are initialized using truncated normal distribution, and the bias vector is initialized to the zero vector; Step 2-2-3, set hyperparameters: preset network structure parameters, batch size, and learning rate, without additional tuning; the network structure parameters include convolution kernel size and number; Step 2-2-4, the training process includes: Forward propagation: forward propagation is performed on each batch of data in the training set to calculate the predicted output; Calculate loss: Use the designed cross entropy loss function to calculate the error between the predicted output and the true label; Back propagation: The back propagation algorithm is used to calculate the gradient of the loss function relative to the weights and biases of each layer. Update weights: Use an optimization algorithm to update the network weights and biases based on the calculated gradients; Save weights: At the end of each epoch, save the model weights obtained from the current training; Steps 2-3 include: Step 2-3-1, quantize the training set, labels, and model weights into 8-bit signed integers, use integer operations in forward propagation and back propagation, complete the quantization process of the model, and convert it into a quantized integer model; Step 2-3-2, setting the scaling factor for range mapping between integers and floating-point numbers to prevent quantization error accumulation; Step 2-3-3, use the Adam optimization algorithm to convert the integer gradient into a floating point number by dividing it by the scaling factor and update the weight; Step 2-3-4, training is terminated. When the performance of the validation set does not improve for consecutive epochs, training is stopped. The trained convolutional neural network will output an M×12 output matrix for the input data. Steps 2-4 include: Step 2-4-1, evaluate the content recognition accuracy and speed of the trained convolutional neural network on the test set; Step 2-4-2, convert the trained quantized integer model into a format suitable for the deployment environment, and provide a unified calling interface according to the M batch mode.

2. The method according to claim 1, characterized in that Step 1 includes: Step 1-1, capture network packets, extract TCP payload data, and construct the following tuple: (timestamp, src_ip, src_port, dst_ip, dst_port, packet_length, payload), Where timestamp is the capture timestamp, src_ip and dst_ip are the source IP address and destination IP address respectively, src_port and dst_port are the source port number and destination port number respectively, packet_length is the payload length, and payload is the payload content; Step 1-2, based on the five-tuple (src_ip, src_port, dst_ip, dst_port, protocol), the network data packets are subjected to session aggregation and TCP reassembly, where protocol is the transport layer protocol type, and the network data packets of the same five-tuple are divided into the same session; Step 1-3, for each session, extract the continuous load data after the fifth packet of the uplink data packet to construct a load data block; the uplink data packet refers to the data from the source address src to the destination address dst; Step 1-4, set the fixed length of the payload data block group to 1024 bytes. If the payload data block length L is less than 1024 bytes, extend it in the following way: Counting repetitions is a round-up symbol; the original L-byte payload data block is repeated T times, and the first 1024 bytes are taken as the extended payload data block; Step 1-5, construct the struct Session structure based on the five-tuple information of the current session: struct Session{ int64 timestamp; char[16]src_ip; int src_port; char[16]dst_ip; int dst_port; int block_num; char content_type; float conf_prob; }, Among them, int64 timestamp indicates that the data type of the session start timestamp is int64, char[16]src_ip indicates that the data type of the source IP address is char[16], int src_port indicates that the data type of the source port number is int, char[16]dst_ip indicates that the data type of the destination IP address is char[16], int dst_port indicates that the data type of the destination port number is int, int block_num indicates that the data type of the accumulated data blocks block_num is int; char content_type indicates that the data type of the content type content_type is char, and the content type is initially empty; float conf_prob indicates that the data type of the confidence probability conf_prob is float, and the confidence probability is initially 0; Step 1-6, fill the payload data blocks obtained from step 1-4 into a buffer of size M × 1024 bytes as a batch, and fill the corresponding structure pointers into a batch structure pointer array of size M; Step 1-7, if the buffer and pointer array are not full, return to step 1-2; if the buffer and pointer array are full, go to step 2.

3. The method according to claim 2, characterized in that In step 2, the hierarchical structure of the convolutional neural network includes: The input layer L1 receives an unsigned byte integer vector of size 1024, representing the original byte sequence of a data block; The first convolutional layer L2 contains three groups of one-dimensional convolution kernels, with convolution kernel sizes of 1, 3, and 5 respectively. The number of convolution kernels in each group is 128, and the step size of all convolution kernels is 1. It outputs three groups of integer feature vectors with a size of 1024×128; The first BN layer L3 performs batch normalization on the output feature vectors of the first convolutional layer L2 and uses the ReLU function for activation; The second convolutional layer L4 contains three groups of one-dimensional convolution kernels, with convolution kernel sizes of 1, 3, and 5 respectively. The number of convolution kernels in each group is 256, and the step size of all convolution kernels is 1. It outputs three groups of integer feature vectors with a size of 1024×256. The second BN layer L5 performs batch normalization on the output feature vectors of the second convolutional layer L4 and uses the ReLU function for activation; The third convolutional layer L6 contains three groups of one-dimensional convolution kernels with sizes of 1, 3, and 5 respectively. The number of convolution kernels in each group is 512, which is a hyperparameter. The step size of all convolution kernels is 1, and it outputs three groups of integer feature vectors with a size of 1024×512. The third BN layer L7 performs batch normalization on the output feature vectors of the third convolutional layer L6 and uses the ReLU function for activation; The global average pooling layer L8 performs global average pooling on the three groups of feature vectors output by the third BN layer L7 to obtain a 3×512-dimensional integer feature vector; The fully connected layer L9 passes the output of the global average pooling layer L8 through a fully connected layer to map the 3×512-dimensional feature vector to a 12-dimensional category output vector. The weights and biases of the fully connected layer are all integers, and the category is defined as: 0: Plain text, 1: ciphertext, 2: Encode Base16, 3: Encode Base32, 4: Encoding Based45, 5: Encode Base64, 6: Encode Base85, 7: Encoding Base91, 8: Encoding Base100, 9: Encoding Base122, 10: Encoding Ascii85, 11: Unknown; Softmax layer L10 performs Softmax normalization on the output vector of the fully connected layer L9 to obtain a 12-dimensional probability distribution vector, in which each element corresponds to the posterior probability of a content type.

4. The method according to claim 3, characterized in that Step 3 includes: Step 3-1, perform softmax operation on the M×12 output matrix row by row to obtain the normalized probability distribution; Step 3-2, for each row of the M×12 output matrix, take the type index corresponding to the maximum probability value as the predicted type. The correspondence between the index and the type name is: {0: plaintext, 1: ciphertext, 2: encoded Base16, 3: encoded Base32, 4: encoded based45, 5: encoded base64, 6: encoded base85, 7: encoded base91, 8: encoded base100, 9: encoded base122, 10: encoded Ascii85, 11: unknown}; Step 3-3, fill the predicted type into the content type content_type field of the structure generated in step 1, fill the maximum probability value into the confidence probability conf_prob field, and output an M-tuple, each element of which is (five-tuple, content_type, conf_prob); Step 3-4, traverse the M tuples and output the corresponding load data blocks to the module for the next step of processing, completing the processing of a batch; Step 3-5: After the current batch is processed, clear the corresponding byte and five-tuple cache in the table or data structure that stores the flow information and wait for the next batch of data.

5. The method according to claim 4, characterized in that The step 4 is also included: determining the batch processing parameter M by performing the following steps in the deployment environment: Step 4-1, count the number of new concurrent connections P per second in the training set, where P is equal to the number of SYN packets of new TCP connections per second; Step 4-2, randomly sample S sessions from the data set and calculate the average inter-arrival time t of the uplink data packets of each session; Step 4-3, sample the 1024-byte payload corresponding to S sessions, send it to the trained and deployed convolutional neural network obtained in step 2-4 for inference, and calculate the average inference time R; Step 4-4, the calculation formula of M is:

6. A device for identifying traffic content type based on the method according to any one of claims 1 to 5, characterized in that: include: A preprocessing module is used to preprocess the collected network data, including: for each TCP transmission control protocol session, extract the continuous load after the X1th packet of the upstream data packet, collect 1024 bytes as a load data block, and for the flow less than 1024 bytes, pad it to 1024 bytes by repeating characters, push M load data blocks into a stack as a batch, and create a structure containing M five-tuples corresponding to the batch, undetermined content type and confidence probability; A neural network inference module is used to input the batches into a deep neural network inference module for forward calculation. The deep neural network inference module is used to receive M 1024-byte inputs and output the corresponding M stream content types; The post-processing module is used to fill the content types of the M flows into the corresponding structure, use the maximum probability of the softmax output as the content type, use the maximum probability as the confidence, output the content type, confidence and quintuple, group the same type of traffic together according to the type label, and clear the flow table.

Citation Information

Patent Citations

  • Deep learning traffic classification method based on spatiotemporal characteristics

    CN110730140B

  • A network traffic classification system and method based on deep discriminative features

    CN110796196B

  • A network traffic classification method and system based on multi-scale feature attention

    CN112839024B

  • A method, apparatus, device and medium for classifying flow.

    CN113452810B

  • Train communication network flow identification method based on deep learning

    CN113037646A