Transform-based comprehensive feature network traffic classification method

Through the comprehensive feature network traffic classification method based on Transformer, multiple features of network traffic are extracted and integrated, solving the problem of encrypted traffic classification in existing technologies, achieving fast and accurate traffic identification and network security monitoring, and improving network performance. and security.

CN118740428AActive Publication Date: 2024-10-01NANJING UNIV OF POSTS & TELECOMM

Patent Information

Application Number
CN202410748223.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-10-01
Estimated Expiration
2044-06-11

AI Technical Summary

Technical Problem

Existing network traffic classification methods are difficult to adapt to the dynamically changing network environment, especially when faced with encrypted traffic, they cannot classify quickly and accurately. Moreover, traditional methods require manual extraction of features, have high computational complexity, and cannot handle encrypted traffic.

Method used

A comprehensive feature network traffic classification method based on Transformer is used to classify data through data preprocessing, extraction of statistical features, global features, local features and time series features, and feature fusion, combined with fully connected neural networks and softmax functions.

Benefits of technology

It improves the accuracy and reliability of network traffic classification, can handle encrypted traffic, reduces computing and storage requirements, is suitable for large-scale data processing, and enhances network security monitoring and performance optimization capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118740428A_ABST
    Figure CN118740428A_ABST
Patent Text Reader

Abstract

The invention relates to a comprehensive feature network flow classification method based on Transform, and the comprehensive feature network flow classification method considers statistical features, global features, local features and time sequence features of flow data at the same time, makes full use of the advantages of different features, and can effectively improve the comprehensiveness and accuracy of network flow classification. A deep learning-based method needs to unify the traffic size, which results in information loss of the overall structure of the network traffic. According to the method, statistical features extracted based on an auto-encoder, local features extracted based on a convolutional neural network, global features extracted based on Transform and time sequence features extracted based on a gating cycle unit are subjected to feature fusion to generate comprehensive flow features, so that a feature set is more comprehensive, and the performance of a classifier is improved. In the classification module, a bottleneck module and residual connection are combined and used, so that the performance of the model is maintained, the requirements of calculation and storage are reduced, and the model is more suitable for processing large-scale one-dimensional data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network security technology, and in particular to a Transformer-based comprehensive feature network traffic classification method. Background Art

[0002] With the rapid development of computer networks, the Internet has become an indispensable part of modern life. More and more people use the Internet to communicate information, and traffic data increases year by year, posing a huge hidden danger to the security of cyberspace. On the one hand, the huge network traffic needs to be analyzed so that computers can reasonably allocate resources and improve network service efficiency; on the other hand, timely detection and identification of the growing malicious traffic on the network can enhance the network's rapid recovery and emergency response capabilities, which is of great value and significance for resisting abnormal network attacks and maintaining cyberspace security and the privacy of private Internet users.

[0003] In the field of network traffic classification, after continuous research and practice by domestic and foreign researchers, a series of achievements have been made. Commonly used traffic classification methods mainly include: port identification-based methods, deep packet inspection-based methods, statistical feature-based methods, and deep learning-based methods. With the emergence of dynamic ports in modern networks, port identification-based methods are no longer applicable. The deep packet inspection-based method determines the traffic type by matching fingerprints, which has high computational complexity and cannot handle encrypted traffic. The statistical feature-based method requires feature engineering of network traffic data and manually extracts representative features of traffic data, which will cost a lot of manpower and cannot guarantee whether the extracted features are effective for traffic classification. Traditional network traffic classification methods are difficult to adapt to dynamically changing network environments, especially when facing encrypted traffic. In high-speed network environments, traffic classification technology needs to classify quickly and accurately to meet the needs of service quality and network security. In order to overcome these problems, researchers and engineers need to continuously explore new traffic classification technologies, such as deep learning-based methods.

