Network traffic classification method, system and device, and storage medium

Classify the network traffic of distributed photovoltaic systems through the graph neural network model, using graph structure and data enhancement technology to solve the problems of insufficient classification results and insufficient model generalization ability in the existing technology, and improve the system's attack resistance and traffic identification accuracy.

CN118626984APending Publication Date: 2024-09-10NARI INFORMATION & COMM TECH +4
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202410744402.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-11
Publication Date
2024-09-10

AI Technical Summary

Technical Problem

Existing network traffic classification methods lack effective data organization patterns in distributed photovoltaic systems, resulting in inaccurate classification results and reduced analysis accuracy in the face of new network environments, making it difficult to improve the model's generalization ability and attack resistance.

Method used

The graph neural network model is used to classify network traffic. By mapping the traffic data set into a graph structure, the graph convolution network is used to extract features, and the ability to identify malicious traffic is improved through data enhancement technology, including constructing matrix representation, normalization operations, Calculate the adjacency matrix and degree matrix, and combine the GCN layer and output layer for feature extraction and classification.

Benefits of technology

It achieves more accurate network traffic classification, improves the attack resistance and model generalization capabilities of distributed photovoltaic systems, can effectively identify abnormal traffic in complex network environments, and reduces false positive and false negative rates.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118626984A
    Figure CN118626984A
Patent Text Reader

Abstract

The invention discloses a network traffic classification method, system and device and a storage medium. The method comprises the following steps: acquiring traffic data in various network environments, representing traffic in a matrix form, and forming a traffic data set; the traffic data set is mapped into a graph structure, each data packet in the data set is mapped into a graph node, the original bits of the data packets form node attribute features, the time stamp size relation of the data packets forms directed edges between the nodes, and therefore traffic representation of the graph structure is formed; performing feature extraction on the graph structure representing the traffic by using a graph convolutional network to obtain a feature vector of each node, and aggregating the feature traffic of all the nodes into one vector to represent the whole traffic; and the output layer is utilized to classify the traffic, the traffic is divided into two classes, one class is normal traffic, and the other class is malicious traffic. According to the method, the abnormal behaviors in the photovoltaic system can be accurately identified, the situations of false alarm and missing alarm are reduced, and the method can also adapt to new attack modes and system changes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of distributed network security, and in particular to a network traffic classification method, system, device and storage medium. Background Art

[0002] Renewable energy is seen as an effective measure to solve environmental problems. Photovoltaics is considered one of the most attractive renewable energy sources due to its advantages such as economy, safety, low geographical demand and low marginal cost. Distributed photovoltaics have the advantages of low entry barriers, flexible settings, and convenient local consumption of electricity. Therefore, the number of distributed photovoltaics is much larger than that of centralized photovoltaics.

[0003] Unlike traditional power grids, new power systems such as distributed photovoltaics are more decentralized. Due to their distributed characteristics, power terminals in distributed photovoltaic power generation systems are very vulnerable to adversarial threats and can easily become targets of attacks. A large number of attack cases have appeared in multi-power terminal systems, highlighting the high risk of distributed photovoltaics. For example, attackers may use information-physical cross-domain interactions to use power terminals as entry points and springboards to implement cross-domain attacks such as tampering with running codes, spreading network viruses, and injecting physical signals. Some existing abnormal traffic detection methods use neural network models to classify traffic, such as convolutional neural networks and recurrent neural networks, to automatically extract features from raw traffic data. This method is particularly suitable for dealing with complex pattern recognition problems. However, the existing methods simply input the original bit sequence directly into the classification model, lacking an effective data organization model to obtain more accurate traffic classification results. At the same time, considering the complexity of the network environment, the accuracy of traffic analysis of existing methods will decrease in the face of new network environments, so it is necessary to further improve the generalization ability of the model and improve the accuracy of traffic classification.

[0004] Therefore, a new network traffic classification method needs to be established for distributed photovoltaics. Summary of the invention

[0005] Purpose of the invention: In view of the shortcomings of the prior art, the present invention proposes a network traffic classification method, system, device and storage medium, which classifies traffic more accurately through a graph neural network model, and uses data enhancement to improve the ability to identify malicious traffic and improve the anti-attack capability of distributed photovoltaic networks.

