A programmable data plane incremental testing method based on graph neural network

By generating and analyzing control flow graphs based on graph neural networks, the path explosion problem in P4 program testing is solved, enabling efficient incremental testing in high-frequency update environments, improving testing efficiency and accuracy, and making it suitable for cloud computing and network security scenarios.

CN119883924BActive Publication Date: 2025-12-26FUZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510044356.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-11
Publication Date
2025-12-26
Estimated Expiration
2045-01-11

AI Technical Summary

Technical Problem

Existing P4 program testing methods are prone to path explosion when faced with complex program structures or frequent minor code updates, resulting in a significant decrease in testing efficiency. Furthermore, they are difficult to provide real-time feedback of error information through intermediate variable output and log recording, which affects the verification of program correctness and security assessment.

Method used

A graph neural network-based approach is used to generate control flow graphs. Path dependencies are analyzed using graph convolutional neural networks, and incremental testing is achieved by dynamically selecting coarse-grained or fine-grained testing strategies. This includes generating control flow graphs, graph data object transformation, graph convolutional neural network analysis, dynamic testing strategy selection, and an automated training mechanism to optimize model performance.

Benefits of technology

It significantly improves testing efficiency, reduces resource consumption, flexibly adapts to high-frequency rule update scenarios, ensures the accuracy and real-time nature of test results, and is suitable for complex scenarios such as cloud computing and network security.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119883924B_ABST
    Figure CN119883924B_ABST
Patent Text Reader

Abstract

The present application relates to a kind of programmable data plane incremental test methods based on graph neural network, comprising:1) the control flow graph of data plane program is generated, the program structure and logic are analyzed, the type, number, accessibility and change flag of each node in program are set, the starting point, end point and transition condition of edge are defined;2) control flow graph is converted into graph data object, and node and edge information are embedded by coding mode;3) graph data object is analyzed using GCN model, node features are aggregated layer by layer, while combining the conditional transition characteristics of edge, gradually integrate the local information between nodes;4) dynamically select coarse-grained or fine-grained test strategy;5) generate defect code sample through regular matching and random modification, and combine the performance of automatic training mechanism to optimize graph neural network model.The method generates control flow graph and analyzes path dependence by combining graph neural network model, realizes efficient incremental testing in the scene of frequent network rule update.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer networks, and particularly relates to a programmable data plane incremental testing method based on a graph neural network. BACKGROUND

[0002] Multi-modal network technology provides a comprehensive and efficient analysis framework in complex network environments by fusing data in multiple dimensions such as topology information, state changes, and logical structures. The core lies in abstracting and collaboratively processing network data in multiple modalities, thereby achieving comprehensive modeling and evaluation of network behavior. In recent years, multi-modal technology has been increasingly applied in network optimization and security verification, demonstrating strong flexibility and adaptability. Drawing on the hierarchical design and collaborative analysis ideas in multi-modal networks, a new solution can be provided for the development and testing of programmable data plane programs.

[0003] With the rapid development of computer networks, data planes play an important role in supporting the flexibility and performance optimization of network devices. Programmable data plane technology enables flexible definition of packet processing logic through protocol-independent programming languages such as P4, and is widely used in dynamic configuration and optimization of network functions. However, the development and testing of P4 programs are complex and involve a large number of engineering details, especially in scenarios where network rules are frequently updated, traditional testing methods face significant challenges.

[0004] Existing P4 program testing methods usually rely on symbolic execution, path constraint solving, or heuristic search techniques to analyze control flow graphs (CFG). Although these methods can guarantee high test coverage, they are prone to path explosion problems when faced with complex program structures or frequent small code updates, resulting in a significant decrease in testing efficiency. In addition, due to the running characteristics of P4 programs in network devices, it is difficult to provide real-time feedback of error information through intermediate variable output and log recording during the testing process, which poses higher requirements for program correctness verification and security evaluation. SUMMARY

[0005] The purpose of the present application is to provide a programmable data plane incremental testing method based on a graph neural network, which generates a control flow graph and analyzes path dependency relationships using a graph neural network model, achieving efficient incremental testing in scenarios where network rules are frequently updated.

