Classification method, device and equipment for decentralized program encryption traffic and medium

Through the combination of intra-stream and inter-stream attention models, feature mining of DApps encrypted traffic solves the problem of unexplored inter-stream relationships in the existing technology, achieves efficient encrypted traffic classification, and improves classification accuracy and efficiency.

CN118535965APending Publication Date: 2024-08-23Chinese People's Liberation Army Cyberspace Force Information Engineering University
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410542764.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-04-30
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

Existing DApps encrypted traffic classification methods fail to effectively mine the relationships between flows, resulting in poor classification results.

Method used

Intra-flow attention model and inter-flow attention model are used to preprocess the encrypted traffic of decentralized applications, generate initial network flows, embed network flow features, and perform intra-flow and inter-flow feature mining through multi-layer perceptrons. Finally, the classification of encrypted traffic is achieved.

Benefits of technology

By combining feature mining from the intra-flow and inter-flow perspectives, a more complete understanding and classification of DApps encrypted traffic is achieved, the classification accuracy and efficiency are improved, and the classification prediction of each flow can be completed within 0.74ms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118535965A
    Figure CN118535965A
Patent Text Reader

Abstract

The embodiment of the invention provides a traffic classification method and device for a decentralized application program, equipment and a medium, and relates to the technical field of data identification, and the method comprises the following steps: carrying out the preprocessing of the original encrypted traffic of the decentralized application program, generating an initial network flow, embedding a network flow feature in the network flow, and carrying out the recognition of the initial network flow; generating an embedded network flow; performing intra-stream feature mining on the embedded network stream by using an intra-stream attention model to generate an intra-stream feature embedded network stream; performing inter-flow feature mining on the in-flow feature embedded network flow by using an inter-flow attention model to generate an inter-flow feature embedded network flow; and identifying the inter-flow feature embedded network flow by using a multi-layer perceptron to obtain the classification of the original encrypted flow. According to the scheme, the whole process of the information flow can be more completely understood and described by combining complementary feature mining of the view angle in the flow and feature mining of the view angle between the flows, and the classification problem of the encrypted flow of the decentralized application program is effectively solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data identification technology, and in particular to a classification method, device, equipment and medium for decentralized program encrypted traffic. Background Art

[0002] DApps are decentralized applications based on the self-attention mechanism. Since the DApps category includes DApps with unfair rules, Ponzi schemes, and financial frauds, some DApps have been attacked by cyber criminals for profit, and there have been many high-impact attacks on DApps in the real world, causing millions of dollars in losses. Therefore, DApps encrypted traffic classification is crucial for network management and threat detection.

[0003] Different types of DApps show great similarities in the handshake process, and all use the TLS protocol to encrypt network traffic. In addition, existing flow-based encrypted traffic classification methods often only focus on the relationship within the flow, while ignoring the relationship between flows that contains rich information; they often treat the intra-flow features as separate individuals and input them into machine learning or deep learning algorithms, making it difficult to deeply mine the relationship between flows.

[0004] Currently, there are relatively few methods for classifying encrypted traffic in DApps, and even fewer methods that comprehensively consider and exploit relationships within and between flows. Summary of the invention

[0005] In view of this, an embodiment of the present invention provides a decentralized program encrypted traffic classification method, which solves the technical problem that the relationship between flows is not mined when classifying encrypted traffic in the prior art. The method includes:

[0006] Preprocess the original encrypted traffic of the decentralized application to generate an initial network flow, embed the network flow features in the network flow, and generate an embedded network flow;

[0007] Use the in-stream attention model to mine in-stream features of the embedded network stream, and generate an in-stream feature embedded network stream, wherein the in-stream attention model is a single-head attention model or a multi-head attention model, the embedded network stream is a single stream composed of multiple data packets, and the in-stream feature embedded network stream is multiple groups of network streams;

[0008] Use the inter-stream attention model to perform inter-stream feature mining on the intra-stream feature embedding network flow to generate the inter-stream feature embedding network flow, wherein the inter-stream attention model is a single-head or multi-head attention model;

[0009] A multi-layer perceptron is used to embed the inter-flow features into the network flow to identify the original encrypted traffic.

[0010] The embodiment of the present invention also provides a decentralized program encrypted traffic classification device, which solves the technical problem that the relationship between flows is not mined when classifying encrypted traffic in the prior art. The device includes:

[0011] A feature embedding module is used to preprocess the original encrypted traffic of the decentralized application to generate an initial network flow, embed network flow features in the network flow, and generate an embedded network flow;

[0012] An in-stream feature mining module is used to mine in-stream features on the embedded network stream using an in-stream attention model to generate an in-stream feature embedded network stream, wherein the in-stream attention model is a single-head attention model or a multi-head attention model, the embedded network stream is a single stream consisting of multiple data packets, and the in-stream feature embedded network stream is multiple groups of network streams;

[0013] An inter-stream feature mining module is used to perform inter-stream feature mining on an intra-stream feature embedding network stream using an inter-stream attention model to generate an inter-stream feature embedding network stream, wherein the inter-stream attention model is a single-head or multi-head attention model;

[0014] The recognition and classification module is used to use a multi-layer perceptron to embed network flows with inter-flow features and obtain the classification of the original encrypted traffic.

[0015] An embodiment of the present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements any of the above-mentioned decentralized program encrypted traffic classification methods, thereby solving the technical problem in the prior art that the relationship between flows is not mined when classifying encrypted traffic.