[0004] The deep learning-based method reduces the stage of manual feature extraction and further improves the classification accuracy by using the strong fitting ability of neural networks to data distribution. Most neural networks require fixed-size inputs, so the original traffic needs to be pruned, which will cause important information loss. Statistical features can be used to supplement the information loss caused by pruning. Transformer is a deep learning model. Due to its powerful sequence modeling capabilities, Transformer is also used in the field of network traffic classification. Transformer is good at capturing long-distance information in network traffic sequences, that is, global features, but ignores local details. One-dimensional convolutional neural networks are specifically designed to process sequence data. They can capture local patterns and long-distance dependencies in time series, but ignore long-distance global features between sequences. Summary of the invention

[0005] In order to solve the above problems existing in the prior art, the present invention proposes a comprehensive feature network traffic classification method based on Transformer. The technical problem to be solved by the present invention is achieved through the following technical solutions:

[0006] The present invention proposes a Transformer-based comprehensive feature network traffic classification method, the method comprising:

[0007] S1: Data preprocessing;

[0008] S2: Use different feature extraction methods to extract statistical features, global features, local features and time series features corresponding to each data sample in the network traffic data;

[0009] S3: Fuse the statistical feature vector, global feature vector, local feature vector and time series feature vector to generate comprehensive features;

[0010] S4: Use fully connected neural network + softmax function to classify network traffic.

[0011] Furthermore, S1 specifically includes:

[0012] S101: dividing continuous flow data into multiple discrete flow units;

[0013] S102: performing data cleaning processing on the segmented flow units;

[0014] S103: Trimming the cleaned traffic data to a fixed length to meet the data input requirements of the neural network.

[0015] Furthermore, S2 specifically includes:

[0016] S201: Extract statistical information from the original network flow data. This information can retain information about the overall structure of the flow and can be used to supplement the structural information of the session, such as the number of packets in the session (Num pkts), the average value of packets with active syn flags in the session (Avg syn flag) and the time from the first packet to the last packet in the session (Duration window flow); use the Max-Min normalization method to normalize the statistical information and distribute all statistical values ​​in the range of [0,1]; the autoencoder encodes the normalized statistical information and extracts low-dimensional statistical features from it.

[0017] S202: The data after S1 is extracted with a feature extraction module based on Transformer to extract global features of traffic data;

[0018] S203: The data after S1 is subjected to a feature extraction module based on one-dimensional convolution to extract local features of the flow data.

[0019] S204: The global features and local features obtained through S202 and S203 are fused, and the fused features are used to extract key timing features using a gated recurrent unit.

[0020] Furthermore, S201 specifically includes:

[0021] The autoencoder includes an encoder and a decoder. The autoencoder is used to encode the normalized statistical information and extract a low-dimensional statistical feature vector from it. Although the manually extracted traffic statistics already contain some key information, the autoencoder can further optimize the feature representation through its automatic feature learning and nonlinear modeling capabilities, thereby potentially improving the accuracy and efficiency of subsequent analysis or prediction tasks.

[0022] Further, S202 specifically includes:

[0023] The Transformer-based feature extraction module uses the encoding part of the Transformer and fine-tunes some of its parameters. The encoder part of the Transformer includes a multi-head attention mechanism and a feedforward neural network.

[0024] Further, S203 specifically includes:

[0025] The one-dimensional convolution module consists of two bottleneck modules, each of which consists of three convolution layers of 1×1, 1×3 and 1×1. Each bottleneck module learns data features by residual connection, and the output of the previous bottleneck module serves as the input of the next bottleneck module.

[0026] Furthermore, S204 specifically includes:

[0027] The global feature vector and the local feature vector are feature expanded to obtain a one-dimensional vector, and then feature fused to generate an initial comprehensive flow;

[0028] Further extracting key timing information from the initial comprehensive flow using a gated recurrent unit to obtain a timing feature vector;

[0029] Furthermore, S3 specifically includes:

[0030] The statistical feature vector and the time series feature vector are concatenated to generate comprehensive features.

[0031] Furthermore, S4 specifically includes:

[0032] Based on the comprehensive features, a fully connected network is adopted, and the softmax function is used for classification to output the encrypted traffic classification results.