[0006] To achieve the above purpose, the technical solution adopted by the present application is as follows: a programmable data plane incremental testing method based on a graph neural network, which generates and analyzes the control flow graph (CFG) of a data plane program, uses a graph neural network to judge path reachability, and realizes incremental testing in a network high-frequency update environment; specifically including the following steps:

[0007] 1) generating a control flow graph of a data plane program, analyzing the structure and logic of the program, setting the type, number, reachability flag and change flag of each node in the program, defining the start point, end point and transition condition of the edge;

[0008] 2) converting the control flow graph into a graph data object, including a node feature matrix and an edge feature matrix, embedding the information of the nodes and edges through an encoding method, so that the information of the nodes and edges can be learned and utilized by the neural network;

[0009] 3) using a graph convolutional neural network (GCN) model to analyze the path-dependent relationship in the graph data object, aggregating node features layer by layer, while combining the conditional transition characteristics of the edges, gradually integrating local information between nodes; in this way, the GCN model can generate a global information representation of the control flow graph, which is used to represent the complete path structure and path-dependent relationship in the program execution logic;

[0010] 4) dynamically selecting a coarse-grained or fine-grained test strategy, switching the test mode according to the time condition, achieving a balance between efficiency and accuracy;

[0011] 5) generating diversified defect code samples through regular matching and random modification, and combining an automated training mechanism to optimize the performance of the graph neural network model and improve the adaptability of the system.

[0012] Further, in step 1), the control flow graph is generated, and the implementation method is:

[0013] First, the P4 program code is parsed to extract the key nodes including tables, keys, actions and conditional judgments in the packet processing logic; by constructing a control flow graph, the attributes of each node are defined, including node type type, unique number id, reachability flag isReachable and change flag isChanged; the node type type includes table node table, key node key and action node action, which are used to distinguish different functional modules in the program structure; the attributes of the edge edge_attr include the start node src, the end node dst and the conditional expression condition, which are used to describe the logical branches in the program execution path; the generated control flow graph is represented in the form of a directed graph, which is formally defined as CFG=(V,E), where V is the node set and E is the edge set.

[0014] Further, in step 2), the control flow graph is converted into a graph data object, and the implementation method is:

[0015] Based on the generated control flow graph, a node feature matrix X, an edge index matrix Edge_Index and an edge feature matrix Edge_Attr are constructed; the node feature matrix X represents the node type and the change flag in one-hot encoding mode; the label vector is represented by isReachable, as the supervision signal of the model; the edge index matrix Edge_Index represents the starting point and the ending point of the edge in the graph; the edge feature matrix Edge_Attr records the conditional attributes of the edge; finally, the generated graph data object includes (X, Edge_Index, Edge_Attr), which can be directly input into the graph neural network model for subsequent processing.

[0016] Further, in step 3), a graph convolutional neural network model is used to analyze the path-dependent relationship in the graph data object, and the implementation method is as follows:

[0017] The node features are gradually aggregated through multi-layer graph convolution operation to generate the global embedding representation of the control flow graph; the core operation of the graph convolutional network is adjacency matrix normalization and feature update, and the forward propagation formula is where H (l) is the node feature matrix of the lth layer, W (l) is the weight matrix, is the adjacency matrix after adding the self-loop, is the degree matrix of , and σ is the activation function; after multi-layer graph convolution, the global embedding representation obtained can effectively capture the path-dependent relationship in the control flow graph for path reachability judgment.

[0018] Further, in step 4), a coarse-grained or fine-grained test strategy is dynamically selected, and the implementation method is as follows:

[0019] According to the task time requirement, two test strategies of coarse-grained and fine-grained are designed; in coarse-grained testing, the coverage of the change node and its neighborhood path is calculated first, and the paths that do not need to be verified are skipped to reduce the test time; fine-grained testing verifies all control flow graph paths through comprehensive path constraint solving to ensure 100% coverage; the dynamic selection of the test strategy is based on ΔT1=T f -T c and ΔT2=T n -T c for adjustment, where T c is the completion time of coarse-grained testing, T f is the completion time of fine-grained testing, and T nThe arrival time of the next update request; when ΔT1> ΔT2, it indicates that the coarse-grained test is completed, and the next update request time has not arrived, at this time, the time is tight, and the coarse-grained test strategy with faster speed is preferentially selected to generate the result; when ΔT1≤ ΔT2, it indicates that the coarse-grained test and the fine-grained test are both completed, and the next update request time has not arrived, at this time, the time is sufficient, and the fine-grained test strategy with higher accuracy is used to verify all paths.