[0006] Technical solution: In the first aspect, a network traffic classification method comprises the following steps:

[0007] Obtain traffic data under various network environments, represent traffic in matrix form, and form a traffic data set, where one flow consists of k packets and one packet consists of multiple bits;

[0008] Map the traffic data set into a graph structure, where each data packet in the data set is mapped to a graph node, the original bits of the data packet form the node attribute features, and the timestamp size relationship of the data packet forms the directed edges between the nodes, thus forming a graph structured traffic representation;

[0009] The adjacency matrix A of the graph is calculated according to the graph structure, and the degree matrix D is calculated based on the adjacency matrix. A and D are input into the graph convolution network, and the graph convolution network is used to extract features of the graph structure representing the traffic to obtain the feature vector of each node. The feature traffic of all k nodes is aggregated into a vector to represent the entire traffic.

[0010] The output layer is used to classify the traffic into two categories, one is normal traffic and the other is malicious traffic.

[0011] Furthermore, traffic data under various network environments are obtained, and the traffic is represented in matrix form to form a traffic data set. The specific method is as follows:

[0012] Obtain traffic data in various network environments, check the source IP address, source port, destination IP address, destination port, and transmission protocol contained in the data packet, and classify the data packets with the same transmission protocol and the same two IP addresses and two ports as the same traffic;

[0013] Construct a matrix F∈R k×L To represent a flow, the i-th row of the matrix stores the original data of the i-th data packet, and L is the length of the data packet;

[0014] The operation of constructing the matrix F is performed for each flow, and a data set representing the flow in the form of a matrix is ​​obtained.

[0015] Furthermore, the traffic data set is mapped into a graph structure, where each data packet in the data set is mapped into a graph node, the original bits of the data packet form the node attribute features, and the timestamp size relationship of the data packet forms the directed edges between the nodes, thereby forming a traffic representation of the graph structure. The specific method is as follows:

[0016] Each packet in the network traffic p i Mapped to a node n in the graph i , i∈{0,1,2,…,k-1};

[0017] Loop through each flow matrix of the flow data set, and for each flow matrix F i , loop through each row in the matrix, normalize the data in that row, and normalize each bit in that row to the interval [0,1] as n i The characteristic attributes of the nodes, each traffic matrix in the data set completes the above normalization operation, and the node characteristic attribute matrix X∈R representing the graph structure is obtainedk×L ;

[0018] Get the timestamp corresponding to each node, compare the timestamps of the nodes pairwise, and create a directed edge from the node corresponding to the data packet with a smaller timestamp to the node with a data packet with a larger timestamp.

[0019] Furthermore, the adjacency matrix A of the graph is calculated according to the graph structure. The specific method is as follows:

[0020] The adjacency matrix of the graph is A, and its i-th row and j-th element A ij The value of is obtained as follows:

[0021] If two nodes n i ,n j There are directed edges between them, and n i Timestamp t i Less than n j Timestamp t j , 0≤i,j≤k-1, then the weight of the directed edge is w ij =t j -t i , then A ij =w ij ;

[0022] If two nodes n i ,n j There is no edge between them, then A ij =0.

[0023] Furthermore, the degree matrix D is calculated based on the adjacency matrix. The specific method is as follows:

[0024] Calculate the self-connection matrix I N is the identity matrix;

[0025] Calculate the degree matrix D, whose elements

[0026] Furthermore, the graph convolutional network includes two GCN layers, one aggregation layer,

[0027] The output of the first layer of GCN is: σ represents the activation function, W (0) is the learnable parameter matrix of this layer;

[0028] The output of the second layer of GCN is: W (1) is the learnable parameter matrix of this layer;

[0029] At the aggregation layer, the features of the entire image are represented as: β i is the attention vector.

[0030] Furthermore, the output layer is used to classify the traffic. The specific method is as follows:

[0031] Randomly initialize the learnable parameter matrix W z and parameter b z ;

