Network traffic data classification method and device, storage medium and electronic equipment

Through the multi-stage feature extraction and pooling fusion operation of the lightweight feature extraction network, the problem of computing resources and speed bottlenecks in network traffic classification is solved, and efficient and accurate network traffic data classification is achieved.

CN120296521APending Publication Date: 2025-07-11CHINA CONSTRUCTION BANK
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510456271.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-11
Publication Date
2025-07-11

Smart Images

  • Figure CN120296521A_ABST
    Figure CN120296521A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a network traffic data classification method and device, a storage medium and electronic equipment. The method comprises the following steps: acquiring initial input data; inputting the initial input data into a pre-trained feature extraction network, and performing feature extraction operation on the initial input data by using the feature extraction network to obtain a target feature vector; and inputting the target feature vector into a pre-trained classification network to obtain classification information of the network traffic data output by the classification network. According to the method and the device, the problem that the network traffic data cannot be efficiently classified in related technologies is solved, and the effect of efficiently classifying the network traffic data is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] Embodiments of the present application relate to the field of computer technologies, and in particular, to a method and apparatus for classifying network traffic data, a storage medium, and an electronic device. Background Art

[0002] Traditional network traffic classification technologies mainly include machine learning-based solutions and deep learning-based models. Although machine learning-based solutions can handle relatively complex data, manual feature engineering is still required, which not only increases the workload, but also the subjectivity and limitations of feature selection may affect the generalization ability of the model, especially in real-time changing network scenarios. Deep learning-based models, although making significant progress in automatic feature extraction and improving classification accuracy, still have defects in terms of computational resource requirements and running speed. Especially for mobile devices and resource-constrained environments, their computational overhead and latency may become bottlenecks. Therefore, there is still a problem of efficiently classifying network traffic data in related technologies of network traffic classification. Summary of the Invention

[0003] Embodiments of the present application provide a method and apparatus for classifying network traffic data, a storage medium, and an electronic device to at least solve the problem that network traffic data cannot be efficiently classified in related technologies.

[0004] According to an embodiment of the present application, a method for classifying network traffic data is provided, including: obtaining initial input data, where the initial input data is data obtained after performing a preprocessing operation on network traffic data; inputting the initial input data into a pre-trained feature extraction network, and using the feature extraction network to perform a feature extraction operation on the initial input data to obtain a target feature vector, where the feature extraction network includes a first feature extraction sub-network, an attention sub-network, and a second feature extraction sub-network, and the process of the feature extraction operation includes: inputting the initial input data into the first feature extraction sub-network to obtain a first feature vector output by the first feature extraction sub-network; inputting the first feature vector into the attention sub-network, and the attention sub-network sequentially performs a pooling operation and a fusion operation on the first feature vector to obtain a second feature vector output by the attention sub-network; inputting the second feature vector into the second feature extraction sub-network to obtain the target feature vector output by the second feature extraction sub-network; inputting the target feature vector into a pre-trained classification network to obtain classification information of the network traffic data output by the classification network.

[0005] In an exemplary embodiment, before obtaining the initial input data, the above method further includes: performing a first segmentation operation on the above network traffic data to obtain first network traffic data, where the above preprocessing operation includes the above first segmentation operation, and the above first segmentation operation is an operation of segmenting the above network traffic data according to data packets with the same multi-tuples; performing a cleaning operation on the above first network traffic data to obtain second network traffic data, where the above preprocessing operation includes the above cleaning operation, and the above cleaning operation is an operation of removing redundant data in the above first network traffic data; performing a standardization operation on the above second network traffic data to obtain the above initial input data, where the above preprocessing operation includes the above standardization operation, and the above standardization operation is an operation of unifying the data format of the above second network traffic data input into the above feature extraction network.

[0006] In an exemplary embodiment, inputting the above initial input data into the above first feature extraction sub-network to obtain the first feature vector output by the above first feature extraction sub-network includes: inputting the above initial input data into the first depth convolution layer in the above first feature extraction sub-network to obtain the above first feature vector output by the above first depth convolution layer.

[0007] In an exemplary embodiment, inputting the above first feature vector into the above attention sub-network, and the above attention sub-network respectively performing a pooling operation and a fusion operation on the above first feature vector to obtain the second feature vector output by the above attention sub-network includes: respectively performing the above pooling operation on the above first feature vector in multiple network branches to obtain multiple branch feature vectors, where the above network branches are determined according to the dimension of the above first feature vector, and one of the above network branches outputs one of the above branch feature vectors; performing the above fusion operation on the multiple above branch feature vectors to fuse the multiple above branch feature vectors to obtain the above second feature vector.

[0008] In an exemplary embodiment, the pooling operation is respectively performed on the first feature vector in multiple above-mentioned network branches to obtain multiple branch feature vectors, including: for each of the above-mentioned network branches, the pooling operation is performed on the first feature vector in the network branch through the following steps to obtain the branch feature vector: when the network branch includes a channel branch, a first pooling operation and a first convolution operation are performed on the first feature vector in the channel branch to obtain a channel branch feature vector; when the network branch includes a height branch, a second pooling operation is performed on the first feature vector in the height branch to obtain a first height branch feature vector, where the second pooling operation is a pooling operation in one-dimensional direction; when the network branch includes a width branch, a third pooling operation is performed on the first feature vector in the width branch to obtain a first width branch feature vector, where the third pooling operation is a pooling operation in one-dimensional direction; a second convolution operation is performed on the first height branch feature vector and the first width branch feature vector to obtain a height branch feature vector and a width branch feature vector; the channel branch feature vector, the height branch feature vector and the width branch feature vector are determined as the branch feature vector.

[0009] In an exemplary embodiment, when the network branch includes a channel branch, a first pooling operation and a first convolution operation are performed on the first feature vector in the channel branch to obtain a channel branch feature vector, including: performing a max pooling operation on the first feature vector in the channel branch to obtain a third feature vector; performing an average pooling operation on the first feature vector in the channel branch to obtain a fourth feature vector; performing a first concatenation operation on the third feature vector and the fourth feature vector based on the channel dimensions of the third feature vector and the fourth feature vector to obtain a fifth feature vector; inputting the fifth feature vector into a second depth convolution layer in the attention sub-network to obtain a sixth feature vector output by the second depth convolution layer, where the second depth convolution layer is used to extract the spatial encoding information within each channel of the fifth feature vector; inputting the sixth feature vector into a first pointwise convolution layer in the attention sub-network to obtain a seventh feature vector output by the first pointwise convolution layer, where the first pointwise convolution layer is used to extract the spatial encoding information between each channel of the sixth feature vector; performing a first normalization operation and a first activation operation on the seventh feature vector in sequence to obtain an eighth feature vector; calculating the product between the eighth feature vector and the first feature vector to obtain a ninth feature vector; calculating the sum value between the ninth feature vector and the first feature vector to obtain the channel branch feature vector.

[0010] In an exemplary embodiment, a second convolution operation is performed on the above-mentioned first height branch feature vector and the above-mentioned first width branch feature vector to obtain a height branch feature vector and a width branch feature vector, including: inputting the concatenated feature vector into a second pointwise convolution layer in the above-mentioned attention sub-network to obtain a first concatenated feature vector, where the above-mentioned concatenated feature vector is a feature vector obtained by performing a second concatenation operation on the above-mentioned first height branch feature vector and the above-mentioned first width branch feature vector; sequentially performing a second normalization operation and a second activation operation on the above-mentioned first concatenated feature vector to obtain a second concatenated feature vector; performing a second splitting operation on the above-mentioned second concatenated feature vector to obtain a second height branch feature vector and a second width branch feature vector; sequentially inputting the above-mentioned second height branch feature vector and the above-mentioned second width branch feature vector into a third pointwise convolution layer in the above-mentioned attention sub-network to respectively obtain the above-mentioned height branch feature vector and the above-mentioned width branch feature vector output by the above-mentioned third pointwise convolution layer.

[0011] In an exemplary embodiment, inputting the above-mentioned second feature vector into the above-mentioned second feature extraction sub-network to obtain the above-mentioned target feature vector output by the above-mentioned second feature extraction sub-network, including: inputting the above-mentioned second feature vector into a fourth pointwise convolution layer in the above-mentioned second feature extraction sub-network to obtain a tenth feature vector output by the above-mentioned fourth pointwise convolution layer, where the above-mentioned fourth pointwise convolution layer is used to expand the channel dimension of the above-mentioned second feature vector; inputting the above-mentioned tenth feature vector into a fifth pointwise convolution layer in the above-mentioned second feature extraction sub-network to obtain an eleventh feature vector output by the above-mentioned fifth pointwise convolution layer, where the above-mentioned fifth pointwise convolution layer is used to reduce the channel dimension of the above-mentioned tenth feature vector; inputting the above-mentioned eleventh feature vector into a third depth convolution layer in the above-mentioned second feature extraction sub-network to obtain the above-mentioned target feature vector output by the above-mentioned third depth convolution layer.