[0020] Further, in step 5), an automatic training mechanism is realized, and the implementation method is as follows:

[0021] Defect code samples are generated through regular matching and random modification, error parts are automatically marked, and the graph neural network model is continuously optimized; specifically, random change operations are introduced in the generated defect code samples, including adding and deleting nodes and modifying edge attributes, a control flow graph containing change marks is generated; the feedback result of the coarse-grained test is used to update the node feature parameters, that is, X'[i] = X[i] + ΔX[i]; after multiple training iterations, the model can adapt to diversified defect scenarios and improve its applicability in actual testing.

[0022] Compared with the prior art, the present application has the following beneficial effects: by combining control flow graph generation and graph neural network modeling, the present application can efficiently analyze path dependence relationships, greatly improve test efficiency, and significantly reduce test time overhead; by optimizing memory usage and computing resource consumption of the model through lightweight design, resource occupation of the test process is reduced; dynamically switching coarse-grained and fine-grained test strategies, flexibly adapting to high-frequency rule update scenarios, not only meets the demand for real-time and rapid verification, but also ensures the accuracy of test results; in addition, the present application adopts standardized control flow graph generation and graph data processing procedures, the structure is clear and simple to implement, and is convenient for integration with existing systems and popularization and application, and is suitable for complex scenarios such as cloud computing and network security that require rapid and efficient testing. BRIEF DESCRIPTION OF DRAWINGS

[0023] Figure 1 The figure is a schematic diagram of the overall structure of the method in the embodiment of the present application and a flowchart.

[0024] Figure 2 The figure is a schematic diagram of the overall structure of the method in the embodiment of the present application and a flowchart.

[0025] Figure 3 The figure is a schematic diagram of the overall structure of the method in the embodiment of the present application and a flowchart. DETAILED DESCRIPTION

[0026] The present application will be further described below in conjunction with the drawings and embodiments.

[0027] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of this application. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains.

[0028] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the exemplary embodiments according to this application. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.

[0029] This embodiment provides a programmable data plane incremental testing method based on graph neural networks. By generating and analyzing the control flow graph (CFG) of the data plane program, the graph neural network is used to efficiently determine path reachability, thereby achieving fast and accurate incremental testing in high-frequency network update environments. The method specifically includes the following steps:

[0030] 1) Generate the control flow graph of the data plane program, analyze the program's structure and logic, set the type, number, reachability flag and change flag for each node in the program, and define the start point, end point and transition conditions of the edges.

[0031] 2) Convert the control flow graph into a graph data object, including node feature matrix and edge feature matrix, and embed the node and edge information through encoding so that the node and edge information can be learned and utilized by the neural network.

[0032] 3) The Graph Convolutional Neural Network (GCN) model is used to analyze the path dependencies in graph data objects, aggregating node features layer by layer, and combining the conditional transition characteristics of edges to gradually integrate the local information between nodes. In this way, the GCN model can generate a global information representation of the control flow graph, which can be used to characterize the complete path structure and path dependencies in the program execution logic.

[0033] 4) Dynamically select coarse-grained or fine-grained testing strategies and switch testing modes according to time conditions to achieve a balance between efficiency and accuracy.

[0034] 5) Generate diverse defect code samples through regular expression matching and random modification, and optimize the performance of graph neural network models by combining automated training mechanisms to improve the system's adaptability.

[0035] In step 1), the control flow graph is generated, which is implemented as follows:

[0036] Firstly, the P4 program code is parsed to extract the key nodes in the data packet processing logic, such as tables, keys, actions, and conditional judgments. By constructing a control flow graph, the attributes of each node are defined, including the node type type, unique number id, reachability flag isReachable, and change flag isChanged. The node type type includes table (table node), key (key node), and action (action node) to distinguish different functional modules in the program structure; the edge attribute edge_attr includes the starting node src, the ending node dst, and the conditional expression condition to describe the logical branching in the program execution path. The generated control flow graph is represented in the form of a directed graph, which is formally defined as CFG=(V, E), where V is the node set and E is the edge set.

