Multimodal encrypted traffic classification method based on graph structure and matrix representation
Through a multimodal encrypted traffic classification method based on graph structure and matrix representation, combined with multi-scale CNN and GraphSAGE networks to extract hierarchical spatial features and interactive features, the problem of insufficient expression of encrypted traffic classification features in the existing technology is solved, and high accuracy is achieved encrypted traffic recognition.
Patent Information
- Application Number
- CN202411103408.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-05
- Estimated Expiration
- 2044-08-13
AI Technical Summary
The existing encrypted traffic classification methods have the problem of single traffic input form and insufficient feature representation, and fail to effectively combine spatial and interactive features, resulting in low classification accuracy.
Using a multimodal encrypted traffic classification method based on graph structure and matrix representation, a multi-level representation matrix and traffic interaction graph are constructed through the data preprocessing layer, and hierarchical spatial features and interaction features are extracted by combining multi-scale CNN and GraphSAGE networks, and using The cross-gating control mechanism performs feature fusion, and ultimately uses the Softmax function to achieve fine-grained classification of encrypted traffic.
Improve the characterization and recognition ability of encrypted traffic and improve classification accuracy, especially the multi-classification accuracy and F1 values on ISCX-NonVPN and ISCX-VPN datasets, reaching 93.59%, 98.23%, 95.78% and 98.30 %.
Smart Images