[0032] The feature representation g of the entire image is input into the linear fully connected layer for traffic classification. The output of this layer is:

[0033] z=softmax(W z g+b z ).

[0034] Furthermore, the graph convolutional network uses the following loss function during training;

[0035] FL(z c )=-α[1-z c ] γ log[z c ]

[0036] Where c is the label of the traffic, α is the pre-set weight, and γ is the adjustment factor.

[0037] Furthermore, the graph convolutional network uses oversampling to increase the number of malicious traffic samples during training. The specific method is as follows:

[0038] Identify malicious traffic samples from the original training dataset;

[0039] For each malicious traffic sample Y i , use Euclidean distance to calculate its m nearest neighbor samples in the feature space, and randomly select a neighbor sample Y from the m nearest neighbors i,nn , calculate the new synthetic sample: Y new =Y i +δ·(Y i,nn -Y i ), where δ∈[0,1];

[0040] Calculate d(Y i ,Y new )=α||Y ia -Y newa || ∞ +β||Y ib -Y newb || ∞ , when d(Y i ,Y new )≤∈, the synthetic samples are merged with the original training data set as a new training set, where Indicates the header information of the original data, Ynewa Indicates the header information of the newly synthesized sample; l h Indicates the header length of the data packet; Indicates the valid information in the original data packet, Y newb It represents the effective information of the newly synthesized data packet, α and β are control coefficients, and ∈ is the preset threshold.

[0041] In a second aspect, a network traffic classification system is provided, comprising:

[0042] The data preprocessing module obtains the flow data under various network environments, represents the flow in matrix form, and forms a flow data set, where one flow consists of k packets and one packet consists of multiple bits;

[0043] The graph structure conversion module maps the traffic data set into a graph structure, where each data packet in the data set is mapped to a graph node, the original bits of the data packet form the node attribute features, and the timestamp size relationship of the data packet forms the directed edges between the nodes, thus forming a graph structure traffic representation;

[0044] The feature extraction module calculates the adjacency matrix A of the graph according to the graph structure, calculates the degree matrix D based on the adjacency matrix, inputs A and D into the graph convolution network, uses the graph convolution network to extract features of the graph structure representing the traffic, obtains the feature vector of each node, and aggregates the feature traffic of all k nodes into a vector to represent the entire traffic;

[0045] The traffic classification module uses the output layer to classify the traffic into two categories, one is normal traffic and the other is malicious traffic.

[0046] In a third aspect, a computer device is provided, comprising one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the programs are executed by the processors, the steps of the network traffic classification method as described in the first aspect of the present invention are implemented.

[0047] In a fourth aspect, a computer storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the network traffic classification method as described in the first aspect of the present invention are implemented.

[0048] Beneficial effects: The present invention provides a method, system, device and storage medium for implementing traffic classification in a distributed photovoltaic network. By inputting the traffic in the distributed photovoltaic into the neural network model provided by the present invention, it is possible to analyze whether the traffic is normal traffic or abnormal traffic, thereby detecting whether there are abnormalities in the system behavior, so as to perform real-time security monitoring. The present invention converts network traffic into a graph structure, which is a more effective data organization mode for traffic, and can extract very effective feature vectors from it. In addition, in view of the problem of unbalanced proportion of network traffic samples, that is, the fact that there are more benign traffic and less malicious traffic, the present invention expands the samples of malicious traffic, improves the model's ability to identify malicious traffic, and improves the generalization ability of the model. The present invention can be applied to many fields involving network information transmission, such as distributed photovoltaic systems, and has broad application prospects. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 This is a flow chart of the network traffic classification method described in the present invention.

[0050] Figure 2 This is a flow diagram of the present invention.

[0051] Figure 3 This is a schematic diagram of constructing a traffic data set according to the present invention.

[0052] Figure 4 A schematic diagram of mapping traffic packets into graph nodes to obtain a node feature attribute matrix according to the present invention.

[0053] Figure 5 A schematic diagram of edges and edge attributes of a constructed graph according to the present invention.

[0054] Figure 6 It is a schematic diagram of the structure of the GNN neural network model described in the invention.