[0037] In step 2), the control flow graph is converted into a graph data object, and the implementation method is as follows:

[0038] Based on the generated control flow graph, the node feature matrix X, the edge index matrix Edge_Index, and the edge feature matrix Edge_Attr are constructed. The node feature matrix X uses one-hot encoding to represent the node type and the change flag, for example, X[i] = [type, isChanged]. The isReachable label vector is used as the supervision signal for the model. The edge index matrix Edge_Index represents the starting and ending points of the edges in the graph, for example, edge e from node v i to node v j is represented as Edge_Index[e] = (v i , v j ); the edge feature matrix Edge_Attr records the conditional attributes of the edges, for example, Edge_Attr[e] = [condition(e)], and the finally generated graph data object includes (X, Edge_Index, Edge_Attr), which can be directly input into the graph neural network model for subsequent processing.

[0039] In step 3), the graph convolutional neural network model is used to analyze the path-dependent relationship in the graph data object, and the implementation method is as follows:

[0040] The node features are gradually aggregated through multi-layer graph convolution operations to generate the global embedding representation of the control flow graph. The core operation of the graph convolutional network is adjacency matrix normalization and feature update, and the forward propagation formula is where H (l) is the node feature matrix of the l-th layer, W (l) is the weight matrix, is the adjacency matrix after adding the self-loop, is wherein W is the weight matrix, A is the adjacency matrix of the control flow graph, σ is the activation function (such as ReLU). After multi-layer graph convolution, the global embedding representation obtained can effectively capture the path dependence relationship in the control flow graph for path reachability judgment.

[0041] In the present embodiment, the graph neural network model adopts multi-layer graph convolution operation when processing the control flow graph, realizing efficient node association and feature aggregation. Specifically, after aggregating the node features at each layer, the whole graph is embedded to generate an overall representation for path dependence analysis.

[0042] In the present embodiment, a lightweight graph neural network model is adopted, and a field selection strategy is used to reduce unnecessary feature calculation burden and reduce memory usage, thereby optimizing the resource consumption of the graph neural network in the data plane test, realizing efficient memory management and performance improvement.

[0043] In step 4), a coarse-grained or fine-grained test strategy is dynamically selected, and the implementation method is as follows:

[0044] According to the task time requirement, two test strategies of coarse-grained and fine-grained are designed. In the coarse-grained test, the coverage of the change node and its neighborhood path is calculated preferentially, and the paths that do not need to be verified are skipped, which significantly reduces the test time; the fine-grained test verifies all control flow graph paths through comprehensive path constraint solving, ensuring 100% coverage. Dynamic adjustment is performed based on ΔT1=T f -T c and ΔT2=T n -T c , wherein T c is the completion time of coarse-grained test, T f is the completion time of fine-grained test, and T n is the arrival time of the next update request. When ΔT1>ΔT2, it indicates that the coarse-grained test is completed, and the next update request time has not arrived, at this time, the time is tight, and the coarse-grained test strategy with faster speed is preferentially selected to generate the result. When ΔT1≤ΔT2, it indicates that the coarse-grained test and the fine-grained test are completed, and the next update request time has not arrived, at this time, the time is sufficient, and the fine-grained test strategy with higher accuracy can be used to verify all paths.

[0045] In this embodiment, a selection method based on dynamic test strategy is proposed to realize the switching of test mode under different network conditions. Coarse-grained testing is based on graph neural network (GNN) method, which quickly analyzes the global information representation of control flow graph, and determines whether the critical path in the program execution logic is reachable based on the aggregation results of node features and edge features, so as to quickly generate test results; Fine-grained testing adopts the traditional 100% coverage method to comprehensively analyze all nodes and edges in the control flow graph, and gradually verifies the reachability of each possible path to ensure the integrity and accuracy of the test results. The switching of the two test strategies is realized by dynamically predicting the time interval of network update request. When the time interval is short, coarse-grained testing is preferred to improve the response speed; when the time interval is long, fine-grained testing is automatically switched to ensure the accuracy of the test.