[0016] An embodiment of the present invention also provides a computer-readable storage medium, which stores a computer program for executing any of the above-mentioned decentralized program encrypted traffic classification methods, thereby solving the technical problem in the prior art that the relationship between flows is not mined when classifying encrypted traffic.

[0017] Compared with the prior art, the at least one technical solution adopted in the embodiments of this specification can achieve the following beneficial effects:

[0018] By combining the complementary feature mining of the intra-flow perspective and the feature mining of the inter-flow perspective, we can more completely understand and describe the entire process of information flow, realize the full mining of network flow information, and effectively solve the classification problem of encrypted traffic of decentralized applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0020] Figure 1 It is a flow chart of a method for classifying decentralized program encrypted traffic provided by an embodiment of the present invention;

[0021] Figure 2 It is a flow chart of a classification method for implementing the above-mentioned decentralized program encrypted traffic provided by an embodiment of the present invention;

[0022] Figure 3 is a processing flow chart of the in-stream attention model provided by an embodiment of the present invention;

[0023] Figure 4 is a processing flow chart of the inter-stream attention model provided by an embodiment of the present invention;

[0024] Figure 5 is a schematic diagram of the result of classifying flow data using the classification method provided by an embodiment of the present invention;

[0025] Figure 6 is a schematic diagram of setting hyperparameters of the classification method provided by an embodiment of the present invention;

[0026] Figure 7 is a structural block diagram of a computer device provided by an embodiment of the present invention;

[0027] Figure 8 It is a structural block diagram of a decentralized program encrypted traffic classification device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0028] The embodiments of the present application are described in detail below with reference to the accompanying drawings.

[0029] The following describes the implementation methods of the present application through specific examples, and those skilled in the art can easily understand other advantages and effects of the present application from the contents disclosed in this specification. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. The present application can also be implemented or applied through other different specific implementation methods, and the details in this specification can also be modified or changed in various ways based on different viewpoints and applications without departing from the spirit of the present application. It should be noted that, in the absence of conflict, the following embodiments and the features in the embodiments can be combined with each other. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without making creative work belong to the scope of protection of the present application.

[0030] In an embodiment of the present invention, a classification method for decentralized program encrypted traffic is provided, such as Figure 1 and Figure 2 As shown, the method includes:

[0031] Step S101: preprocessing the original encrypted traffic of the decentralized application to generate an initial network flow, embedding network flow features in the network flow, and generating an embedded network flow;

[0032] Step S102: using the in-stream attention model to perform in-stream feature mining on the embedded network flow, generating an in-stream feature embedded network flow, wherein the in-stream attention model is a single-head attention model or a multi-head attention model, the embedded network flow is a single flow composed of multiple data packets, and the in-stream feature embedded network flow is multiple groups of network flows;

[0033] Step S103: using the inter-stream attention model to perform inter-stream feature mining on the intra-stream feature embedding network flow to generate the inter-stream feature embedding network flow, wherein the inter-stream attention model is a single-head or multi-head attention model, the embedded network flow is a single flow composed of multiple data packets, and the intra-stream feature embedding network flow is multiple groups of network flows;

[0034] Step S104: Use a multi-layer perceptron to identify the network flow embedded with the inter-flow features to obtain the classification of the original encrypted traffic.

[0035] The traffic classification method of the embodiment of the present invention is based on mining intra-flow relationships and inter-flow relationships. It is necessary to extract distinguishing features of encrypted traffic from network flows with the same <source IP, destination IP, source port, destination port, protocol> quintuple; intra-flow relationships refer to the relationship between packets in a flow, and inter-flow relationships refer to the relationship between flows. The intra-flow and inter-flow relationship mining module designed by the present invention has a structural schematic diagram shown in FIG. Figure 2 .

[0036] Specifically, the multilayer perceptron of the embodiment of the present invention includes an input layer, a single hidden layer and an output layer, the hidden layer is located between the input layer and the output layer, and each neuron in the hidden layer and the output layer is nonlinearly transformed through the activation function of the rectified linear unit.

[0037] In the specific implementation, a learnable embedding tag [CLS] is added to each sample, and the original encrypted traffic of the decentralized application is preprocessed through the following steps to generate an initial network flow, and the network flow features are embedded in the initial network flow to generate an embedded network flow:

[0038] According to the program classification standard, the original encrypted traffic is divided into traffic generated by the same application and traffic generated by different applications, and the traffic generated by the same application is taken as the classified target traffic; the classified target traffic is taken as the initial network flow, and the initial network flow is divided into n network flows, each network flow includes i data packets, where i is a hyperparameter; the following steps are performed for each network flow in a loop until all network flows are processed, and an embedded sub-network flow is generated. All embedded sub-network flows constitute an embedded network flow, and the loop ends: a learnable embedding tag [CLS] is embedded for each network flow to generate an embedded sub-network flow.

[0039] Specifically, the program classification of the embodiment of the present invention is to divide the original encrypted traffic data captured by packet capture software such as Wireshark or tcpdump according to the five-tuple <source IP, destination IP, source port, destination port, protocol>. Traffic with the same five-tuple is divided into the same type of traffic (traffic generated by the same DApp).

[0040] In specific implementation, the following steps are performed to embed a learnable embedding tag [CLS] for each network flow and generate an embedded sub-network flow:

[0041] Read the first i packets of each initial network flow and use vector f to represent the first i packets, where the vector Element p i is the packet length of each data packet in the classified target traffic, The packet arrival timestamp contained in each data packet; add the learnable embedding tag [CLS] to the vector f to generate the embedded labeled vector f = [[CLS], f1, f2, …, f 3i ]; Input the embedded labeled vector f into the embedding function to generate the embedded sub-network flow E(f), where, Embed subnetwork flow mlp i is a multi-layer perceptron, is the domain of the function in the multilayer perceptron.

[0042] Specifically, the purpose of embedding network flow features is to add a learnable embedding [CLS] tag to each sample (vector f). After [CLS] is processed by the intra-stream attention model and the inter-stream attention model in sequence, the global information of the entire sample will be learned. Then, the [CLS] token is input into the multi-layer perceptron to predict the category of the unknown DApps network flow.

[0043] Specifically, the embedding module maps each digital feature into a d-dimensional vector to accelerate model convergence. Each initial network flow is represented as a vector At this time, the number of elements in vector f is len(f) = 3k, and the element p in vector f is i The meaning is the length of the data packet in the network flow. Each data packet contains a timestamp field, and the value of t is exactly this timestamp. Then the vector f can be formally expressed as f = [f1,f2,…,f 3i ], where f i is the i-th component of f.

[0044] Specifically, if the number of packets in the initial network flow of the decentralized application (DApp) is less than i, the length of the insufficient packets is set to 0, and the packet arrival timestamp is also replaced with 0.

[0045] Specifically, mlp j Representation Mapping Different MLPs j The embedding module E is composed of mlp j (Multi-layer Perceptron), j = 0, 1, …, 3k. The meaning is that the domain of the activation function is

[0046] In the specific implementation, in order to use the single-head in-stream attention model to calculate the attention, the attention score is used to perform feature mining on the embedded network flow. The following steps are used to use the in-stream attention model to perform in-stream feature mining on the embedded network flow and generate in-stream feature embedded network flow:

[0047] Construct the q vector, v vector, and k vector of the in-stream attention model, where q = W q E(f),k=W k E(f),v=W v E(f), E(f) is the embedded network flow, q vector is the search standard vector, k vector is the queried object vector, v vector is the content vector of the queried object, W q , W k , W vare the parameter matrices corresponding to the q vector, k vector, and v vector respectively; according to the q vector and the k vector, the self-attention score attn is calculated, where the self-attention score Softmax(·) is the activation function, T is the matrix transpose, and d represents the dimension of the k vector. The in-stream self-attention weighted vector Attention(q,k,v) is calculated by the self-attention score attn and the v vector, and the in-stream self-attention weighted vector Attention(q,k,v) is embedded into the network flow output as the in-stream feature, where the in-stream self-attention weighted vector Attention(q,k,v)=attn·v.

[0048] Specifically, the self-attention score attn reflects the relationship between any two elements of the input vector f.

[0049] like Figure 3 As shown in the figure, the process of feature mining using a single-head attention model is shown in the figure. a is calculated by k0 in the k vector and q0 in the q vector. 0,0 , a is calculated by q0 in the q vector and k1 in the k vector 0,1 , a is calculated by q0 in the q vector and k2 in the k vector 0,2 , through q0 in the q vector and k in the k vector m Calculate a 0,m All vectors are calculated according to the above algorithm. 0,0 ,a 0,1 ,a 0,2 ,…,a 0,m ; a 1,0 ,a 1,1 ,a 1,2 ,…,a 1,m to a m,0 ,a m,1 ,a m,2 ,…,a m,m The above attention scores are multiplied by the v vector (weighted sum) to obtain the in-stream self-attention weighted vector.

[0050] In the specific implementation, in order to use the multi-head in-stream attention model to calculate the attention, the attention score is used to perform feature mining on the embedded network flow. The following steps are used to use the in-stream attention model to perform in-stream feature mining on the embedded network flow to generate an in-stream feature embedded network flow:

[0051] Determine the number of heads h and calculate the in-stream self-attention weighted vector head for each head m , add all the self-attention weighted vectors head within the stream mAfter the head-to-tail connection, the intra-stream feature embedding network flow is generated, where m is 1 to h, and the intra-stream self-attention weighted vector head of each head is calculated m The steps include: constructing h in-stream attention models q m vector, k m vector, v m vector, where m is from 1 to h, E(f) is the embedded network flow, q m Vector is used to find the standard vector, k m The vector is the queried object vector, v m The vector is the content vector of the queried object. They are q m vector, k m vector, v m The parameter matrix corresponding to the vector; through the dimension d of the in-stream attention model m And the number of longs h is calculated to get k m The dimension of the vector is d k , where d k =d m ÷h; according to q m Vector and k m Vector, calculate the self-attention score attn m , where the self-attention score softmax(·) is the activation function, T is the matrix transpose; through the self-attention score attn m and v m Vector calculation obtains the self-attention weighted vector head within the flow m , the self-attention weighted vector in the stream is embedded into the network stream output as the in-stream feature, where head m =attn m ·v m .

[0052] Specifically, the use of a multi-head attention model can give the output of the attention layer a representation of the encoding information in different subspaces, thereby enhancing the expressive power of the model. In the multi-head attention model, the q vector, k vector, and v vector are mapped to d m / h dimension, not d m dimensional vector, where h is the number of heads and d is m is the dimension of the in-stream attention model. Then, the in-stream self-attention weight vector head of each head m Connect them together to get a length of d m The vector is embedded into the network flow as an in-stream feature (i.e., each set of self-attention results are concatenated and linearly transformed to obtain the final output result).