[0033] Compared with the prior art, the beneficial effects achieved by the present invention are as follows: the present invention provides a comprehensive feature network traffic classification method based on Transformer. In the preprocessing stage, since the input of the neural network requires a uniform size, the original traffic data will be pruned, which will cause the loss of important information. Statistical features are usually extracted based on expert knowledge or statistical principles, which, to a certain extent, make up for the information loss caused by pruning. The statistical features extracted based on the autoencoder, the local features extracted based on the convolutional neural network, the global features extracted based on the Transformer, and the temporal features extracted based on the gated cyclic unit are fused to generate comprehensive traffic features, so that the feature set is more comprehensive, thereby improving the performance of the classifier. In the classification module, the present invention combines the use of bottleneck modules and residual connections, which can reduce the requirements for calculation and storage while maintaining the performance of the model, making the model more suitable for processing large-scale one-dimensional data. The present invention makes full use of the advantages of different features to improve the performance and reliability of network traffic classification. The diversity and adaptability of this method make it an effective strategy for solving complex classification problems. The method can be applied to multiple fields, mainly used for optimizing network performance, improving network security, network management and analysis, etc. In the field of network management and optimization, this method can automatically identify different types of traffic, such as video, audio, file transfer, and web browsing, for bandwidth allocation and traffic control. Mission-critical traffic can be prioritized based on business needs and service quality requirements. In the field of network security, this method can be used to detect and defend against network attacks, such as DDoS attacks, phishing attacks, malware propagation, etc. By identifying suspicious traffic patterns, intrusion detection and prevention can be performed. In the field of network monitoring and analysis, network traffic data is collected and the method is used for trend analysis and network behavior research to identify network bottlenecks and performance issues. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 A schematic diagram of a Transformer-based comprehensive feature network traffic classification method provided by the present invention;

[0035] Figure 2 It is the overall framework diagram of the model of the method of the present invention.

[0036] Figure 3 This is a specific network structure diagram of the Transformer module and the one-dimensional convolution module of the method of the present invention. DETAILED DESCRIPTION

[0037] In order to make the technical means, creative features, objectives and effects achieved by the present invention easy to understand, the present invention is further explained below in conjunction with specific implementation methods.

[0038] Example 1

[0039] This embodiment provides a comprehensive feature network traffic classification method based on Transformer. Figure 1 A schematic diagram of a Transformer-based comprehensive feature network traffic classification method provided by the present invention is shown in FIG. Figure 1 As shown, the method includes:

[0040] S1: Data preprocessing;

[0041] S2: Use different feature extraction methods to extract statistical features, global features, local features and time series features corresponding to each data sample in the network traffic data in parallel;

[0042] S3: Concatenate the statistical feature vector, global feature vector, local feature vector and temporal feature vector to generate comprehensive features;

[0043] S4: Use fully connected neural network + softmax function to classify network traffic.

[0044] The above method is elaborated in detail:

[0045] Figure 2 The overall framework diagram of the model of the method of the present invention is shown in FIG. Figure 2 As shown:

[0046] The overall framework of the model includes an autoencoder, two Transformer modules, two one-dimensional convolution modules, a feature alignment module, a gated recurrent unit module, and two feature fusion modules;

[0047] Calculate statistical information from raw network traffic data and input the statistical information into the autoencoder to extract statistical features;

[0048] The preprocessed network traffic data is first input into the Transformer module and the one-dimensional convolution module;

[0049] Next, the traffic features generated by the Transformer module and the one-dimensional convolution module are aligned so that the features extracted by the two modules can complement each other, thereby optimizing the feature representation of the network traffic sequence;

[0050] After feature alignment, the feature vectors generated by the Transformer module and the one-dimensional convolution module are expanded respectively, and then the features are fused by splicing the one-dimensional feature vectors to generate the initial comprehensive features;

[0051] Further extracting key timing features from the initial comprehensive features using a gated recurrent unit;

[0052] Performing feature fusion on the key time series features and the statistical features to obtain comprehensive features;

[0053] Perform full connection classification based on comprehensive features and output the classification results.

[0054] Furthermore, the data preprocessing specifically includes:

[0055] Step 1: Network traffic consists of a sequence of packets, and a session is a packet with the same five-tuple (source IP address, source port number, destination IP address, destination port number, and transport protocol type). The continuous raw traffic data is divided into multiple discrete traffic units, i.e., multiple sessions, in a session-based manner.