[0046] In step 5), an automatic training mechanism is implemented by the following method:

[0047] Defect code samples are generated by regular matching and random modification, and the error parts are automatically marked and the graph neural network model is continuously optimized. Specifically, random change operations are introduced in the generated defect code samples, including adding or deleting nodes, modifying edge attributes, etc., to generate control flow graphs containing change markers. The feedback results of coarse-grained testing are used to update the node feature parameters, i.e. X'[i] = X[i] + ΔX[i]. After multiple training iterations, the model can adapt to diverse defect scenarios and improve its applicability in actual testing.

[0048] In this embodiment, an automatic training mechanism is used to generate defect code samples. Specifically, regular expressions are used to match the code and modify the table definition, action and condition judgment structure to form multiple variant codes. The control flow graph is regenerated on each variant code, the changed part of the code is marked, and the model is retrained. Through the automatic training data feedback mechanism, the accuracy of the graph neural network model is continuously optimized. The feedback results of fine-grained testing are added to the process of coarse-grained testing as model training samples, and the feature parameters of nodes and edges are dynamically adjusted. After multiple training iterations, the test accuracy of coarse-grained mode is improved to adapt to different testing tasks in different scenarios.

[0049] The specific implementation process of the method will be further described below.

[0050] Please refer to Figure 1 The method includes four main parts: control flow graph generation, graph neural network modeling, dynamic test strategy selection and automatic optimization.

[0051] (1) Control flow graph generation

[0052] In the control flow graph generation phase, the present application first parses the P4 program code, extracts key nodes such as tables, keys, actions and conditional judgments in the packet processing logic, to construct the control flow graph (CFG) of the program. The control flow graph is represented in the form of a directed graph, which structurally describes the logical path of the program.

[0053] Firstly, the program code is syntax analyzed, and each logical unit is abstracted as a node in the graph. The node types include table, key and action, and each node contains the following attributes:

[0054] Type attribute (type): used to distinguish different logical units.

[0055] Number attribute (id): a unique number is assigned to each node.

[0056] Reachability flag (isReachable): marks whether the node is reachable in the current path.

[0057] Change flag (isChanged): marks whether the node has changed due to code update.

[0058] Then, the connection relationship of the edges is established according to the control logic in the code. Each edge contains the starting node, the ending node and the conditional expression. For example, the if statement in the program corresponds to the conditional edge, and the calling relationship between table and action corresponds to the unconditional edge. The finally generated control flow graph is formally defined as:

[0059] CFG = (V, E)

[0060] Where V is the node set, and E is the edge set. The condition attribute of the edge is described by a logical expression and recorded in the edge feature. The generated control flow graph provides a basis for subsequent graph neural network modeling.

[0061] (2) Graph neural network modeling

[0062] In the graph neural network modeling phase, the generated control flow graph is converted into an input data structure suitable for the graph neural network, including the node feature matrix, the edge index matrix and the edge feature matrix.

[0063] First, the node feature matrix X is generated, including the node type and the change flag. Please refer to Figure 2 The node features are encoded by one-hot, and the label vector isReachable is generated as the supervision signal of the model. For example:

[0064] X[i] = [type, isChanged]

[0065] Edge_Index records the connection relationship of edges in the graph, which is used to describe the starting point and end point of each edge, for example:

[0066] Edge_Index[e] = (v i ,v j )

[0067] Edge_Attr records the attribute information of the edge, for example:

[0068] Edge_Attr[e] = [condition(e)]

[0069] The graph convolutional neural network (GCN) is used to model the path dependence relationship of the control flow graph, and the global embedding representation is generated by layer-by-layer aggregation of node features. The core formula of graph convolution is:

[0070]

[0071] Where H (l) is the node feature matrix of the lth layer, is the adjacency matrix after adding the self-loop, is the degree matrix of the adjacency matrix, W (l) is the weight matrix, and sigma is the activation function (such as ReLU). Through multi-layer convolution operation, the node features are updated step by step, and the global embedding of the whole graph is generated, which is used for path reachability judgment.

[0072] (3) Dynamic test strategy selection