Figure CN118643376B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of secure data transmission, and in particular to a multi-modal encrypted traffic classification method based on graph structure and matrix representation. Background Art
[0002] In order to protect the security of data transmission, the Transport Layer Security (TLS) encryption protocol has gradually developed and matured. The TLS protocol can effectively protect the integrity and security of transmitted data and has been widely deployed in actual networks. However, more and more attackers use TLS encrypted channels to transmit and distribute malware payloads and for communication between command and control (C&C) infected hosts and servers. In recent years, many network attacks have been related to port 443 of the TLS protocol. Therefore, the classification of encrypted traffic is of great significance for information protection, illegal data supervision and network security maintenance.
[0003] At present, the classification methods of encrypted malicious traffic have been widely studied. According to the order in which the methods appear, they can be divided into rule-matching based methods, machine learning and deep learning methods based on manually extracted features, and deep learning methods based on feature self-extraction.
[0004] Existing deep learning methods have the disadvantages of single flow input form (such as using only one-dimensional sequences or grayscale images) and insufficient feature representation (such as not combining spatial features and interaction features at the same time). Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a multimodal encrypted traffic classification method based on graph structure and matrix representation, which has excellent characterization and identification capabilities for encrypted traffic and improves classification accuracy.
[0006] The technical solution adopted by the present invention to solve the technical problem is: a multimodal encrypted traffic classification method based on graph structure and matrix representation, and a multimodal encrypted traffic classification system; the multimodal encrypted traffic classification system includes a data preprocessing layer, a network traffic representation layer and a network traffic classification layer;
[0007] The data preprocessing layer is used to construct a multi-level representation matrix of the conversation flow and a traffic interaction graph;
[0008] The network traffic characterization layer is used for traffic hierarchical spatial feature extraction and traffic interaction information feature extraction;
[0009] The network traffic classification layer is used for cross-gating feature fusion and traffic classification;
[0010] The following steps are also included:
[0011] S1. In the data preprocessing layer, the original PCAP file is divided into session flows, and then converted into a session flow multi-level representation matrix and a traffic interaction graph as multimodal inputs; the traffic interaction graph includes a traffic header interaction graph and a load interaction graph;
[0012] S2, the conversation flow multi-level representation matrix obtained in S1 is used as branch one; the traffic interaction graph is used as branch two;
[0013] In the network traffic representation layer, branch 1 uses Q-layer multi-scale CNN with convolution kernels of different sizes to extract the intra-packet spatial features and inter-packet spatial features of the traffic representation matrix, and connects them to obtain the hierarchical spatial features of the traffic;
[0014] Branch 2 uses a stacked N-layer GraphSAGE network with a skip connection mechanism to extract the interaction features of the header interaction graph and the load interaction graph, and fuses the header features and load features to obtain the graph representation features of a single data packet; then the graph representation features of the first P data packets in the bidirectional flow are connected to obtain the interaction features of the traffic;
[0015] S3. In the network traffic classification layer, a cross-gating mechanism is used to fuse hierarchical spatial features and interactive features to obtain the final representation vector of the traffic, which enhances the expression of important features while limiting the redundant noise introduced by irrelevant features. Then, the Softmax function is used to achieve fine-grained classification of encrypted traffic.
[0016] Furthermore, in step S1, the original PCAP file is divided into session flows, and the conversion of the original PCAP file into a session flow multi-level representation matrix and a traffic interaction graph includes the following steps:
[0017] S11. Use the traffic segmentation tool SplitCap to split the original Pcap file into session flows according to the five-tuple information;
[0018] S12, remove duplicate samples and damaged packages;
[0019] S13, remove strong identification information;
[0020] S14, remove irrelevant protocols and abnormal sessions;
[0021] S15. Select the first m bytes of the header and the first n bytes of the payload of the first P data packets, convert them into a multi-level representation matrix of the session flow of size P×(m+n), and convert them into P header interaction graphs and P payload interaction graphs.
[0022] Furthermore, in step S15, the first m bytes of the headers and the first n bytes of the payload of the first P data packets are converted into a multi-level representation matrix of a session flow of size P×(m+n) using the following method:
[0023] Intercept the first P packets of the session flow. For each packet, extract the first m bytes of its header data and the first n bytes of its payload data. If the length of the packet, header data, and payload data is insufficient, fill the number 256 to P, m, and n respectively; if the length is too long, perform truncation.
[0024] Each row of the traffic multi-level representation matrix corresponds to a data packet, which consists of the header bytes and payload bytes of the data packet; the one-dimensional representation matrices of P data packets are stacked to form a two-dimensional representation matrix of size P×(m+n).
[0025] Furthermore, in step S15, the first m bytes of the headers and the first n bytes of the payloads of the first P data packets are selected and converted into P header interaction graphs and P payload interaction graphs using the following method:
[0026] Convert raw traffic bytes to graph , where V is the node set, E is the node edge set, X represents the initial feature of node V, and the initial feature of node V is an original traffic byte with a value range of 0~255;
[0027] Pointwise Mutual Information (PMI) is used to connect data packets or bytes together; that is, pointwise mutual information is used to calculate the correlation between two bytes, and then the edge E of the traffic interaction graph is constructed based on the PMI value;
[0028] First, a fixed-size sliding window is used to collect traffic byte co-occurrence statistics. Then, the byte co-occurrence is calculated according to the following formula: and The correlation between :
[0029]
[0030]
[0031]
[0032] in Contains bytes The number of sliding windows, It contains both bytes and The number of sliding windows, is the total number of sliding windows;
[0033] The adjacency matrix of the traffic interaction graph G is used to describe the edges between nodes. The elements in the adjacency matrix are Representation Node and nodes Whether there is an edge connection between them is expressed as the following formula:
[0034]
[0035] A positive value indicates that the correlation between the two bytes is high, and vice versa. A zero or negative value indicates a low correlation; Graph edges are created between pairs of bytes with values greater than zero, since , so the constructed flow graph is an undirected graph.
[0036] Furthermore, in step S2, extracting the hierarchical spatial features of the traffic representation matrix using a multi-scale CNN includes the following steps:
[0037] a1. The multi-level representation matrix of the session flow has a hierarchical structure of "header bytes, payload bytes-data packets-bidirectional flows". The convolution kernel of shape (1, 5) is used to extract the internal spatial features of the bytes in the same row of the matrix (a single data packet). At the same time, the convolution kernels of shape (2, 4) and (3, 3) are used to extract the inter-packet spatial features of adjacent data packets.
[0038] a2. Use the Flatten function to flatten the two-dimensional feature matrix into a one-dimensional vector;
[0039] a3. Concatenate all feature vectors to obtain the flow-level hierarchical spatial features of the conversation flow.
[0040] Furthermore, in step S2, the traffic interaction graph uses a stacked N-layer GraphSAGE network to extract the interaction features of the traffic, including the following steps:
[0041] b1. For each node v in the traffic interaction graph G, GraphSAGE Hop depth of adjacent nodes Perform iterative sampling, and then aggregate the neighboring node feature set through the aggregation function to enhance the embedded information representation of the current node v;
[0042] is the number of hops for aggregating node information in each iteration. In the layer, node v is based on the aggregated features of the sampled neighborhood N(v) It can be expressed as the following formula:
[0043]
[0044] in represents the neighborhood nodes, Representation Node The embedding vector in the previous layer, AGG k represents a differentiable aggregator function;
[0045] Use the AGG aggregation function to iteratively aggregate node features from the sampled neighborhood with its own node features;
[0046] b2. Aggregate features of the sampling neighborhood Embedding features with the previous layer nodes Connect them together and apply trainable weights and nonlinear activation function σ to calculate the The final embedding feature of layer node v is shown in the following formula:
[0047]
[0048] Where Concat represents the concatenation operation, and σ represents the Relu activation function;
[0049] b3. For each node, use the skip connection idea to concatenate the output vectors of each layer of the GraphSAGE network as the final representation vector of the node; then apply mean pooling on all nodes to obtain the feature vector of a single graph. , which can be expressed as:
[0050]
[0051] in represents matrix addition, It refers to the final representation vector of each graph node; that is, the final embedding feature of the vth node in the kth layer; v is the number of graph nodes, and k represents the number of layers;
[0052] Finally, the header graph features and the load graph features are connected to obtain the features of a single data packet. The features of each data packet are concatenated to obtain the final interactive features of the bidirectional flow.
[0053] Furthermore, in step S3, using the cross-gated feature fusion mechanism to fuse the flow-level spatial features and the packet-level interaction features into the final representation vector of the traffic includes the following steps:
[0054] c1. Input the feature vector into the filter and the Sigmoid function to form the corresponding gating vector. The filter consists of a PRelu activation function and two linear layers.
[0055] c2. Then use the Sigmoid function to scale the vector elements one by one to the interval [0, 1];
[0056] Using spatial gating vector Filtering Interaction Feature Vectors , otherwise use the interactive gating vector Filtering spatial feature vectors , cross-gated feature fusion is expressed as the following formula:
[0057]
[0058]
[0059]
[0060] The symbol represents element-wise product, is the overall representation vector of the flow, , , , are the weights of the linear layer, , , , is the bias of the linear layer.
[0061] Furthermore, in step S3, implementing fine-grained classification of encrypted traffic using the Softmax function includes the following steps:
[0062] The traffic representation vector z is transformed into the sample category space through the fully connected layer, and the probability P of each category is calculated using the Softmax function. The category corresponding to the maximum P value is taken as the classification result;
[0063] The Softmax function can be expressed as the following formula:
[0064]
[0065] Indicates that the input sample is identified as The probability of a flow rate, is the score of the corresponding category, and e represents a natural constant.
[0066] Beneficial Effects of the Invention
[0067] The multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention has the following advantages:
[0068] 1. The multimodal encrypted traffic classification method based on graph structure and matrix representation described in this application converts traffic into sequence matrix and interaction graph, thereby eliminating feature loss and noise introduction caused by data preprocessing;
[0069] 2. The multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present application uses the multi-level representation matrix of the session flow as branch one; the traffic interaction graph as branch two; branch two uses a stacked N-layer GraphSAGE network with a jump connection mechanism to extract the interaction features of the header interaction graph and the load interaction graph, fuses the header features and the load features to obtain the graph representation features of a single data packet, and then connects the graph representation features of the first P data packets in the bidirectional flow to obtain the interaction features of the traffic; therefore, it can deepen the feature extraction depth and avoid the network being too smooth;
[0070] 3. The multimodal encrypted traffic classification method based on graph structure and matrix representation described in this application uses a cross-gating mechanism to fuse hierarchical spatial features and interactive features to obtain the final representation vector of the traffic, while enhancing the degree of expression of important features and limiting the redundant noise introduced by irrelevant features;
[0071] 4. The multi-modal encrypted traffic classification method based on graph structure and matrix representation described in this application achieved multi-classification accuracies of 93.59% and 98.23% on the public datasets ISCX-NonVPN and ISCX-VPN, respectively, and the average F1 values reached 95.78% and 98.30%; this method has excellent characterization and recognition capabilities for encrypted traffic. BRIEF DESCRIPTION OF THE DRAWINGS
[0072] Figure 1 is a block diagram of a multimodal encrypted traffic classification system in an embodiment of the present invention;
[0073] Figure 2 It is a flowchart of a multi-modal encrypted traffic classification method based on graph structure and matrix representation in an embodiment of the present invention;
[0074] Figure 3 is a flowchart of data preprocessing in an embodiment of the present invention;
[0075] Figure 4 It is a flowchart of the conversation flow hierarchical spatial feature extraction based on multi-scale CNN in an embodiment of the present invention;
[0076] Figure 5 is a schematic diagram of the neighborhood sampling process of GraphSAGE in an embodiment of the present invention;
[0077] Figure 6 is a schematic diagram of a stacked GraphSAGE architecture with jump connections in an embodiment of the present invention;
[0078] Figure 7 is a schematic diagram of gated feature fusion in an embodiment of the present invention;
[0079] Figure 8 is a schematic diagram of experimental results of different embedding dimensions in an embodiment of the present invention;
[0080] Fig. 9 are the experimental results of different (N, Q) combinations on the NonVPN data set in the embodiment of the present invention;
[0081] Fig.10 These are the experimental results of different (N, Q) combinations on the VPN data set in the embodiments of the present invention. DETAILED DESCRIPTION
[0082] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0083] like Figures 1 to 10 As shown, the multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention adopts a multimodal encrypted traffic classification system; the multimodal encrypted traffic classification system includes a data preprocessing layer, a network traffic representation layer and a network traffic classification layer;
[0084] The data preprocessing layer is used to construct a multi-level representation matrix of the conversation flow and a flow interaction graph;
[0085] The network traffic characterization layer is used for traffic hierarchical spatial feature extraction and traffic interaction information feature extraction;
[0086] The network traffic classification layer is used for cross-gating feature fusion and traffic classification;
[0087] The following steps are also included:
[0088] S1. In the data preprocessing layer, the original PCAP file is divided into session flows, and then converted into a session flow multi-level representation matrix and a traffic interaction graph as multimodal inputs; the traffic interaction graph includes a traffic header interaction graph and a load interaction graph;
[0089] Specifically, S11, using the traffic segmentation tool SplitCap to split the original Pcap file into session flows according to the five-tuple information;
[0090] S12, remove duplicate samples and damaged packages;
[0091] S13, remove strong identification information;
[0092] S14, remove irrelevant protocols and abnormal sessions;
[0093] S15. Select the first m bytes of the header and the first n bytes of the payload of the first P data packets, convert them into a multi-level representation matrix of the session flow of size P×(m+n), and convert them into P header interaction graphs and P payload interaction graphs.
[0094] The following method is used to convert the first m bytes of the header and the first n bytes of the payload of the first P packets into a multi-level representation matrix of the session flow of size P×(m+n):
[0095] Intercept the first P packets of the session flow. For each packet, extract the first m bytes of its header data and the first n bytes of its payload data. If the length of the packet, header data, and payload data is insufficient, fill the number 256 to P, m, and n respectively; if the length is too long, perform truncation.
[0096] Each row of the traffic multi-level representation matrix corresponds to a data packet, which consists of the header bytes and payload bytes of the data packet; the one-dimensional representation matrices of P data packets are stacked to form a two-dimensional representation matrix of size P×(m+n).
[0097] The following method is used to select the first m bytes of the header and the first n bytes of the payload of the first P data packets and convert them into P header interaction graphs and P payload interaction graphs:
[0098] Convert raw traffic bytes to graph , where V is the node set, E is the node edge set, X represents the initial feature of node V, and the initial feature of node V is an original traffic byte with a value range of 0~255;
[0099] Pointwise Mutual Information (PMI) is used to connect data packets or bytes together; that is, pointwise mutual information is used to calculate the correlation between two bytes, and then the edge E of the traffic interaction graph is constructed based on the PMI value;
[0100] First, a fixed-size sliding window is used to collect traffic byte co-occurrence statistics. Then, the byte co-occurrence is calculated according to the following formula: and The correlation between :
[0101]
[0102]
[0103]
[0104] in Contains bytes The number of sliding windows, It contains both bytes and The number of sliding windows, is the total number of sliding windows;
[0105] The adjacency matrix of the traffic interaction graph G is used to describe the edges between nodes. The elements in the adjacency matrix are Representation Node and nodes Whether there is an edge connection between them is expressed as the following formula:
[0106]
[0107] A positive value indicates that the correlation between the two bytes is high, and vice versa. A zero or negative value indicates a low correlation; Graph edges are created between pairs of bytes with values greater than zero, since , so the constructed flow graph is an undirected graph.
[0108] S2, the conversation flow multi-level representation matrix obtained in S1 is used as branch one; the traffic interaction graph is used as branch two;
[0109] In the network traffic representation layer, branch 1 uses Q-layer multi-scale CNN with convolution kernels of different sizes to extract the intra-packet spatial features and inter-packet spatial features of the traffic representation matrix, and connects them to obtain the hierarchical spatial features of the traffic;
[0110] Specifically, a1. The multi-level representation matrix of the session flow has a hierarchical structure of "header bytes, payload bytes-data packets-bidirectional flows". The convolution kernel of shape (1, 5) is used to extract the internal spatial features of the same row bytes (single data packet) of the matrix. At the same time, the convolution kernels of shapes (2, 4) and (3, 3) are used to extract the inter-packet spatial features of adjacent data packets.
[0111] a2. Use the Flatten function to flatten the two-dimensional feature matrix into a one-dimensional vector;
[0112] a3. Concatenate all feature vectors to obtain the flow-level hierarchical spatial features of the conversation flow.
[0113] Branch 2 uses a stacked N-layer GraphSAGE network with a skip connection mechanism to extract the interaction features of the header interaction graph and the load interaction graph, and fuses the header features and load features to obtain the graph representation features of a single data packet; then the graph representation features of the first P data packets in the bidirectional flow are connected to obtain the interaction features of the traffic;
[0114] Specifically, b1. For each node v in the traffic interaction graph G, GraphSAGE Hop depth of adjacent nodes Perform iterative sampling, and then aggregate the neighboring node feature set through the aggregation function to enhance the embedded information representation of the current node v;
[0115] K is the number of hops for aggregating node information in each iteration. In the k∈(1, 2, 3, …, K)th layer, the aggregated features of node v based on the sampled neighborhood N(v) It can be expressed as the following formula:
[0116]
[0117] in represents the neighborhood nodes, Representation Node The embedding vector in the previous layer, AGG k represents a differentiable aggregator function;
[0118] Use the AGG aggregation function to iteratively aggregate node features from the sampled neighborhood with its own node features;
[0119] b2. Aggregate features of the sampling neighborhood Embedding features with the previous layer nodes Connect them together and apply trainable weights and nonlinear activation function σ to calculate the The final embedding feature of layer node v is shown in the following formula:
[0120]
[0121] Where Concat represents the concatenation operation, and σ represents the Relu activation function;
[0122] b3. For each node, use the skip connection idea to concatenate the output vectors of each layer of the GraphSAGE network as the final representation vector of the node; then apply mean pooling on all nodes to obtain the feature vector of a single graph. , which can be expressed as:
[0123]
[0124] in represents matrix addition, It refers to the final representation vector of each graph node; that is, the final embedding feature of the vth node in the kth layer; v is the number of graph nodes, and k represents the number of layers;
[0125] Finally, the header graph features and the load graph features are connected to obtain the features of a single data packet. The features of each data packet are concatenated to obtain the final interactive features of the bidirectional flow.
[0126] S3. In the network traffic classification layer, a cross-gating mechanism is used to fuse hierarchical spatial features and interactive features to obtain the final representation vector of the traffic, which enhances the expression of important features while limiting the redundant noise introduced by irrelevant features.
[0127] Specifically, c1, the feature vector is input into the filter and the Sigmoid function to form the corresponding gating vector. The filter consists of a PRelu activation function and two linear layers;
[0128] c2. Then use the Sigmoid function to scale the vector elements one by one to the interval [0, 1];
[0129] Using spatial gating vector Filtering Interaction Feature Vectors , otherwise use the interactive gating vector Filtering spatial feature vectors , cross-gated feature fusion is expressed as the following formula:
[0130]
[0131]
[0132]
[0133] The symbol represents element-wise product, is the overall representation vector of the flow, w c1, w c2, w g1, w g2 is the weight of the linear layer, b c1, b c2, b g1, b g2 is the bias of the linear layer.
[0134] Use the Softmax function to achieve fine-grained classification of encrypted traffic. Specifically, the traffic representation vector z is transformed into the sample category space through the fully connected layer, and the Softmax function is used to calculate the probability P of each category, and the category corresponding to the maximum P value is taken as the classification result;
[0135] The Softmax function can be expressed as the following formula:
[0136]
[0137] Indicates that the input sample is identified as The probability of a flow rate, is the score of the corresponding category, and e represents a natural constant.
[0138] Example
[0139] The multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention adopts a multimodal encrypted traffic classification system mainly including a data preprocessing layer (constructing a multi-level representation matrix of a session flow and a traffic interaction graph), a network traffic characterization layer (extracting traffic hierarchical spatial features and extracting traffic interaction information features), and a network traffic classification layer (cross-gating feature fusion and traffic classification). The model architecture is as follows: Figure 1 shown.
[0140] The workflow is as follows: First, the original PCAP file is split into session flows, and then converted into a multi-level representation matrix of the session flow and a traffic interaction graph as the multimodal input of the model. Branch 1 uses a Q-layer multi-scale CNN with convolution kernels of different sizes to extract the intra-packet spatial features and inter-packet spatial features of the traffic representation matrix, and connects them to obtain the hierarchical spatial features of the traffic. In order to deepen the feature extraction depth and avoid the network being too smooth, branch 2 uses a stacked N-layer GraphSAGE network with a skip connection mechanism to extract the interactive features of the head interaction graph and the load interaction graph, and fuses the head features and load features to obtain the graph representation features of a single data packet. Then, the graph representation features of the first P data packets in the bidirectional flow are connected to obtain the interactive features of the traffic. Finally, the cross-gating mechanism is used to fuse the hierarchical spatial features and the interactive features to obtain the final representation vector of the traffic, which enhances the expression of important features while limiting the redundant noise introduced by irrelevant features, and then the Softmax function is used to achieve fine-grained classification of encrypted traffic.
[0141] The specific steps include:
[0142] 1. Data preprocessing
[0143] WANG W, ZHU M, WANG J, et al. End-to-end encrypted traffic classification with one-dimensional convolution neural networks[C] / / 2017 IEEEinternational conference on intelligence and security informatics (ISI).Beijing, China, 2017. Piscataway: IEEE, 2017: 43-48. Experiments have shown that bidirectional (conversation) flows are composed of data packet interactions between the two communicating parties and have richer features. Therefore, the multimodal encrypted traffic classification method based on graph structure and matrix representation described in this application uses conversation flows in encrypted traffic classification tasks to help achieve better performance. Figure 3As shown in the figure, the traffic segmentation tool SplitCap is used to split the original Pcap file into session streams according to the five-tuple information, and duplicate samples and damaged packets are removed. Since strong identification information (such as IP and port number) is not effective information for distinguishing different types of traffic, the model may cause overfitting when learning this information. In order to eliminate bias interference, the Ethernet header, IP address and protocol port number are deleted, and the following three samples that are irrelevant to communication or abnormal communication are removed: (1) DNS, LLMNR and other protocol sessions (2) Sessions with more than 10,000 packets (3) Sessions with no payload in all packets.
[0144] 1.1. Most existing methods directly intercept the first fixed number of bytes in the bidirectional stream to form a two-dimensional matrix, but in some streams, the first long data packet will occupy the entire matrix, so the matrix cannot fully represent the stream. At the same time, compared with the header, the size of the encrypted payload is usually much larger, resulting in too much low-level semantic information in the matrix, which affects the effectiveness and efficiency of the model.
[0145] The multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention intercepts the first P data packets of the session flow. For each data packet, the first m bytes of its header data and the first n bytes of its payload data are extracted. If the length of the data packet, header data and payload data is insufficient, the number 256 is filled to P, m and n respectively. If the length is too long, a truncation operation is performed. Each row of the traffic multi-level representation matrix corresponds to a data packet, which consists of the header bytes and payload bytes of the data packet. The one-dimensional representation matrices of P data packets are stacked to form a data packet of size This design avoids the loss of traffic information caused by a single data packet being too long.
[0146] 1.2. In order to retain the traffic characteristics as much as possible, the multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention uses the first m header bytes and the first n load bytes of the data packet to construct a traffic interaction graph, but it should be noted that the bytes of the encrypted traffic header and the load have different meanings, which are specifically reflected in: the data header mainly contains unencrypted plaintext information such as quintuples and protocols, which plays a role of control and description in the communication process, while the effective load carries the specific content of the encrypted communication between the two parties. That is, when the bytes of the data header and the effective load have the same representation, their meanings may be vague and different. Based on the above principles, the multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention processes the header and load of the data packet separately, and constructs traffic graphs (i.e., traffic header interaction graph and traffic load interaction graph) for these two parts respectively, with the purpose of reducing confusion in the entire data learning process.
[0147] The multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention converts the original traffic bytes into graph , where V is the node set, E is the node edge set, and X represents the initial feature of node V. The initial feature of node V is an original traffic byte with a value range of 0~255. The traditional traffic graph construction method is to connect data packets or bytes together in chronological order. Its disadvantage is that the constructed graph is very dense and lacks distinguishability in topological structure. Therefore, pointwise mutual information (PMI) is used to calculate the correlation between two bytes, and then the edge E of the traffic interaction graph is constructed based on the PMI value. Pointwise mutual information is a popular measure for modeling the correlation between two words in natural language processing. First, a fixed-size sliding window is used to collect traffic byte co-occurrence statistics, and then the byte co-occurrence statistics are calculated according to formulas (1)-(3). and The correlation between :
[0148] (1)
[0149] (2)
[0150] (3)
[0151] in Contains bytes The number of sliding windows, It contains both bytes and The number of sliding windows, is the total number of sliding windows.
[0152] A positive value indicates that the correlation between the two bytes is high, and vice versa. A zero or negative value indicates a low correlation. Graph edges are created between pairs of bytes with values greater than zero, since , so the constructed traffic graph is an undirected graph. Specifically, the multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention uses the adjacency matrix of the traffic interaction graph G to describe the edges between nodes. The elements in the adjacency matrix are Representation Node and nodes Whether there is an edge connecting them can be expressed as formula (4):
[0153] (4)
[0154] The advantage of using point-by-point mutual information to construct an interaction graph is that edges are only added between bytes with high correlation, which ensures the sparsity of the graph while retaining the correlation information of the graph nodes, prevents the introduction of a large amount of redundant information, and makes the feature extraction process more efficient.
[0155] 2. Network traffic characterization
[0156] The processed traffic representation matrix and interaction graph are used as two inputs of the traffic representation layer. Each byte in the matrix and graph node can be quantified into a specific numerical value, but these values in network traffic lack specific numerical meaning and continuity. Therefore, the multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention maps the initial header bytes and the initial load bytes to two high-dimensional embedding spaces respectively, which can be expressed as , .in , are the number of types of embedded header and payload elements, is the embedding dimension.
[0157] 2.1. Conversation Flow Hierarchical Spatial Feature Extraction Based on Multi-scale CNN
[0158] The multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention uses the multi-level representation matrix of the session flow as the input of the spatial feature extraction layer. Benefiting from the nonlinear hierarchical abstraction ability of deep learning, CNN has been widely used in encrypted traffic classification tasks and has shown impressive performance. CNN can effectively reduce the data dimension and retain most of the key information. Therefore, the multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention uses multi-scale CNN to extract the intra-packet spatial features and inter-packet spatial features of the traffic representation matrix, and connects them to obtain the hierarchical spatial features of the traffic; Figure 4 shown.
[0159] The multi-level representation matrix of the session flow is used as the input of the module, which has a hierarchical structure of "header bytes, payload bytes-data packets-bidirectional flows". If only a fixed-size convolution kernel is used, the internal features of the bytes of the traffic matrix and the spatial features between the previous and next data packets cannot be taken into account during the feature extraction process. Therefore, in order to fully extract the multi-scale spatial information of the traffic matrix, a convolution kernel with a shape of (1, 5) is used to extract the internal spatial features of the bytes in the same row of the matrix (a single data packet), and convolution kernels with shapes of (2, 4) and (3, 3) are used to extract the inter-packet spatial features of adjacent data packets. By extracting features in parallel with three convolution kernels, the receptive field in the multi-scale feature extraction process can be maximized and the feature loss of traffic can be reduced. By performing convolution operations on different receptive areas with three convolution kernels, the model's ability to represent traffic spatial information can be improved.
[0160] The local feature matrix captured by the convolution operation has a high dimension. In order to speed up the calculation and prevent overfitting, the feature matrix is compressed using global maximum pooling, and then the two-dimensional feature matrix is flattened into a one-dimensional vector using the Flatten function. Finally, all feature vectors are concatenated to obtain the flow-level hierarchical spatial features of the conversation flow.
[0161] 2.2 Interactive feature extraction based on GraphSAGE
[0162] The multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention uses traffic interaction graphs to characterize the behavior patterns and structural information of network traffic, and uses graph neural networks for feature extraction. Compared with convolutional neural networks and recurrent neural networks that mainly focus on spatial and temporal features, GNN can integrate spatial topological structures into node feature learning thanks to the node message passing mechanism, and can easily and directly utilize the rich structural information in network flow data.
[0163] like Figure 2 As shown, the module input is the header interaction graph and the load interaction graph of the traffic. The same network structure is used to learn the features of the header and the payload in parallel, but they do not share parameters. The multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention uses a stacked graph sampling and aggregation network as a graph encoder to extract deep implicit interaction information of the traffic. GraphSAGE is WL Hamilton, R. Ying and J. Leskovec. Inductive representation learning on large graphs[C] / / In Proceedings of the31st International Conference on Neural Information Processing Systems (NIPS'17). Red Hook, NY, USA, 2017. New York: ACM, 2017:1025–1035. A deep graph neural network algorithm proposed to solve the transductive learning defects of graph convolutional networks (GCN). For each node v in the traffic interaction graph G, GraphSAGE Hop depth of adjacent nodes Iterative sampling is performed, and then the neighborhood node feature set is aggregated through the aggregation function to enhance the embedded information representation of the current node v. is the number of hops for aggregating node information in each iteration. In the layer, node v is based on the aggregated features of the sampled neighborhood N(v) It can be expressed as formula (5):
[0164] (5)
[0165] in represents the neighborhood nodes, Representation Node In the embedding vector of the previous layer, AGGk represents a differentiable aggregator function. Node aggregation is as follows Figure 5 As shown, the AGG aggregation function is used to iteratively aggregate node features from the sampled neighborhood with its own node features.
[0166] Then the aggregate features of the sampling neighborhood are Embedding features with previous layer nodes Connect them together and apply the model’s trainable weights and nonlinear activation function σ to calculate the first The final embedding feature of layer node v is shown in formula (6):
[0167] (6)
[0168] Concat represents a concatenation operation. is the weight, and σ represents the Relu activation function. The node aggregation process can be visually represented as Figure 5 Taking A as an example, a 2-hop deep neighborhood aggregation is performed on it. The neighborhood nodes of A are B, C, and D, and the neighborhood nodes of B, C, and D are (A, D), (A, D, E), and (B, A, C), respectively. The neighborhood features of nodes B, C, and D are aggregated using the AGG function, and they are concatenated with their own features respectively. Then, the concatenated three features are aggregated using the AGG function to obtain the neighborhood aggregation features of A.
[0169] Due to the problem of over-smoothing in the stacked graph neural network model, for each node, the output vectors of each layer of the GraphSAGE network are concatenated using the skip connection idea as the final representation vector of the node, as shown in Figure 6 Then, mean pooling is applied on all nodes to obtain the feature vector of a single graph. , which can be expressed as:
[0170] (7)
[0171] in represents matrix addition, It refers to the final representation vector of each graph node; that is, the final embedding feature of the vth node in the kth layer; v is the number of graph nodes, and k represents the number of layers;
[0172] Finally, the header graph features and the load graph features are connected to obtain the features of a single data packet. The features of each data packet are concatenated to obtain the final interactive features of the bidirectional flow.
[0173] 3. Cross-gated feature fusion and classification
[0174] The flow-level hierarchical spatial features and packet-level interactive features come from different modal data and represent different meanings, so it is necessary to create a reasonable feature fusion relationship between the two to obtain the overall representation of the traffic. To this end, a cross-gated feature fusion mechanism is used to fuse the flow-level spatial features and packet-level interactive features into the final representation vector of the traffic.
[0175] like Figure 7 As shown in the figure, the feature vector is input into the filter and the Sigmoid function to form the corresponding gating vector. The filter consists of a PRelu activation function and two linear layers. It can learn and adjust the weights in the feature fusion process, and then use the Sigmoid function to scale the vector elements one by one to the [0, 1] interval. Using the spatial gating vector Filtering Interaction Feature Vectors , otherwise use the interactive gating vector Filtering spatial feature vectors ,Such a mechanism can capture the interaction between input features and retain important information of features.,Cross-gated feature fusion can be expressed as formulas (8)-(10).
[0176] (8)
[0177] (9)
[0178] (10)
[0179] The symbol represents element-wise product, is the overall representation vector of the flow, , , , are the weights of the linear layer, , , , is the deviation of the linear layer. Then, the traffic representation vector z is transformed into the sample category space through the fully connected layer, and the Softmax function is used to calculate the probability P of each category, and the category corresponding to the maximum P value is taken as the classification result. The Softmax function can be expressed as formula (11):
[0180] (11)
[0181] Indicates that the input sample is identified as The probability of a flow rate, is the score of the corresponding category, and e represents a natural constant.
[0182] Verification experiment
[0183] 1. Experimental settings and datasets
[0184] This experiment was completed in the Windows 10 operating system, with an Intel(R) Xeon(R) W-2275 @3.30GHz CPU and NVIDIA A4000 graphics card acceleration. Python 3.7, Pytorch and the deep graph neural library DGL were used to complete the model construction and training tuning.
[0185] The model parameters are as follows: In the spatial feature extraction layer, the convolution kernel sizes are (1, 5), (2, 4) and (3, 3), the number of convolution kernels is 64, the activation function is Relu, the global maximum pooling is used, the pooling window size is 2, and the Dropout is set to 0.5. In the interactive feature extraction layer, the PMI sliding window size is 5, the number of node aggregation hops is 1, the pooling method is mean pooling, the batch normalization operation is used, and the Dropout is set to 0.2. In the training stage, the batch size is set to 64, the initial learning rate is set to 0.01, the Adam optimizer with a learning rate scheduler is used, the cross entropy function is selected as the loss function, and the ratio of the training set to the test set is 8:2.
[0186] In order to prove the credibility and effectiveness of the research results, this paper selects the ISCX VPN-nonVPN2016 dataset published in DRAPER-GIL G, LASHKARI AH, MAMUN MSI, et al. Characterization of encrypted and vpn traffic using time-related[C] / / Proceedings of the 2nd international conference on informationsystems security and privacy (ICISSP). Rome, Italy, 2016. Setúbal: SCITEPRESS, 2016: 407-414. to evaluate the multimodal encrypted traffic classification method based on graph structure and matrix representation described in this invention. This is a public dataset with virtual private network (VPN) encryption protocol, which is widely used in the field of network traffic classification research. The original dataset has a total of 25GB of data stored in PCAP format, which contains regular TLS sessions and VPN TLS sessions captured using Wireshark and Tcpdump. From the application perspective, the dataset contains network traffic traces of various functional types, such as email, file transfer, and streaming media traces; from the perspective of encrypted communication, the dataset consists of VPN traces and non-VPN traces. In this study, the dataset is divided into two subsets. The subset of VPN traffic traces is called the VPN data subset, and the subset of non-VPN traffic traces is called the NonVPN data subset. Both subsets contain six types of labels, as shown in Table 1.
[0187] Table 1 Composition of the ISCX VPN-nonVPN2016 data subset
[0188]
[0189] 2. Evaluation indicators
[0190] In order to evaluate the classification effect of the model in this paper on encrypted traffic from multiple aspects, the performance of the multimodal encrypted traffic classification method based on graph structure and matrix representation described in this invention is evaluated using four indicators: accuracy, precision, recall, and F1-score. The specific calculation formula is as follows:
[0191] (12)
[0192] (13)
[0193] (14)
[0194] (15)
[0195] In the above formula, TP represents the number of correctly classified positive examples, FP represents the number of incorrectly classified negative examples, TN represents the number of correctly classified negative examples, and FN represents the number of incorrectly classified positive examples. In terms of Precision, Recall, and F1-score indicators, the macro average is used as the result of all categories.
[0196] 3. Baseline model comparison
[0197] Five deep learning models and two GNN models are used as baselines, and six classification comparison experiments are conducted on two data subsets: 1) 1D-CNN disclosed in WANG W, ZHU M, WANG J, et al. End-to-end encrypted traffic classification with one-dimensional convolution neural networks[C] / / 2017 IEEEinternational conference on intelligence and security informatics (ISI).Beijing, China, 2017. Piscataway: IEEE, 2017: 43-48.: The original data packet bytes are converted into grayscale images and learned using the CNN model.
[0198] 2) LSTM: Convert the original data packet into a one-dimensional sequence, and use the LSTM model in LIN K, XU X, XIAO F. MFFusion:A multi-level features fusion model for malicious traffic detection based on deep learning[J]. Computer Networks, 2022, 202: 108658. to extract features and perform classification.
[0199] 3) FS-Net disclosed in LIU C, HE L, XIONG G, et al. Fs-net: A flow sequence network for encrypted traffic classification[C] / / I-EEE INFOCOM 2019-IEEE Conference OnComputer Communications. , Paris, France, 2019. Piscataway: IE-EE, 2019:1171-1179.: uses packet length sequence as input, adopts bidirectional GRU for feature encoding, and introduces a reconstruction mechanism to ensure the effectiveness of learned features.
[0200] 4) MIMETIC disclosed in ACETO G, CIUONZO D, MONTIERI A, et al. MIMETIC: Mobile encrypted traffic classification using multimodal deep learning[J]. Computer networks, 2019, 165: 106944.: is a multimodal learning method that uses CNN and GRU to learn the first 576 bytes of the payload and information protocol fields respectively.
[0201] 5)WANG X, CHEN S, SU J. App-net: A hybrid neural network for encrypted mobile traffic classification[C] / / IEEE INFOCOM 2020-IEEE Conferenceon Computer Communications Workshops (INFOCOM WKSHPS). T-oronto, ON, Canada,2020. Piscataway: IEEE, 2020: 424-429. App-Net: is a multimodal approach that uses LSTM and CNN to learn the packet length sequence and payload bytes of the initial packet, respectively.
[0202] 6) FB-GNN disclosed in HUOH TL, LUO Y, LI P, et al. Flow-based encrypted network traffic classification with graph neural networks[J]. IEEE Transactions on Network and Service Management, 2022.: Edges are directly created based on the temporal relationship of data packets in the flow, and a geometric learning model is used to learn node, edge and global features.
[0203] 7) HAN X, XU G, ZHANG M, et al. DE-GNN: Dual embedding with graphneural network for fine-grained encrypted traffic classification[J]. ComputerNetworks, 2024, 245: 110372. DE-GNN disclosed in: Use CNN to encode the traffic header and payload into a high-dimensional vector, which is then constructed into a traffic interaction graph, and use the GAT network and attention mechanism to extract traffic interaction features.
[0204] Table 2 Baseline comparison experimental results on VPN data subset (unit: %)
[0205]
[0206] Table 3 Baseline comparison experimental results on the NonVPN data subset (unit: %)
[0207]
[0208] The baseline comparison results obtained on the ISCX-VPN and ISCX-NonVPN data subsets are shown in Table 2-3, and the following conclusions can be drawn:
[0209] 1) Among the seven baseline models, the proposed method achieves the best performance in all four evaluation indicators. Specifically, on the VPN dataset, the accuracy is improved by 14.64%, 4.87%, 5.25%, 17.76%, 2.14%, 13.92%, and 1.35%, respectively; on the NonVPN dataset, the accuracy is improved by 14.88%, 18.20%, 17.33%, 29.53%, 6.48%, 28.56%, and 3.75%, respectively, proving the effectiveness of the encrypted traffic classification method that combines hierarchical spatial features and traffic interaction features.
[0210] 2) The performance of 1D-CNN, LSTM and FS-Net models on both datasets is poor. This is because the three models only apply single temporal features or spatial features of traffic and cannot extract complete and sufficient effective information when traffic is encrypted.
[0211] 3) The method in this study is superior to the two GNN-based methods in all four indicators. This is because the GraphDAPP method only uses the length and direction of the data packet as node features, ignoring the rich information carried by the original bytes, resulting in the loss of traffic features. The DE-GNN method uses the time relationship of the data packet to construct the graph edge. This construction method makes the graph very dense, and it is difficult for the model to extract satisfactory interaction features from the graph that lacks a clear topological relationship. At the same time, graph neural networks are mostly suitable for feature supplementation. Connecting CNN and GNN in series will deepen the network depth, and the error of information will gradually increase during the feature mapping process, resulting in a decrease in model accuracy.
[0212] 4. Ablation experiment
[0213] In order to study the effect of each component of the multimodal encrypted traffic classification method based on graph structure and matrix representation, the following five ablation experiments were conducted on two data subsets:
[0214] 1) Remove the packet payload and construct the traffic representation matrix and interaction graph using only the packet header, expressed w / o P.
[0215] 2) Remove the packet header and use only the packet payload to construct the traffic representation matrix and interaction graph, expressed as w / o H.
[0216] 3) Remove the hierarchical spatial feature extraction branch and only use the traffic interaction features as the final representation of traffic, expressed as w / oC.
[0217] 4) Remove the interactive feature extraction branch and only use the hierarchical spatial features as the final representation of the flow, expressed as w / o G.
[0218] 5) Remove the gated feature fusion strategy and use the Concat operation instead, which is represented by w / o F.
[0219] The results of the ablation test are shown in Table 4-5; the following conclusions can be drawn:
[0220] 1) On the NoVPN dataset, after removing the header information and the payload information, the model accuracy dropped by 1.18% and 9.04% respectively; on the VPN dataset, after removing the header information and the payload information, the model accuracy dropped by 2.84% and 12.77% respectively, indicating that using only the data header or the payload information will lead to a decline in model performance. After removing the header information, the model accuracy dropped more, indicating that in the traffic classification task, the packet header plays a more important role than the payload.
[0221] 2) On both datasets, the classification results of w / o G and w / o C showed different degrees of decline, indicating that using only a single traffic level spatial feature or interactive feature cannot fully characterize the encrypted traffic. The complementary fusion of the two features can effectively improve the recognition rate of encrypted traffic.
[0222] 3) The decrease in w / o F classification accuracy is because the spatial features and interaction features come from different modal data and their features cannot be simply concatenated.
[0223] Table 4 Ablation experiment results on the NoVPN data subset (unit: %)
[0224]
[0225] Table 5 Ablation experiment results on VPN dataset (unit: %)
[0226]
[0227] 5. Model sensitivity analysis
[0228] 5.1. Impact of Packet, Header, and Payload Length on Classification Accuracy
[0229] In the data preprocessing stage, the parameters P, m and n are introduced. P represents the number of data packets used to characterize the bidirectional flow. In this experiment, the value range of P is fixed between 5 and 40, with a value interval of 5. m represents the first m header bytes of a single data packet. The number of bytes in the data packet header is relatively small and consistent, consisting of an IP header (20 bytes), a TCP header (20 bytes) or a UDP header (8 bytes), and an optional header (40 bytes), so the value of m is set to 40 or 50. n represents the first n payload bytes of the data packet, and its value range is set to 150 to 450, with a value interval of 100.
[0230] According to the rule that the header bytes and payload bytes increase simultaneously, they are combined from small to large, and then cross-combined with the number of data packets. Experiments are conducted on the NonVPN data subset to obtain reasonable data packets and byte interception lengths. The experimental results are shown in Table 6.
[0231] Table 6 Accuracy of different (P, m, n) on NoVPN dataset (unit: %)
[0232]
[0233] As can be seen from Table 6, as the number of packets P increases, the classification accuracy of the model initially shows an upward trend. When P is 15, the model performance basically reaches the optimal point. This is because more packet information is used as a representation of the conversation flow, and there is enough information to support the model to learn effectively. As the number of packets P continues to increase, the accuracy of the model generally shows a downward trend. This is because the increase in packet information leads to an increase in the noise introduced by the model, which leads to a decrease in generalization ability. For parameters (m, n), when the number of packets is the same, the model recognition accuracy basically increases with the increase of (m, n), and begins to decrease when it reaches (50, 350), indicating that (m, n) is too large and will introduce too much noise, which will have an adverse effect on the training of the model.
[0234] 5.2 Impact of Embedding Dimension on Classification Accuracy
[0235] In the process of embedding raw bytes, if the embedding dimension is too low, it is difficult to represent the diverse data features, resulting in insufficient generalization ability of the model during the learning process; if the embedding dimension is too high, the data representation is too dense, the model is prone to overfitting during the learning process, and the consumption of computing resources will increase. Therefore, seven embedding dimensions were designed for experiments. The results obtained on two data subsets are as follows: Figure 8 As shown in the figure, as the embedding dimension increases, the classification accuracy of the model gradually increases, reaching the optimal value when dim is 32. Then, as the embedding dimension continues to increase, the generalization ability of the model gradually decreases.
[0236] 5.3 Impact of the number of network layers on classification accuracy
[0237] In the multimodal encrypted traffic classification method based on graph structure and matrix representation described in the present invention, the parameters N and Q are the number of stacking layers of GraphSAGE and CNN, respectively, and they are closely related to the complexity and fitting ability of the model. If the number of stacking layers is too small, the model is not sufficient to extract the deep features of the traffic. Conversely, the model will overfit the subtle information of the data samples, resulting in reduced generalization ability, and as the number of layers is stacked too much, the memory overhead of the model will also increase exponentially. Therefore, only by selecting the appropriate number of layers can the model have excellent generalization and fitting capabilities at the same time. In order to select parameters suitable for the model, N is set to 2-4 layers and Q is set to 1-3 layers, and then cross-combined. The experimental results on two data subsets are as follows. Fig. 9 and 10 As shown. Fig. 9 and 10It can be seen that when N (GraphSAGE layer) is 3 and Q (CNN layer) is 1, the classification results of the model on the two data subsets are optimal. At the same time, it can be found that the number of CNN layers has a great impact on the performance of the model. This is because the stacked deep CNN network has a large number of parameters, and the model is difficult to converge during the training process, resulting in a serious decrease in generalization ability.
[0238] The above-mentioned comparative tests, ablation experiments, and parameter analysis can prove the effectiveness of the multimodal encrypted traffic classification method based on graph structure and matrix representation described in the invention; and it has excellent characterization and identification capabilities for encrypted traffic.
Claims
1. A multimodal encrypted traffic classification method based on graph structure and matrix representation, characterized by: A multimodal encrypted traffic classification system is used; the multimodal encrypted traffic classification system includes a data preprocessing layer, a network traffic characterization layer, and a network traffic classification layer; The data preprocessing layer is used to construct a multi-level representation matrix of the conversation flow and a traffic interaction graph; The network traffic characterization layer is used for traffic hierarchical spatial feature extraction and traffic interaction information feature extraction; The network traffic classification layer is used for cross-gating feature fusion and traffic classification; The following steps are also included: S1. In the data preprocessing layer, the original PCAP file is divided into session flows, and then converted into a session flow multi-level representation matrix and a traffic interaction graph as multimodal inputs; the traffic interaction graph includes a traffic header interaction graph and a load interaction graph; S2, the conversation flow multi-level representation matrix obtained in S1 is used as branch one; the traffic interaction graph is used as branch two; In the network traffic representation layer, branch 1 uses Q-layer multi-scale CNN with convolution kernels of different sizes to extract the intra-packet spatial features and inter-packet spatial features of the traffic representation matrix, and connects them to obtain the hierarchical spatial features of the traffic; Branch 2 uses a stacked N-layer GraphSAGE network with a skip connection mechanism to extract the interaction features of the header interaction graph and the load interaction graph, and fuses the header features and load features to obtain the graph representation features of a single data packet; then the graph representation features of the first P data packets in the bidirectional flow are connected to obtain the interaction features of the traffic; The traffic interaction graph uses a stacked N-layer GraphSAGE network to extract the interaction features of the head interaction graph and the load interaction graph, including the following steps: b1. For each node V in the traffic interaction graph G, GraphSAGE iteratively samples the neighboring nodes u∈N(v) with a depth of k hops, and then aggregates the feature set of the neighboring nodes through an aggregation function to enhance the embedded information representation of the current node V. k is the number of hops for aggregating node information in each iteration. In the kth layer, the aggregated feature h of node v based on the sampled neighborhood N(v) N(v) It can be expressed as the following formula: Where u represents the neighboring node, represents the embedding vector of node u in the previous layer, AGGk represents the differentiable aggregator function; Use the AGG aggregation function to iteratively aggregate node features from the sampled neighborhood with its own node features; b2. Aggregate features of the sampling neighborhood Embedding features with the previous layer nodes Connect them together and apply trainable weights and nonlinear activation function σ to calculate the final embedding features of the k-th layer node v, as shown in the following formula: Where Concat represents the concatenation operation, and σ represents the Relu activation function; b3. For each node, the output vectors of each layer of the GraphSAGE network are concatenated using the idea of skip connection as the final representation vector of the node; then mean pooling is applied on all nodes to obtain the feature vector g of a single graph, which can be expressed as: Finally, the header graph features and the load graph features are connected to obtain the features of a single data packet, and the features of P data packets are concatenated to obtain the final interactive features of the bidirectional flow; S3. In the network traffic classification layer, a cross-gating mechanism is used to fuse hierarchical spatial features and interactive features to obtain the final representation vector of the traffic, which enhances the expression of important features while limiting the redundant noise introduced by irrelevant features. Then, the Softmax function is used to achieve fine-grained classification of encrypted traffic.
2. The multimodal encrypted traffic classification method based on graph structure and matrix representation as claimed in claim 1, characterized in that: In step S1, the original PCAP file is divided into session flows, and the conversion of the session flows into a multi-level representation matrix and a traffic interaction graph includes the following steps: S11. Use the traffic segmentation tool SplitCap to split the original Pcap file into session flows according to the five-tuple information; S12, remove duplicate samples and damaged packages; S13, remove strong marking information; S14, remove irrelevant protocols and abnormal sessions; S15. Select the first m bytes of the header and the first n bytes of the payload of the first P data packets, convert them into a multi-level representation matrix of the session flow of size P×(m+n), and convert them into P header interaction graphs and P payload interaction graphs.
3. The multimodal encrypted traffic classification method based on graph structure and matrix representation as claimed in claim 2, characterized in that: In step S15, the first m bytes of the headers and the first n bytes of the payload of the first P data packets are converted into a multi-level representation matrix of a session flow of size P×(m+n) using the following method: Intercept the first P packets of the session flow. For each packet, extract the first m bytes of its header data and the first n bytes of its payload data. If the length of the packet, header data, and payload data is insufficient, fill the number 256 to P, m, and n respectively; if the length is too long, perform truncation. Each row of the traffic multi-level representation matrix corresponds to a data packet, which is composed of the header bytes and payload bytes of the data packet; the one-dimensional representation matrices of P data packets are stacked to form a two-dimensional representation matrix of size P×(m+n).
4. The multimodal encrypted traffic classification method based on graph structure and matrix representation as claimed in claim 2, characterized in that: In step S15, the first m bytes of the headers and the first n bytes of the payload of the first P data packets are selected and converted into P header interaction graphs and P payload interaction graphs using the following method: Convert the original traffic bytes into a graph G = {V, E, X}, where V is a node set, E is a node edge set, and X represents the initial feature of node V. The initial feature of node V is an original traffic byte with a value range of 0 to 255. Pointwise Mutual Information (PMI) is used to connect data packets or bytes together; that is, pointwise mutual information is used to calculate the correlation between two bytes, and then the edge E of the traffic interaction graph is constructed according to the PMI value; First, a fixed-size sliding window is used to collect traffic byte co-occurrence statistics. Then, the correlation PMI(i, j) between bytes i and j is calculated according to the following formula: Where #W(i) is the number of sliding windows containing byte i, #W(i,j) is the number of sliding windows containing both bytes i and j, and #W is the total number of sliding windows; A positive PMI value indicates that the correlation between the two bytes is high, whereas a zero or negative PMI value indicates a low correlation. Graph edges are created only between byte pairs whose PMI values are greater than zero. Since PMI(i, j) = PMI(j, i), the constructed flow graph is an undirected graph. The adjacency matrix of the traffic interaction graph G is used to describe the edges between nodes. The element a in the adjacency matrix is ij Indicates whether there is an edge connecting node i and node , which is expressed as the following formula:
5. The multimodal encrypted traffic classification method based on graph structure and matrix representation as claimed in claim 1, characterized in that: In step S2, extracting the hierarchical spatial features of the traffic representation matrix using a multi-scale CNN includes the following steps: a1. The multi-level representation matrix of the session flow has a hierarchical structure of "header bytes, payload bytes-data packets-bidirectional flows". The convolution kernel of shape (1, 5) is used to extract the internal spatial features of the bytes in the same row of the matrix (a single data packet). At the same time, the convolution kernels of shapes (2, 4) and (3, 3) are used to extract the inter-packet spatial features of adjacent data packets. a2. Use the Flatten function to flatten the two-dimensional feature matrix into a one-dimensional vector; a3. Concatenate all feature vectors to obtain the flow-level hierarchical spatial features of the conversation flow.
6. The multimodal encrypted traffic classification method based on graph structure and matrix representation as claimed in claim 1, characterized in that: In step S3, using the cross-gated feature fusion mechanism to fuse the flow-level spatial features and the packet-level interaction features into the final representation vector of the traffic includes the following steps: c1. Input the feature vector into the filter and the Sigmoid function to form the corresponding gating vector. The filter consists of a PRelu activation function and two linear layers. c2. Then use the Sigmoid function to scale the vector elements one by one to the interval [0, 1]; Use the spatial gating vector s c Filter the interactive feature vector g, and use the interactive gating vector s instead g Filter the spatial feature vector c, and cross-gated feature fusion is expressed as the following formula: The symbol represents the element-by-element product, z is the overall representation vector of the flow, and w c1 , w c2 , w g1 , w g2 is the weight of the linear layer, b c1 , b c2 , b g1 , b g2 is the bias of the linear layer.
7. The multimodal encrypted traffic classification method based on graph structure and matrix representation as claimed in claim 1, characterized in that: In step S3, the fine-grained classification of encrypted traffic using the Softmax function includes the following steps: The traffic representation vector z is transformed into the sample category space through the fully connected layer, and the probability P of each category is calculated using the Softmax function. The category corresponding to the maximum P value is taken as the classification result; The Softmax function can be expressed as the following formula: P i represents the probability of the input sample being identified as the i-th type of traffic, x i is the score of the corresponding category, and e represents a natural constant.