[0012] In an exemplary embodiment, inputting the above-mentioned target feature vector into a pre-trained classification network to obtain the classification information of the above-mentioned network traffic data output by the above-mentioned classification network, including: inputting the above-mentioned target feature vector into a dense fully-connected layer in the above-mentioned classification network to obtain a first target feature vector output by the above-mentioned dense fully-connected layer; inputting the above-mentioned first target feature vector into a first function layer in the above-mentioned classification network to obtain the classification information of the above-mentioned network traffic data output by the above-mentioned first function layer.

[0013] According to an embodiment of the present application, a classification device for network traffic data is further provided, including: a first acquisition module, configured to acquire initial input data, where the initial input data is data obtained after performing a preprocessing operation on network traffic data; a first input module, configured to input the initial input data into a pre-trained feature extraction network, and use the feature extraction network to perform a feature extraction operation on the initial input data to obtain a target feature vector, where the feature extraction network includes a first feature extraction sub-network, an attention sub-network, and a second feature extraction sub-network, and the process of the feature extraction operation includes: a first input sub-module, configured to input the initial input data into the first feature extraction sub-network to obtain a first feature vector output by the first feature extraction sub-network; a second input sub-module, configured to input the first feature vector into the attention sub-network, and the attention sub-network sequentially performs a pooling operation and a fusion operation on the first feature vector to obtain a second feature vector output by the attention sub-network; a third input sub-module, configured to input the second feature vector into the second feature extraction sub-network to obtain the target feature vector output by the second feature extraction sub-network; a first output module, configured to input the target feature vector into a pre-trained classification network to obtain classification information of the network traffic data output by the classification network.

[0014] In an exemplary embodiment, the device further includes: a first execution module, configured to perform a first segmentation operation on the network traffic data to obtain first network traffic data before acquiring the initial input data, where the first segmentation operation is included in the preprocessing operation, and the first segmentation operation is an operation of segmenting the network traffic data according to packets with the same multi-tuple; a second execution module, configured to perform a cleaning operation on the first network traffic data to obtain second network traffic data, where the cleaning operation is included in the preprocessing operation, and the cleaning operation is an operation of removing redundant data from the first network traffic data; a third execution module, configured to perform a standardization operation on the second network traffic data to obtain the initial input data, where the standardization operation is included in the preprocessing operation, and the standardization operation is an operation of unifying the data format of the second network traffic data input into the feature extraction network.

[0015] In an exemplary embodiment, the first input sub-module includes: a first input unit, configured to input the initial input data into a first depth convolution layer in the first feature extraction sub-network to obtain the first feature vector output by the first depth convolution layer.

[0016] In an exemplary embodiment, the second input sub-module includes: a first execution unit configured to perform the pooling operation on the first feature vector in multiple network branches respectively to obtain multiple branch feature vectors, where the network branches are determined according to the dimension of the first feature vector, and one network branch outputs one branch feature vector; and a second execution unit configured to perform the fusion operation on the multiple branch feature vectors to fuse the multiple branch feature vectors and obtain the second feature vector.

[0017] In an exemplary embodiment, the first execution unit includes: for each of the network branches, performing the pooling operation on the first feature vector in the network branch through the following steps to obtain the branch feature vector: a first execution sub-unit configured to, when the network branch includes a channel branch, perform a first pooling operation and a first convolution operation on the first feature vector in the channel branch to obtain a channel branch feature vector; a second execution sub-unit configured to, when the network branch includes a height branch, perform a second pooling operation on the first feature vector in the height branch to obtain a first height branch feature vector, where the second pooling operation is a pooling operation in a one-dimensional direction; a third execution sub-unit configured to, when the network branch includes a width branch, perform a third pooling operation on the first feature vector in the width branch to obtain a first width branch feature vector, where the third pooling operation is a pooling operation in a one-dimensional direction; a fourth execution sub-unit configured to perform a second convolution operation on the first height branch feature vector and the first width branch feature vector to obtain a height branch feature vector and a width branch feature vector; and a first determination sub-unit configured to determine the channel branch feature vector, the height branch feature vector, and the width branch feature vector as the branch feature vector.

[0018] In an exemplary embodiment, the above-mentioned first execution subunit includes: a first execution sub-subunit, configured to perform a max pooling operation on the above-mentioned first feature vector in the above-mentioned channel branch to obtain a third feature vector; a second execution sub-subunit, configured to perform an average pooling operation on the above-mentioned first feature vector in the above-mentioned channel branch to obtain a fourth feature vector; a third execution sub-subunit, configured to perform a first concatenation operation on the above-mentioned third feature vector and the above-mentioned fourth feature vector based on the channel dimension of the above-mentioned third feature vector and the channel dimension of the above-mentioned fourth feature vector to obtain a fifth feature vector; a first input sub-subunit, configured to input the above-mentioned fifth feature vector into a second depth convolution layer in the above-mentioned attention sub-network to obtain a sixth feature vector output by the above-mentioned second depth convolution layer, where the above-mentioned second depth convolution layer is configured to extract spatial encoding information within each channel of the above-mentioned fifth feature vector; a second input sub-subunit, configured to input the above-mentioned sixth feature vector into a first pointwise convolution layer in the above-mentioned attention sub-network to obtain a seventh feature vector output by the above-mentioned first pointwise convolution layer, where the above-mentioned first pointwise convolution layer is configured to extract spatial encoding information between each channel of the above-mentioned sixth feature vector; a third input sub-subunit, configured to sequentially perform a first normalization operation and a first activation operation on the above-mentioned seventh feature vector to obtain an eighth feature vector; a first calculation sub-subunit, configured to calculate the product between the above-mentioned eighth feature vector and the above-mentioned first feature vector to obtain a ninth feature vector; a second calculation sub-subunit, configured to calculate the sum value between the above-mentioned ninth feature vector and the above-mentioned first feature vector to obtain the above-mentioned channel branch feature vector.

[0019] In an exemplary embodiment, the above-mentioned fourth execution subunit includes: a fourth input sub-subunit, configured to input a concatenated feature vector into a second pointwise convolution layer in the above-mentioned attention sub-network to obtain a first concatenated feature vector, where the above-mentioned concatenated feature vector is a feature vector obtained by performing a second concatenation operation on the above-mentioned first height branch feature vector and the above-mentioned first width branch feature vector; a fourth execution sub-subunit, configured to sequentially perform a second normalization operation and a second activation operation on the above-mentioned first concatenated feature vector to obtain a second concatenated feature vector; a fifth execution sub-subunit, configured to perform a second splitting operation on the above-mentioned second concatenated feature vector to obtain a second height branch feature vector and a second width branch feature vector; a fifth input sub-subunit, configured to sequentially input the above-mentioned second height branch feature vector and the above-mentioned second width branch feature vector into a third pointwise convolution layer in the above-mentioned attention sub-network to respectively obtain the above-mentioned height branch feature vector and the above-mentioned width branch feature vector output by the above-mentioned third pointwise convolution layer.

[0020] In an exemplary embodiment, the above-mentioned third input sub-module includes: a first input sub-unit, configured to input the above-mentioned second feature vector into the fourth pointwise convolution layer in the above-mentioned second feature extraction sub-network to obtain a tenth feature vector output by the fourth pointwise convolution layer, wherein the fourth pointwise convolution layer is used to expand the channel dimension of the second feature vector; a second input sub-unit, configured to input the tenth feature vector into the fifth pointwise convolution layer in the above-mentioned second feature extraction sub-network to obtain an eleventh feature vector output by the fifth pointwise convolution layer, wherein the fifth pointwise convolution layer is used to reduce the channel dimension of the tenth feature vector; a third input sub-unit, configured to input the eleventh feature vector into the third depth convolution layer in the above-mentioned second feature extraction sub-network to obtain the above-mentioned target feature vector output by the third depth convolution layer.

[0021] In an exemplary embodiment, the above-mentioned first output module includes: a first output sub-module, configured to input the above-mentioned target feature vector into the dense fully-connected layer in the above-mentioned classification network to obtain a first target feature vector output by the dense fully-connected layer; a second output sub-module, configured to input the first target feature vector into the first function layer in the above-mentioned classification network to obtain the classification information of the above-mentioned network traffic data output by the first function layer.