[0073] The application designs a dynamic test strategy selection mechanism, which can flexibly switch between coarse-grained and fine-grained test strategies according to the time condition of the task scene. In the time-tight or high-frequency rule update scene, the coarse-grained test strategy is selected, and only the changed nodes and their adjacent paths are verified, and the paths that do not need to be tested are skipped. The coarse-grained test reduces the test time overhead through fast calculation. In the case of time allowance, the fine-grained test strategy is selected, which combines path constraint solving and symbolic execution technology to comprehensively verify all paths, ensuring test coverage and accuracy.

[0074] The test method selection strategy is based on the following formula:

[0075] Delta T1 = T f -T c , Delta T2 = T n -T c

[0076] Where T c is the completion time of coarse-grained test, T f is the completion time of fine-grained test, and T nis the arrival time of the next update request. When ΔΤ1> ΔΤ2, it means that the coarse-grained test is completed, and the next update request time has not yet arrived, at this time the time is tight, and the coarse-grained test strategy with faster speed is preferentially selected to generate the result. When ΔΤ1≤ ΔΤ2, it means that the coarse-grained test and the fine-grained test are both completed, and the next update request time has not yet arrived, at this time the time is sufficient, and the fine-grained test strategy with higher accuracy can be used to verify all paths. Please refer to Figure 3 .

[0077] (4) Automation optimization

[0078] In the automation optimization stage, the present application generates diversified defect code samples through regular matching and random modification, and optimizes the graph neural network model in combination with the automatic training feedback mechanism.

[0079] In the defect code sample generation stage, the code structure of the P4 program is randomly modified, such as adding or deleting nodes, modifying edge attributes, or adjusting logical conditions. For each defect sample, the control flow graph is regenerated, and the nodes and edges of the changed part are marked. In the training stage, the node features are updated in combination with the coarse-grained test feedback results:

[0080] X'[i] = X[i] + ΔX[i]

[0081] and the model parameters are adjusted through the gradient descent method. The trained model verifies the applicability in the actual network environment, and gradually improves the test efficiency and accuracy in complex scenarios. The overall operation process is shown in Algorithm 1.

[0082]

[0083]

[0084] Those skilled in the art will appreciate that embodiments of the present application can be provided as methods, systems, or computer program products. Therefore, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, the present application can 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-ROMs, optical storage, etc.) containing computer usable program code.

[0085] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flow or blocks Figure 1 one or more flow or blocks

[0086] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the function specified in the flowchart block or blocks. Figure 1 one or more flow or blocks Figure 1 one or more flow or blocks

[0087] The computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer-implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart block or blocks. Figure 1 one or more flow or blocks Figure 1 one or more flow or blocks

[0088] The above descriptions are only preferred embodiments of the present application, and are not intended to limit the present application to other forms described. Any person skilled in the art may make modifications or improvements to the above-described embodiments based on the technical content disclosed in the present application, and the modifications or improvements are equivalent embodiments. However, any simple modifications, equivalent changes and modifications made to the above embodiments without departing from the technical solutions of the present application, and based on the technical essence of the present application, are still within the protection scope of the present application.

Claims

1. A programmable data plane incremental testing method based on graph neural networks, characterized in that, By generating and analyzing the control flow graph of the data plane program, the path reachability is judged by using a graph neural network to realize incremental testing in the network high-frequency update environment; Specifically comprising the following steps: 1) generating a control flow graph of the data plane program, analyzing the structure and logic of the program, setting the type, number, reachability flag and change flag of each node in the program, defining the start point, end point and transition condition of the edge; 2) converting the control flow graph into a graph data object, including a node feature matrix and an edge feature matrix, embedding the information of the nodes and edges through an encoding method, so that the information of the nodes and edges can be learned and utilized by the neural network; 3) using a graph convolutional neural network model to analyze the path dependence relationship in the graph data object, aggregating node features layer by layer, while combining the conditional transition characteristics of the edges, gradually integrating the local information between nodes; in this way, the graph convolutional neural network model can generate a global information representation of the control flow graph, which is used to represent the complete path structure and path dependence relationship in the program execution logic; 4) dynamically selecting coarse-grained or fine-grained testing strategies, switching the test mode according to the time condition to balance efficiency and accuracy; 5) generating diversified defect code samples through regular matching and random modification, and combining an automated training mechanism to optimize the performance of the graph neural network model and improve the adaptability of the system; In step 3), the graph convolutional neural network model is used to analyze the path dependence relationship in the graph data object, and the implementation method is: The node features are gradually aggregated by multi-layer graph convolution operations to generate the global embedding representation of the control flow graph. The core operation of the graph convolution network is adjacency matrix normalization and feature update, and the forward propagation formula is where H (l) is the node feature matrix of the lth layer, W (l) is the weight matrix, is the adjacency matrix after adding a self-loop, is the degree matrix of H , and σ is an activation function. After multi-layer graph convolution, the global embedding representation obtained can effectively capture the path dependence relationship in the control flow graph for path reachability judgment.