[0055] Figure 7 A schematic diagram of the header and valid data of the packet described in the invention. DETAILED DESCRIPTION

[0056] The technical solutions in the embodiments of the present invention will be described clearly and completely below with reference to the accompanying drawings.

[0057] The present invention provides a method for implementing distributed photovoltaic network traffic classification. Figure 1The method flow chart is shown, which mainly includes the following steps: Step 1, obtain traffic data under various network environments to form a traffic data set, in which a traffic line is composed of multiple packets; Step 2, map the traffic data set to a graph structure, and construct nodes and edges according to the packets and their attributes; Step 3, use the graph convolution network to extract features of the graph structure representing the traffic; Step 4, use the output layer to classify the traffic. In the method, the deep learning model can learn patterns in historical data, so that abnormal behavior of current data can be identified in real time.

[0058] Figure 2 The figure shows a flow data set constructed by the present invention. The flow in the present invention is composed of many packets. The packets are composed of multiple bits. Figure 2 , the flow consists of k packets (p i ), each package p i The length of is L, and the size of L in the present invention is set to 1500, that is, the value is taken according to the popular Ethernet maximum transmission unit MTU. A single record of the data set is a matrix of k×1500, which represents a flow. The present invention intercepts a bidirectional flow for network traffic analysis. The bidirectional flow refers to the traffic in which data packets are transmitted bidirectionally between two terminals in a network communication session. In a bidirectional flow, the traffic is not just a one-way transmission from a sender to a receiver, but includes data transmission in two directions. This method more accurately reflects the actual situation of network communication, because most network communications involve bidirectional exchange of information, such as request and response modes. A bidirectional flow can be identified by a 5-tuple. The 5-tuple is a set of identifiers consisting of the following five key elements: source IP address, source port, destination IP address, destination port, and transmission protocol. The source and destination can be replaced because in the process of identifying a bidirectional flow, not only the traffic from the source address to the destination address is included, but also the traffic from the destination address back to the source address. The communication involved in the bidirectional flow is mutual, and the data moves in two directions to form a complete session. Therefore, whether the data flows from source to destination or from destination to source, as long as the remaining four elements (two IP addresses and two ports) and the transport protocol used match, the traffic is considered to be part of the same bidirectional flow.

[0059] In step 1 of the present invention, traffic data under various network environments are obtained to form a traffic data set. Specifically, the following steps are included:

[0060] Step 101, based on the captured traffic packets, check the source IP address, source port, destination IP address, destination port, and transmission protocol, and classify packets with the same transmission protocol, two IP addresses, and two ports as one traffic.

[0061] Figure 3The data preprocessing diagram of the present invention is shown in FIG. 1 . All the original data are used as the input of the neural network to improve the accuracy of traffic classification. The present invention retains all the traffic packets as the input of the neural network, and a traffic contains 5 packets ([P 1 ,P 2 ,P 3 ,P 4 ,P 5 ]) is used as an example for explanation.

[0062] Step 102, construct a matrix F∈R 5×1500 To represent the traffic, there are 5 packets in the traffic, so the matrix F has 5 rows. The first row represents the first data packet, the second row represents the second data packet, and so on. The i-th row of the matrix stores the original data of the i-th data packet. The first row F 0 Used to indicate, use P 0 To represent the first data packet of this flow, that is, the packet with the smallest timestamp in the flow, that is, the packet with the earliest arrival time, then F 0 ∈R 1×1500 Indicates P 0 , the data stored in each row is all the raw bit data of the captured data packet.

[0063] Step 103, execute step 102 for each flow in the data set to obtain a data set representing the flow in a matrix. For example, if there are 10 flows, 10 Fs are obtained, and these 10 Fs are the results obtained by preprocessing.

[0064] Step 104: data preprocessing is completed.

[0065] In step 2, the present invention maps the traffic packet into a graph structure. Figure 4 Schematic diagram of mapping traffic packets to graph nodes to obtain node feature attribute matrix according to the present invention. For a network flow, each packet p in the network flow i will be mapped to a node n in the graph i , and i∈{0,1,2,…,k-1}, k is the number of packets in the flow. i ∈R 1×1500 Each bit in is normalized to the interval [0,1], as n i The characteristic attributes of the node. Specifically include the following steps:

[0066] Step 201 , looping through each flow matrix of the flow data set obtained in step 103 .

[0067] Step 202, loop through each row in the matrix of step 201, perform normalization operation on the data of the row, and normalize each bit of the row to the interval [0, 1].

[0068] Step 203: Each traffic matrix in the data set completes the normalization operation of step 201 and step 202 to obtain the node feature attribute matrix X∈R representing the graph structure. k×1500 .

[0069] Figure 5 Schematic diagram of the edge and edge attributes of the constructed graph according to the present invention. The timestamp of the data packet is t i (i∈{0,1,2,…,k-1}), where the traffic contains k packets.

[0070] Step 204, use the timestamp of the packet to determine the directed edge. Compare the timestamps of two nodes in pairs. The node corresponding to the packet with the smaller timestamp has a directed edge pointing to the node with the packet with the larger timestamp. r and n s represent two different nodes respectively. r The package ratio represented by n s The packet represented by arrives earlier, then there is a directed edge e r,s , indicating n r Point to n s .

[0071] In step 3, the present invention calculates the adjacency matrix of the graph according to the graph structure and uses it for the calculation of the graph neural network model. The calculation of the adjacency matrix and the degree matrix includes:

[0072] Step 301: If two nodes n i ,n j There is a directed edge between (0≤i,j≤k-1), and n i Timestamp t i Less than n j Timestamp t j , then the weight of the directed edge is w ij =t j -t i . Let the adjacency matrix of the graph be A, then A ij =w ij .

[0073] Step 302: If two nodes n i ,n j There is no edge between (0≤i,j≤k-1), then A ij =0.

[0074] Step 303: The adjacency matrix A of the graph is constructed.

[0075] Step 304, calculate the self-connection matrix I N is the N×N identity matrix, where N represents the matrix dimension of A.

[0076] Step 305, calculate the degree matrix

[0077] Figure 6 This is a structural diagram of the GNN neural network model described in the invention. The neural network consists of a graph encoder (i.e., the graph convolutional network in step 3) and a graph classifier (i.e., the output layer in step 4). When a flow is converted into a graph, the information contained in the flow is re-encoded into the topological structure of the graph. The graph encoder consists of two layers of GCN and one aggregation layer. The two GCN layers transmit and update the node information in the graph, and the aggregation layer aggregates the entire graph into a vector. The vector representing the graph is input into the classifier, and the graph can be classified. The specific processing steps of the graph encoder include:

[0078] Step 311, randomly initialize the learnable parameter matrix W (0) ,W (1) . Here 1 is the number of neurons in the first hidden layer, l 2 It is the number of neurons in the second hidden layer and the dimension of the final output feature vector.

[0079] Step 312, calculate the output of the first layer GCN as: σ is the activation function.

[0080] Step 313, calculate the output of the second layer GCN as:

[0081] Step 314, randomly initialize the attention vector β.

[0082] Set up two trainable parameter matrices W s2 ∈R l×d , used to calculate the attention score of each node, the calculation formula is as follows:

[0083]

[0084] Step 315, calculate the feature representation of the entire image: k is the number of nodes in the graph structure, that is, the number of packets contained in the traffic. In the example of the present invention, k is 5.

[0085] The specific processing method of the graph classifier is as follows:

[0086] Step 401, randomly initialize the learnable parameter matrix W z and parameter b z .

[0087] Step 402: Input the feature representation g of the entire graph into the linear fully connected layer for traffic classification. This method divides the traffic into two categories: normal traffic with a label of 1 and malicious traffic with a label of 0. The input of the output layer is g, and the output is z∈R 2×1 , the two numbers in the two-dimensional vector represent the probability that the traffic is normal traffic and malicious traffic respectively. The output result of this layer is: z = softmax (W z g+b z ).

[0088] The above-mentioned GNN neural network model needs to be trained in advance. The training data in the traffic classification scenario is often unbalanced. The present invention uses Focal Loss to replace the common cross entropy loss as the loss function. The loss function is as follows:

[0089] FL(z c )=-α[1-z c ] γ log[z c ]

[0090] Where c is the label of the traffic, α is the pre-set weight, and γ is the adjustment factor.

[0091] The traffic distribution of distributed networks is often unbalanced, that is, the number of benign traffic samples is far greater than the number of malignant traffic samples. In order to combat this imbalance in distribution, the present invention uses an oversampling method to increase the number of malignant traffic samples. The oversampling method is to mix the samples, first identify minority class samples from the data set, that is, those categories that need to increase the number of samples, and then obtain the neighboring samples for each minority class sample, and then interpolate to generate a new synthetic sample. In this process, changes to the traffic data packets are involved. Figure 7 The figure is a schematic diagram of the packet header and valid data of the invention. The header of the traffic packet contains a lot of important information, such as IP address, port number, and protocol. This information cannot be changed at will, so the header information of the packet cannot be changed too much. Therefore, the invention increases the number of samples of malicious traffic, and the specific steps are as follows:

[0092] Step 601, identifying malicious traffic samples from a data set.

[0093] Step 602: For each malicious traffic sample, calculate its m nearest neighbor samples in the feature space, use Euclidean distance to calculate the nearest neighbors, and set the parameter m.

[0094] Step 603: for each malicious traffic sample Y i , randomly select a neighbor sample Y from its m nearest neighbors i,nn .

[0095] Step 604, generate a random number δ∈[0,1].

[0096] Step 605, calculate a new synthetic sample, Y new =Y i +δ·(Y i,nn -Y i ).

[0097] Step 606, calculate d(Y i ,Y new )=α||Y ia -Y newa || ∞ +β||Y ib -Y newb || ∞ , if d(Y i ,Y new )≤∈, then proceed to step 607; otherwise, discard the current synthetic sample and go to step 604 to regenerate a new synthetic sample. .j (0 <j<l h <1500) is the header information of each data packet, l h Indicates the header length of the data packet.

[0098] Indicates the header information of the original data, Y newa Indicates the header information of the newly synthesized sample; Indicates the valid information in the original data packet, Y newb Indicates the valid information of the newly synthesized data packet. The coefficients α and β are used to control the degree of modification of the header information. The larger the α is set, the smaller the disturbance to the header is. ∈ is the preset threshold.

[0099] Step 607 , determine whether a sufficient number of synthetic samples are generated, if not, go to step 603 ; if yes, go to step 608 .

[0100] Step 608: merge the generated synthetic samples with the original data set to obtain a balanced data set.

[0101] Step 609: Use the balanced data set to train a classification model to improve the ability to identify malicious traffic samples.

[0102] Step 610, the process ends.

[0103] In summary, the present invention provides a method for implementing distributed photovoltaic network traffic classification and malicious traffic data enhancement. This technology can not only be applied to distributed photovoltaic networks, but also can be migrated to many other systems involving network information transmission. For example, in a distributed photovoltaic system, the technology of network traffic classification and data enhancement can be applied to system monitoring. A distributed photovoltaic power generation system is often deployed in a wide area and contains hundreds of photovoltaic panels, which are collected and analyzed through a centralized monitoring system. The trained model of the present invention is deployed in a real-time monitoring system to predict the collected real-time data to identify whether there are abnormalities or attack behaviors. When a potential security threat is detected, the administrator is automatically notified and preset response measures are taken, such as isolating the affected equipment. The deep learning model of the present invention can accurately identify abnormal behaviors in photovoltaic systems, reduce false positives and false negatives, and can also adapt to new attack modes and system changes. Even attack types that have not been encountered before may be successfully identified. Automated attack detection reduces the burden of manual monitoring, and system administrators can focus on attack response and system maintenance instead of constantly monitoring data.

[0104] Based on the same technical concept as the method embodiment, the present invention also provides a network traffic classification system, including:

[0105] The data preprocessing module obtains the flow data under various network environments, represents the flow in matrix form, and forms a flow data set, where one flow consists of k packets and one packet consists of multiple bits;