[0053] In the specific implementation, in order to use the single-head inter-stream attention model to calculate the attention, multiply the attention score by the content vector of the queried object, and perform inter-stream feature mining on the intra-stream feature embedding network flow, the following steps are used to implement the inter-stream feature mining on the intra-stream feature embedding network flow using the inter-stream attention model to generate the inter-stream feature embedding network flow:

[0054] The shape of the network flow embedded with the in-stream features is transformed by a reshaping function to generate a reshaped embedded network flow, where the reshaped embedded network flow f″=reshape(f′,(1,batch,(3k+1)·d)), f′ is the network flow embedded with the in-stream features, batch·(3k+1)·d is the vector shape of the network flow embedded with the in-stream features, reshape is a reshaping function, batch is the number of samples input each time in the inter-stream attention model, k is the number of packets used in the network flow, and d is the dimension of k; construct the q vector, v vector, and k vector in the inter-stream attention model, where q=W q E(f″),k=W k ·E(f″),v=W v E(f″), q vector is the search standard vector, k vector is the queried object vector, v vector is the content vector of the queried object, W q , W k , W v are the parameter matrices corresponding to the q vector, k vector, and v vector respectively; according to the q vector and the k vector, the self-attention score attn is calculated, where the self-attention score softmax(·) is the activation function, mm(·,·) is the matrix multiplication, Transpose(·,·) is the function of exchanging array dimensions, and d represents the dimension of the k vector. The inter-stream self-attention weighted vector Attention(q,k,v) is calculated by the self-attention score attn and the v vector, and the inter-stream self-attention weighted vector Attention(q,k,v) is embedded into the network flow output as the inter-stream feature, where the inter-stream self-attention weighted vector Attention(q,k,v)=attn·v.

[0055] like Figure 4 As shown, the black box is the part processed by the inter-stream attention model. In the case of a single head, the processing flow of the features embedded in the three input streams (i.e., a batch of embedded streams, batch is an integer, generally a power of 2. In the embodiment of the present invention, it can be 64 network streams, then 64 network streams are a batch of samples). The input stream feature embedding network stream can be a batch of inputs. The k1 vector of the first input stream feature embedding network stream and the q2 vector of the second input stream feature embedding network stream are calculated to obtain a2,1 , the k2 vector of the feature embedding in the second input stream into the network stream and the q2 vector of the feature embedding in the second input stream into the network stream are calculated to obtain a 2,2 , the q2 vector of the feature embedding network stream in the second input stream and the k3 vector of the feature embedding network stream in the third input stream are calculated to obtain a 2,3 Among them, a 2,1 ,a 2,2 ,a 2,3 Both are inter-stream attention scores.

[0056] In the specific implementation, in order to use the multi-head inter-stream attention model to calculate the attention, multiply the attention score by the content vector of the queried object, and perform inter-stream feature mining on the intra-stream feature embedding network flow, the following steps are used to implement the inter-stream feature mining on the intra-stream feature embedding network flow using the inter-stream attention model to generate the inter-stream feature embedding network flow:

[0057] The self-attention weighted vector head between streams is transformed through the shaping function n The shape of is transformed to generate the reshaped inter-flow network flow, where the reshaped inter-flow network flow f″ n = reshape(f′ n ,(1,batch,(3k+1)·d)),f″ n is the network flow between flows after shaping, f′ n is the inter-stream self-attention weighted vector head n , batch·(3k+1)·d is the inter-stream self-attention weight vector head n The vector shape of h is reshaped, batch is the number of input samples in the inter-stream attention model, k is the number of packets used in the network flow (k is a hyperparameter), and d is the dimension of k; construct q in h inter-stream attention models n vector, k n vector, v n Vector, where n is 1 to h, q = W q ·E(f″ n ),k=W k ·E(f″ n ),v=W v ·E(f″ n ), q n Vector is used to find the standard vector, k n The vector is the queried object vector, v n The vector is the content vector of the queried object. They are q n vector, k n vector, v n The parameter matrix corresponding to the vector; through the dimension d of the inter-stream attention modeln And the number of longs h is calculated to get k n The dimension of the vector is d k , where d k =d n ÷h; according to q n Vector and k n Vector, calculate the self-attention score attn n , where the self-attention score Softmax(·) is the activation function, mm(·,·) is the matrix multiplication, Transpose(·,·) is the function of exchanging array dimensions; through the self-attention score attn n and v n Vector calculation obtains the inter-stream self-attention weighted vector head n , the inter-stream self-attention weighted vector is embedded into the network output as the inter-stream feature, where head n =attn n ·v n .

[0058] Specifically, if the dimension of the input matrix (embedded network flow) is [WH, C], the total computational effort of the single-head attention model is 3WHC 2 +2(WH) 2 The total computational effort of the multi-head attention model is 4WHC 2 +2(WH) 2 . Determine whether to use a single-head attention model or a multi-head attention model (including determining the number of heads) based on the required computing time and required accuracy.

[0059] like Figure 5 and Figure 6 As shown in the figure, a schematic diagram of the effect of using the traffic classification method of the embodiment of the present invention to classify decentralized applications. The test experiment DApp selected 44 DApps with the most users on Ethereum. There are 14 categories in total, including exchanges, finance, games, high-risk, etc. A total of 258,471 raw encrypted traffic was collected, and the traffic count of each type of DApp is summarized in Figure 5 We can see that the traffic volume of different categories of DApps varies greatly. Figure 6 The model hyperparameters used by the attention model in this test experiment. On a DApps encrypted traffic dataset containing 44 categories, the recognition accuracy of this method is 97.164%, and the classification prediction time for each flow is only 0.74ms.