2. The programmable data plane incremental testing method based on graph neural network according to claim 1, characterized in that, In step 1), the control flow graph is generated, and the implementation method is: First, perform syntax analysis on the P4 program code to extract key nodes including tables, keys, actions and conditional judgments in the packet processing logic; by constructing a control flow graph, define the attributes of each node, including node type type, unique number id, reachability flag isReachable and change flag isChanged; node type type includes table node table, key node key and action node action, which are used to distinguish different functional modules in the program structure; the attributes of the edge edge_attr include the start node src, the end node dst and the conditional expression condition, which are used to describe the logical branches in the program execution path; the generated control flow graph is represented in the form of a directed graph, which is formally defined as CFG=(V,E), where V is the node set and E is the edge set.

3. The programmable data plane incremental testing method based on graph neural network according to claim 1, characterized in that, In step 2), the control flow graph is converted into a graph data object, and the implementation method is: Based on the generated control flow graph, a node feature matrix X, an edge index matrix Edge_Index and an edge feature matrix Edge_Attr are constructed; the node feature matrix X represents the node type and the change flag in one-hot encoding mode; the label vector is represented by isReachable as the supervision signal of the model; the edge index matrix Edge_Index represents the start and end points of the edges in the graph; the edge feature matrix Edge_Attr records the conditional attributes of the edges; the finally generated graph data object includes (X, Edge_Index, Edge_Attr) and can be directly input into the graph neural network model for subsequent processing.

4. The programmable data plane incremental testing method based on graph neural network according to claim 1, characterized in that, In step 4), a coarse-grained or fine-grained test strategy is dynamically selected, and the implementation method is as follows: According to the task time requirement, two kinds of test strategies of coarse-grained and fine-grained are designed; in coarse-grained test, the coverage of change nodes and their neighborhood paths is calculated preferentially, and the paths that do not need to be verified are skipped to reduce the test time; The fine-grained test verifies all control flow graph paths through comprehensive path constraint solving, ensuring 100% coverage; the dynamic selection of the test strategy is based on ΔT1=T f -T c and ΔT2=T n -T c is adjusted, where T c is the completion time of the coarse-grained test, T f is the completion time of the fine-grained test, T n is the arrival time of the next update request; when ΔT1>ΔT2, it indicates that the coarse-grained test is completed, and the next update request time has not yet arrived, at which time the time is tight, and the coarse-grained test strategy with faster speed is preferentially selected to generate the result; when ΔT1≤ΔT2, it indicates that the coarse-grained test and the fine-grained test are both completed, and the next update request time has not yet arrived, at which time the time is sufficient, and the fine-grained test strategy with higher accuracy is used to verify all paths.

5. The programmable data plane incremental testing method based on graph neural network according to claim 1, characterized in that, In step 5), an automatic training mechanism, and the implementation method is as follows: Defect code samples are generated by regular matching and random modification, and the error parts are automatically marked and the graph neural network model is continuously optimized; specifically, random change operations are introduced into the generated defect code samples, including adding and deleting nodes and modifying edge attributes, to generate a control flow graph containing change marks; the feedback result of coarse-grained test is used to update the node feature parameters, that is, X'[i] = X[i] + ΔX[i]; after multiple training iterations, the model can adapt to diversified defect scenarios and improve its applicability in actual test.

Citation Information

Patent Citations

  • Incremental code defect detection method and system based on graph network model

    CN113127341A

  • Program vulnerability detection method and system based on hypergraph neural network

    CN116415253A