A network fault troubleshooting method applied to programmable switches
By recording and forwarding data plane table information on a programmable switch, combined with the solution of maximizing information entropy, the problem of failure of programmable switches cannot be quickly located in the prior art, and the troubleshooting efficiency and accuracy are improved.
Patent Information
- Application Number
- CN202310066701.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-01-29
- Publication Date
- 2025-08-22
- Estimated Expiration
- 2043-01-29
AI Technical Summary
Existing network troubleshooting systems are unable to quickly and efficiently locate failures of programmable switches, especially failures to consider their programmability and new features.
By recording the table information of the data plane in real time on a programmable switch, and sending it to a specific port using the mirroring function, combining the table information recording scheme with maximum information entropy, an optimal table information recording scheme is generated, and the P4 program code is modified to achieve troubleshooting.
Improves the efficiency of network troubleshooting, provides more information to support network engineers to quickly locate faults, considers the hardware limitations of programmable switches, and ensures the accuracy and efficiency of information recording.
Smart Images

Figure CN116132271B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer networks, and in particular relates to a network fault troubleshooting method applied to a programmable switch. Background Art
[0002] Commercial switches typically have two planes: a control plane and a data plane. The control plane is responsible for calculating and populating routing tables, while the data plane forwards network packets from one port to another according to the control plane's logic. The control plane is typically implemented by a general-purpose CPU and is programmable, while the data plane is not. In recent years, several switches with programmable data planes have become available, which we call programmable switches or programmable data planes.
[0003] Programmable switches use the P4 (Programming Protocol-independent Packet Processors) programming language to describe the logic of the data plane processing network packets. When processing network packets, P4 extracts information from the packet header and places it into a PHV (Packet Header Vector). It then processes these headers using a match-and-action table. Each table matches specific fields in the PHV and performs different actions based on the field's value, thus achieving flexible network functionality.
[0004] Actual hardware programmable switches possess a number of resources, such as PHV, stage, SRAM, and TCAM. Each resource is limited, and P4 programs utilize these resources. The P4 compiler automatically analyzes the program's resource requirements and allocates them. If the program's resource requirements exceed the hardware limits, a compilation error occurs, resulting in limited flexibility on programmable switches. Despite this, academia and industry are surging with research on in-network computing and measurement based on programmable switches, offloading some software functions to the hardware switches to achieve performance or cost advantages.
[0005] In a rapidly changing network environment, failures are inevitable. Therefore, quickly and efficiently locating the cause of failures has been a hot topic in academia and industry. The switch's mirroring function has been widely used in these network troubleshooting studies. This function copies incoming network packets and then forwards them to a specific outbound port without affecting the original packets. These troubleshooting efforts use mirroring to forward network packets to a server, where they analyze the mirrored packets to locate the fault. However, these efforts simply treat the switch as a black box, failing to consider its programmability or the new capabilities offered by programmable switches. Consequently, existing network troubleshooting efforts cannot effectively address the troubleshooting challenges of programmable switches.
[0006] In information theory, information entropy is used to measure the amount of information. Information theory posits that the amount of information contained in an event is inversely correlated with the probability of that event occurring; that is, the smaller the probability of occurrence, the more information it contains. The quantitative relationship is I = -log2 p, where I is the amount of information and p is the probability of the event occurring. Information entropy is the expected value of the amount of information, namely, E = -∑plog2p, where E is the information entropy. Information entropy has numerous applications in computer science, and many algorithms, such as decision tree algorithms, seek to maximize information entropy. This invention also seeks to maximize information entropy when designing a table information recording scheme for the data plane.
[0007] The programmability of programmable switches enables many new functions to be offloaded to the network. Traditional network troubleshooting systems are unable to quickly locate the failures of these new functions. Therefore, it is of great value to implement a network troubleshooting method applied to programmable switches. Summary of the Invention
[0008] The present invention aims to provide a network troubleshooting method applied to programmable switches in response to faults generated in actual deployment. The method aims to record table information in real time on the programmable data plane and send this information to a specific port through a mirroring function for use by network engineers in troubleshooting, thereby improving the efficiency of network troubleshooting.
[0009] To achieve the above object, the present invention adopts the following technical solutions:
[0010] A network fault troubleshooting method applied to a programmable switch, characterized by comprising the following steps:
[0011] Step 1: Collect network packets passing through the programmable switch and generate a probabilistic transition DAG based on the programs running on the programmable switch.
[0012] Step 2: Based on the PHV resources, probability conversion DAG, and P4 program, calculate and generate a set of table information recording schemes so that the information entropy obtained by the table information recording scheme is maximized, and use it as the optimal table information recording scheme;
[0013] Step 3: Based on the generated optimal table information recording scheme, modify the P4 program code on the programmable switch, recompile and run it, and forward the table information of the data plane to a specific egress port for subsequent troubleshooting.
[0014] To optimize the above technical solutions, specific measures taken also include:
[0015] Furthermore, in step 1, the method for generating a probabilistic conversion DAG is specifically as follows: converting the P4 program logic executed on the programmable switch into a DAG, where the nodes in the DAG are tables in the P4 program, and the edges of the DAG are logical jump relationships in the P4 program; replaying the collected network packets on the programmable switch, and simultaneously counting the frequency of these network packets passing through each table; and approximating the frequency of the table as the probability in the probabilistic conversion DAG to generate the probabilistic conversion DAG.
[0016] Furthermore, in step 2, the branch and bound method is used to calculate the optimal table information recording scheme as follows:
[0017] Sort all tables in the P4 program from largest to smallest according to information entropy, run a depth-first search algorithm, and traverse these tables in turn. For each table, there are two options: record the table or not record the table, corresponding to two sets of candidate tables.
[0018] After selecting a table, the information entropy of the candidate table set is calculated, and the SMT solver is used to determine whether the candidate table set meets the switch hardware constraints:
[0019] If the candidate table set meets the hardware constraints, the SMT solver returns a set of legal candidate recording schemes and compares their information entropy with the currently available optimal table information recording scheme. If the information entropy of this candidate recording scheme is greater, the optimal table information recording scheme is updated to this candidate recording scheme, and the upper bound of the information entropy that can be achieved by this search branch in the future is estimated.
[0020] If the candidate table set does not meet the hardware constraints, or the upper bound of the information entropy is lower than the information entropy of the currently available optimal table information recording scheme, the current search branch is cut off and the search is stopped. Otherwise, the search continues until the PHV resources are exhausted and the search is completed.
[0021] Furthermore, the upper bound of the information entropy that can be obtained by estimating the search branch in the future is specifically as follows: the number N of tables that can record information is derived based on the remaining PHV resources, and the N largest information entropies in the remaining tables are summed to obtain the upper bound of the information entropy of the search branch.
[0022] Furthermore, in step 2, the greedy algorithm is used to calculate the optimal table information recording scheme as follows: in each round of calculation, all unrecorded tables in the P4 program are traversed in turn, and they are recorded to form a new candidate table set. The information entropy of the candidate table set is calculated, and the SMT solver is used to determine whether the candidate table set meets the switch hardware restrictions. If the candidate table set meets the hardware restrictions, the SMT solver will return a set of legal candidate recording schemes. The recording scheme with the largest information entropy and meeting the switch hardware restrictions is selected from the current round of calculation and used as the initial value for the next round of calculation. The calculation process is repeated until the PHV resources are exhausted or no recording scheme meeting the hardware restrictions can be found. The recording scheme with the largest information entropy in the last round of calculation is returned as the optimal table information recording scheme.
[0023] Furthermore, the information entropy of the candidate table set is calculated as follows:
[0024] First, the probability transformation DAG represented by the P4 program is divided into multiple subgraphs based on the cut points. The sum of the information entropy of the multiple subgraphs is equal to the information entropy of the entire graph.
[0025] Calculate the information entropy of the candidate table set on each subgraph: Start from the starting point of the subgraph and perform a depth-first search. During the search, maintain the probability of the current search path. When the end point of the subgraph is found, add the tables recorded in the path and the probability of the path to the path set. When the entire subgraph is searched, traverse the path set, extract each path and its corresponding probability p, and add -plog2p to the information entropy of the subgraph. The information entropy obtained after the calculation is the information entropy of the candidate table set on the subgraph.
[0026] The information entropy of the candidate table set on each subgraph is summed up, and the obtained information entropy is the information entropy of the candidate table set.
[0027] Furthermore, the method of using the SMT solver to determine whether the candidate table set meets the switch hardware constraints is as follows: assigning a number of PHV i , stage i Variable, PHV i The value of represents the PHV number used in recording table i, stage iIndicates the stage number where table i is placed; analyze the initial program of P4, extract the program dependencies, and load them into the SMT solver; consider the new constraints brought by the candidate table set, including that the bit width used by PHV needs to be less than or equal to the available width, and that tables using the same PHV record cannot be placed in the same stage; use the SMT solver to solve the problem. If the problem has no solution, return "no solution". If the problem has a solution, return a set of legal candidate record solutions.
[0028] Furthermore, in step 3, based on the generated optimal table information recording scheme, the P4 program code on the programmable switch is modified as follows: several variables are initialized to record the table information of the data plane, and the variables consume PHV resources; based on the optimal table information recording scheme, variable assignment statements are injected into the behavior of the corresponding table, and the assignment statements set the bit of the table in the variable to 1, thereby recording whether the behavior of the table is executed; and code for implementing the mirroring function is added to the P4 program code to forward the table information to a specific output port.
[0029] The present invention also provides a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the network fault troubleshooting method applied to a programmable switch as described above.
[0030] The present invention also proposes an electronic device, characterized in that it includes: a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the computer program, it implements the network fault troubleshooting method applied to a programmable switch as described above.
[0031] The beneficial effects of the present invention are as follows: the present invention uses the programmability of programmable switches to record and forward table information on the data plane, providing network engineers with more information when troubleshooting network faults, thereby improving troubleshooting efficiency. The present invention takes into account the hardware limitations of programmable switches, uses information entropy as a criterion for judging a table information recording scheme, and records as much information as possible. The information entropy calculation method proposed in the present invention can accurately and efficiently calculate the information entropy of a table information recording scheme. The branch and bound method and greedy algorithm of the present invention can efficiently calculate the (approximate) optimal table information recording scheme for a P4 program. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 Schematic diagram of the probability conversion DAG of the present invention.
[0033] Figure 2 This is the divided subgraph of the present invention.
[0034] Figure 3 Schematic diagram of information entropy calculation of the present invention.
[0035] Figure 4 Schematic diagram of the branch and bound method of the present invention.
[0036] Figure 5 Schematic diagram of the greedy algorithm of the present invention.
[0037] Figure 6 A schematic diagram of a code snippet for recording table information of the present invention. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0039] In one embodiment, the present invention provides a network fault troubleshooting method applied to a programmable switch, comprising the following steps:
[0040] Step 1: Collect network packets passing through the switch and generate a probability transition DAG (Directed Acyclic Graph) based on the program running on the programmable switch.
[0041] In step 1, the P4 program execution logic running on the programmable switch is converted into a DAG. The nodes in the DAG are the tables in the P4 program, and the edges in the DAG are the logical jump relationships in the P4 program. The collected network packets are then replayed on the switch, and the frequency of these packets passing through each table is counted. The table frequencies are then approximated as probabilities in the probabilistic transformation DAG, generating a probabilistic transformation DAG.
[0042] Step 2: Based on the PHV resources, probability conversion DAG, and P4 program, calculate and generate a set of table information recording schemes so that the information entropy obtained by the scheme is maximized. This scheme is the optimal table information recording scheme.
[0043] In step 2, a strategy, such as a branch-and-bound or greedy algorithm, is employed to generate an optimal or near-optimal table information recording scheme, using maximum information entropy as the criterion. Both branch-and-bound and greedy algorithms follow these steps: generating a set of candidate table information recording schemes, calculating the information entropy of each scheme, and then passing it to the SMT solver to determine whether the scheme meets the constraints. The algorithm ultimately outputs an optimal or near-optimal table information recording scheme.
[0044] Step 3: Modify the P4 program code on the programmable switch based on the generated optimal path solution, recompile, and run it. This will forward the data plane table information to a specific port for subsequent troubleshooting.
[0045] In step 3, several variables are initialized to record table information in the data plane. These variables consume PHV resources. According to the allocation plan, variable assignment statements are injected into the corresponding table behaviors. An assignment statement sets a bit in the table variable to 1, thus recording whether the table or behavior is executed. Mirroring code is then added to the P4 code to forward the table information to a specific egress port.
[0046] Figure 1 This is the probabilistic conversion DAG of the present invention. This DAG represents a simple P4 program, with nodes representing code snippets within the program. Square nodes represent conditional branch statements, which are not recordable, while circular nodes represent tables, which are recordable. Directed edges represent node jump relationships. Node start represents the starting node, indicating where the program begins. Nodes cond1 and cond2 represent two conditional branch statements. When the program reaches cond1, it may either execute the statement represented by node tb11 or directly enter the statement represented by cond2. The probability p attached to the edge in the graph represents the probability that a network packet will transfer to the next node after reaching this node. For example, cond1 will transfer to node tb11 with probability p2 and to node cond2 with probability p3. These probabilities p follow basic laws of probability, such as p1 = p2 + p3, p2 = p4, and so on.
[0047] Figure 2 This is the subgraph of the present invention. The present invention divides the DAG represented by the entire P4 program into several subgraphs based on the cut points. Cut points are originally a concept in undirected graphs. If the graph is no longer connected after deleting a node, it is called a cut point. The present invention extends the concept of cut points to directed graphs. The generalization method is to regard the directed graph as an undirected graph. If the point is a cut point in this undirected graph, then it is also a cut point in the original directed graph. For example Figure 2 The generalized undirected graph is connected, meaning there is a path between any two points. If cond2 is removed, X1 and X2 will no longer be able to access Y1 and Y2, so cond2 is a cut point in the graph. The cond2 node can partition the entire DAG into two disjoint subgraphs.
[0048] Figure 3 Schematic diagram of information entropy calculation of the present invention. Figure 3 On the left is a picture similar to Figure 1The gray nodes in the probability transition DAG, namely Table B and Table C, represent the tables where information is recorded, so the graph also represents the set of candidate tables that record Table B and Table C in the P4 program represented by the DAG. Figure 3 The right half of the diagram shows the process of calculating the information entropy of the solution. Starting from the starting node A, a depth-first search is performed on the graph, maintaining the probability of the current path occurring during the search. The search results of the depth-first search are displayed under "Search Path" in the figure. The program will search for four paths, AXBDE, AXYCDE, AXYDE, and AE, with probabilities of 0.2, 0.5, 0.2, and 0.1, respectively. Because only messages in Tables B and C are recorded, extracting Tables B and C from these paths yields four path-probability pairs: (B, 0.2), (C, 0.5), (empty set, 0.2), and (empty set, 0.1). These are added to the path set, and paths with the same probability are merged during the addition process. That is, (empty set, 0.2) and (empty set, 0.1) are merged into (empty set, 0.3). Finally, traverse the path set and add the information entropy of all paths, that is, -0.2*log20.2+(-0.5*log20.5)+(-0.3*log20.3).
[0049] Figure 4 This is a schematic diagram of the branch and bound method of the present invention. Figure 3 The branch-and-bound algorithm is demonstrated using the probability transformation DAG in Figure 1 as an example. In this example, we assume that the PHV resource is a single 2-bit PHV, meaning that there are at most two tables in the recording scheme. This PHV is named PHV1. First, we calculate the information entropy of each table. In the figure, there are five tables, A, B, C, D, and E, with entropies of 0, 0.72, 1, 0.47, and 0, respectively. We sort these tables in descending order, obtaining the order C, B, D, A, and E.
[0050] Figure 4The lower half of the figure is the search tree for the branch-and-bound method. The Start node represents the starting point of the search. The maximum entropy obtained at this time is 0. First, consider whether to record the information of Table C. If the record is chosen, the search node 1 is reached, and a candidate table set {C} is generated. The SMT solver determines whether the solution meets the restrictions and calculates the information entropy of the solution. In this embodiment, the set meets the restrictions. The solver returns a candidate recording solution: "Use PHV1's 1-bit record table set {C}". The information entropy of this table set is calculated to be 1. The maximum entropy is then updated to 1, and the upper bound of the information entropy that can be obtained in the future is estimated. The calculation method is: select the one with the largest information entropy from the remaining tables, that is, Table B, with an entropy of 0.72. Because the PHV resource only supports recording information of two tables, and Table C has already been recorded, the upper bound of the information entropy that can be obtained in the future for this search branch is 1.72. This upper bound is greater than the current maximum value, so this search branch continues to search forward.
[0051] Next, the search considers whether to record the information in Table B. If so, the search proceeds to search node 2, generating a candidate recording solution {C, B} with an entropy of 1.48. The SMT solver determines that this meets the constraints and returns a candidate recording solution: "Use PHV1's two-bit recording table set {C, B}." This updates the maximum entropy to 1.48. Because two tables have already been recorded, the PHV resources are exhausted, the search is complete, and the search returns. If Table B is not recorded, the search proceeds to search node 3, generating a candidate table set {C} with an entropy of 1. The SMT solver determines that this meets the constraints, but this value is less than the current maximum entropy, so the maximum entropy is not updated. The upper bound of the entropy for this branch is then estimated, calculated to be 1 + 0.47. This upper bound is less than the current maximum entropy of 1.48, so this search branch is pruned and the search is discontinued.
[0052] If table C is not recorded, the search proceeds to node 4, generating the candidate table set {}, whose information entropy is 0. The SMT solver determines that this meets the constraints. Since its entropy is less than the current maximum entropy, the maximum entropy value is not updated. The estimated upper bound of the information entropy for this branch is 0.72 + 0.47, which is less than the existing maximum entropy of 1.48. Therefore, this search branch is pruned and no further search is performed. The search is now complete, and the optimal solution, "using PHV1's two-bit recording table set {C, B}," is returned.
[0053] Figure 5 This is a schematic diagram of the greedy algorithm of the present invention. Figure 3The branch-and-bound algorithm is demonstrated using the probability transformation DAG in [1]. In this example, the PHV resource is assumed to be a single 2-bit PHV, meaning that the recording scheme has a maximum of two tables. This PHV is named PHV1. The Start node represents the starting point of the algorithm. In the first round of calculation, all currently available tables (A, B, C, D, and E) are traversed. Each time a table is recorded, a corresponding candidate table set ({A}, {B}, {C}, {D}, and {E}) is generated. The information entropy of each set is then calculated and its compliance with the constraints is determined. In the first round of calculation, all these table sets meet the constraints. The candidate recording scheme corresponding to the table set {C} with the highest information entropy is selected: "Use the 1-bit recording table set {C} from PHV1." Based on this, the second round of calculation is performed. At this point, the remaining available tables are A, B, D, and E. These tables are traversed, each time a table is recorded, a corresponding candidate table set ({C, A}, {C, B}, {C, D}, and {C, E}) is generated. The information entropy of each set is then calculated and its compliance with the constraints is determined. Finally, among the tables that meet the constraints in the second round of calculations, namely {C, A}, {C, B}, and {C, E}, the candidate recording solution corresponding to the table set {C, B} with the highest information entropy is selected: "Use the two-bit recording table set {C, B} from PHV1." At this point, the PHV resources are exhausted, the algorithm ends, and the approximate optimal solution {C, B} is returned.
[0054] Figure 6 This is a code snippet for recording table information of the present invention. This code snippet contains a conditional statement if(cond) and a table tbl. The code logic is that if the result corresponding to cond is true, the content in the table tbl will be executed. The tbl table will match the a field in PHV and then execute the action tbl_action. The code marked in red in this snippet is specifically used to record information. The path variable represents the information of table execution, and its specific bit is assigned to 1 in the action code of tbl. In this way, when the network packet enters the switch and executes the table, the specific bit of the path variable will become 1. If the table is not executed, the bit of the path will still be 0. After the path information is transmitted through the mirroring function, the network engineer can determine whether the tbl table is executed based on the value of the path. This example describes how to record the information of a table, which can be easily extended to the case of multiple tables, that is, using different bits of one or more variables to represent the execution status of different tables.
[0055] In another embodiment, the present invention provides a computer-readable storage medium storing a computer program, wherein the computer program enables a computer to execute the network fault troubleshooting method applied to a programmable switch as described in the first embodiment.
[0056] In another embodiment, the present invention proposes an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the network troubleshooting method applied to a programmable switch as described in the first embodiment is implemented.
[0057] In the embodiments disclosed herein, computer storage media can be tangible media that can contain or store programs for use by or in conjunction with an instruction execution system, device, or apparatus. Computer storage media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or equipment, or any suitable combination of the foregoing. More specific examples of computer storage media can include electrical connections based on one or more lines, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROMs), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.
[0058] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed in this application can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0059] The above are merely preferred embodiments of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions based on the principles of the present invention are within the scope of protection of the present invention. It should be noted that for those skilled in the art, various improvements and modifications that do not depart from the principles of the present invention should be considered within the scope of protection of the present invention.
Claims
1. A network troubleshooting method applied to a programmable switch, characterized in that: The steps include: Step 1: Collect network packets passing through the programmable switch and generate a probability transformation DAG based on the programs running on the programmable switch. The specific method for generating the probability transformation DAG is as follows: convert the P4 program logic executed on the programmable switch into a DAG, where the nodes in the DAG are tables in the P4 program and the edges in the DAG are logical jump relationships in the P4 program. Replay the collected network packets on the programmable switch and count the frequency of these network packets passing through each table. Approximate the table frequencies as probabilities in the probability transformation DAG to generate the probability transformation DAG. Step 2: Based on the PHV resources, probability conversion DAG, and P4 program, calculate and generate a set of table information recording schemes so that the information entropy obtained by the table information recording scheme is maximized, and use it as the optimal table information recording scheme; Step 3: Based on the generated optimal table information recording scheme, modify the P4 program code on the programmable switch, recompile and run it, and forward the table information of the data plane to a specific egress port for subsequent troubleshooting.
2. A network fault troubleshooting method applied to a programmable switch according to claim 1, characterized in that: In step 2, the optimal table information recording scheme is calculated using the branch and bound method as follows: Sort all tables in the P4 program from largest to smallest according to information entropy, run a depth-first search algorithm, and traverse these tables in turn. For each table, there are two options: record the table or not record the table, corresponding to two sets of candidate tables. After selecting a table, the information entropy of the candidate table set is calculated, and the SMT solver is used to determine whether the candidate table set meets the switch hardware constraints: If the candidate table set meets the hardware constraints, the SMT solver returns a set of legal candidate recording schemes and compares their information entropy with the currently available optimal table information recording scheme. If the information entropy of this candidate recording scheme is greater, the optimal table information recording scheme is updated to this candidate recording scheme, and the upper bound of the information entropy that the current search branch can achieve in the future is estimated. If the candidate table set does not meet the hardware constraints, or the upper bound of the information entropy is lower than the information entropy of the currently available optimal table information recording scheme, the current search branch is cut off and the search is stopped. Otherwise, the search continues until the PHV resources are exhausted and the search is completed.
3. A network fault troubleshooting method applied to a programmable switch according to claim 2, characterized in that: The estimated upper bound of the information entropy that can be obtained in the future by the current search branch is specifically as follows: the number N of tables that can record information is derived based on the remaining PHV resources, and the largest N information entropies in the remaining tables are summed to obtain the upper bound of the information entropy of the search branch.
4. The network troubleshooting method for a programmable switch according to claim 1, wherein: In step 2, the greedy algorithm is used to calculate the optimal table information recording scheme as follows: in each round of calculation, all unrecorded tables in the P4 program are traversed in sequence, recorded and formed into a new candidate table set, the information entropy of the candidate table set is calculated, and the SMT solver is used to determine whether the candidate table set meets the switch hardware restrictions; if the candidate table set meets the hardware restrictions, the SMT solver will return a set of legal candidate recording schemes; the candidate recording scheme with the largest information entropy and meeting the switch hardware restrictions is selected from the current round of calculation and used as the initial value for the next round of calculation. This calculation process is repeated until the PHV resources are exhausted or no candidate recording scheme meeting the hardware restrictions can be found, and the candidate recording scheme with the largest information entropy in the last round of calculation is returned as the optimal table information recording scheme.
5. A network fault troubleshooting method applied to a programmable switch according to claim 2 or 4, characterized in that: The information entropy of the candidate table set is calculated as follows: First, the probability transformation DAG represented by the P4 program is divided into multiple subgraphs based on the cut points. The sum of the information entropy of the multiple subgraphs is equal to the information entropy of the entire graph. Calculate the information entropy of the candidate table set on each subgraph: Start from the starting point of the subgraph and perform a depth-first search. During the search, maintain the probability of the current search path. When the end point of the subgraph is found, add the tables recorded in the path and the probability of the path to the path set. When the entire subgraph is searched, traverse the path set, extract each path and its corresponding probability p, and add -plog2p to the information entropy of the subgraph. The information entropy obtained after the calculation is the information entropy of the candidate table set on the subgraph. The information entropy of the candidate table set on each subgraph is summed up, and the obtained information entropy is the information entropy of the candidate table set.
6. A network fault troubleshooting method applied to a programmable switch according to claim 2 or 4, characterized in that: The use of the SMT solver to determine whether the candidate table set meets the switch hardware constraints is specifically as follows: assigning a number of PHV i ,stage i Variable, PHV i The value of represents the PHV number used in recording table i, stage i Represents the stage number where table i is placed; analyze the initial P4 program, extract the program dependencies, and load them into the SMT solver; consider the new constraints brought by the candidate table set, including that the bit width used by the PHV must be less than or equal to the available width, and that tables using the same PHV record cannot be placed in the same stage; use the SMT solver to solve the problem. If the problem has no solution, return "no solution"; if the problem has a solution, return a set of legal candidate record solutions.
7. The network troubleshooting method for a programmable switch according to claim 1, wherein: In step 3, based on the generated optimal table information recording scheme, the P4 program code on the programmable switch is modified as follows: several variables are initialized to record the table information of the data plane, and the variables consume PHV resources; based on the optimal table information recording scheme, variable assignment statements are injected into the behavior of the corresponding table. The assignment statement sets the bit of the table in the variable to 1, thereby recording whether the behavior of the table is executed; and code for implementing the mirroring function is added to the P4 program code to forward the table information to a specific output port.
8. A computer-readable storage medium storing a computer program, characterized in that: The computer program enables a computer to execute the network fault troubleshooting method applied to a programmable switch according to any one of claims 1 to 4.
9. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the network fault troubleshooting method for a programmable switch according to any one of claims 1 to 4 is implemented.