[0060] The final result of feature mining is the output of the entire attention module. The effectiveness of feature mining depends on the various indicators of the final prediction results (recall rate, precision rate, accuracy rate, F1-score, etc.).

[0061] In this embodiment, a computer device is provided, such as Figure 7 As shown, it includes a memory 701, a processor 702, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, any of the above-mentioned decentralized program encrypted traffic classification methods is implemented.

[0062] Specifically, the computer device may be a computer terminal, a server or a similar computing device.

[0063] In this embodiment, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program for executing any of the above-mentioned decentralized program encrypted traffic classification methods.

[0064] Specifically, computer-readable storage media include permanent and non-permanent, removable and non-removable media that can be used to store information by any method or technology. Information can be computer-readable instructions, data structures, program modules or other data. Examples of computer-readable storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, tape disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable storage media does not include temporary computer-readable media (transitory media), such as modulated data signals and carrier waves.

[0065] Based on the same inventive concept, a classification device for decentralized program encrypted traffic is also provided in an embodiment of the present invention, as described in the following embodiments. Since the principle of solving the problem by the classification device for decentralized program encrypted traffic is similar to the classification method for decentralized program encrypted traffic, the implementation of the classification device for decentralized program encrypted traffic can refer to the implementation of the classification method for decentralized program encrypted traffic, and the repeated parts will not be repeated. As used below, the term "unit" or "module" can be a combination of software and / or hardware that implements predetermined functions. Although the device described in the following embodiments is preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceived.

[0066] Figure 8 is a structural block diagram of a classification device for decentralized program encrypted traffic according to an embodiment of the present invention, such as Figure 8As shown, it includes: a feature embedding module 801, an intra-stream feature mining module 802, an inter-stream feature mining module 803 and a recognition and classification module 804. The structure is described below.

[0067] The feature embedding module 801 is used to pre-process the original encrypted traffic of the decentralized application to generate an initial network flow, embed the network flow feature in the network flow, and generate an embedded network flow;

[0068] An in-stream feature mining module 802 is used to perform in-stream feature mining on the embedded network stream using an in-stream attention model to generate an in-stream feature embedded network stream, wherein the in-stream attention model is a single-head attention model or a multi-head attention model;

[0069] The inter-stream feature mining module 803 is used to perform inter-stream feature mining on the intra-stream feature embedded network flow using an inter-stream attention model to generate an inter-stream feature embedded network flow, wherein the inter-stream attention model is a single-head or multi-head attention model, the embedded network flow is a single flow composed of multiple data packets, and the intra-stream feature embedded network flow is a plurality of groups of network flows;

[0070] The identification and classification module 804 is used to use a multi-layer perceptron to identify the network flow in which the inter-flow features are embedded, and obtain the classification of the original encrypted traffic.

[0071] In one embodiment, the feature embedding module includes:

[0072] A traffic classification unit is used to classify the original encrypted traffic into traffic generated by the same application program and traffic generated by different applications program according to a program classification standard, and to classify the traffic generated by the same application program as the classification target traffic;

[0073] A segmentation unit is used to take the classified target traffic as the initial network flow, and divide the initial network flow into n network flows, each network flow includes i data packets, where i is a hyperparameter;

[0074] The loop unit is used to loop through the following steps for each network flow until all network flows are processed, generate an embedded sub-network flow, and all the embedded sub-network flows form an embedded network flow, and then end the loop:

[0075] The embedding unit is used to embed a learnable embedding tag [CLS] for each network flow to generate a sub-embedded network flow.

[0076] In one embodiment, the embedding unit includes: reading the first i packets of each initial network flow, using a vector f to represent the first i packets, wherein the vector Element p i is the packet length of each data packet in the classified target traffic, For each data packet, it contains the packet arrival timestamp, Add the learnable embedding tag [CLS] to the vector f to generate the embedded tag vector f = [[CLS], f1, f2, …, f 3i ]; Input the embedded labeled vector f into the embedding function to generate the embedded network flow E(f), where, Embedding Network Streams mlp i is a multi-layer perceptron, is the domain of the function in the multilayer perceptron.

[0077] In one embodiment, the in-stream feature mining module includes:

[0078] The first vector construction unit is used to construct the q vector, v vector, and k vector of the in-stream attention model, where q = W q E(f),k=W k E(f),v=W v E(f), E(f) is the embedded network flow, q vector is the search standard vector, k vector is the queried object vector, v vector is the content vector of the queried object, W q , W k , W v They are the parameter matrices corresponding to the q vector, k vector, and v vector respectively;

[0079] The first attention score calculation unit is used to calculate the self-attention score attn according to the q vector and the k vector, where the self-attention score softmax(·) is the activation function, T is the matrix transpose, and d represents the dimension of the k vector;

[0080] The first weighted vector generating unit is used to calculate the in-stream self-attention weighted vector Attention(q,k,v) through the self-attention score attn and the v vector, and embed the in-stream self-attention weighted vector Attention(q,k,v) as the in-stream feature into the network flow output, wherein the in-stream self-attention weighted vector Attention(q,k,v)=attn·v.

[0081] In one embodiment, the in-stream feature mining module further includes:

[0082] The first multi-head vector calculation unit is used to determine the number of heads h and calculate the self-attention weighted vector head of each head. m , add all the self-attention weighted vectors head within the stream m After the head-to-tail connection, the intra-stream feature embedding network flow is generated, where m is 1 to h, and the intra-stream self-attention weighted vector head of each head is calculated mThe steps include:

[0083] The second vector construction unit is used to construct q of h in-stream attention models. m vector, k m vector, v m vector, where m is from 1 to h, E(f) is the embedded network flow, q m Vector is used to find the standard vector, k m The vector is the queried object vector, v m The vector is the content vector of the queried object. They are q m vector, k m vector, v m The parameter matrix corresponding to the vector;

[0084] Dimensionality calculation unit, used to pass the dimension d of the in-stream attention model m And the number of longs h is calculated to get k m The dimension of the vector is d k , where d k =d m ÷h;

[0085] The second attention score calculation unit is used to calculate the m Vector and k m Vector, calculate the self-attention score attn m , where the self-attention score Softmax(·) is the activation function, T is the matrix transpose;

[0086] The second weighted vector generation unit is used to generate the self-attention score attn m and v m Vector calculation obtains the self-attention weighted vector head within the flow m , the self-attention weighted vector in the stream is embedded into the network stream output as the in-stream feature, where head m =attn m ·v m .

[0087] In one embodiment, the inter-flow feature mining module includes:

[0088] A reshaping unit is used to transform the shape of the intra-stream feature embedded network flow through a reshaping function to generate a reshaped embedded network flow, wherein the reshaped embedded network flow f″=reshape(f′,(1,batch,(3k+1)·d)), f′ is the intra-stream feature embedded network flow, batch·(3k+1)·d is the vector shape of the intra-stream feature embedded network flow, reshape is the reshaping function, batch is the number of input samples each time in the inter-stream attention model, k is the number of packets used in the network flow, and d is the dimension of k;

[0089] The third vector construction unit is used to construct the q vector, v vector, and k vector in the inter-stream attention model, where q = W q E(f″),k=W k ·E(f″),v=W v E(f″), q vector is the search standard vector, k vector is the queried object vector, v vector is the content vector of the queried object, W q , W k , W v They are the parameter matrices corresponding to the q vector, k vector, and v vector respectively;

[0090] The third attention score calculation unit is used to calculate the self-attention score attn according to the q vector and the k vector, where the self-attention score softmax(·) is the activation function, mm(·,·) is the matrix multiplication, Transpose(·,·) is the function of exchanging array dimensions, and d represents the dimension of the k vector;

[0091] The third weighted vector generating unit is used to calculate the inter-stream self-attention weighted vector Attention(q,k,v) through the self-attention score attn and the v vector, and embed the inter-stream self-attention weighted vector Attention(q,k,v) as the inter-stream feature into the network stream output, wherein the inter-stream self-attention weighted vector Attention(q,k,v)=attn·v.

[0092] In one embodiment, the inter-flow feature mining module further includes:

[0093] The second multi-head vector calculation unit is used to determine the number of heads h and calculate the inter-flow self-attention weighted vector head of each head. n , the self-attention weighted vector head between all flows n After the head-to-tail connection, the inter-stream feature embedding network flow is generated, where n is 1 to h, and the inter-stream self-attention weighted vector head of each head is calculated n The steps include:

[0094] Multi-head shaping unit, used to transform the inter-stream self-attention weighted vector head through the shaping function n The shape of is transformed to generate the reshaped inter-flow network flow, where the reshaped inter-flow network flow f″ n = reshape(f′ n ,(1,batch,(3k+1)·d)),f″ n is the network flow between flows after shaping, f′ n is the inter-stream self-attention weighted vector head n , batch·(3k+1)·d is the inter-stream self-attention weight vector head n The vector shape of , reshape is the reshaping function, batch is the number of input samples each time in the inter-stream attention model, k is the number of packets used in the network flow, and d is the dimension of k;

[0095] The fourth vector construction unit is used to construct q in the h inter-stream attention model n vector, k n vector, v n Vector, where n is 1 to h, q = W q ·E(f″ n ),k=W k ·E(f″ n ),v=W v ·E(f″ n ), q n Vector is used to find the standard vector, k n The vector is the queried object vector, v n The vector is the content vector of the queried object. They are q n vector, k n vector, v n The parameter matrix corresponding to the vector;

[0096] The second dimension calculation unit is used to pass the dimension d of the inter-stream attention model n And the number of longs h is calculated to get k n The dimension of the vector is d k , where d k =d n ÷h;

[0097] The fourth attention score calculation unit is used to calculate the attention score according to q n Vector and k n Vector, calculate the self-attention score attn n , where the self-attention score softmax(·) is the activation function, mm(·,·) is the matrix multiplication, and Transpose(·,·) is the function of exchanging the dimensions of the array;

[0098] The fourth weighted vector generation unit is used to generate the self-attention score attn n and v n Vector calculation obtains the inter-stream self-attention weighted vector head n , the inter-stream self-attention weighted vector is embedded into the network output as the inter-stream feature, where head n =attn n ·v n .