[0022] According to another embodiment of the present application, there is also provided a computer program product, including a computer program, and the above-mentioned computer program is set to be executed by a processor to perform the steps in any one of the above method embodiments.

[0023] According to another embodiment of the present application, there is also provided a computer-readable storage medium, in which a computer program is stored, and the above-mentioned computer program is set to be executed by a processor to perform the steps in any one of the above method embodiments.

[0024] According to another embodiment of the present application, there is also provided an electronic device, including a memory, a processor, and a computer program stored on the above-mentioned memory and executable on the above-mentioned processor, and the above-mentioned processor is set to execute the above-mentioned computer program to perform the steps in any one of the above method embodiments.

[0025] Through this application, the network traffic data after performing preprocessing operations is input into a lightweight feature extraction network, which consists of a first feature extraction sub-network, an attention sub-network, and a second feature extraction sub-network, and performs multi-stage feature extraction on the preprocessed data. The first feature vector output by the first feature extraction sub-network is sent to the attention sub-network, which enhances the ability to capture key features through pooling and fusion operations. At the same time, compared with traditional convolutions, this operation can significantly reduce the computational amount while maintaining rich features, improving the classification efficiency. Finally, the classification network outputs classification information based on the target feature vector, completing the efficient classification of network traffic data. In the whole process, the combination of the feature extraction network and the classification network not only reduces the consumption of computing resources, but also significantly improves the classification accuracy, especially in different application scenarios that require high-precision classification, and the performance is particularly prominent. Therefore, the problem in the related technology of being unable to efficiently classify network traffic data is solved, and the effect of efficiently classifying network traffic data is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 is a block diagram of the hardware structure of a mobile terminal for a method of classifying network traffic data according to an embodiment of the present application;

[0027] Figure 2 is a flowchart of a method of classifying network traffic data according to an embodiment of the present application;

[0028] Figure 3 is a flowchart of a method of classifying network traffic data in a specific embodiment of the present application;

[0029] Figure 4 is a schematic diagram of a preprocessing operation in a specific embodiment of the present application;

[0030] Figure 5 is a schematic diagram of a feature extraction network in a specific embodiment of the present application;

[0031] Figure 6 is a schematic diagram of an attention sub-network in a specific embodiment of the present application;

[0032] Figure 7 is a block diagram of the structure of a device for classifying network traffic data according to an embodiment of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0033] In the following, embodiments of the present application will be described in detail with reference to the drawings and in conjunction with the embodiments.

[0034] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily need to be used to describe a specific order or sequence.

[0035] The method embodiments provided in the embodiments of the present application can be executed on a mobile terminal, a computer terminal, or a similar computing device. Taking running on a mobile terminal as an example, Figure 1 is a hardware block diagram of a mobile terminal for a method of classifying network traffic data according to an embodiment of the present application. As Figure 1 shown, the mobile terminal may include one or more ( Figure 1 only one is shown in the figure) processors 102 (the processor 102 may include, but is not limited to, a processing device such as a microprocessor MCU or a programmable logic device FPGA) and a memory 104 for storing data. Among them, the above-mentioned mobile terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those of ordinary skill in the art can understand that Figure 1 the structure shown is only schematic and does not limit the structure of the above-mentioned mobile terminal. For example, the mobile terminal may further include more or fewer components than Figure 1 shown in the figure, or have a different configuration from Figure 1 shown in the figure.

[0036] The memory 104 can be used to store computer programs. For example, software programs and modules of application software, such as the computer program corresponding to a method of classifying network traffic data in the embodiments of the present application. The processor 102 executes various functional applications and data processing by running the computer program stored in the memory 104, that is, implements the above method. The memory 104 may include a high-speed random access memory, and may further include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some instances, the memory 104 may further include a memory remotely provided with respect to the processor 102, and these remote memories may be connected to the mobile terminal through a network. Examples of the above network include, but are not limited to, the Internet, an enterprise intranet, a local area network, a mobile communication network, and combinations thereof.

[0037] The transmission device 106 is used to receive or send data via a network. Specific examples of the above network may include a wireless network provided by a communication provider of the mobile terminal. In one instance, the transmission device 106 includes a network adapter (abbreviated as NIC for Network Interface Controller), which can be connected to other network devices through a base station and thus communicate with the Internet. In one instance, the transmission device 106 may be a radio frequency (abbreviated as RF) module, which is used to communicate with the Internet wirelessly.

[0038] In this embodiment, a method of classifying network traffic data is provided. Figure 2It is a flowchart of a method for classifying network traffic data according to an embodiment of the present application. As Figure 2 shown, the process includes the following steps:

[0039] Step S202, obtain initial input data, where the initial input data is data obtained after performing a preprocessing operation on the network traffic data;

[0040] Optionally, the network traffic data is data stream information generated during network transmission, including but not limited to the source address, destination address, port number, protocol type, transmission time, etc. of the data packet. These data are usually recorded in different formats, and the most common one is the.pcap file format, which can be captured by network analysis tools. The network traffic data is a key information source in the fields of network monitoring, security analysis, traffic management, and optimization. By analyzing these data, the activity patterns in the network can be insighted, potential network attacks can be detected, and network resource allocation can be optimized, etc. The scenario for capturing network traffic data can be the scenario of interaction between two communication parties, such as web browsing, email, online chat, etc.

[0041] Optionally, the preprocessing operation is a series of format conversion and information extraction processes performed on the network traffic data, used to convert the network traffic data into a form that the model can understand and process. The preprocessing operation includes but not limited to traffic segmentation operation, data cleaning operation, and data normalization operation.

[0042] Step S204, input the initial input data into a pre-trained feature extraction network, and use the feature extraction network to perform a feature extraction operation on the initial input data to obtain a target feature vector, where the feature extraction network includes a first feature extraction sub-network, an attention sub-network, and a second feature extraction sub-network. The process of the feature extraction operation includes: inputting the initial input data into the first feature extraction sub-network to obtain a first feature vector output by the first feature extraction sub-network; inputting the first feature vector into the attention sub-network, and the attention sub-network sequentially performs a pooling operation and a fusion operation on the first feature vector to obtain a second feature vector output by the attention sub-network; inputting the second feature vector into the second feature extraction sub-network to obtain the target feature vector output by the second feature extraction sub-network;

[0043] Optionally, input the training set data into the initial feature extraction network, perform multiple rounds of iterative training, and save the network model parameters with the best effect after the training tends to converge to obtain a pre-trained feature extraction network, where the training set data can be the network traffic data after performing a preprocessing operation.

[0044] Optionally, the first feature extraction sub-network consists of a first depth convolution layer, which is used to convert the initial input data into a feature representation for further analysis and learning by the attention sub-network, providing a preliminary data basis for the subsequent attention sub-network.

[0045] Optionally, the attention sub-network is used to perform a pooling operation on the first feature vector, perform a convolution operation on the first feature vector after the pooling operation, perform a batch normalization operation and a sigmoid activation operation on the first feature vector after the convolution operation, and perform a fusion operation on the first feature vector after the batch normalization operation and the sigmoid activation operation.

[0046] Optionally, the second feature extraction sub-network consists of a fourth pointwise convolution layer and a fifth pointwise convolution layer, which are respectively responsible for expanding and reducing the channel dimension, playing a role in reducing the number of network parameters.

[0047] Step S206: Input the above target feature vector into a pre-trained classification network to obtain the classification information of the above network traffic data output by the above classification network.

[0048] Optionally, the pre-trained classification network consists of a dense fully-connected layer and a first function layer, which is used to perform class judgment on the input target feature vector to obtain the classification information of the network traffic data. Among them, different classification problems are divided based on different application scenarios to obtain different classification information. For example, classifying network traffic data at the application category level can set the network traffic data of different application categories to different priorities, and combined with some technical solutions for network congestion control, improve the utilization rate of network resources. Another example is to classify network traffic data from the perspective of nature, identify malicious traffic brought by network attacks and threats, and take effective security measures in a timely manner to protect the security and stability of the financial system.

[0049] In this embodiment, the execution subject of the above steps may be a terminal, a server, a specific processor set in the terminal or the server, or a processor or processing device set relatively independently of the terminal or the server, but is not limited thereto.