[0106] The graph structure conversion module maps the traffic data set into a graph structure, where each data packet in the data set is mapped to a graph node, the original bits of the data packet form the node attribute features, and the timestamp size relationship of the data packet forms the directed edges between the nodes, thus forming a graph structure traffic representation;

[0107] The feature extraction module calculates the adjacency matrix A of the graph according to the graph structure, calculates the degree matrix D based on the adjacency matrix, inputs A and D into the graph convolution network, uses the graph convolution network to extract features of the graph structure representing the traffic, obtains the feature vector of each node, and aggregates the feature traffic of all k nodes into a vector to represent the entire traffic;

[0108] The traffic classification module uses the output layer to classify the traffic into two categories, one is normal traffic and the other is malicious traffic.

[0109] It should be understood that the network traffic classification system in the embodiment of the present invention can implement all the technical solutions in the above-mentioned method embodiment, and the functions of its various functional modules can be specifically implemented according to the methods in the above-mentioned method embodiments. The specific implementation process can refer to the relevant description in the above-mentioned embodiments, which will not be repeated here.

[0110] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, devices (systems), computer equipment or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0111] The present invention is described with reference to a flowchart of a method according to an embodiment of the present invention. It should be understood that each process in the flowchart and a combination of processes in the flowchart can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the flowchart. Figure 1 A device that specifies functions in a process or multiple processes.

[0112] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A function specified in a process or multiple processes.

[0113] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 The steps of a specified function in a process or multiple processes.

Claims

1. A network traffic classification method, characterized in that: The method comprises the following steps: Obtain traffic data under various network environments, represent traffic in matrix form, and form a traffic data set, where one flow consists of k packets and one packet consists of multiple bits; Map the traffic data set into a graph structure, where each data packet in the data set is mapped to a graph node, the original bits of the data packet form the node attribute features, and the timestamp size relationship of the data packet forms the directed edges between the nodes, thus forming a graph structured traffic representation; The adjacency matrix A of the graph is calculated according to the graph structure, and the degree matrix D is calculated based on the adjacency matrix. A and D are input into the graph convolution network, and the graph convolution network is used to extract features of the graph structure representing the traffic to obtain the feature vector of each node. The feature traffic of all k nodes is aggregated into a vector to represent the entire traffic. The output layer is used to classify the traffic into two categories, one is normal traffic and the other is malicious traffic.

2. The method according to claim 1, characterized in that Obtain traffic data under various network environments, represent the traffic in matrix form, and form a traffic data set. The specific method is as follows: Obtain traffic data in various network environments, check the source IP address, source port, destination IP address, destination port, and transmission protocol contained in the data packet, and classify the data packets with the same transmission protocol and the same two IP addresses and two ports as the same traffic; Construct a matrix F∈R k×L To represent a flow, the i-th row of the matrix stores the original data of the i-th data packet, and L is the length of the data packet; The operation of constructing the matrix F is performed for each flow, and a data set representing the flow in the form of a matrix is ​​obtained.

3. The method according to claim 2, characterized in that The traffic data set is mapped into a graph structure, where each data packet in the data set is mapped into a graph node, the original bits of the data packet form the node attribute features, and the timestamp size relationship of the data packet forms the directed edges between the nodes, thereby forming a graph structure traffic representation. The specific method is as follows: Each packet in the network traffic i Mapped to a node n in the graph i , i∈{0,1,2,…,k-1}; Loop through each flow matrix of the flow data set, and for each flow matrix F i , loop through each row in the matrix, normalize the data in that row, and normalize each bit in that row to the interval [0,1] as n i The characteristic attributes of the nodes, each traffic matrix in the data set completes the above normalization operation, and the node characteristic attribute matrix X∈R representing the graph structure is obtained k×L ; Get the timestamp corresponding to each node, compare the timestamps of the nodes pairwise, and create a directed edge from the node corresponding to the data packet with a smaller timestamp to the node with a data packet with a larger timestamp.