[0099] The embodiment of the present invention achieves the following technical effects: the encrypted traffic classification method of the embodiment of the present invention is a classification method based on the self-attention mechanism, which is applied to the traffic classification of decentralized applications (DApps), and effectively solves the classification problem of DApps encrypted traffic, wherein the feature mining from the intra-stream perspective focuses on the information transmission between different data packets in the stream, and the feature mining from the inter-stream perspective emphasizes the information interaction between different streams. By combining the complementary feature mining from the intra-stream perspective and the feature mining from the inter-stream perspective, the entire process of the information flow can be more completely understood and described, and the full mining of network flow information can be achieved. At the same time, with the help of the parallel computing power of self-attention, the network flow (original encrypted traffic) can be quickly classified, and the efficiency of traffic classification is effectively improved; the attention model can use a single-head or multi-head attention model, and the use of the multi-head attention mechanism can give the output of the attention layer containing the coded representation information in different subspaces, thereby enhancing the expression ability of the attention model, and the calculation time of the multi-head attention model is slightly more than that of the single-head attention model. According to the required calculation time and required accuracy, it is determined whether to use a single-head attention model or a multi-head attention model.

[0100] Obviously, those skilled in the art should understand that the modules or steps of the above-mentioned embodiments of the present invention can be implemented by a general computing device, they can be concentrated on a single computing device, or distributed on a network composed of multiple computing devices, and optionally, they can be implemented by a program code executable by a computing device, so that 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 that here, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. In this way, the embodiments of the present invention are not limited to any specific combination of hardware and software.

[0101] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the embodiments of the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.

Claims

1. A classification method for decentralized program encrypted traffic, characterized in that: include: Preprocessing the original encrypted traffic of the decentralized application to generate an initial network flow, embedding network flow features in the network flow, and generating an embedded network flow; Using an in-stream attention model to perform in-stream feature mining on the embedded network flow to generate an in-stream feature embedded network flow, wherein the in-stream attention model is a single-head attention model or a multi-head attention model, the embedded network flow is a single flow composed of multiple data packets, and the in-stream feature embedded network flow is a plurality of groups of network flows; Using an inter-stream attention model to perform inter-stream feature mining on the intra-stream feature embedding network flow to generate an inter-stream feature embedding network flow, wherein the inter-stream attention model is a single-head or multi-head attention model; A multi-layer perceptron is used to identify the inter-flow feature embedded in the network flow to obtain the classification of the original encrypted traffic.

2. The method for classifying decentralized program encrypted traffic according to claim 1, characterized in that: Preprocessing the original encrypted traffic of the decentralized application to generate an initial network flow, embedding network flow features in the initial network flow, and generating an embedded network flow, including: According to the program classification standard, the original encrypted traffic is divided into traffic generated by the same application and traffic generated by different applications, and the traffic generated by the same application is used as the classification target traffic; Taking the classified target traffic as an initial network flow, dividing the initial network flow into n network flows, each network flow includes i data packets, where i is a hyperparameter; The following steps are performed for each network flow loop until all network flows are processed, an embedded sub-network flow is generated, and all the embedded sub-network flows form an embedded network flow, and the loop ends: Embed a learnable embedding tag [CLS] for each network flow to generate an embedded sub-network flow; The embedded sub-network flow is added to the embedded network flow.

3. The method for classifying decentralized program encrypted traffic according to claim 2, characterized in that: Embed a learnable embedding tag [CLS] for each network flow, generating an embedded sub-network flow, including: Read the first i packets of each initial network flow and use vector f to represent the first i packets, where the vector Element p i is the packet length of each data packet in the classified target traffic, Packet arrival timestamp for each data packet; Add the learnable embedding tag [CLS] to the vector f to generate the embedded tag vector f = [[CLS], f1, f2, …, f 3i ]; The embedded labeled vector f is input into the embedding function to generate an embedded sub-network stream E(f), where E(f) = E([[CLS], f1, f2, …, f 3i ])=[mlp0([CLS]),mlp1(f1),mlp2(f2),…,mlp 3i (f 3i )], embedding sub-network flow mlp i is a multi-layer perceptron, is the domain of the function in the multilayer perceptron.

4. The method for classifying decentralized program encrypted traffic according to claim 1, characterized in that: Using an in-stream attention model to perform in-stream feature mining on the embedded network stream to generate an in-stream feature embedded network stream, including: Construct the q vector, v vector, and k vector of the in-stream attention model, where q = W q E(f),k=W k E(f),v=W v E(f), E(f) is the embedded network flow, q vector is the search standard vector, k vector is the queried object vector, v vector is the content vector of the queried object, W q , W k , W v They are the parameter matrices corresponding to the q vector, k vector, and v vector respectively; According to the q vector and the k vector, the self-attention score attn is calculated, where the self-attention score softmax(·) is the activation function, T is the matrix transpose, and d is the dimension of the k vector; The in-stream self-attention weighted vector Attention(q,k,v) is calculated by the self-attention score attn and the v vector, and the in-stream self-attention weighted vector Attention(q,k,v) is embedded in the network flow output as the in-stream feature, wherein the in-stream self-attention weighted vector Attention(q,k,v)=attn·v.

5. The method for classifying decentralized program encrypted traffic according to claim 1, characterized in that: Using an in-stream attention model to perform in-stream feature mining on the embedded network stream to generate an in-stream feature embedded network stream, including: Determine the number of heads h, and calculate the in-stream self-attention weighted vector head for each head m , all the self-attention weighted vectors head in the stream m After the head-to-tail connection, the intra-stream feature embedding network flow is generated, where m is 1 to h, and the intra-stream self-attention weighted vector head of each head is calculated m The steps include: Construct h in-stream attention models q m vector, k m vector, v m vector, where m is from 1 to h, E(f) is the embedded network flow, q m Vector is used to find the standard vector, k m The vector is the queried object vector, v m The vector is the content vector of the queried object. are respectively m vector, the k m vector, the v m The parameter matrix corresponding to the vector; The dimension d of the in-stream attention model is m and the number of longs h to obtain k m The dimension of the vector is d k , where d k =d m ÷h; According to the q m vector and the k m Vector, calculate the self-attention score attn m , where the self-attention score softmax(·) is the activation function, T is the matrix transpose; Through the self-attention score attn m and the v m Vector calculation obtains the self-attention weighted vector head within the flow m , the self-attention weighted vector in the stream is used as the in-stream feature embedding network stream output, where head m =attn m ·v m .