[0050] Through the above steps, the network traffic data after performing the preprocessing operation is input into a lightweight feature extraction network, which consists of a first feature extraction sub-network, an attention sub-network, and a second feature extraction sub-network, to perform multi-stage feature extraction on the preprocessed data. The first feature vector output by the first feature extraction sub-network is fed into the attention sub-network, which enhances the ability to capture key features through pooling and fusion operations. At the same time, compared with traditional convolution, this operation can significantly reduce the computational amount while maintaining rich features, improving the classification efficiency. Finally, the classification network outputs classification information based on the target feature vector, completing the efficient classification of the network traffic data. In the whole process, the combination of the feature extraction network and the classification network not only reduces the consumption of computing resources but also significantly improves the accuracy of classification, especially in different application scenarios that require high-precision classification, which is particularly prominent. Therefore, the problem in the related technology of being unable to efficiently classify network traffic data is solved, and the effect of efficiently classifying network traffic data is achieved.

[0051] In an exemplary embodiment, before obtaining the initial input data, the above method further includes: performing a first segmentation operation on the above network traffic data to obtain first network traffic data, where the above preprocessing operation includes the above first segmentation operation, and the first segmentation operation is an operation of segmenting the above network traffic data according to packets with the same multi-tuple; performing a cleaning operation on the above first network traffic data to obtain second network traffic data, where the above preprocessing operation includes the above cleaning operation, and the cleaning operation is an operation of removing redundant data from the above first network traffic data; performing a normalization operation on the above second network traffic data to obtain the above initial input data, where the above preprocessing operation includes the above normalization operation, and the normalization operation is an operation of unifying the data format of the above second network traffic data input into the above feature extraction network.

[0052] Optionally, the network traffic data consists of multiple.pcap format files, and the feature extraction network cannot directly process it. Therefore, a series of preprocessing operations need to be performed on it to convert it into a format that can be directly input into the feature extraction network.

[0053] Optionally, the first segmentation operation includes, but is not limited to, a traffic segmentation operation. The multi-tuple can be a five-tuple, including the source Internet Protocol Address (abbreviated as IP address), source port, destination IP address, destination port, and transport layer protocol. The first segmentation operation is used to segment the network traffic data according to packets with the same multi-tuple to obtain several two-way session flows, without limiting the specific information of the multi-tuple.

[0054] Optionally, the cleaning operation includes, but is not limited to, data cleaning operations for removing some relatively useless redundant information in the global header and data packet header of network traffic data, and filtering and deleting duplicate file packets in the network traffic data, etc.

[0055] Optionally, the standardization operation includes, but is not limited to, data standardization operations to meet the requirements of the feature extraction network for unified input data dimensions. For example, for network traffic data with a length greater than 784 bytes, the first 784 bytes are intercepted as valid input. For network traffic data with a length less than 784 bytes, padding with 0s is performed on the insufficient part. For the network traffic data with unified length, it can be optionally converted into a grayscale image in binary format for visualizing the network traffic data in terms of representation. Finally, the standardized network traffic data is converted into a specific input file format.

[0056] In this embodiment, through the first segmentation operation, data packets with the same communication characteristics can be aggregated together to form logically related data streams. Through the cleaning operation, redundant or useless information in the first network traffic data after segmentation can be removed. Through the standardization operation, the format and size of the second network traffic data after cleaning are unified to ensure that all data can be input into the feature extraction network in the same format and size, achieving the purpose of improving the efficiency and accuracy of feature extraction.

[0057] In an exemplary embodiment, inputting the above initial input data into the above first feature extraction sub-network to obtain the first feature vector output by the above first feature extraction sub-network includes: inputting the above initial input data into the first depth convolution layer in the above first feature extraction sub-network to obtain the above first feature vector output by the above first depth convolution layer.

[0058] Optionally, the first depth convolution layer is used to convert the initial input data into a feature representation for further analysis and learning by the attention sub-network, providing a preliminary data basis for the subsequent attention sub-network.

[0059] Optionally, the first feature vector is the data processed by the first depth convolution layer, and the first depth convolution layer has extracted primary features from the initial input data, such as statistical features such as the edges, textures, lengths, and frequencies of data packets.

[0060] In this embodiment, the initial input data is converted into the first feature vector through the first depth convolution layer, achieving the purpose of reducing the computational complexity.

[0061] In an exemplary embodiment, the above-mentioned first feature vector is input into the above-mentioned attention sub-network. The attention sub-network respectively performs a pooling operation and a fusion operation on the above-mentioned first feature vector to obtain a second feature vector output by the attention sub-network, including: respectively performing the above-mentioned pooling operation on the above-mentioned first feature vector in multiple network branches to obtain multiple branch feature vectors, where the above-mentioned network branches are determined according to the dimension of the above-mentioned first feature vector, and one above-mentioned network branch outputs one above-mentioned branch feature vector; performing the above-mentioned fusion operation on the multiple above-mentioned branch feature vectors to fuse the multiple above-mentioned branch feature vectors to obtain the above-mentioned second feature vector.

[0062] Optionally, a network branch is a computational path or module in a feature extraction network that parallelly processes features of different dimensions of input data, and is a way and structure for processing the first feature vector. For example, if the first feature vector is a multi-dimensional tensor with a shape of H×W×G, where H represents the height of the first feature vector, W represents the width, and G represents the number of channels, then the network branches include a channel branch, a height branch, and a width branch. Specifically, the channel branch focuses on features in the channel dimension, the height branch focuses on features in the height dimension, and the width branch focuses on features in the width dimension.

[0063] Optionally, performing the above-mentioned fusion operation on the multiple above-mentioned branch feature vectors to fuse the multiple above-mentioned branch feature vectors to obtain the above-mentioned second feature vector includes: calculating the product of the multiple branch feature vectors to obtain the second feature vector. For example, if the branch feature vectors output by three network branches are X C , X H , X W , then the second feature vector is

[0064] In this embodiment, by performing a pooling operation on the first feature vector in each network branch, the size of the first feature vector can be reduced while retaining or enhancing the key features in the first feature vector. Moreover, the first feature vector can be understood from multiple perspectives. Then, the attention sub-network fuses the branch feature vectors generated by the network branches, which can construct a more comprehensive and accurate second feature vector, achieving the purpose of precisely mining the key information in the first feature vector that needs more attention.

[0065] In an exemplary embodiment, the pooling operation is performed on the first feature vector in a plurality of the above-mentioned network branches respectively to obtain a plurality of branch feature vectors, including: for each of the above-mentioned network branches, the pooling operation is performed on the first feature vector in the network branch through the following steps to obtain the branch feature vector: when the network branch includes a channel branch, a first pooling operation and a first convolution operation are performed on the first feature vector in the channel branch to obtain a channel branch feature vector; when the network branch includes a height branch, a second pooling operation is performed on the first feature vector in the height branch to obtain a first height branch feature vector, where the second pooling operation is a pooling operation in a one-dimensional direction; when the network branch includes a width branch, a third pooling operation is performed on the first feature vector in the width branch to obtain a first width branch feature vector, where the third pooling operation is a pooling operation in a one-dimensional direction; a second convolution operation is performed on the first height branch feature vector and the first width branch feature vector to obtain a height branch feature vector and a width branch feature vector; the channel branch feature vector, the height branch feature vector and the width branch feature vector are determined as the branch feature vector.

[0066] Optionally, the first pooling operation includes, but is not limited to, a max pooling operation and an average pooling operation.

[0067] Optionally, the first convolution operation is implemented by a second depth convolution layer and a first pointwise convolution layer.

[0068] Optionally, the second pooling operation and the third pooling operation include, but are not limited to, an average pooling operation.

[0069] Optionally, the second convolution operation is implemented by a second pointwise convolution layer.

[0070] In this embodiment, by performing a pooling operation and a convolution operation on the first feature vector in a plurality of network branches, multi-dimensional features of network traffic data can be effectively extracted and fused, achieving the purpose of improving the accuracy of the classification result of network traffic data.

[0071] In an exemplary embodiment, when the above network branch includes a channel branch, a first pooling operation and a first convolution operation are performed on the above first feature vector in the above channel branch to obtain a channel branch feature vector, including: performing a max pooling operation on the above first feature vector in the above channel branch to obtain a third feature vector; performing an average pooling operation on the above first feature vector in the above channel branch to obtain a fourth feature vector; performing a first concatenation operation on the above third feature vector and the above fourth feature vector based on the channel dimensions of the above third feature vector and the above fourth feature vector to obtain a fifth feature vector; inputting the above fifth feature vector into a second depth convolution layer in the above attention subnetwork to obtain a sixth feature vector output by the above second depth convolution layer, where the above second depth convolution layer is used to extract the spatial encoding information within each channel of the above fifth feature vector; inputting the above sixth feature vector into a first pointwise convolution layer in the above attention subnetwork to obtain a seventh feature vector output by the above first pointwise convolution layer, where the above first pointwise convolution layer is used to extract the spatial encoding information between each channel of the above sixth feature vector; sequentially performing a first normalization operation and a first activation operation on the above seventh feature vector to obtain an eighth feature vector; calculating the product between the above eighth feature vector and the above first feature vector to obtain a ninth feature vector; calculating the sum value between the above ninth feature vector and the above first feature vector to obtain the above channel branch feature vector.