[0056] Step 2: Data cleaning. After segmenting the traffic into sessions, remove their IP addresses and MAC addresses by masking the relevant strings with 0x00. Each traffic class has a unique IP address in the dataset. If the IP addresses and MAC addresses are not removed, the model may overfit. Empty files and duplicate files are also deleted;

[0057] Step 3, since neural networks require fixed-size input, trim all files to the same length. If the size of the file is greater than 784 bytes, trim it to 784 bytes. If the size of the file is less than 784 bytes, add 0x00 at the end of the file.

[0058] Furthermore, the method of extracting statistical features, global features, local features and time series features corresponding to each data sample in the network traffic data set by using different feature extraction methods specifically includes:

[0059] (1) Extracting statistical features from raw network traffic data

[0060] Step 1: Manually extract a set of numerical features from network traffic data. Wireshark can be used for packet capture and analysis. These features can summarize and describe the key characteristics of traffic data, such as the number of packets in a session (Num pkts), the average value of packets with active syn flags in a session (Avg syn flag), and the time from the first packet to the last packet in a session (Duration window flow).

[0061] Step 2: Perform feature statistics on the original traffic data based on these statistical information. After calculating the statistical data, it is necessary to normalize it and use the Max-Min normalization method to normalize the data. After normalization, all statistical values ​​are distributed in the range of [0,1]; let S be the set of statistical information, s∈S represents a certain statistical value, and the Max-Min normalization calculation formula is:

[0062]

[0063] Among them, s min is the minimum value in S, s max is the maximum value in S, s new is the normalized result.

[0064] Step 3: Use an autoencoder to encode the normalized statistical information and extract a low-dimensional statistical feature vector from it. The autoencoder consists of two parts: an encoder and a decoder. The specific encoding process includes:

[0065] The encoder encodes the high-dimensional input X into a low-dimensional latent variable h, thus forcing the neural network to learn the most informative features; the decoder restores the latent variable h of the hidden layer to its initial dimension. The best state is the decoder output X R Can perfectly or approximately restore the original input X, that is

[0066] X R ≈X

[0067] Specifically, the encoding process of the original data X from the input layer to the hidden layer is:

[0068] h=f encoder (W1X+b1)

[0069] The decoding process from the hidden layer to the output layer is:

[0070] X R =f decoder (W2h+b2)

[0071] Where W1, W2, b1, b2 are the parameters of the autoencoder network, f encoder 、f decoder are the functions of the encoder and decoder respectively.

[0072] (2) Extracting global features of traffic data based on the Transformer module

[0073] The network traffic data is preprocessed, and the preprocessed data is input into the Transformer module for global feature extraction;

[0074] The Transformer module specifically includes:

[0075] The original Transformer model structure includes two parts: encoding and decoding. This invention uses the encoding part of the Transformer and fine-tunes some of its parameters. The Transformer module structure used is as follows: Figure 3As shown, the encoding part includes a multi-head attention mechanism and a feed-forward neural network.

[0076] Step 1: The multi-head attention mechanism uses the self-attention mechanism, including Query, Key, and Value. The Query and Key are used to calculate the weight score assigned to each value, and then the weight is added to the Value to get the output. The attention calculation formula is:

[0077] Q=ZW Q ; K = ZW K ; V = ZW V

[0078]

[0079] Where Q, K, and V represent the Query, Key, and Value matrices respectively; Z represents the input of the encoder; W Q , W K , W V d is the parameter learned by the self-attention mechanism; k is the dimension of Key; the softmax function is an activation function used for multi-class classification problems. The calculation formula of the softmax function is as follows:

[0080]

[0081] where z i is the i-th element in the vector, K is the number of elements in the vector, and e is the base of the natural logarithm.

[0082] Step 2: In order to enrich the extracted features, a multi-head attention structure is used. The multi-head attention calculation formula is as follows:

[0083] MultiHead(Z)=Concat(H1,H2,…H6)W M

[0084] where i∈1,2,…,6,H i The Concat function concatenates the vector sequences output by each attention mechanism into a larger vector sequence. M To learn parameters, its role is to perform a linear transformation on the result of concatenating multiple attention mechanisms.

