Graph neural network-based programmable data plane increment test method
By generating control flow graphs based on graph neural network, analyzing path dependencies, and dynamically selecting test strategies, the problem of low testing efficiency of P4 program is solved, and efficient incremental testing and accuracy verification are achieved.
Patent Information
- Application Number
- CN202510044356.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-11
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2045-01-11
AI Technical Summary
The existing P4 program testing methods are prone to path explosion problems when facing complex program structures or frequent small code updates, resulting in a significant decrease in testing efficiency and it is difficult to feedback error information in real time through intermediate variable output and logging.
The programmable data plane incremental testing method based on graph neural network is adopted. By generating a control flow diagram and analyzing the path dependence relationship with the graph neural network model, coarse-grained or fine-grained testing strategies are dynamically selected to achieve efficient incremental testing.
It greatly improves the testing efficiency, significantly reduces the test time overhead, and flexibly adapts to high-frequency rule update scenarios, which not only meets the needs of real-time and fast verification, but also ensures the accuracy of test results.
Smart Images

Figure CN119883924A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer network technology, and in particular to a programmable data plane incremental testing method based on graph neural network. Background Art
[0002] Multimodal network technology provides a comprehensive and efficient analysis framework in complex network environments by integrating data from multiple dimensions (such as topology information, state changes, and logical structures). Its core lies in abstracting and co-processing network data of multiple modes, thereby achieving all-round modeling and evaluation of network behavior. In recent years, the application of multimodal technology in network optimization and security verification has continued to expand, showing strong flexibility and adaptability. Drawing on the layered design and collaborative analysis ideas in multimodal networks, it can provide a new solution for the development and testing of programmable data plane programs.
[0003] With the rapid development of computer networks, data plane plays 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 process of P4 programs is complex and involves 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 the control flow graph (CFG). Although these methods can guarantee a high test coverage rate, they are prone to path explosion problems when faced with complex program structures or frequent small code updates, resulting in a significant decrease in test efficiency. In addition, due to the running characteristics of P4 programs in network devices, it is difficult to feedback error information in real time during the test process through intermediate variable output and logging, which puts higher requirements on program correctness verification and security assessment. Summary of the invention
[0005] The purpose of the present invention is to provide a method for incremental testing of programmable data planes based on graph neural networks. The method generates a control flow graph and analyzes path dependencies in combination with a graph neural network model, thereby achieving efficient incremental testing in scenarios where network rules are frequently updated.
[0006] In order to achieve the above-mentioned purpose, the technical solution adopted by the present invention is: a method for incremental testing of programmable data plane based on graph neural network, which generates and analyzes the control flow graph (CFG) of the data plane program and uses the graph neural network to judge the path reachability, so as to realize incremental testing in a high-frequency network update environment; specifically, it includes the following steps:
[0007] 1) Generate a control flow graph for the data plane program, analyze the structure and logic of the program, set the type, number, reachability flag and change flag for each node in the program, and define the starting point, end point and transfer conditions of the edge;
[0008] 2) Convert the control flow graph into a graph data object, including a node feature matrix and an edge feature matrix, and embed the node and edge information by encoding so that the node and edge information can be learned and used by the neural network;
[0009] 3) A graph convolutional neural network (GCN) model is used to analyze the path dependencies in graph data objects, aggregate node features layer by layer, and combine the conditional transfer characteristics of edges to gradually integrate 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 characterize the complete path structure and path dependency in the program execution logic.
[0010] 4) Dynamically select coarse-grained or fine-grained test strategies and switch test modes according to time conditions to achieve a balance between efficiency and accuracy;
[0011] 5) Generate diverse defective code samples through regular matching and random modification, and optimize the performance of the graph neural network model with the automated training mechanism to improve the system’s adaptability.
[0012] Furthermore, in step 1), a control flow graph is generated, and the implementation method thereof is as follows:
[0013] Firstly, the P4 program code is parsed to extract the key nodes in the data packet processing logic, including table, key, action and condition judgment. Then, the properties of each node are defined by constructing a control flow graph, 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. Edge attribute edge_attr includes starting node src, ending node dst and conditional expression condition, which are used to describe the logical branch 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] Furthermore, in step 2), the control flow graph is converted into a graph data object, and the implementation method is as follows:
[0015] Based on the generated control flow graph, the node feature matrix X, edge index matrix Edge_Index and edge feature matrix Edge_Attr are constructed; the node feature matrix X uses one-hot encoding to represent the node type and change flag; isReachable is used to represent the label vector as the supervision signal of the model; the edge index matrix Edge_Index represents the starting and end points of the edges in the graph; the edge feature matrix Edge_Attr records the conditional attributes of the edges. The final 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] Furthermore, in step 3), a graph convolutional neural network model is used to analyze the path dependency relationship in the graph data object, and the implementation method is as follows:
[0017] Through multi-layer graph convolution operations, node features are gradually aggregated to generate a global embedding representation of the control flow graph; the core operation of the graph convolution network is adjacency matrix normalization and feature update, and its forward propagation formula is: Among them, H (l) is the node feature matrix of the lth layer, W (l) is the weight matrix, is the adjacency matrix after adding self-loops, for is the degree matrix, σ is the activation function; after multi-layer graph convolution, the obtained global embedding representation can effectively capture the path dependency in the control flow graph and is used for path reachability judgment.
[0018] Furthermore, in step 4), a coarse-grained or fine-grained testing strategy is dynamically selected, and the implementation method is as follows:
[0019] According to the task time requirements, two test strategies, coarse-grained and fine-grained, are designed. In coarse-grained testing, the coverage of the changed nodes and their neighborhood paths 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 test strategies is based on ΔT1=T f -T c And ΔT2=T n -T c Adjust, where T c is the completion time of the coarse-grained test, T f is the completion time of fine-grained testing, T nis the arrival time of the next update request; when ΔT1>ΔT2, it means that after the coarse-grained test is completed, the next update request time has not arrived. At this time, time is tight, and the faster coarse-grained test strategy is preferred to generate results; when ΔT1≤ΔT2, it means that both the coarse-grained test and the fine-grained test are completed, and the next update request time has not arrived. At this time, time is sufficient, and a fine-grained test strategy with higher accuracy is used to verify all paths.
[0020] Furthermore, in step 5), the automated training mechanism is implemented by:
[0021] Defective code samples are generated through regular matching and random modification, the erroneous parts are automatically marked and the graph neural network model is continuously optimized. Specifically, random change operations are introduced into the generated defective code samples, including adding and deleting nodes and modifying edge attributes, to generate a control flow graph containing change marks. The node feature parameters are updated using the feedback results of coarse-grained testing, i.e., X'[i]=X[i]+ΔX[i]. After multiple training iterations, the model can adapt to a variety of defect scenarios, improving its applicability in actual testing.
[0022] Compared with the prior art, the present invention has the following beneficial effects: by combining control flow graph generation with graph neural network modeling, the present invention can efficiently analyze path dependencies, greatly improve test efficiency, and significantly reduce test time overhead; by optimizing the memory usage and computing resource consumption of the model through lightweight design, the resource occupation of the test process is reduced; dynamically switch between coarse-grained and fine-grained test strategies, and flexibly adapt to high-frequency rule update scenarios, which not only meets the needs of real-time and rapid verification, but also ensures the accuracy of test results; in addition, the present invention adopts standardized control flow graph generation and graph data processing procedures, with a clear structure and simple implementation, which is convenient for integration with existing systems and promotion and application, and is suitable for complex scenarios such as cloud computing and network security that require fast and efficient testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] Figure 1 The overall structure diagram and flow chart of the method in the embodiment of the present invention are shown in FIG.
[0024] Figure 2 This is an example diagram of node feature encoding of the method in an embodiment of the present invention.
[0025] Figure 3 An example diagram of test strategy selection for the method in an embodiment of the present invention. DETAILED DESCRIPTION
[0026] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0027] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0028] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0029] This embodiment provides a method for incremental testing of programmable data planes based on graph neural networks, which generates and analyzes the control flow graph (CFG) of the data plane program and uses graph neural networks to efficiently judge path reachability, so as to achieve fast and accurate incremental testing in a high-frequency network update environment. The method specifically includes the following steps:
[0030] 1) Generate a control flow graph for the data plane program, analyze the structure and logic of the program, set the type, number, reachability flag and change flag for each node in the program, and define the starting point, end point and transfer conditions of the edge.
[0031] 2) Convert the control flow graph into a graph data object, including the node feature matrix and the edge feature matrix, and embed the node and edge information through encoding so that the node and edge information can be learned and used by the neural network.
[0032] 3) A graph convolutional neural network (GCN) model is used to analyze the path dependencies in graph data objects, aggregate node features layer by layer, and gradually integrate local information between nodes in combination with the conditional transfer characteristics of edges. In this way, the GCN model can generate a global information representation of the control flow graph, which is 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 test modes according to time conditions to achieve a balance between efficiency and accuracy.
[0034] 5) Generate diverse defective code samples through regular matching and random modification, and optimize the performance of the graph neural network model with the automated training mechanism to improve the system’s adaptability.
[0035] In step 1), a control flow graph is generated, and the implementation method is as follows:
[0036] First, the P4 program code is parsed to extract key nodes such as tables, keys, actions, and conditional judgments in the data 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. Node types type include table (table node), key (key node), and action (action node), which are used to distinguish different functional modules in the program structure; the edge attributes edge_attr include the starting 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, formally defined as CFG = (V, E), where V is a node set and E is an 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, construct the node feature matrix X, edge index matrix Edge_Index and edge feature matrix Edge_Attr. The node feature matrix X uses one-hot encoding to represent the node type and change flag, for example, X[i] = [type, isChanged]. IsReachable is used to represent the label vector as the supervision signal of 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 It is represented as Edge_Index[e]=(v i ,v j ); the edge feature matrix Edge_Attr records the conditional attributes of the edge, for example, Edge_Attr[e] = [condition(e)], and the final 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), a graph convolutional neural network model is used to analyze the path dependency 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 a global embedding representation of the control flow graph. The core operation of the graph convolution network is adjacency matrix normalization and feature update. Its forward propagation formula is: Among them, H (l) is the node feature matrix of the lth layer, W (l) is the weight matrix, is the adjacency matrix after adding self-loops, for is the degree matrix, and σ is the activation function (such as ReLU). After multiple layers of graph convolution, the global embedding representation obtained can effectively capture the path dependencies in the control flow graph and is used for path reachability judgment.
[0041] In this embodiment, the graph neural network model uses multi-layer graph convolution operations when processing the control flow graph to achieve efficient node association and feature aggregation. Specifically, after aggregating the node features at each layer, the entire graph is embedded to generate an overall representation for path dependency analysis.
[0042] In this embodiment, a lightweight graph neural network model is adopted to reduce unnecessary feature calculation burden and memory usage through field selection strategy, thereby optimizing the resource consumption of the graph neural network in data plane testing and achieving efficient memory management and performance improvement.
[0043] In step 4), a coarse-grained or fine-grained testing strategy is dynamically selected, and the implementation method is as follows:
[0044] According to the task time requirements, two testing strategies, coarse-grained and fine-grained, are designed. In coarse-grained testing, the coverage of the changed nodes and their neighborhood paths is calculated first, and the paths that do not need to be verified are skipped, which significantly reduces the testing time; fine-grained testing verifies all control flow graph paths through comprehensive path constraint solving to ensure 100% coverage. Dynamically based on ΔT1=T f -T c And ΔT2=T n -T c Adjust, where T c is the completion time of the coarse-grained test, T f is the completion time of fine-grained testing, T n is the arrival time of the next update request. When ΔT1>ΔT2, it means that after the coarse-grained test is completed, the next update request time has not arrived. At this time, time is tight, and the faster coarse-grained test strategy is preferred to generate results. When ΔT1≤ΔT2, it means that both the coarse-grained test and the fine-grained test are completed, and the next update request time has not arrived. At this time, 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 switch the test mode under different network conditions. Coarse-grained testing is based on the graph neural network (GNN) method. It quickly analyzes the global information representation of the 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, thereby quickly generating test results; fine-grained testing uses the traditional 100% coverage method to comprehensively analyze all nodes and edges in the control flow graph, and gradually verify the reachability of each possible path to ensure the integrity and accuracy of the test results. The switching of the two test strategies is achieved by dynamically predicting the time interval of network update requests. When the time interval is short, coarse-grained testing is preferred to improve the response speed; when the time interval is long, it automatically switches to fine-grained testing to ensure the accuracy of the test.
[0046] In step 5), the automated training mechanism is implemented as follows:
[0047] Generate defective code samples through regular matching and random modification, automatically mark the error parts and continuously optimize the graph neural network model; specifically, introduce random change operations in the generated defective code samples, including adding and deleting nodes, modifying edge attributes, etc., to generate a control flow graph containing change marks. Use the feedback results of coarse-grained testing to update node feature parameters, that is, X'[i]=X[i]+ΔX[i]. After multiple training iterations, the model can adapt to a variety of defect scenarios and improve its applicability in actual testing.
[0048] In this embodiment, a mechanism for automatically training and generating defective code samples is adopted. Specifically, regular expressions are used to match the code and modify the table definition, action and conditional judgment structure to form multiple mutated codes, and the control flow graph is regenerated on each mutated code, and the changed part of the code is marked and re-substituted into the model training. The accuracy of the graph neural network model is continuously optimized through an automated training data feedback mechanism. The feedback results of fine-grained tests are added to the coarse-grained testing process as model training samples, and the characteristic parameters of nodes and edges are dynamically adjusted. After multiple training iterations, the test accuracy of the coarse-grained mode is improved to adapt to test tasks in different scenarios.
[0049] The specific implementation process of this method is further explained below.
[0050] Please refer to Figure 1 ,This 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 stage, the present invention first parses the P4 program code and extracts key nodes such as tables, keys, actions, and conditional judgments in the data 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 describes the logical path of the program in a structured manner.
[0053] First, perform syntax analysis on the program code and abstract each logical unit into a node in the graph. 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): Assign a unique number 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 edge is established according to the control logic in the code. Each edge contains a starting node, an end node and a conditional expression. For example, the if statement in the program corresponds to a conditional edge, and the call relationship between table and action corresponds to an unconditional edge. The control flow graph generated in the end is formally defined as:
[0059] CFG=(V,E)
[0060] Where V is the node set and E is the edge set. The conditional attributes of the edge are described by logical expressions and recorded in the edge features. The generated control flow graph provides the basis for subsequent graph neural network modeling.
[0061] (2) Graph Neural Network Modeling
[0062] In the graph neural network modeling stage, the generated control flow graph is converted into the input data structure adapted to the graph neural network, which includes the node feature matrix, edge index matrix and edge feature matrix.
[0063] First, generate the node feature matrix X, including node types and change flags. Figure 2 , the node features are encoded through one-hot encoding to generate the label vector isReachable as the supervision signal of the model. For example:
[0064] X[i]=[type,isChanged]
[0065] The edge index matrix Edge_Index records the connection relationship of the edges in the graph and is used to describe the starting point and end point of each edge. For example:
[0066] Edge_Index[e]=(v i ,v j )
[0067] The edge feature matrix 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 dependency of the control flow graph, and the node features are aggregated layer by layer to generate a global embedding representation. The core formula of the graph convolution is:
[0070]
[0071] Among them, H (l) is the feature matrix of the l-th layer node, is the adjacency matrix after adding self-loops, is the degree matrix of the adjacency matrix, W (l) is the weight matrix, and σ is the activation function (such as ReLU). Through multi-layer convolution operations, the node features are gradually updated, and the global embedding of the entire graph is generated for path reachability judgment.
[0072] (3) Dynamic test strategy selection
[0073] The present invention designs a dynamic test strategy selection mechanism, which flexibly switches between coarse-grained and fine-grained test strategies according to the time conditions of the task scenario. In scenarios with tight time or high-frequency rule updates, a coarse-grained test strategy is selected to verify only the changed nodes and their neighborhood paths, skipping paths that do not need to be tested. Coarse-grained testing significantly reduces test time overhead through fast calculations. When time is ample, a fine-grained test strategy is selected, combined with path constraint solving and symbolic execution technology, to fully verify all paths to ensure test coverage and accuracy.
[0074] The test method selection strategy is based on the following formula:
[0075] ΔT1=T f -T c ,ΔT2=T n -T c
[0076] Among them, T c is the completion time of the coarse-grained test, T f is the completion time of fine-grained testing, T nis the arrival time of the next update request. When ΔT1>ΔT2, it means that after the coarse-grained test is completed, the next update request time has not arrived. At this time, time is tight, and the faster coarse-grained test strategy is preferred to generate results. When ΔT1≤ΔT2, it means that both the coarse-grained test and the fine-grained test are completed, and the next update request time has not arrived. At this time, time is sufficient, and the more accurate fine-grained test strategy can be used to verify all paths. Please refer to Figure 3 .
[0077] (4) Automated Optimization
[0078] In the automated optimization stage, the present invention generates diverse defective code samples through regular matching and random modification, and optimizes the graph neural network model in combination with an automated training feedback mechanism.
[0079] In the defect code sample generation phase, 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 parts are marked. In the training phase, the node features are updated in combination with the coarse-grained test feedback results:
[0080] X'[i]=X[i]+ΔX[i]
[0081] The model parameters are adjusted by gradient descent method. The applicability of the trained model is verified in the actual network environment, and the test efficiency and accuracy in complex scenarios are gradually improved. The overall operation process is detailed in Algorithm 1.
[0082]
[0083]
[0084] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0085] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, 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 generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0086] 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 process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0087] 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 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0088] The above is only a preferred embodiment of the present invention, and does not limit the present invention in other forms. Any technician familiar with the profession may use the above disclosed technical content to change or modify it into an equivalent embodiment with equivalent changes. However, any simple modification, equivalent change and modification made to the above embodiment according to the technical essence of the present invention without departing from the technical solution of the present invention still belongs to the protection scope of the technical solution of the present invention.
Claims
1. A method for incremental testing of programmable data plane based on graph neural network, characterized in that: By generating and analyzing the control flow graph of the data plane program, the graph neural network is used to judge the path reachability to achieve incremental testing in a high-frequency network update environment; The specific steps include: 1) Generate a control flow graph for the data plane program, analyze the structure and logic of the program, set the type, number, reachability flag and change flag for each node in the program, and define the starting point, end point and transfer conditions of the edge; 2) Convert the control flow graph into a graph data object, including a node feature matrix and an edge feature matrix, and embed the node and edge information by encoding so that the node and edge information can be learned and used by the neural network; 3) Use the graph convolutional neural network model to analyze the path dependency relationship in the graph data object, aggregate node features layer by layer, and combine the conditional transfer characteristics of the edge to gradually integrate 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 characterize the complete path structure and path dependency relationship in the program execution logic; 4) Dynamically select coarse-grained or fine-grained test strategies and switch test modes according to time conditions to achieve a balance between efficiency and accuracy; 5) Generate diverse defective code samples through regular matching and random modification, and optimize the performance of the graph neural network model with the automated training mechanism to improve the system’s adaptability.
2. According to claim 1, a method for incremental testing of programmable data plane based on graph neural network is characterized in that: In step 1), a control flow graph is generated, and the implementation method is as follows: Firstly, the P4 program code is parsed to extract the key nodes in the data packet processing logic, including table, key, action and condition judgment. Then, the properties of each node are defined by constructing a control flow graph, 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. Edge attribute edge_attr includes starting node src, ending node dst and conditional expression condition, which are used to describe the logical branch 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 method for incremental testing of programmable data plane 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 as follows: Based on the generated control flow graph, the node feature matrix X, edge index matrix Edge_Index and edge feature matrix Edge_Attr are constructed; the node feature matrix X uses one-hot encoding to represent the node type and change flag; isReachable is used to represent the label vector as the supervision signal of the model; the edge index matrix Edge_Index represents the starting and end points of the edges in the graph; the edge feature matrix Edge_Attr records the conditional attributes of the edges. The final generated graph data object includes (X, Edge_Index, Edge_Attr), which can be directly input into the graph neural network model for subsequent processing.
4. The method for incremental testing of programmable data plane based on graph neural network according to claim 1, characterized in that: In step 3), a graph convolutional neural network model is used to analyze the path dependency relationship in the graph data object, and the implementation method is as follows: Through multi-layer graph convolution operations, node features are gradually aggregated to generate a global embedding representation of the control flow graph; the core operation of the graph convolution network is adjacency matrix normalization and feature update, and its forward propagation formula is: Among them, H (l) is the node feature matrix of the lth layer, W (l) is the weight matrix, is the adjacency matrix after adding self-loops, for is the degree matrix, σ is the activation function; after multi-layer graph convolution, the obtained global embedding representation can effectively capture the path dependency in the control flow graph and is used for path reachability judgment.
5. The method for incremental testing of programmable data plane based on graph neural network according to claim 1, characterized in that: In step 4), a coarse-grained or fine-grained testing strategy is dynamically selected, and the implementation method is as follows: According to the task time requirements, two testing strategies, coarse-grained and fine-grained, are designed. In coarse-grained testing, the coverage of the changed nodes and their neighborhood paths is calculated first, and paths that do not need to be verified are skipped to reduce the testing time. Fine-grained testing verifies all control flow graph paths through comprehensive path constraint solving to ensure 100% coverage; dynamic selection of test strategies based on ΔT1=T f -T c And ΔT2=T n -T c Adjust, where T c is the completion time of the coarse-grained test, T f is the completion time of fine-grained testing, T n is the arrival time of the next update request; when ΔT1>ΔT2, it means that after the coarse-grained test is completed, the next update request time has not arrived. At this time, time is tight, and the faster coarse-grained test strategy is preferred to generate results; when ΔT1≤ΔT2, it means that both the coarse-grained test and the fine-grained test are completed, and the next update request time has not arrived. At this time, time is sufficient, and a fine-grained test strategy with higher accuracy is used to verify all paths.
6. The method for incremental testing of programmable data plane based on graph neural network according to claim 1, characterized in that: In step 5), the automated training mechanism is implemented as follows: Defective code samples are generated through regular matching and random modification, the erroneous parts are automatically marked and the graph neural network model is continuously optimized. Specifically, random change operations are introduced into the generated defective code samples, including adding and deleting nodes and modifying edge attributes, to generate a control flow graph containing change marks. The node feature parameters are updated using the feedback results of coarse-grained testing, i.e., X'[i]=X[i]+ΔX[i]. After multiple training iterations, the model can adapt to a variety of defect scenarios, improving its applicability in actual testing.
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
Software aging defect deep semantic feature learning method based on code attribute graph
CN117743142A
Code vulnerability detection method based on graph neural network
CN118094562A
Path delay prediction method for integrated circuit based on feature selection and deep learning
US20240265190A1