[0072] Optionally, the max pooling operation is used to select the maximum value as the output within each local region of the first feature vector, which can reduce the size of the first feature vector while retaining the most important local features. In the channel branch, performing the max pooling operation on the first feature vector is carried out in the channel dimension to identify and retain the maximum feature value in each channel. For example, if the shape of the first feature vector is (H×W×G), the max pooling operation can extract the maximum value feature of each of the G channels to form a third feature vector of (H×W×G).

[0073] Optionally, the average pooling operation is used to select the average value as the output within each local region of the first feature vector. In the channel branch, performing the average pooling operation on the first feature vector is also carried out in the channel dimension, which can capture the relatively smooth statistical features within the channel. For example, performing average pooling on the first feature vector will obtain a fourth feature vector with the same shape of (H×W×G).

[0074] Optionally, the first concatenation operation is used to concatenate the third and fourth feature vectors in the channel dimension after the max pooling operation and the average pooling operation are completed. This step can combine the results of the two pooling operations to form a more expressive fifth feature vector, reducing the dilution of local prominent features by the average pooling operation and strengthening the representation of secondary features that were ignored in the max pooling operation, thus integrating the advantages of the two pooling operations.

[0075] Optionally, the second depth convolutional layer and the first pointwise convolutional layer are used to implement a depthwise separable convolution operation. The second depth convolutional layer can be a depth convolutional layer for extracting the spatial encoding information within each channel of the fifth feature vector.

[0076] Optionally, the first pointwise convolutional layer is used to extract the spatial encoding information between each channel of the sixth feature vector.

[0077] Optionally, the first normalization operation can be a batch normalization operation. The first activation operation can be a sigmoid activation operation.

[0078] In this embodiment, through the max pooling and average pooling operations, the most representative statistical features in the channel dimension, namely the maximum value and the average value, can be extracted from the first feature vector, which represent the local most significant features and the global stable features respectively. These two features are fused into the fifth feature vector through the concatenation operation, increasing the information dimension and achieving the purpose that the attention sub-network can simultaneously consider the local peak and the global average, thereby enhancing the expressiveness of the features.

[0079] In this embodiment, by processing the fifth feature vector through the second depth convolutional layer, deeper spatial encoding information can be extracted within the channel. This operation is lighter than the traditional convolution, avoiding information loss and helping to capture more complex feature patterns in the high-dimensional space, achieving the purpose of improving the attention sub-network's ability to understand the internal details of the channel.

[0080] In this embodiment, the first normalization operation can adjust the distribution of the feature vector to ensure the stability and efficiency in the feature extraction process. The first activation operation introduces non-linearity, increasing the expressiveness of the attention sub-network, enabling the attention sub-network to learn more complex feature relationships, and achieving the purpose of obtaining a more reasonable and more discriminative feature representation.

[0081] In an exemplary embodiment, a second convolution operation is performed on the first height branch feature vector and the first width branch feature vector to obtain a height branch feature vector and a width branch feature vector, including: inputting the concatenated feature vector into a second pointwise convolution layer in the attention sub-network to obtain a first concatenated feature vector, where the concatenated feature vector is a feature vector obtained by performing a second concatenation operation on the first height branch feature vector and the first width branch feature vector; sequentially performing a second normalization operation and a second activation operation on the first concatenated feature vector to obtain a second concatenated feature vector; performing a second splitting operation on the second concatenated feature vector to obtain a second height branch feature vector and a second width branch feature vector; and sequentially inputting the second height branch feature vector and the second width branch feature vector into a third pointwise convolution layer in the attention sub-network to respectively obtain the height branch feature vector and the width branch feature vector output by the third pointwise convolution layer.

[0082] Optionally, the second normalization operation may be a batch normalization operation. The second activation operation may be a sigmoid activation operation. The third pointwise convolution layer is used for channel dimension upsampling.

[0083] In this embodiment, through the second convolution operation, a height branch feature vector and a width branch feature vector containing more dimensional information and more complex feature representations are obtained, achieving the purpose of improving the classification accuracy.

[0084] In an exemplary embodiment, inputting the second feature vector into the second feature extraction sub-network to obtain the target feature vector output by the second feature extraction sub-network, including: inputting the second feature vector into a fourth pointwise convolution layer in the second feature extraction sub-network to obtain a tenth feature vector output by the fourth pointwise convolution layer, where the fourth pointwise convolution layer is used to expand the channel dimension of the second feature vector; inputting the tenth feature vector into a fifth pointwise convolution layer in the second feature extraction sub-network to obtain an eleventh feature vector output by the fifth pointwise convolution layer, where the fifth pointwise convolution layer is used to reduce the channel dimension of the tenth feature vector; and inputting the eleventh feature vector into a third depth convolution layer in the second feature extraction sub-network to obtain the target feature vector output by the third depth convolution layer.

[0085] Optionally, the fourth pointwise convolution layer is used for the fusion of inter-channel information and the expansion of the channel dimension, learning more types of feature representations from richer channel information.

[0086] Optionally, the fifth pointwise convolution layer can reduce the complexity of the feature vector and the computational cost of subsequent processing by changing the number of output channels of the convolution kernel, while maintaining the representational ability of the feature vector.

[0087] In this embodiment, the process of obtaining the target feature vector by processing the second feature vector through the second feature extraction sub-network is actually through the channel expansion and reduction of pointwise convolution and the spatial feature extraction of depth convolution, which can effectively improve the feature expression ability of the feature extraction network, reduce the consumption of computing resources, and enhance the generalization performance of the feature extraction network. In the classification task, the target feature vector can more accurately reflect the internal attributes of network traffic, helping the classifier make more accurate decisions. Especially when dealing with high-dimensional and complex-structured traffic data, the advantages of this feature processing method are particularly obvious.

[0088] In an exemplary embodiment, inputting the above target feature vector into a pre-trained classification network to obtain the classification information of the above network traffic data output by the above classification network includes: inputting the above target feature vector into the dense fully-connected layer in the above classification network to obtain a first target feature vector output by the dense fully-connected layer; inputting the first target feature vector into the first function layer in the above classification network to obtain the classification information of the above network traffic data output by the first function layer.

[0089] Optionally, the dense fully-connected layer includes but is not limited to a first dense fully-connected layer and a second dense fully-connected layer. Among them, the first dense fully-connected layer is used to perform a linear combination of the target feature vector output by the second feature extraction sub-network, and the second dense fully-connected layer is used to match the format of the data output by the classification network, that is, the number of classification categories in the classification information.

[0090] Optionally, the first function layer includes but is not limited to a softmax function layer.

[0091] Through the combined use of the dense fully-connected layer and the first function layer in this embodiment, not only can the information in the target feature vector be effectively transformed and integrated, improving the operation efficiency and decision-making quality of the classification network, but also the generalization ability and adaptability of the model can be enhanced, achieving the purpose of maintaining high classification accuracy and response speed when facing complex and changing network traffic data.

[0092] The present invention will be described below with specific embodiments:

[0093] As Figure 3 shown, Figure 3 is a flowchart of a method for classifying network traffic data according to a specific embodiment of the present application, including the following steps:

[0094] S302, obtain network traffic data.

[0095] S304, such as Figure 4 shown Figure 4 is a schematic diagram of a preprocessing operation in a specific embodiment of the present application. First, perform a traffic segmentation operation to split the network traffic data according to packets with the same five-tuple (source IP address, source port, destination IP address, destination port, transport layer protocol) to obtain a number of two-way session flows. Then, perform a data cleaning operation to remove some relatively useless redundant information in the global header and data header of the network traffic data, and filter and delete duplicate file packets in the network traffic data. Finally, perform a standardization operation. For network traffic data with a length greater than 784 bytes, intercept the first 784 bytes as the valid input. For network traffic data with a length less than 784 bytes, perform a zero-padding operation on the insufficient part. For the network traffic data with a unified length, it can be optionally converted into a grayscale image in binary format to facilitate the visualization of the network traffic data in terms of representation. Finally, convert the standardized network traffic data into a specific input file format.

[0096] S306, after obtaining the network traffic data after the preprocessing operation, divide it into a training set and a test set according to a certain ratio.