[0085] Step 3: The output of the multi-head attention mechanism is input into the feedforward neural network after residual connection;

[0086] The residual connection specifically includes:

[0087] Assume that the output of the multi-head attention mechanism is m, and the residual connection is to add the input m and the output F(m). The output of the network is:

[0088] H(m)=F(m)+m

[0089] The feedforward neural network is the data m′ after the output m of the multi-head attention mechanism is residually connected, and then the feedforward neural network performs two linear transformations in order to extract features more deeply.

[0090] The linear transformation introduces a nonlinear activation function. In the multi-head attention mechanism, matrix multiplication is mainly performed, which belongs to linear transformation. However, the learning ability of linear transformation is not as strong as that of nonlinear transformation. The calculation formula of the feedforward neural network is as follows:

[0091] FFN(m′)=Relu(0,m′W′1+b′1)W′2+b′2

[0092] Where m′ is the input of the feedforward neural network, W′1, W′2, b′1, b′2 are the parameters of the feedforward neural network. The Relu function is one of the activation functions of deep learning and is a nonlinear activation function. The mathematical expression is:

[0093] Relu(x)=max(0,x)

[0094] Where x is the input of the function. If the input x is positive, the output of the function is itself; if the input x is negative, the output is 0.

[0095] (3) Extracting local features of traffic data based on one-dimensional convolution module

[0096] like Figure 3 As shown, the one-dimensional convolution module consists of two bottleneck modules, each bottleneck module consists of three convolutional layers of 1×1, 1×3 and 1×1, and each bottleneck module is followed by a residual connection.

[0097] The specific implementation steps are:

[0098] In the process of local feature extraction, after the 1×3 convolution layer of the first bottleneck module, the local feature vectors generated by the one-dimensional convolution module are feature aligned; after the first 1×1 convolution layer of the second bottleneck module, the global features generated by the Transformer module are received, and then the traffic sequence features of the one-dimensional convolution module are obtained.

[0099] The feature alignment specifically includes:

[0100] Since the feature dimensions output by the Transformer module and the one-dimensional convolution module are different, the features of the two blocks cannot be received and fused with each other. Therefore, it is necessary to align the feature channels of the traffic sequences provided by both parties.

[0101] The feature channel alignment specifically includes:

[0102] The average pooling function is used to downsample the features of the one-dimensional convolution module. Specifically, a 1×1 convolution layer is first required to reduce the dimension, and then the spatial dimension of the feature is reduced by calculating the average value of the input feature in each pooling window, that is, reducing the length of the feature vector.

[0103] The features of the Transformer module are upsampled using an interpolation function. Specifically, a 1×1 convolution layer is required to increase the dimension, and then for each feature value, a new feature point is generated between the original feature points using a selected interpolation method to obtain a higher-dimensional feature representation to map the low-dimensional features to a high-dimensional space.

[0104] (4) Feature Fusion Module

[0105] Step 1: After the up-sampling and down-sampling are completed, the generated global features and local features are expanded to generate a one-dimensional feature vector, and then the feature vectors are spliced ​​to generate an initial comprehensive flow;

[0106] Step 2, further extracting key timing feature information from the initial comprehensive flow using a gated recurrent unit;

[0107] The gated recurrent unit specifically comprises:

[0108] The gated recurrent unit controls the flow of information through the update gate and the reset gate. The input of the reset gate and the update gate is composed of the hidden state of the previous time step and the input of the current time step. These two inputs will be put into the fully connected layer in the sigmoid activation function for calculation, and finally the results of these two gates are obtained. The calculation process of the reset gate and the update gate includes:

[0109] For any given time step t, assume that the input is a small batch of data X t , the hidden state of the previous time step is H t-1 , then update gate Z t and reset gate R t The calculation formula is as follows:

[0110] Z t =σ(X t W xz +H t-1 W hz +b z )

[0111] R t =σ(X t W xr +H t-1 W hr +b r )

[0112] Where W xz ,W xr ,W hz ,W hr is the weight parameter, b z ,b r is the bias parameter. The σ function is the sigmoid activation function, which is a nonlinear function that maps the input to the (0,1) interval. Its mathematical expression is:

[0113]

[0114] Where u is the input to the function and e is the natural logarithm base.

[0115] Step 3: Concatenate the statistical features and the key time series features into one-dimensional feature vectors to generate comprehensive features.

[0116] Furthermore, based on the comprehensive features, the network traffic is classified using a fully connected neural network + softmax function.

[0117] In practical applications, the method of the present invention can quickly and accurately identify various network traffic, including encrypted traffic, significantly improving the efficiency and effectiveness of network security monitoring. At the same time, the method takes into account the needs of privacy protection, performance optimization and real-time processing. It solves the problems of traditional network traffic classification methods that are difficult to adapt to dynamically changing network environments, resource consumption, and low real-time performance.

[0118] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A Transformer-based comprehensive feature network traffic classification method, characterized by: The method comprises the following steps: S1: data preprocessing; S2: Use different feature extraction methods to extract statistical features, global features, local features, and temporal features corresponding to each data sample in the network traffic data; S3: Fuse the statistical feature vector, global feature vector, local feature vector and time series feature vector to generate comprehensive features; S4: Based on the comprehensive features, a fully connected network is used, and softmax function is used for classification to output the encrypted traffic classification result.

2. The Transformer-based comprehensive feature network traffic classification method according to claim 1 is characterized in that: Step S1 specifically includes: S101: dividing continuous flow data into multiple discrete flow units; S102: performing data cleaning on the segmented traffic units; S103: Trimming the cleaned traffic data to a fixed length to meet the data input requirements of the neural network.

3. The Transformer-based comprehensive feature network traffic classification method according to claim 1 is characterized in that: Step S2 specifically includes: S201: extracting statistical information from the original network traffic data, S202: The data after S1 is extracted with a Transformer-based feature extraction module to extract global features of the traffic data; S203: The data after S1 is extracted using a feature extraction module based on one-dimensional convolution to extract local features of the flow data. S204: The global features and local features obtained through S202 and S203 are fused, and the fused features are used to extract key timing features using a gated recurrent unit.

4. The Transformer-based comprehensive feature network traffic classification method according to claim 1 is characterized in that: Step S1 data preprocessing specifically includes: Step 1: Network traffic consists of a sequence of data packets. A session is a data packet with the same five-tuple (source IP address, source port number, destination IP address, destination port number, and transport protocol type). Continuous raw traffic data is divided into multiple discrete traffic units, i.e., multiple sessions, in a session-based manner. Step 2: Data cleaning. After segmenting the traffic into sessions, their IP and MAC addresses are removed by masking the relevant strings with 0x00. Each traffic class has a unique IP address in the dataset. If the IP and MAC addresses are not removed, the model may overfit. Empty and duplicate files are also removed. Step 3: Since the neural network requires fixed-size input, all files are trimmed to the same length. If the size of the file is greater than 784 bytes, it is trimmed to 784 bytes. If the size of the file is less than 784 bytes, 0x00 is added to the end of the file.

5. The Transformer-based comprehensive feature network traffic classification method according to claim 3 is characterized in that: S201: Extract statistical information from the original network traffic data, as follows: Step 1: Manually extract a set of numerical features from the network traffic data. Use Wireshark to capture and analyze packets. These features can summarize and describe the key characteristics of the traffic data. Common statistical information includes the following: the number of packets in the session (Num pkts), the average number of packets with active syn flags in the session (Avg syn flag), and the time from the first packet to the last packet in the session (Duration window flow). Step 2: Perform feature statistics on the original traffic data based on these statistical information. After the statistical data is calculated, it needs to be normalized. The Max-Min normalization method is used to normalize the data. After normalization, all statistical values ​​are distributed in the range of [0, 1]. Let S be the set of statistical information, s∈S represents a statistical value therein, and the Max-Min normalization calculation formula is: Among them, s min is the minimum value in S, s max is the maximum value in S, s new is the normalized result, Step 3: Use an autoencoder to encode the normalized statistical information and extract a low-dimensional statistical feature vector from it. The autoencoder consists of two parts: an encoder and a decoder. The specific encoding process includes: The encoder encodes the high-dimensional input X into a low-dimensional latent variable h, thereby forcing the neural network to learn the most informative features; the role of the decoder is to restore the latent variable / h of the hidden layer to its initial dimension. The best state is the decoder output X R Can approximately restore the original input X, that is X R ≈X Specifically, the encoding process of the original data X from the input layer to the hidden layer is: h=f encoder (W1X+b1) The decoding process from the hidden layer to the output layer is: X R =f decoder (W2h+b2) Where W1, W2, b1, b2 are the parameters of the autoencoder network, f encoder 、f decoder are the encoder and decoder functions respectively.