4. The method according to claim 3, characterized in that The adjacency matrix A of the graph is calculated according to the graph structure. The specific method is as follows: The adjacency matrix of the graph is A, and its i-th row and j-th element A ij The value of is obtained as follows: If two nodes n i ,n j There are directed edges between them, and n i Timestamp t i Less than n j Timestamp t j , 0≤i,j≤k-1, then the weight of the directed edge is w ij =t j -t i , then A ij =w ij ; If two nodes n i ,n j There is no edge between them, then A ij =0.

5. The method according to claim 4, characterized in that The degree matrix D is calculated based on the adjacency matrix. The specific method is as follows: Calculate the self-connection matrix I N is the unit matrix, N represents the dimension of matrix A; Calculate the degree matrix D, whose elements 6. The method according to claim 5, characterized in that The graph convolutional network consists of two GCN layers, one aggregation layer, The output of the first layer of GCN is: σ represents the activation function, W (0) is the learnable parameter matrix of this layer; The output of the second layer of GCN is: W (1) is the learnable parameter matrix of this layer; At the aggregation layer, the features of the entire image are represented as: β i is the attention vector.

7. The method according to claim 6, characterized in that The output layer is used to classify the traffic. The specific method is as follows: Randomly initialize the learnable parameter matrix W z and parameter b z ; The feature representation g of the entire graph is input into the linear fully connected layer for traffic classification. The output of this layer is: z = softmax (W z g+b z ).

8. The method according to claim 7, characterized in that The graph convolutional network uses the following loss function during training; FL(from c )=-α[1-z c ] γ log[z c ] Where c is the label of the traffic, α is the pre-set weight, and γ is the adjustment factor.

9. The method according to claim 1, characterized in that: The graph convolutional network uses oversampling to increase the number of malicious traffic samples during training. The specific method is as follows: Identify malicious traffic samples from the original training dataset; For each malicious traffic sample Y i , use Euclidean distance to calculate its m nearest neighbor samples in the feature space, and randomly select a neighbor sample Y from the m nearest neighbors i,nn , calculate the new synthetic sample: Y new =Y i +δ·(Y i,nn -Y i ), where δ∈[0,1]; Calculate d(Y i ,Y new )=α||Y ia -Y newa || ∞ +β||Y ib -Y newb || ∞ , when d(Y i ,Y new )≤∈, the synthetic samples are merged with the original training data set as a new training set, where Indicates the header information of the original data, Y newa Indicates the header information of the newly synthesized sample; l h Indicates the header length of the data packet; Indicates the valid information in the original data packet, Y newb It represents the effective information of the newly synthesized data packet, α and β are control coefficients, and ∈ is the preset threshold.

10. A network traffic classification system, characterized in that: include: The data preprocessing module obtains the flow data under various network environments, represents the flow in matrix form, and forms a flow data set, where one flow consists of k packets and one packet consists of multiple bits; The graph structure conversion module maps the traffic data set into a graph structure, where each data packet in the data set is mapped to a graph node, the original bits of the data packet form the node attribute features, and the timestamp size relationship of the data packet forms the directed edges between the nodes, thus forming a graph structure traffic representation; The feature extraction module calculates the adjacency matrix A of the graph according to the graph structure, calculates the degree matrix D based on the adjacency matrix, inputs A and D into the graph convolution network, uses the graph convolution network to extract features of the graph structure representing the traffic, obtains the feature vector of each node, and aggregates the feature traffic of all k nodes into a vector to represent the entire traffic; The traffic classification module uses the output layer to classify the traffic into two categories, one is normal traffic and the other is malicious traffic.

11. A computer device, characterized in that: The device includes one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and when the programs are executed by the processors, the steps of the network traffic classification method as described in any one of claims 1-9 are implemented.

12. A computer storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the network traffic classification method according to any one of claims 1 to 9 are implemented.

Citation Information

Cited By

  • Encrypted traffic classification method based on multi-view heterogeneous graph model

    CN119719895A

  • An encrypted traffic classification method based on multi-view heterogeneous graph model

    CN119719895B

  • Abnormal network flow identification method and apparatus, and electronic device

    CN121508984A

  • Abnormal network traffic identification method, device and electronic equipment

    CN121508984B