A network traffic anomaly detection method and system based on graph representation
Through the combination of graph neural network and random forest model, graph representations in network traffic data are extracted, which solves the problem of difficulty in identifying complex network attack patterns with existing technology, achieves high efficiency and accuracy in network traffic anomaly detection, and ensures network communication safety.
Patent Information
- Application Number
- CN202410593930.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-14
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-05-14
AI Technical Summary
When detecting abnormal network traffic, the existing technology is difficult to effectively identify attack patterns in complex network environments, resulting in the inability to respond to network intrusion attacks in a timely manner and the lack of targeted detection using network node relationships.
Design a network traffic anomaly detection method based on graph representation. Use the graph neural network model to obtain the graph representation from the graph structure of the network traffic data set, combine it with the random forest model for prediction, reduce the size of the sample to be processed and perform parallel calculations to improve Detection efficiency and accuracy.
It achieves accurate identification of network attack behaviors and abnormal traffic activities, improves the accuracy and efficiency of network traffic anomaly detection, and ensures the security and stability of network communications.
Smart Images

Figure CN118200047B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of machine learning, and in particular to a network traffic anomaly detection method and system based on graph representation. Background Art
[0002] With the increasing development of the Internet, the security of network communications has become increasingly important, and a key point is the detection of network traffic anomalies. Network traffic anomalies are early warning signals of network security incidents. Real-time detection and analysis of network traffic anomalies can not only optimize network congestion failures in a timely manner, but also provide early warning of network intrusion attacks, so as to quickly take countermeasures to reduce losses.
[0003] In the existing technology, network traffic anomaly detection usually adopts methods based on statistical analysis and pattern recognition. However, in the face of today's complex and changeable network environment and attack methods, there are great limitations. Attackers can use the relationship patterns of network nodes to launch complex attacks, and the existing detection methods cannot effectively identify the attack patterns, resulting in the inability to respond in time.
[0004] It can be seen that the existing technology has obvious defects in considering the relationship between network nodes. Therefore, how to perform targeted enhancement based on the relationship between network nodes to improve the accuracy and efficiency of network traffic anomaly detection and thus ensure the security and stability of network communications is an urgent problem to be solved. Summary of the invention
[0005] Based on this, the purpose of the present invention is to provide a network traffic anomaly detection method and system based on graph representation. By designing a graph neural network model, the graph representation is obtained from the graph structure of the network traffic data set, the abnormal patterns in the network are effectively captured, and potential network attack behaviors and abnormal traffic activities are accurately identified. Then, by designing a random forest model that integrates graph representation, the scale of samples to be processed is reduced, and parallel calculations can be performed at the same time, which greatly improves the efficiency of network traffic anomaly detection.
[0006] The present invention proposes a network traffic anomaly detection method based on graph representation, comprising:
[0007] Collect network traffic data and perform preprocessing to obtain a network traffic data set;
[0008] Extracting a graph structure according to the network traffic data set, the graph structure includes a node set, an edge set and an edge attribute matrix, marking abnormal nodes of the node set, and then inputting the graph structure into a graph neural network model to obtain a graph representation, the graph neural network model includes a single-layer convolutional layer, a multi-layer graph convolutional layer, a multi-layer linear layer and a fully connected layer;
[0009] The graph representation is enhanced, and then the enhanced graph representation is clustered to obtain sub-datasets of multiple different graph representation categories, and the sub-datasets are input into a random forest model. The random forest model obtains the final network traffic anomaly detection result according to a weighted prediction algorithm.
[0010] In summary, according to the above-mentioned network traffic anomaly detection method based on graph representation, by designing a graph neural network model, the graph representation is obtained from the graph structure of the network traffic data set, the abnormal patterns in the network are effectively captured, and potential network attack behaviors and abnormal traffic activities are accurately identified. Then, by designing a random forest model that integrates graph representation, the scale of samples to be processed is reduced, and parallel computing can be performed at the same time, which greatly improves the efficiency of network traffic anomaly detection. Specifically, network traffic data is collected and preprocessed to obtain a network traffic data set, a graph structure is extracted based on the network traffic data set, the graph structure includes a node set, an edge set and an edge attribute matrix, the node set is labeled with abnormal nodes, and the graph structure is input into a graph neural network model to obtain a graph representation. The graph neural network model includes a single-layer convolutional layer, a multi-layer graph convolutional layer, a multi-layer linear layer and a fully connected layer, which accurately identifies potential network attack behaviors and abnormal traffic activities, greatly improving the accuracy of network traffic anomaly detection, and enhancing the graph representation. The enhanced graph representation is clustered to obtain multiple sub-datasets of different graph representation categories, and the sub-datasets are input into a random forest model. The random forest model obtains the final network traffic anomaly detection result according to a weighted prediction algorithm, reduces the scale of samples to be processed, and can also perform parallel calculations, greatly improving the efficiency of network traffic anomaly detection and achieving security and stability of network communications.
[0011] Furthermore, the steps of collecting network traffic data and preprocessing to obtain a network traffic data set include:
[0012] Collect network traffic data, the network traffic data includes normal traffic data flow and abnormal traffic data flow, convert the network traffic data into feature vectors, and perform standardization and scaling processing on the feature vectors. The standardization and scaling processing formula is as follows:
[0013]
[0014]
[0015]
[0016] in, represents the standardized data of the i-th group in the feature vector, represents the i-th group of original data in the feature vector, represents the mean of the eigenvector, represents the standard deviation of the eigenvector, represents the mean of the i-th group of data in the feature vector, represents the mean of the eigenvector;
[0017] The feature vector after the normalization and scaling process is made into a network traffic data set.
[0018] Furthermore, the step of extracting the graph structure according to the network traffic data set includes:
[0019] The destination IP address and source IP address in the network traffic data set are filtered by feature column content to obtain N non-repeated IP addresses and numbered according to {1,2,3,...,N} to obtain a node set of the graph structure;
[0020] Taking each individual data in the network traffic data set as an edge, and taking the destination IP address and the source IP address as the connection points of the edge, so as to obtain an edge set of a graph structure;
[0021] The features other than the destination IP address and the source IP address in the network traffic data set are used as edge features, and the discrete data in the edge features are converted into continuous data according to a one-hot encoding algorithm to obtain an edge attribute matrix of a graph structure;
[0022] A graph structure is obtained according to the node set, the edge set and the edge attribute matrix.
[0023] Furthermore, the step of marking abnormal nodes on the node set includes:
[0024] Obtain the destination IP address and source IP address of the abnormal traffic data flow in the network traffic data set to screen the abnormal IP addresses, and then screen the corresponding abnormal nodes in the node set of the graph structure according to the abnormal IP addresses;
[0025] According to the label feature A b The node set is labeled, and the label feature A of the abnormal node b (v)=1, label feature A of normal node b (v)=0, where v represents a node.
[0026] Furthermore, the step of inputting the graph structure into the graph neural network model to obtain the graph representation includes:
[0027] Inputting the graph structure into a graph neural network model, wherein the graph neural network model includes a single convolution layer, a multi-layer graph convolution layer, a multi-layer linear layer, and a fully connected layer;
[0028] The single-layer convolution layer is a one-dimensional convolution layer, which maps each node v in the graph structure node set to an embedding vector of dimension d, where d represents the number of features in a single node, and d is 400. The embedding vector is represented as follows:
[0029]
[0030] in, represents the embedding vector of the i-th node, i∈{1,2,...,N}, N represents the total number of nodes in the node set;
[0031] The multi-layer graph convolution layer includes a multi-layer aggregation module, which aggregates information between a single node and its adjacent nodes in the graph structure node set to obtain multi-scale node features. The layer propagation formula of the multi-layer graph convolution layer is as follows:
[0032]
[0033] in, is a nonlinear activation function, is the adjacency matrix, To add a self-join, for The degree matrix of For the l The feature representation of the layer, For the l +1 layer of feature representation, For the l The learnable filter parameters of the layer;
[0034] The multi-layer linear layer performs multi-scale node feature splicing according to the following formula:
[0035]
[0036] in, is the output of the previous linear layer, is the input of the initial linear layer, is the weight matrix;
[0037] The binary classification prediction result of the node output by the fully connected layer is used to obtain a graph representation;
[0038] The loss is calculated according to the Focal Loss function, which is as follows:
[0039]
[0040] in, is the difference between the predicted value and the target value, Represents the predicted value, ɑ is the adjustment factor for adjusting the category weight, γ represents the adjustment factor for adjusting the contribution of simple sample loss, set γ=2, ɑ=0.25, y is the true value of the sample, y=1 represents a positive sample, and y=0 represents a negative sample.
[0041] Furthermore, the step of enhancing the graph representation and clustering the enhanced graph representation to obtain a plurality of sub-datasets of different graph representation categories includes:
[0042] According to the graph representation, the destination IP address and source IP address in the network traffic dataset are replaced with the embedded vector and concatenated back into the original network traffic dataset, and the network traffic dataset is enhanced to a size of R-2+C×2, where R is the original dimension of the network traffic dataset and C is the embedding dimension of the graph representation.
[0043] The enhanced network traffic dataset is clustered according to the graph representation categories to obtain K sub-datasets, where K is a hyperparameter.
[0044] Furthermore, the step of inputting the sub-dataset into a random forest model, wherein the random forest model obtains a final network traffic anomaly detection result according to a weighted prediction algorithm comprises:
[0045] The sub-datasets are input into the random forest model, and the random forest model assigns separate random forest classifiers to the sub-datasets of different graph representation categories and performs parallel classification detection operations. After obtaining the classification detection results, weight calculation is performed. The weight calculation formula is as follows:
[0046]
[0047] in, is the error rate of the random forest classifier, is the voting weight. When the error rate is 0.5, the random forest classifier has no voting weight. When the error rate is greater than 0.5, a negative weight vote is cast. When the error rate is less than 0.5, a positive weight vote is cast.
[0048] The final network traffic anomaly detection result is obtained according to the following formula:
[0049]
[0050] in, is the result of sample x on the i-th random forest classifier, is the voting weight of the i-th random forest classifier, sign(·) is a function that parses positive and negative signs, The final detection result of sample x after integrating all k random forest classifiers.
[0051] The present invention proposes a network traffic anomaly detection system based on graph representation, comprising:
[0052] A collection module, used for collecting network flow data and performing preprocessing to obtain a network flow data set;
[0053] A graph processing module, used to extract a graph structure according to the network traffic data set, the graph structure including a node set, an edge set and an edge attribute matrix, annotate the node set with abnormal nodes, and then input the graph structure into a graph neural network model to obtain a graph representation, the graph neural network model including a single-layer convolutional layer, a multi-layer graph convolutional layer, a multi-layer linear layer and a fully connected layer;
[0054] The detection module is used to enhance the graph representation and then cluster the enhanced graph representation to obtain sub-datasets of multiple different graph representation categories, and input the sub-datasets into a random forest model. The random forest model obtains the final network traffic anomaly detection result according to a weighted prediction algorithm.
[0055] The present invention also provides a storage medium, which stores one or more programs, and when the programs are executed by a processor, the network traffic anomaly detection method based on graph representation as described above is implemented.
[0056] The present invention also provides a computer device, the computer device comprising a memory and a processor, wherein:
[0057] The memory is used to store computer programs;
[0058] When the processor is used to execute the computer program stored in the memory, the network traffic anomaly detection method based on graph representation as described above is implemented. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 A flowchart of a network traffic anomaly detection method based on graph representation proposed in the first embodiment of the present invention;
[0060] Figure 2 A flowchart of a network traffic anomaly detection method based on graph representation proposed in the second embodiment of the present invention;
[0061] Figure 3 This is a schematic diagram of the structure of a network traffic anomaly detection system based on graph representation proposed in the third embodiment of the present invention.
[0062] The following specific implementation manner will further illustrate the present invention in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION
[0063] In order to facilitate understanding of the present invention, the present invention will be described more fully below with reference to the relevant drawings. Several embodiments of the present invention are provided in the drawings. However, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present invention more thorough and comprehensive.
[0064] It should be noted that when an element is referred to as being "fixed to" another element, it may be directly on the other element or there may be a central element. When an element is considered to be "connected to" another element, it may be directly connected to the other element or there may be a central element at the same time. The terms "vertical", "horizontal", "left", "right" and similar expressions used herein are for illustrative purposes only.
[0065] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present invention belongs. The terms used herein in the specification of the present invention are only for the purpose of describing specific embodiments and are not intended to limit the present invention. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.
[0066] See also Figure 1 , which is a flow chart of a network traffic anomaly detection method based on graph representation proposed in the first embodiment of the present invention, and the network traffic anomaly detection method based on graph representation includes steps S01 to S03, wherein:
[0067] Step S01: Collect network traffic data and perform preprocessing to obtain a network traffic data set;
[0068] It should be noted that in this embodiment, a PCAP network flow record file is obtained by using a flow capture software, and the characteristic information of the network data packets contained in the PCAP file is collected by using a CICflowmeter tool according to the Netflow v9 processing format, and the network flow data is output in the form of a csv file, and the network flow data is converted into a feature vector, and the feature vector is standardized and scaled. The standardized scaling processing formula is as follows:
[0069]
[0070]
[0071]
[0072] in, represents the standardized data of the i-th group in the feature vector, represents the i-th group of original data in the feature vector, represents the mean of the eigenvector, represents the standard deviation of the eigenvector, represents the mean of the i-th group of data in the feature vector, It represents the mean of the feature vector, and the feature vector after standardization and scaling is made into a network traffic data set.
[0073] Step S02: extracting a graph structure according to the network traffic data set, the graph structure includes a node set, an edge set and an edge attribute matrix, annotating abnormal nodes in the node set, and then inputting the graph structure into a graph neural network model to obtain a graph representation, the graph neural network model includes a single-layer convolutional layer, a multi-layer graph convolutional layer, a multi-layer linear layer and a fully connected layer;
[0074] It should be noted that in order to extract the graph structure in this embodiment, it is necessary to obtain the node set, edge set and edge attribute matrix of the graph structure. First, the feature column content of the destination IP address and the source IP address in the network traffic data set is screened to obtain N non-repeating IP addresses and number them according to {1, 2, 3, ..., N} to obtain the node set of the graph structure. Then, each individual data in the network traffic data set is used as an edge, and the destination IP address and the source IP address are used as the connection points of the edges to obtain the edge set of the graph structure. The features other than the destination IP address and the source IP address in the network traffic data set are used as the features of the edges. According to the one-hot encoding algorithm, the discrete data in the edge features are converted into continuous data to obtain the edge attribute matrix of the graph structure, and finally the graph structure extraction is completed.
[0075] It should be noted that in this embodiment, the abnormal node annotation of the node set is performed by utilizing the annotation of abnormal traffic in the network traffic data set, and the contents of the two feature columns of the destination IP address and source IP address of the network traffic data set involving abnormal traffic are screened to obtain t non-repeated IP addresses, which are mapped to t nodes in the node set V. At the data level, a feature A is added to the node set V. b As the abnormal label, A b The node v marked by (v)=1 is an abnormal node, A b The node v marked by (v)=0 is a normal node.
[0076] It should be noted that the graph neural network model in this embodiment includes a single-layer convolution layer, a multi-layer graph convolution layer, a multi-layer linear layer and a fully connected layer. The single-layer convolution layer is a one-dimensional convolution layer, and each node v in the graph structure node set is mapped to an embedding vector of dimension d, where d represents the number of features in a single node, and d is 400. The embedding vector is represented as follows:
[0077]
[0078] in, represents the embedding vector of the i-th node, i∈{1,2,...,N}, N represents the total number of nodes in the node set, and the multi-layer graph convolution layer includes a multi-layer aggregation module, which aggregates the information between a single node and its adjacent nodes in the graph structure node set to obtain multi-scale node features. The layer propagation formula of the multi-layer graph convolution layer is as follows:
[0079]
[0080] in, is a nonlinear activation function, is the adjacency matrix, To add a self-join, for The degree matrix of For the l The feature representation of the layer, For the l +1 layer of feature representation, For the l The learnable filter parameters of the layer, the multi-layer linear layer performs multi-scale node feature splicing according to the following formula:
[0081]
[0082] in, is the output of the previous linear layer, is the input of the initial linear layer, is the weight matrix, and the binary classification prediction result of the fully connected layer output node is used to obtain the graph representation. In this embodiment, the loss is calculated according to the Focal Loss function, and the Focal Loss function is as follows:
[0083]
[0084] in, is the difference between the predicted value and the target value, Represents the predicted value, ɑ is the adjustment factor for adjusting the category weight, γ represents the adjustment factor for adjusting the contribution of simple sample loss, set γ=2, ɑ=0.25, y is the true value of the sample, y=1 represents a positive sample, y=0 represents a negative sample, and the graph neural network model used in this embodiment can effectively capture the complex structural information in the network traffic data. By converting the IP addresses in the network traffic into nodes, it can consider the connection relationship and interaction mode between nodes, thereby extracting richer and more representative graph representations. The graph representation of network traffic can more accurately identify abnormal traffic, improve the accuracy and recall rate of anomaly detection in various attack scenarios, and help the model understand and summarize the basic characteristics of network traffic, thereby showing better generalization ability on new attack types or variants that have not been seen. Especially when facing large-scale network traffic data, the graph representation reduces the dimension and complexity of the data, making the model training and reasoning process more efficient.
[0085] Step S03: Enhance the graph representation, and then cluster the enhanced graph representation to obtain multiple sub-datasets of different graph representation categories, input the sub-datasets into the random forest model, and the random forest model obtains the final network traffic anomaly detection result according to the weighted prediction algorithm;
[0086] It should be noted that the enhancement processing in this embodiment is to replace the destination IP address and source IP address in the network traffic dataset with embedded vectors according to the graph representation and splice them back into the original network traffic dataset, and enhance the network traffic dataset to a size of R-2+C×2, where R is the original dimension of the network traffic dataset and C is the embedded dimension of the graph representation. In this embodiment, the enhanced network traffic dataset is clustered according to the graph representation category, and the K-MEANS clustering algorithm is used to obtain K sub-datasets, where K is a hyperparameter.
[0087] It should be noted that the random forest model in this embodiment includes multiple random forest classifiers, each of which is composed of multiple decision trees. The decision trees are random sampled with replacement by using the Bootstrap Sampling algorithm to create multiple different training subsets as samples at their root nodes. Each iteration of the decision tree selects a split point from all features according to the rule of information entropy, splits the node into two child nodes, and obtains a left child node and a right child node. These child nodes will become new split candidate nodes in the next round of iteration. Each round of iteration will increase the depth of the decision tree by one layer until the preset maximum depth is reached. In order to integrate the detection results of each random forest classifier, weight calculation needs to be performed after the classification detection results are obtained. The weight calculation formula is as follows:
[0088]
[0089] in, is the error rate of the random forest classifier, is the voting weight. When the error rate is 0.5, the random forest classifier has no voting weight. When the error rate is greater than 0.5, a negative weight vote is cast. When the error rate is less than 0.5, a positive weight vote is cast. The final network traffic anomaly detection result is obtained according to the following formula:
[0090]
[0091] in, is the result of sample x on the i-th random forest classifier, is the voting weight of the i-th random forest classifier, sign(·) is a function that parses positive and negative signs, The random forest model integrating graph representations designed by the present invention is able to learn data features at multiple levels, from the global characteristics of the graph structure to local node features. This multi-level feature learning method helps to improve the performance of the model on complex data sets, cluster the graph representations, and divide the samples based on the graph representation categories, which can not only significantly enhance the model's ability to process and understand complex network structure data, but also reduce the sample size and improve the efficiency of network traffic anomaly detection. Furthermore, the random forest model integrating graph representations designed by the present invention also has good flexibility. By modifying the number of graph representation clustering clusters, the total number of random forest classifiers and the number of samples processed by each classifier can be controlled, thereby affecting the processing speed and classification accuracy to adapt to different network traffic anomaly detection demand scenarios.
[0092] In summary, according to the above-mentioned network traffic anomaly detection method based on graph representation, by designing a graph neural network model, the graph representation is obtained from the graph structure of the network traffic data set, the abnormal patterns in the network are effectively captured, and potential network attack behaviors and abnormal traffic activities are accurately identified. Then, by designing a random forest model that integrates graph representation, the scale of samples to be processed is reduced, and parallel computing can be performed at the same time, which greatly improves the efficiency of network traffic anomaly detection. Specifically, network traffic data is collected and preprocessed to obtain a network traffic data set, a graph structure is extracted based on the network traffic data set, the graph structure includes a node set, an edge set and an edge attribute matrix, the node set is labeled with abnormal nodes, and the graph structure is input into a graph neural network model to obtain a graph representation. The graph neural network model includes a single-layer convolutional layer, a multi-layer graph convolutional layer, a multi-layer linear layer and a fully connected layer, which accurately identifies potential network attack behaviors and abnormal traffic activities, greatly improving the accuracy of network traffic anomaly detection, and enhancing the graph representation. The enhanced graph representation is clustered to obtain multiple sub-datasets of different graph representation categories, and the sub-datasets are input into a random forest model. The random forest model obtains the final network traffic anomaly detection result according to a weighted prediction algorithm, reduces the scale of samples to be processed, and can also perform parallel calculations, greatly improving the efficiency of network traffic anomaly detection and achieving security and stability of network communications.
[0093] See also Figure 2 , which is a flow chart of a network traffic anomaly detection method based on graph representation proposed in the second embodiment of the present invention, and the network traffic anomaly detection method based on graph representation includes steps S11 to S16, wherein:
[0094] Step S11: collecting network flow data, performing standardization and scaling processing on the network flow data, and making the network flow data after the standardization and scaling processing into a network flow data set;
[0095] Step S12: filtering the destination IP address and the source IP address in the network traffic data set for feature column content to obtain N non-repeating IP addresses and numbering them to obtain a node set of a graph structure, taking each individual data in the network traffic data set as an edge, and the destination IP address and the source IP address as edge connection points to obtain an edge set of a graph structure, taking the features other than the destination IP address and the source IP address in the network traffic data set as edge features, converting discrete data in the edge features into continuous data according to a one-hot encoding algorithm to obtain an edge attribute matrix of a graph structure, and obtaining a graph structure according to the node set, the edge set and the edge attribute matrix;
[0096] Step S13: Obtain the destination IP address and source IP address of the abnormal traffic data flow in the network traffic data set to screen the abnormal IP addresses, and then screen the corresponding abnormal nodes in the node set of the graph structure according to the abnormal IP addresses, and mark the nodes in the node set according to the label features;
[0097] Step S14: input the graph structure into the graph neural network model, which includes a single-layer convolution layer, a multi-layer graph convolution layer, a multi-layer linear layer and a fully connected layer. The single-layer convolution layer maps each node in the graph structure node set to an embedding vector. The multi-layer graph convolution layer includes a multi-layer aggregation module. The multi-layer aggregation module aggregates the information between a single node in the graph structure node set and its adjacent nodes to obtain multi-scale node features. The multi-layer linear layer performs multi-scale node feature splicing. The fully connected layer outputs the binary classification prediction results of the nodes to obtain the graph representation, and the loss is calculated according to the Focal Loss function.
[0098] Step S15: According to the graph representation, the destination IP address and the source IP address in the network traffic data set are replaced with the embedded vector and spliced back into the original network traffic data set, the network traffic data set is enhanced to a size of R-2+C×2, and the enhanced network traffic data set is clustered according to the graph representation category to obtain K sub-data sets;
[0099] Step S16: Input the sub-datasets into the random forest model. The random forest model assigns separate random forest classifiers to the sub-datasets of different graph representation categories and performs parallel classification detection operations. After obtaining the classification detection results, weight calculation is performed to obtain the final network traffic anomaly detection results.
[0100] In summary, according to the above-mentioned network traffic anomaly detection method based on graph representation, by designing a graph neural network model, the graph representation is obtained from the graph structure of the network traffic data set, the abnormal patterns in the network are effectively captured, and potential network attack behaviors and abnormal traffic activities are accurately identified. Then, by designing a random forest model that integrates graph representation, the scale of samples to be processed is reduced, and parallel computing can be performed at the same time, which greatly improves the efficiency of network traffic anomaly detection. Specifically, network traffic data is collected and preprocessed to obtain a network traffic data set, a graph structure is extracted based on the network traffic data set, the graph structure includes a node set, an edge set and an edge attribute matrix, the node set is labeled with abnormal nodes, and the graph structure is input into a graph neural network model to obtain a graph representation. The graph neural network model includes a single-layer convolutional layer, a multi-layer graph convolutional layer, a multi-layer linear layer and a fully connected layer, which accurately identifies potential network attack behaviors and abnormal traffic activities, greatly improving the accuracy of network traffic anomaly detection, and enhancing the graph representation. The enhanced graph representation is clustered to obtain multiple sub-datasets of different graph representation categories, and the sub-datasets are input into a random forest model. The random forest model obtains the final network traffic anomaly detection result according to a weighted prediction algorithm, reduces the scale of samples to be processed, and can also perform parallel calculations, greatly improving the efficiency of network traffic anomaly detection and achieving security and stability of network communications.
[0101] See also Figure 3 , which is a schematic diagram of the structure of a network traffic anomaly detection system based on graph representation proposed in the third embodiment of the present invention, and the system includes:
[0102] The collection module 10 is used to collect network flow data and perform preprocessing to obtain a network flow data set;
[0103] A graph processing module 20 is used to extract a graph structure according to the network traffic data set, wherein the graph structure includes a node set, an edge set, and an edge attribute matrix, annotate the node set with abnormal nodes, and then input the graph structure into a graph neural network model to obtain a graph representation, wherein the graph neural network model includes a single-layer convolutional layer, a multi-layer graph convolutional layer, a multi-layer linear layer, and a fully connected layer;
[0104] The detection module 30 is used to enhance the graph representation, and then cluster the enhanced graph representation to obtain sub-datasets of multiple different graph representation categories, and input the sub-datasets into the random forest model. The random forest model obtains the final network traffic anomaly detection result according to the weighted prediction algorithm.
[0105] Furthermore, the acquisition module 10 includes:
[0106] The collecting unit 101 is used to collect network flow data and perform preprocessing to obtain a network flow data set.
[0107] Furthermore, the graph processing module 20 includes:
[0108] A graph structure extraction and annotation unit 201 is used to extract a graph structure according to the network traffic data set, wherein the graph structure includes a node set, an edge set and an edge attribute matrix, and annotate abnormal nodes on the node set;
[0109] The graph representation acquisition unit 202 is used to input the graph structure into a graph neural network model to obtain a graph representation. The graph neural network model includes a single convolutional layer, a multi-layer graph convolutional layer, a multi-layer linear layer and a fully connected layer.
[0110] Furthermore, the detection module 30 includes:
[0111] An enhanced clustering unit 301 is used to enhance the graph representation, and then cluster the enhanced graph representation to obtain a plurality of sub-datasets of different graph representation categories;
[0112] The detection unit 302 is used to input the sub-dataset into the random forest model, and the random forest model obtains the final network traffic anomaly detection result according to the weighted prediction algorithm.
[0113] The present invention also proposes a computer storage medium on which one or more programs are stored, and when the program is executed by a processor, the above-mentioned network traffic anomaly detection method based on graph representation is implemented.
[0114] The present invention also proposes a computer device, comprising a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to implement the above-mentioned network traffic anomaly detection method based on graph representation.
[0115] Those skilled in the art will appreciate that the logic and / or steps represented in the flowchart or otherwise described herein, for example, may be considered as an ordered list of executable instructions for implementing logical functions, and may be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in conjunction with such instruction execution systems, devices or apparatuses. For purposes of this specification, "computer-readable medium" may be any device that can contain storage, communication, propagation or transmission of a program for use by an instruction execution system, device or apparatus, or in conjunction with such instruction execution systems, devices or apparatuses.
[0116] More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk case (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be a paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, deciphering or, if necessary, processing in another suitable manner, and then stored in a computer memory.
[0117] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or a combination thereof: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0118] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0119] The above-mentioned embodiments only express several implementation methods of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the patent of the present invention. It should be pointed out that, for ordinary technicians in this field, several variations and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention. Therefore, the protection scope of the patent of the present invention shall be subject to the attached claims.
Claims
1. A network traffic anomaly detection method based on graph representation, characterized in that: include: Collect network traffic data and perform preprocessing to obtain a network traffic data set; Extracting a graph structure according to the network traffic data set, the graph structure includes a node set, an edge set and an edge attribute matrix, marking abnormal nodes of the node set, and then inputting the graph structure into a graph neural network model to obtain a graph representation, the graph neural network model includes a single-layer convolutional layer, a multi-layer graph convolutional layer, a multi-layer linear layer and a fully connected layer; The single-layer convolution layer is a one-dimensional convolution layer, which maps each node v in the graph structure node set to an embedding vector of dimension d, where d represents the number of features in a single node, and d is 400. The embedding vector is represented as follows: in, represents the embedding vector of the i-th node, i∈{1,2,...,N}, N represents the total number of nodes in the node set; The multi-layer graph convolution layer includes a multi-layer aggregation module, which aggregates information between a single node and its adjacent nodes in the graph structure node set to obtain multi-scale node features. The layer propagation formula of the multi-layer graph convolution layer is as follows: in, is a nonlinear activation function, is the adjacency matrix, To add a self-join, for The degree matrix of For the l The feature representation of the layer, For the l +1 layer of feature representation, For the l The learnable filter parameters of the layer; The multi-layer linear layer performs multi-scale node feature concatenation according to the following formula: in, is the output of the previous linear layer, is the input of the initial linear layer, is the weight matrix; The binary classification prediction result of the node output by the fully connected layer is used to obtain a graph representation; The loss is calculated according to the Focal Loss function, which is as follows: in, is the difference between the predicted value and the target value, represents the predicted value, ɑ is the adjustment factor for adjusting the category weight, γ represents the adjustment factor for adjusting the contribution of simple sample loss, set γ=2, ɑ=0.25, y is the true value of the sample, y=1 represents a positive sample, y=0 represents a negative sample; The graph representation is enhanced, and then the enhanced graph representation is clustered to obtain sub-datasets of multiple different graph representation categories, and the sub-datasets are input into a random forest model. The random forest model obtains the final network traffic anomaly detection result according to a weighted prediction algorithm.
2. The network traffic anomaly detection method based on graph representation according to claim 1 is characterized in that: The steps of collecting network traffic data and preprocessing to obtain a network traffic data set include: Collect network traffic data, the network traffic data includes normal traffic data flow and abnormal traffic data flow, convert the network traffic data into feature vectors, and perform standardization and scaling processing on the feature vectors. The standardization and scaling processing formula is as follows: in, represents the standardized data of the i-th group in the feature vector, represents the i-th group of original data in the feature vector, represents the mean of the eigenvector, represents the standard deviation of the eigenvector, represents the mean of the i-th group of data in the feature vector, represents the mean of the eigenvector; The feature vector after the normalization and scaling process is made into a network traffic data set.
3. The network traffic anomaly detection method based on graph representation according to claim 1 is characterized in that: The step of extracting a graph structure according to the network traffic data set comprises: The destination IP address and source IP address in the network traffic data set are filtered by feature column content to obtain N non-repeated IP addresses and numbered according to {1,2,3,...,N} to obtain a node set of the graph structure; Taking each individual data in the network traffic data set as an edge, and taking the destination IP address and the source IP address as the connection points of the edge, so as to obtain an edge set of a graph structure; The features other than the destination IP address and the source IP address in the network traffic data set are used as edge features, and the discrete data in the edge features are converted into continuous data according to a one-hot encoding algorithm to obtain an edge attribute matrix of a graph structure; A graph structure is obtained according to the node set, the edge set and the edge attribute matrix.
4. The network traffic anomaly detection method based on graph representation according to claim 1 is characterized in that: The step of marking abnormal nodes on the node set comprises: Obtain the destination IP address and source IP address of the abnormal traffic data flow in the network traffic data set to screen the abnormal IP addresses, and then screen the corresponding abnormal nodes in the node set of the graph structure according to the abnormal IP addresses; According to the label feature A b The node set is labeled, and the label feature A of the abnormal node b (v)=1, label feature A of normal node b (v)=0, where v represents a node.
5. The network traffic anomaly detection method based on graph representation according to claim 1 is characterized in that: The step of enhancing the graph representation and clustering the enhanced graph representation to obtain a plurality of sub-datasets of different graph representation categories includes: According to the graph representation, the destination IP address and source IP address in the network traffic dataset are replaced with the embedded vector and concatenated back into the original network traffic dataset, and the network traffic dataset is enhanced to a size of R-2+C×2, where R is the original dimension of the network traffic dataset and C is the embedding dimension of the graph representation. The enhanced network traffic dataset is clustered according to the graph representation categories to obtain K sub-datasets, where K is a hyperparameter.
6. The network traffic anomaly detection method based on graph representation according to claim 1 is characterized in that: The step of inputting the sub-dataset into a random forest model, wherein the random forest model obtains a final network traffic anomaly detection result according to a weighted prediction algorithm comprises: The sub-datasets are input into the random forest model, and the random forest model assigns separate random forest classifiers to the sub-datasets of different graph representation categories and performs parallel classification detection operations. After obtaining the classification detection results, weight calculation is performed. The weight calculation formula is as follows: in, is the error rate of the random forest classifier, is the voting weight. When the error rate is 0.5, the random forest classifier has no voting weight. When the error rate is greater than 0.5, a negative weight vote is cast. When the error rate is less than 0.5, a positive weight vote is cast. The final network traffic anomaly detection result is obtained according to the following formula: in, is the result of sample x on the i-th random forest classifier, is the voting weight of the i-th random forest classifier, sign(·) is a function that parses positive and negative signs, The final detection result of sample x after integrating all k random forest classifiers.
7. A network traffic anomaly detection system based on graph representation, characterized in that: include: A collection module, used for collecting network flow data and performing preprocessing to obtain a network flow data set; A graph processing module is used to extract a graph structure according to the network traffic data set, wherein the graph structure includes a node set, an edge set and an edge attribute matrix, annotate the node set with abnormal nodes, and then input the graph structure into a graph neural network model to obtain a graph representation, wherein the graph neural network model includes a single-layer convolution layer, a multi-layer graph convolution layer, a multi-layer linear layer and a fully connected layer, wherein the single-layer convolution layer is a one-dimensional convolution layer, and each node v in the graph structure node set is mapped to an embedding vector of dimension d, wherein d represents the number of features in a single node, and d is 400. The embedding vector is represented as follows: in, represents the embedding vector of the i-th node, i∈{1,2,...,N}, N represents the total number of nodes in the node set, the multi-layer graph convolution layer includes a multi-layer aggregation module, the multi-layer aggregation module aggregates the information between a single node and its adjacent nodes in the graph structure node set to obtain multi-scale node features, and the layer propagation formula of the multi-layer graph convolution layer is as follows: in, is a nonlinear activation function, is the adjacency matrix, To add a self-join, for The degree matrix of For the l The feature representation of the layer, For the l +1 layer of feature representation, For the l The learnable filter parameters of the layer, the multi-layer linear layer performs multi-scale node feature splicing according to the following formula: in, is the output of the previous linear layer, is the input of the initial linear layer, is a weight matrix, and the binary classification prediction result of the fully connected layer output node is used to obtain the graph representation. The loss is calculated according to the Focal Loss function. The Focal Loss function is as follows: in, is the difference between the predicted value and the target value, represents the predicted value, ɑ is the adjustment factor for adjusting the category weight, γ represents the adjustment factor for adjusting the contribution of simple sample loss, set γ=2, ɑ=0.25, y is the true value of the sample, y=1 represents a positive sample, y=0 represents a negative sample; The detection module is used to enhance the graph representation and then cluster the enhanced graph representation to obtain sub-datasets of multiple different graph representation categories, and input the sub-datasets into a random forest model. The random forest model obtains the final network traffic anomaly detection result according to a weighted prediction algorithm.
8. A storage medium, characterized in that: The storage medium stores one or more programs, which, when executed by a processor, implement the network traffic anomaly detection method based on graph representation as described in any one of claims 1 to 6.
9. A computer device, characterized in that: The computer device comprises a memory and a processor, wherein: The memory is used to store computer programs; When the processor is used to execute the computer program stored in the memory, it implements the network traffic anomaly detection method based on graph representation as described in any one of claims 1-6.