6. The Transformer-based comprehensive feature network traffic classification method according to claim 3 is characterized in that: S202: Extract global features of traffic data based on the Transformer module, as follows: The network traffic data undergoes data preprocessing, and the preprocessed data is input into the Transformer module for global feature extraction; The Transformer module specifically includes: The original Transformer model structure consists of two parts: encoding and decoding. The encoding part of the Transformer is used and its parameters are fine-tuned. The encoding part includes a multi-head attention mechanism and a feedforward neural network. Step 1: The multi-head attention mechanism uses the self-attention mechanism, including Query, Key, and Value. The Query and Key are used to calculate the weight score assigned to each value, and then the weight is added to the Value to get the output. The attention calculation formula is: Q=ZW Q ;K=ZW K ;V=ZW V Where Q, K, and V represent the Query, Key, and Value matrices respectively; Z represents the input of the encoder; W Q , W K , W V d is the parameter learned by the self-attention mechanism; k is the dimension of Key; the softmax function is an activation function used for multi-class classification problems. The calculation formula of the softmax function is as follows: Where zi is the i-th element in the vector, K is the number of elements in the vector, and e is the base of the natural logarithm. Step 2: In order to enrich the extracted features, a multi-head attention structure is used. The multi-head attention calculation formula is as follows: MultiHead(Z)=Concat(H1, H2,...H6)W M where i∈1,2,...,6,H i The Concat function is to concatenate the vector sequences output by each attention mechanism into a larger vector sequence, W M To learn parameters, its role is to perform linear transformation on the result of splicing multiple attention mechanisms. Step 3: The output of the multi-head attention mechanism is input into the feedforward neural network after residual connection; The residual connection specifically includes: Assume that the output of the multi-head attention mechanism is m. The residual connection is to add the input m and the output F(m). The output of the network is: H(m)=F(m)+m The feedforward neural network is the data m′ after the output m of the multi-head attention mechanism is connected through residual connection. Then the feedforward neural network performs two linear transformations in order to extract features more deeply. The linear transformation introduces a nonlinear activation function. In the multi-head attention mechanism, matrix multiplication is mainly performed, which is a linear transformation. However, the learning ability of linear transformation is not as strong as that of nonlinear transformation. The calculation formula of the feedforward neural network is as follows: FFN(m′)=Relu(0,m′W′1+b′1)W′2+b′2 Where m′ is the input of the feedforward neural network, W′1, W′2, b′1, b′2 are the parameters of the feedforward neural network, and the Relu function is one of the activation functions of deep learning. It is a nonlinear activation function and its mathematical expression is: Relu(x)=max(0,x) Where x is the input of the function. If the input x is positive, the output of the function is itself; if the input x is negative, the output is 0.

7. The Transformer-based comprehensive feature network traffic classification method according to claim 3 is characterized in that: S203: Extract local features of the traffic data based on a one-dimensional convolution module, as follows: The one-dimensional convolution module consists of two bottleneck modules, each of which consists of three convolutional layers of 1×1, 1×3, and 1×1. Each bottleneck module is followed by a residual connection. The specific implementation steps are: During the local feature extraction process, after the 1×3 convolution layer of the first bottleneck module, the local feature vectors generated by the one-dimensional convolution module are aligned; after the first 1×1 convolution layer of the second bottleneck module, the global features generated by the Transformer module are received, and then the traffic sequence features of the one-dimensional convolution module are obtained. The feature alignment specifically includes: Since the feature dimensions of the Transformer module and the one-dimensional convolution module are different, the features of the two blocks cannot be received and fused with each other. Therefore, it is necessary to align the feature channels of the traffic sequence provided by both parties. The feature channel alignment specifically includes: The average pooling function is used to downsample the features of the one-dimensional convolution module. Specifically, a 1×1 convolution layer is required to reduce the dimension. Then, the spatial dimension of the feature is reduced by calculating the average value of the input feature in each pooling window, that is, reducing the length of the feature vector. The interpolation function is used to upsample the features of the Transformer module. Specifically, a 1×1 convolution layer is required to increase the dimension, and then for each feature value, a new feature point is generated between the original feature points using the selected interpolation method to obtain a higher-dimensional feature representation to map the low-dimensional features to the high-dimensional space.