6. The method for classifying decentralized program encrypted traffic according to claim 1, characterized in that: Using the inter-stream attention model to perform inter-stream feature mining on the intra-stream feature embedding network flow to generate an inter-stream feature embedding network flow, including: The shape of the intra-stream feature embedded network flow is transformed by a reshaping function to generate a reshaped embedded network flow, wherein the reshaped embedded network flow f″=reshape(f′,(1,batch,(3k+1)·d)), f′ is the intra-stream feature embedded network flow, batch·(3k+1)·d is the vector shape of the intra-stream feature embedded network flow, reshape is a reshaping function, batch is the number of samples input each time in the inter-stream attention model, k is the number of packets used in the network flow, and d is the dimension of k; Construct the q vector, v vector, and k vector in the inter-stream attention model, where q = W q E(f″),k=W k ·E(f″),v=W v E(f″), q vector is the search standard vector, k vector is the queried object vector, v vector is the content vector of the queried object, W q , W k , W v are parameter matrices corresponding to the q vector, the k vector, and the v vector respectively; According to the q vector and the k vector, the self-attention score attn is calculated, where the self-attention score softmax(·) is an activation function, mm(·,·) is a matrix multiplication, Transpose(·,·) is a function for exchanging array dimensions, and d represents the dimension of the k vector; The inter-stream self-attention weighted vector Attention(q,k,v) is calculated by the self-attention score attn and the v vector, and the inter-stream self-attention weighted vector Attention(q,k,v) is used as the inter-stream feature embedding network flow output, wherein the inter-stream self-attention weighted vector Attention(q,k,v)=attn·v.

7. The method for classifying decentralized program encrypted traffic according to claim 1, characterized in that: Using the inter-stream attention model to perform inter-stream feature mining on the intra-stream feature embedding network flow to generate an inter-stream feature embedding network flow, including: Determine the number of heads h, and calculate the inter-flow self-attention weighted vector head for each head n , add all the self-attention weighted vectors head between the streams n After the head-to-tail connection, the inter-stream feature embedding network flow is generated, where n is 1 to h, and the inter-stream self-attention weighted vector head of each head is calculated n The steps include: The inter-stream self-attention weighted vector head is transformed by a shaping function n The shape of is transformed to generate the reshaped inter-flow network flow, where the reshaped inter-flow network flow f″ n = reshape(f′ n ,(1,batch,(3k+1)·d)),f″ n is the network flow after shaping, f′ n is the self-attention weighted vector head between the streams n , batch·(3k+1)·d is the self-attention weighted vector head between the streams n The vector shape of , reshape is a reshaping function, batch is the number of input samples each time in the inter-stream attention model, k is the number of packets used in the network flow, and d is the dimension of k; Construct q of h inter-stream attention models n vector, k n vector, v n Vector, where n is 1 to h, q = W q ·E(f″ n ),k=W k ·E(f″ n ),v=W v ·E(f″ n ), q n Vector is used to find the standard vector, k n The vector is the queried object vector, v n The vector is the content vector of the queried object. are respectively n vector, the k n vector, the v n The parameter matrix corresponding to the vector; By the dimension d of the inter-stream attention model n and the number of longs h to obtain the k n The dimension of the vector is d k , where d k =d n ÷h; According to the q n vector and the k n Vector, calculate the self-attention score attn n , where the self-attention score softmax(·) is the activation function, mm(·,·) is the matrix multiplication, and Transpose(·,·) is the function of exchanging the dimensions of the array; By the self-attention score attn n and the v n Vector calculation to obtain the inter-stream self-attention weighted vector head n , the inter-stream self-attention weighted vector is used as the inter-stream feature embedding network stream output, where head n =attn n ·v n .

8. A decentralized program encrypted traffic classification device, characterized in that: include: A feature embedding module, used to pre-process the original encrypted traffic of the decentralized application to generate an initial network flow, embed the network flow features in the network flow, and generate an embedded network flow; An in-stream feature mining module is used to perform in-stream feature mining on the embedded network flow using an in-stream attention model to generate an in-stream feature embedded network flow, wherein the in-stream attention model is a single-head attention model or a multi-head attention model, the embedded network flow is a single flow composed of multiple data packets, and the in-stream feature embedded network flow is a plurality of groups of network flows; An inter-stream feature mining module, used for performing inter-stream feature mining on the intra-stream feature embedding network stream using an inter-stream attention model to generate an inter-stream feature embedding network stream, wherein the inter-stream attention model is a single-head or multi-head attention model; The identification and classification module is used to use a multi-layer perceptron to identify the network flow in which the inter-flow features are embedded, so as to obtain the classification of the original encrypted flow.

9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for classifying encrypted traffic of a decentralized program as described in any one of claims 1 to 7 is implemented.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program for executing the method for classifying encrypted traffic of a decentralized program according to any one of claims 1 to 7.