[0097] S308, input the training set data into the initial feature extraction network and perform multiple rounds of iterative training. After the training tends to converge, save the network model parameters with the best effect to obtain the best model (corresponding to the above-mentioned feature extraction network).

[0098] S310, after the preprocessing operation, the network traffic data can be directly input into the feature extraction network. Considering the requirement for network lightweight in the potential application scenarios of the network traffic classification task, different from traditional deep neural networks, in this embodiment, ordinary convolutions are replaced with a combination of several depth convolutions and pointwise convolutions, and an attention module (corresponding to the above-mentioned attention network) is embedded between the convolutional layers, such as Figure 5 shown Figure 5 is a schematic diagram of a feature extraction network in a specific embodiment of the present application. Among them, the first depth convolutional layer is the first feature extraction sub-network, and the fourth pointwise convolutional layer, the fifth pointwise convolutional layer, and the third depth convolutional layer are the second feature extraction sub-network.

[0099] Specifically, a first depth convolutional layer and a third depth convolutional layer are respectively placed at the head and tail ends of the feature extraction network, which can extract the spatial information inside the channels in the high-dimensional space; the fourth pointwise convolutional layer and the fifth pointwise convolutional layer are located between the two first depth convolutional layers and the third depth convolutional layer at the head and tail, and are respectively responsible for expanding and reducing the channel dimension, playing the role of reducing the number of network parameters; in a deep learning model, if there are many stacked convolutional layers, the problem of gradient disappearance may occur. At this time, adding residual connections can effectively alleviate this problem. As Figure 5 shown, the dotted line represents the residual connection of the residual connection. The addition method is to add the input value at the head of the model to the output value at the tail of the model to obtain the added output value. Compared with the bottleneck residual block in the classical network, in this embodiment, the depth convolutional operation is moved from the low-dimensional space to the high-dimensional space, reducing the spatial domain information encoding phenomenon caused by the 1×1 pointwise convolutional operation, and can extract richer feature representations.

[0100] When using the feature extraction network for feature extraction, the early approach was usually to stack multiple convolutional layers. However, when stacked to a certain number, it can no longer bring benefits in terms of effect except for increasing the computational complexity of the feature extraction network. The attention module in this embodiment can overcome the above technical problems. Specifically, as Figure 6 shown, the input data X (corresponding to the above first feature vector) in the attention module is formed by the initial input data after preprocessing through the first convolutional layer in the feature extraction network, with the shape of H×W×G, that is, X∈R H×W×G . For the input data X, one-dimensional feature encoding operations are respectively performed on its three dimensions to form three parallel network branches. According to the dimension of the encoding operation, these three network branches are respectively named the C branch (corresponding to the above channel branch), the H branch (corresponding to the above height branch), and the W branch (corresponding to the above width branch).

[0101] 1), In the C branch, first perform the Z-pool operation on the input data X. The Z-pool operation means first performing the max-pooling operation and the average-pooling operation on the input data X respectively in the channel dimension, and then the third feature vector obtained by the max-pooling operation and the fourth feature vector obtained by the average-pooling operation, and finally performing the first concatenation operation in the channel dimension to form a fifth feature vector containing spatial information. The shape of the fifth feature vector is H×W×2. The Z-pool operation reduces the dilution of local prominent features by average pooling and also strengthens the representation of secondary features that are ignored in max pooling, integrating the advantages of the two pooling operations. The Z-pool operation can be expressed by the following formula: X Z-pool =concat C [Maxpool C (X),Avgpool C(X), where Maxpool C (X) and Avgpool C (X) respectively represent the max - pooling operation and the average - pooling operation in the channel dimension.

[0102] Next, the fifth feature vector is input into the second depth - wise convolutional layer to extract the spatial encoding information within each channel of the fifth feature vector, obtaining the sixth feature vector. Then, the sixth feature vector is input into the first point - wise convolutional layer to extract the spatial encoding information between each channel of the sixth feature vector. The depth - separable convolution process (corresponding to the processing processes of the above - mentioned second depth - wise convolutional layer and the first point - wise convolutional layer) is shown in the following formula (2): where PW represents point - wise convolution, and DW 7×7 represents a 7×7 depth - wise convolution.

[0103] Next, batch normalization operation (corresponding to the above - mentioned first normalization operation) and sigmoid activation operation (corresponding to the above - mentioned first activation operation) are performed on the sixth feature vector to obtain the eighth feature vector. To avoid the problems of gradient vanishing and network degradation, the eighth feature vector and the input data X are first multiplied and then added to obtain the channel - branch feature vector X C of branch C. This process is shown in the following formula: where represents element - wise multiplication, and σ represents the sigmoid activation function and batch normalization operation.

[0104] 2) For branches H and W, one - dimensional average - pooling operations are respectively performed on the input data X in the H and W dimensions to generate a pair of first - height - branch feature vectors along the horizontal direction and first - width - branch feature vectors along the vertical direction, as shown in the following formulas respectively: X H-pool = Avgpool H (X), X W-pool = Avgpool W (X), where X H-pool ∈R 1×W×G , X W-pool ∈R H ×1×G . The above two transformations decompose the global average - pooling calculation process in channel attention into two one - dimensional pooling operations, which can capture long - range dependencies along one spatial direction while retaining accurate position information along the other direction. To effectively capture the interaction relationship between channels, the first - height - branch feature vector and the first - width - branch feature vector are concatenated and then passed through a shared point - wise convolutional layer (corresponding to the above - mentioned second point - wise convolutional layer), and after the second activation operation, the second concatenated feature vector Z is generated, as shown in the following formula:

[0105] Z = δ(PW(concat[X H-pool , X W-pool )), where δ represents a non - linear activation function, Z ∈ R 1×(H+W)×(G / R) , and R represents the reduction rate of the parameters. Then, the second concatenated feature vector is split into a second height - branch feature vector Z h and a second width - branch feature vector Z w , and each is then dimension - increased in channels through two point - wise convolutional layers (corresponding to the above - mentioned third point - wise convolutional layer), and transformed into a height - branch feature vector X H-pool and a width - branch feature vector X W-pool that have the same shape as X H and X W respectively, which are the outputs of the H and W branches. The calculations of X H and X W are shown as follows: X H = σ(PW((Z h ))), X W = σ(PW((Z w ))), where σ represents the sigmoid activation function, Z h ∈ R 1×W×(G / R) , Z w ∈ R H×1×(G / R) . The outputs X C , X H , and X W of the three network branches are multiplied to obtain the second feature vector Y output by the attention module, as shown in the following formula:

[0106] Finally, the second feature vector is successively input between the fourth point - wise convolutional layer, the fifth point - wise convolutional layer, and the third depth - wise convolutional layer to obtain the target feature vector.

[0107] S312, in the classification problem of deep learning, the classifier (corresponding to the above - mentioned classification network) is a key component, and its main function is to judge the category of the input data. In this embodiment, the classifier consists of two dense fully - connected layers (corresponding to the above - mentioned dense fully - connected layer) and one softmax function layer (corresponding to the above - mentioned first function layer). The input of the classifier is the target feature vector. Among them, the number of nodes in the second dense fully - connected layer is determined by the number of categories of the classification task. For example, when performing intrusion detection on the traffic data of the financial system, the input samples respectively output the probabilities belonging to two categories after passing through the softmax classifier, and the category with the higher probability value is taken as the category classified by the classifier, so as to realize the judgment of malicious and benign traffic categories.

[0108] S314, output the classification result.

[0109] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, in essence, or the part that makes a contribution to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions for causing a terminal device (which may be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of the various embodiments of the present application.

[0110] In this embodiment, a classification device for network traffic data is also provided. This device is used to implement the above embodiments and preferred implementation methods, and those that have been described will not be repeated. As used below, the term "module" can be a combination of software and / or hardware that can achieve a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware is also possible and contemplated.

[0111] Figure 7 is a structural block diagram of a classification device for network traffic data according to an embodiment of the present application. As Figure 7 shown, the device includes:

[0112] A first acquisition module 702, configured to acquire initial input data, where the initial input data is data obtained after performing a preprocessing operation on network traffic data;

[0113] A first input module 704, configured to input the initial input data into a pre-trained feature extraction network, and use the feature extraction network to perform a feature extraction operation on the initial input data to obtain a target feature vector. The feature extraction network includes a first feature extraction sub-network, an attention sub-network, and a second feature extraction sub-network. The process of the feature extraction operation includes: a first input sub-module, configured to input the initial input data into the first feature extraction sub-network to obtain a first feature vector output by the first feature extraction sub-network; a second input sub-module, configured to input the first feature vector into the attention sub-network, and the attention sub-network sequentially performs a pooling operation and a fusion operation on the first feature vector to obtain a second feature vector output by the attention sub-network; a third input sub-module, configured to input the second feature vector into the second feature extraction sub-network to obtain the target feature vector output by the second feature extraction sub-network;

[0114] The first output module 706 is configured to input the above-mentioned target feature vector into a pre-trained classification network to obtain classification information of the above-mentioned network traffic data output by the above-mentioned classification network.

[0115] In an exemplary embodiment, the above-mentioned apparatus further includes: a first execution module, configured to perform a first segmentation operation on the above-mentioned network traffic data to obtain first network traffic data before obtaining the initial input data, where the above-mentioned preprocessing operation includes the above-mentioned first segmentation operation, and the above-mentioned first segmentation operation is an operation of segmenting the above-mentioned network traffic data according to data packets with the same multi-tuples; a second execution module, configured to perform a cleaning operation on the above-mentioned first network traffic data to obtain second network traffic data, where the above-mentioned preprocessing operation includes the above-mentioned cleaning operation, and the above-mentioned cleaning operation is an operation of removing redundant data in the above-mentioned first network traffic data; a third execution module, configured to perform a normalization operation on the above-mentioned second network traffic data to obtain the above-mentioned initial input data, where the above-mentioned preprocessing operation includes the above-mentioned normalization operation, and the above-mentioned normalization operation is an operation of unifying the data format of the above-mentioned second network traffic data input into the above-mentioned feature extraction network.

[0116] In an exemplary embodiment, the above-mentioned first input sub-module includes: a first input unit, configured to input the above-mentioned initial input data into a first depth convolution layer in the above-mentioned first feature extraction sub-network to obtain the above-mentioned first feature vector output by the above-mentioned first depth convolution layer.

[0117] In an exemplary embodiment, the above-mentioned second input sub-module includes: a first execution unit, configured to perform the above-mentioned pooling operation on the above-mentioned first feature vector in multiple network branches respectively to obtain multiple branch feature vectors, where the above-mentioned network branches are determined according to the dimension of the above-mentioned first feature vector, and one of the above-mentioned network branches outputs one of the above-mentioned branch feature vectors; a second execution unit, configured to perform the above-mentioned fusion operation on the multiple above-mentioned branch feature vectors to fuse the multiple above-mentioned branch feature vectors to obtain the above-mentioned second feature vector.

[0118] In an exemplary embodiment, the above-mentioned first execution unit includes: for each of the above-mentioned network branches, the following steps are used to perform the above-mentioned pooling operation on the above-mentioned first feature vector in the above-mentioned network branch to obtain the above-mentioned branch feature vector: a first execution subunit, configured to perform a first pooling operation and a first convolution operation on the above-mentioned first feature vector in the above-mentioned channel branch when the above-mentioned network branch includes a channel branch, to obtain a channel branch feature vector; a second execution subunit, configured to perform a second pooling operation on the above-mentioned first feature vector in the above-mentioned height branch when the above-mentioned network branch includes a height branch, to obtain a first height branch feature vector, where the above-mentioned second pooling operation is a pooling operation in a one-dimensional direction; a third execution subunit, configured to perform a third pooling operation on the above-mentioned first feature vector in the above-mentioned width branch when the above-mentioned network branch includes a width branch, to obtain a first width branch feature vector, where the above-mentioned third pooling operation is a pooling operation in a one-dimensional direction; a fourth execution subunit, configured to perform a second convolution operation on the above-mentioned first height branch feature vector and the above-mentioned first width branch feature vector to obtain a height branch feature vector and a width branch feature vector; a first determination subunit, configured to determine the channel branch feature vector, the above-mentioned height branch feature vector, and the width branch feature vector as the above-mentioned branch feature vector.

[0119] In an exemplary embodiment, the above-mentioned first execution sub-unit includes: a first execution sub-sub-unit, configured to perform a max pooling operation on the above-mentioned first feature vector in the above-mentioned channel branch to obtain a third feature vector; a second execution sub-sub-unit, configured to perform an average pooling operation on the above-mentioned first feature vector in the above-mentioned channel branch to obtain a fourth feature vector; a third execution sub-sub-unit, configured to perform a first splicing operation on the above-mentioned third feature vector and the above-mentioned fourth feature vector based on the channel dimension of the above-mentioned third feature vector and the channel dimension of the above-mentioned fourth feature vector to obtain a fifth feature vector; a first input sub-sub-unit, configured to input the above-mentioned fifth feature vector into the second depth convolution layer in the above-mentioned attention sub-network to obtain a sixth feature vector output by the above-mentioned second depth convolution layer, where the above-mentioned second depth convolution layer is configured to extract the spatial encoding information within each channel of the above-mentioned fifth feature vector; a second input sub-sub-unit, configured to input the above-mentioned sixth feature vector into the first pointwise convolution layer in the above-mentioned attention sub-network to obtain a seventh feature vector output by the above-mentioned first pointwise convolution layer, where the above-mentioned first pointwise convolution layer is configured to extract the spatial encoding information between each channel of the above-mentioned sixth feature vector; a third input sub-sub-unit, configured to sequentially perform a first normalization operation and a first activation operation on the above-mentioned seventh feature vector to obtain an eighth feature vector; a first calculation sub-sub-unit, configured to calculate the product between the above-mentioned eighth feature vector and the above-mentioned first feature vector to obtain a ninth feature vector; a second calculation sub-sub-unit, configured to calculate the sum value between the above-mentioned ninth feature vector and the above-mentioned first feature vector to obtain the above-mentioned channel branch feature vector.

[0120] In an exemplary embodiment, the above-mentioned fourth execution sub-unit includes: a fourth input sub-sub-unit, configured to input the spliced feature vector into the second pointwise convolution layer in the above-mentioned attention sub-network to obtain a first spliced feature vector, where the above-mentioned spliced feature vector is a feature vector obtained by performing a second splicing operation on the above-mentioned first height branch feature vector and the above-mentioned first width branch feature vector; a fourth execution sub-sub-unit, configured to sequentially perform a second normalization operation and a second activation operation on the above-mentioned first spliced feature vector to obtain a second spliced feature vector; a fifth execution sub-sub-unit, configured to perform a second segmentation operation on the above-mentioned second spliced feature vector to obtain a second height branch feature vector and a second width branch feature vector; a fifth input sub-sub-unit, configured to sequentially input the above-mentioned second height branch feature vector and the above-mentioned second width branch feature vector into the third pointwise convolution layer in the above-mentioned attention sub-network to respectively obtain the above-mentioned height branch feature vector and the above-mentioned width branch feature vector output by the above-mentioned third pointwise convolution layer.

[0121] In an exemplary embodiment, the third input sub-module includes: a first input sub-unit configured to input the second feature vector into a fourth pointwise convolution layer in the second feature extraction sub-network to obtain a tenth feature vector output by the fourth pointwise convolution layer, where the fourth pointwise convolution layer is configured to expand the channel dimension of the second feature vector; a second input sub-unit configured to input the tenth feature vector into a fifth pointwise convolution layer in the second feature extraction sub-network to obtain an eleventh feature vector output by the fifth pointwise convolution layer, where the fifth pointwise convolution layer is configured to reduce the channel dimension of the tenth feature vector; and a third input sub-unit configured to input the eleventh feature vector into a third depth convolution layer in the second feature extraction sub-network to obtain the target feature vector output by the third depth convolution layer.

[0122] In an exemplary embodiment, the first output module includes: a first output sub-module configured to input the target feature vector into a dense fully-connected layer in the classification network to obtain a first target feature vector output by the dense fully-connected layer; and a second output sub-module configured to input the first target feature vector into a first function layer in the classification network to obtain the classification information of the network traffic data output by the first function layer.

[0123] An embodiment of the present application further provides a computer-readable storage medium storing a computer program, where the computer program is configured to execute the steps in any one of the method embodiments when running.

[0124] In an exemplary embodiment, the computer-readable storage medium may include, but is not limited to, various media such as a USB flash drive, a read-only memory (ROM), a random access memory (RAM), a mobile hard disk, a magnetic disk, or an optical disc that can store a computer program.

[0125] An embodiment of the present application further provides an electronic device including a memory and a processor, where the memory stores a computer program, and the processor is configured to run the computer program to execute the steps in any one of the method embodiments.

[0126] In an exemplary embodiment, the electronic device may further include a transmission device and an input / output device, where the transmission device is connected to the processor, and the input / output device is connected to the processor.

[0127] Specific examples in this embodiment may refer to the examples described in the above embodiments and exemplary embodiments, and will not be repeated here.

[0128] Obviously, those skilled in the art should understand that the various modules or steps of the present application described above can be implemented by a general-purpose computing device. They can be concentrated on a single computing device or distributed over a network composed of multiple computing devices. They can be implemented by program code executable by the computing device. Thus, they can be stored in a storage device and executed by the computing device. And in some cases, the steps shown or described can be executed in a different order from here, or they can be separately made into individual integrated circuit modules, or multiple modules or steps among them can be made into a single integrated circuit module for implementation. In this way, the present application is not limited to any specific combination of hardware and software.

[0129] The above are only the preferred embodiments of the present application and are not used to limit the present application. For those skilled in the art, the present application can have various changes and modifications. Any modification, equivalent replacement, improvement, etc. made within the principle of the present application shall be included within the protection scope of the present application.

Claims

1. A method for classifying network traffic data, characterized in that, Including: Obtain initial input data, where the initial input data is data obtained after performing a preprocessing operation on network traffic data; Input the initial input data into a pre-trained feature extraction network, and use the feature extraction network to perform a feature extraction operation on the initial input data to obtain a target feature vector. The feature extraction network includes a first feature extraction sub-network, an attention sub-network, and a second feature extraction sub-network. The process of the feature extraction operation includes: inputting the initial input data into the first feature extraction sub-network to obtain a first feature vector output by the first feature extraction sub-network; inputting the first feature vector into the attention sub-network, and the attention sub-network sequentially performs a pooling operation and a fusion operation on the first feature vector to obtain a second feature vector output by the attention sub-network; inputting the second feature vector into the second feature extraction sub-network to obtain the target feature vector output by the second feature extraction sub-network; Input the target feature vector into a pre-trained classification network to obtain classification information of the network traffic data output by the classification network.

2. The method according to claim 1, wherein Before obtaining the initial input data, the method further includes: Perform a first segmentation operation on the network traffic data to obtain first network traffic data. The preprocessing operation includes the first segmentation operation, and the first segmentation operation is an operation of segmenting the network traffic data according to data packets with the same multi-tuple; Perform a cleaning operation on the first network traffic data to obtain second network traffic data. The preprocessing operation includes the cleaning operation, and the cleaning operation is an operation of removing redundant data from the first network traffic data; Perform a standardization operation on the second network traffic data to obtain the initial input data. The preprocessing operation includes the standardization operation, and the standardization operation is an operation of unifying the data format of the second network traffic data input into the feature extraction network.

3. The method according to claim 1, characterized in that Inputting the initial input data into the first feature extraction sub-network to obtain a first feature vector output by the first feature extraction sub-network includes: Input the initial input data into the first depth convolution layer in the first feature extraction sub-network to obtain the first feature vector output by the first depth convolution layer.

4. The method according to claim 1, wherein Inputting the first feature vector into the attention sub-network, and the attention sub-network respectively performs a pooling operation and a fusion operation on the first feature vector to obtain a second feature vector output by the attention sub-network includes: Respectively perform the pooling operation on the first feature vector in multiple network branches to obtain multiple branch feature vectors. The network branches are determined according to the dimension of the first feature vector, and one network branch outputs one branch feature vector; Perform the fusion operation on multiple branch feature vectors to fuse multiple branch feature vectors to obtain the second feature vector.

5. The method according to claim 4, wherein Performing the pooling operation on the first feature vector in multiple said network branches respectively to obtain multiple branch feature vectors, including: For each said network branch, performing the pooling operation on the first feature vector in the network branch through the following steps respectively to obtain the branch feature vector: When the network branch includes a channel branch, performing a first pooling operation and a first convolution operation on the first feature vector in the channel branch to obtain a channel branch feature vector; When the network branch includes a height branch, performing a second pooling operation on the first feature vector in the height branch to obtain a first height branch feature vector, where the second pooling operation is a pooling operation in one-dimensional direction; When the network branch includes a width branch, performing a third pooling operation on the first feature vector in the width branch to obtain a first width branch feature vector, where the third pooling operation is a pooling operation in one-dimensional direction; Performing a second convolution operation on the first height branch feature vector and the first width branch feature vector to obtain a height branch feature vector and a width branch feature vector; Determining the channel branch feature vector, the height branch feature vector and the width branch feature vector as the branch feature vector.

6. The method according to claim 5, characterized in that, When the network branch includes a channel branch, performing a first pooling operation and a first convolution operation on the first feature vector in the channel branch to obtain a channel branch feature vector, including: Performing a max pooling operation on the first feature vector in the channel branch to obtain a third feature vector; Performing an average pooling operation on the first feature vector in the channel branch to obtain a fourth feature vector; Performing a first concatenation operation on the third feature vector and the fourth feature vector based on the channel dimensions of the third feature vector and the fourth feature vector to obtain a fifth feature vector; Inputting the fifth feature vector into the second depth convolution layer in the attention sub-network to obtain a sixth feature vector output by the second depth convolution layer, where the second depth convolution layer is used to extract the spatial encoding information inside each channel of the fifth feature vector; Inputting the sixth feature vector into the first pointwise convolution layer in the attention sub-network to obtain a seventh feature vector output by the first pointwise convolution layer, where the first pointwise convolution layer is used to extract the spatial encoding information between each channel of the sixth feature vector; Performing a first normalization operation and a first activation operation on the seventh feature vector in sequence to obtain an eighth feature vector; Calculating the product between the eighth feature vector and the first feature vector to obtain a ninth feature vector; Calculating the sum value between the ninth feature vector and the first feature vector to obtain the channel branch feature vector.

7. The method according to claim 5, wherein Performing a second convolution operation on the first height branch feature vector and the first width branch feature vector to obtain a height branch feature vector and a width branch feature vector, including: Input the spliced feature vector into the second pointwise convolutional layer in the attention sub-network to obtain a first spliced feature vector, where the spliced feature vector is a feature vector obtained by performing a second splicing operation on the first height branch feature vector and the first width branch feature vector; Perform a second normalization operation and a second activation operation on the first spliced feature vector in sequence to obtain a second spliced feature vector; Perform a second splitting operation on the second spliced feature vector to obtain a second height branch feature vector and a second width branch feature vector; Input the second height branch feature vector and the second width branch feature vector into the third pointwise convolutional layer in the attention sub-network in sequence to obtain the height branch feature vector and the width branch feature vector output by the third pointwise convolutional layer respectively.

8. The method according to claim 1, wherein Input the second feature vector into the second feature extraction sub-network to obtain the target feature vector output by the second feature extraction sub-network, including: Input the second feature vector into the fourth pointwise convolutional layer in the second feature extraction sub-network to obtain a tenth feature vector output by the fourth pointwise convolutional layer, where the fourth pointwise convolutional layer is used to expand the channel dimension of the second feature vector; Input the tenth feature vector into the fifth pointwise convolutional layer in the second feature extraction sub-network to obtain an eleventh feature vector output by the fifth pointwise convolutional layer, where the fifth pointwise convolutional layer is used to reduce the channel dimension of the tenth feature vector; Input the eleventh feature vector into the third depth convolutional layer in the second feature extraction sub-network to obtain the target feature vector output by the third depth convolutional layer.

9. The method according to claim 1, wherein Input the target feature vector into a pre-trained classification network to obtain the classification information of the network traffic data output by the classification network, including: Input the target feature vector into the dense fully-connected layer in the classification network to obtain a first target feature vector output by the dense fully-connected layer; Input the first target feature vector into the first function layer in the classification network to obtain the classification information of the network traffic data output by the first function layer.

10. A classification device for network traffic data, characterized in that Including: A first acquisition module for acquiring initial input data, where the initial input data is data obtained by performing a preprocessing operation on network traffic data; A first input module, configured to input the initial input data into a pre-trained feature extraction network, and use the feature extraction network to perform a feature extraction operation on the initial input data to obtain a target feature vector. The feature extraction network includes a first feature extraction sub-network, an attention sub-network, and a second feature extraction sub-network. The process of the feature extraction operation includes: inputting the initial input data into the first feature extraction sub-network to obtain a first feature vector output by the first feature extraction sub-network; inputting the first feature vector into the attention sub-network, and the attention sub-network sequentially performs a pooling operation and a fusion operation on the first feature vector to obtain a second feature vector output by the attention sub-network; inputting the second feature vector into the second feature extraction sub-network to obtain the target feature vector output by the second feature extraction sub-network; A first output module, configured to input the target feature vector into a pre-trained classification network to obtain classification information of the network traffic data output by the classification network.

11. A computer-readable storage medium, characterized in that, A computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 9 are implemented.

12. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 9 are implemented.