8. The Transformer-based comprehensive feature network traffic classification method according to claim 3 is characterized in that: S204: The global features and local features obtained in S202 and S203 are fused, and the fused features are used to extract key temporal features using a gated recurrent unit, as follows: Step 1: After upsampling and downsampling are completed, the generated global features and local features are expanded to generate a one-dimensional feature vector, and then the feature vectors are spliced ​​to generate the initial integrated flow; Step 2: further extract key timing feature information from the initial integrated traffic using a gated recurrent unit; The gated recurrent unit specifically includes: The gated recurrent unit controls the flow of information through the update gate and the reset gate. The inputs of the reset gate and the update gate are composed of the hidden state of the previous time step and the input of the current time step. These two inputs will be put into the fully connected layer of the sigmoid activation function for calculation, and finally the results of these two gates are obtained. The calculation process of the reset gate and the update gate specifically includes: For any given time step t, assume that the input is a mini-batch of data X t , the hidden state of the previous time step is H t-1 , then update gate Z t and reset gate R t The calculation formula is as follows: Z t =σ(X t W xz +H t-1 W hz +b z ) R t =σ(X t W xr +H t-1 W hr +b r ) Where W xz , W xr , W hz , W hr is the weight parameter, b z , b r is the bias parameter, and the σ function is the sigmoid activation function, which is a nonlinear function that maps the input to the (0, 1) interval. Its mathematical expression is: Where u is the input of the function, e is the natural logarithm base, Step 3: Concatenate the statistical features and the key time series features into one-dimensional feature vectors to generate comprehensive features.

9. A Transformer-based comprehensive feature network traffic classification model, characterized by: The model is used to implement the Transformer-based comprehensive feature network traffic classification method according to any one of claims 1 to 8, and the model includes an autoencoder, two Transformer modules, two one-dimensional convolution modules, a feature alignment module, a gated recurrent unit module, and two feature fusion modules; Calculate statistical information from raw network traffic data and input the statistical information into the autoencoder to extract statistical features; The preprocessed network traffic data is first input into the Transformer module and the one-dimensional convolution module; Next, the traffic features generated by the Transformer module and the one-dimensional convolution module are aligned so that the features extracted by the two modules can complement each other, thereby optimizing the feature representation of the network traffic sequence. After feature alignment, the feature vectors generated by the Transformer module and the one-dimensional convolution module are expanded respectively, and then the features are fused by splicing the one-dimensional feature vectors to generate the initial comprehensive features; Further extracting key timing features from the initial comprehensive features using a gated recurrent unit; Performing feature fusion on the key time series features and the statistical features to obtain comprehensive features; Perform full connection classification based on comprehensive features and output the classification results.

Citation Information

Patent Citations

  • Encrypted traffic identification method based on Transform deep learning model

    CN114401229A

  • Network traffic classification method based on attention mechanism

    CN114818867A

  • Network intrusion detection method and system based on flow feature fusion

    CN116506210A

  • TBG model intrusion detection method for industrial Internet of Things

    CN117786315A

  • Sparse attention neural networks

    US20220253672A1

Cited By

  • Cloth animation generation method for virtual character and related device

    CN119323631A

  • Multi-modal data-based mouse species classification method and system

    CN119479016A

  • Transform-based river extreme flow measuring and calculating method and system

    CN119783548A

  • A method and system for calculating river extreme flow based on Transformer

    CN119783548B

  • Encrypted traffic identification method based on multi-feature fusion

    CN120030501A