Large and small tree algorithm for enabling newly-added flow table rules to take effect quickly in massive flow tables

By splitting large rule trees and small rule trees in massive flow tables, dynamically adjusting rules to add positions and matching patterns, the problem of too long taking effect in massive flow tables is solved, and rapid effectiveness and low performance when the number of rules is large is achieved Cost-efficient rule management.

CN119071225AActive Publication Date: 2024-12-03QINGCHUANG WANGYU (HEFEI) TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411277599.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-12
Publication Date
2024-12-03
Estimated Expiration
2044-09-12

AI Technical Summary

Technical Problem

In massive flow tables, when the number of rules is much larger than the equipment flow table space capacity, the new flow table rules take effect for too long, resulting in network administrators needing to limit the flow table space capacity to reduce the number of rules, increase personnel investment costs and are invalid.

Method used

Using the size and tree algorithm, the rule tree is split into a large rule tree that does not care about the compilation time of the tree but has a large rule capacity and a small rule tree that focuses on the compilation time of the tree but has a limited rule capacity, and dynamically adjust the rules to add location and Network traffic packet matching mode ensures that the rules in the two rule trees take effect at the same time.

Benefits of technology

When the number of rules is much larger than the capacity of the device flow table space, the high-performance tree search algorithm will speed up the entry rate of rules, reduce the investment cost of network equipment, avoid the risk of building construction exceeding the maximum tolerance time of the rules, improve work efficiency, and ensure the entry time of rules Faster.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119071225A_ABST
    Figure CN119071225A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of rule trees, and particularly discloses a big and small tree algorithm for enabling a newly-added flow table rule to quickly take effect in a mass flow table, and the algorithm comprises the following steps: S1, rule addition: determining whether the tree rebuilding time exceeds the rule effective maximum tolerance time or not according to the upper limit value of a rule entry of a big and small rule tree, the method comprises the following steps of: dividing an original single rule tree into a large rule tree which does not concern tree-building compiling time but has an ultra-large rule capacity and a small rule tree which focuses on tree-building compiling time but has a limited rule capacity, and dynamically adjusting a rule adding position; and adjusting a network flow message rule matching mode to perform serial matching on the two rule trees to ensure that the rules in the two rule trees can be simultaneously effective, thereby ensuring that when the number of the rules is far greater than the space capacity of the equipment flow table, the efficiency of the equipment flow table is greatly improved by using a high-performance tree search algorithm. The problem that the effective time of newly added rules is too long due to massive flow table rules is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of rule trees, and in particular to a large and small tree algorithm for enabling newly added flow table rules to take effect quickly in a massive flow table. Background Art

[0002] Current network devices use multi-group rule flow table functions for network access control. In order to ensure high-performance packet processing capabilities, they mainly use dictionary trees or other tree algorithms to implement flow table rule searches. Tree algorithms have a very high search speed when matching rules.

[0003] When the number of rules in a rule tree is small, the tree-based algorithm takes a short time to recompile and build, allowing the rules to take effect without the network administrator noticing. However, when the number of rules in a rule tree exceeds several million or tens of millions, the time required to build the rule tree based on the current CPU hardware main frequency speed will allow the administrator to clearly notice that the newly added rules are taking a long time to take effect. The more rules there are, the longer it will take for the new rules to take effect. Therefore, when faced with massive flow tables, the flow table space capacity is usually limited, forcing network administrators to merge address segments of similar network segments to compress the number of flow table rules and reduce the time it takes for the rules to take effect.

[0004] However, the method of limiting the capacity of the flow table space and forcing network administrators to merge similar address segments and compress the number of flow table rules is only a temporary solution and does not address the root cause. It will not only increase the cost of personnel investment, but also become ineffective in scenarios where the number of rules is far greater than the capacity of the device flow table space. Summary of the invention

[0005] The purpose of the present invention is to provide a large and small tree algorithm that allows newly added flow table rules to take effect quickly in massive flow tables, and solve the following technical problems:

[0006] How to reduce the rule effectiveness time when the number of rules is much larger than the device flow table space capacity.

[0007] The purpose of the present invention can be achieved through the following technical solutions:

[0008] A large-small tree algorithm for quickly taking effect on newly added flow table rules in a massive flow table, the algorithm comprising:

[0009] S1: Add rules. According to the upper limit of the rule entries in the rule tree, determine whether the time for rebuilding the tree exceeds the maximum tolerance time for the rule to take effect, and decide to which rule tree the rule will be added.

[0010] S2: rule merging, the timer loop checks the current number of rule entries in the small rule tree, and automatically merges the rule entries in the small rule tree into the large rule tree when the current number of rule entries in the small rule tree exceeds the lower limit of rule merging;

[0011] S3: rule matching, based on the fields in the input network traffic message, serial search is performed in the large and small rule trees through the tree search algorithm, so that all the rules in the large and small rule trees are in effect.

[0012] Furthermore, the process of adding rules in S1 includes:

[0013] S11: Create two rule trees with different capacities, a large tree and a small tree. The capacity of the small rule tree is set to a value that the tree building time required when the rules are fully configured is less than or equal to the maximum tolerance time for the large tree rules to take effect. The capacity of the large rule tree is the maximum capacity that the corresponding hardware can carry.

[0014] S12: Set the large rule tree to directly add the upper limit value, that is, after exceeding the upper limit value, the tree building time will be greater than the maximum tolerance time for the rule to take effect;

[0015] S13: Setting the upper limit and lower limit of rule merging of the small rule tree, wherein the upper limit of rule merging indicates that rule merging needs to be performed immediately after exceeding the upper limit, and the lower limit of rule merging indicates that rule merging will not be performed if the lower limit is lower than the lower limit;

[0016] S14: After receiving the newly added flow table rule, parse out the five-element field required by the rule tree algorithm, and search for the newly added rule entry in the large and small rule trees according to the tree type search algorithm. If there are duplicate rules, return to add the rule duplication and the rule addition is completed. Otherwise, proceed to step S15;

[0017] S15: When there are no duplicate rules, determine whether the number of current rule entries in the large rule tree exceeds the upper limit of direct addition.

[0018] Furthermore, the judgment process in S15 includes:

[0019] By formula Calculate and obtain the capacity occupancy value δ of all current rule entries;

[0020] Among them, i is any rule entry, n is the total number of rule entries in the current large rule tree, dx i is the packet size of the ith rule entry, dx b dx i The standard value of jm i is the encryption level of the i-th rule entry, jm y is the default encryption level, ds i is the impact coefficient of packet loss of the ith rule entry, which is set according to empirical fitting; Sl is the number of nodes in the current large rule tree; μ is the impact coefficient of rule complexity, which is set according to empirical fitting.

[0021] Furthermore, the determination process in S15 further includes:

[0022] By comparing the capacity occupancy value δ of all current rule entries with the preset capacity occupancy value δ x Perform a comparison and compare the current total number of rule entries with the upper limit value added directly;

[0023] If the current total number of rule entries is greater than the upper limit of direct addition, the new rules will be added directly to the small rule tree configuration;

[0024] If the current total number of rule entries is less than the upper limit of adding directly, and δ≥δ x , determine that the capacity occupancy value of all current rule entries is high, and add the new rules directly to the small rule tree configuration;

[0025] If the current total number of rule entries is less than the upper limit of adding directly, and δ<δ x , determine that the capacity occupancy value of all current rule entries is low, and add the new rules to the large rule tree configuration.

[0026] Furthermore, the determination process in S15 further includes:

[0027] S151: When the number of current rule entries in the big rule tree does not exceed the upper limit of direct addition, and the capacity occupancy value of all current rule entries is less than the preset capacity occupancy value, the newly added rule is directly added to the big rule tree configuration, the big rule tree counter is updated, and the big rule tree is recompiled to make the newly added rule take effect, and the rule addition is completed;

[0028] S152: When the number of current rule entries in the large rule tree exceeds the upper limit of direct addition, or does not exceed the upper limit of direct addition but the capacity occupancy value of all rule entries is greater than the preset capacity occupancy value, the newly added rule is added to the small rule tree configuration, the small rule tree counter is updated, and the small rule tree is recompiled to make the newly added rule effective;

[0029] S153: Determine whether the number of rule entries in the small rule tree exceeds the upper limit of rule merging. If so, trigger the rule merging process and complete the rule adding. If not, directly complete the rule adding.

[0030] Furthermore, the process of merging rules in S2 includes:

[0031] S21: Create a rule merging timer and check whether the number of current rule entries in the small rule tree exceeds the rule merging lower limit. If not, perform a loop judgment. Otherwise, proceed to step S22.

[0032] S22: merge all current rule entries of the small tree into the rule configuration of the large rule tree to form a new large rule tree configuration;

[0033] S23: Create a big rule tree running copy according to the new big rule tree configuration;

[0034] S24: After the big rule tree running copy is compiled, the big rule tree running original in the original rule matching process is replaced with the big rule tree running copy, so that the big rule tree running copy becomes the running original, and the running original and copy replacement is completed;

[0035] S25: Delete the replaced large rule tree copy, release memory space, and complete the rule merging.

[0036] Furthermore, the rule matching process in S3 includes:

[0037] S31: Parse the input network traffic message, and parse out the five-element field required by the rule tree search algorithm from the traffic message;

[0038] S32: searching the field by the tree algorithm parsed from the traffic message, and matching the rules in the large rule tree by using the tree search algorithm to determine whether the rule is matched. If yes, proceed to step S33; otherwise, proceed to step S34.

[0039] S33, processing the traffic message according to the behavior field corresponding to the rule;

[0040] S34: Searching for small tree rules, searching fields by tree algorithm parsed from traffic packets, and matching rules in small rule trees using tree search algorithms to determine whether the rules match. If yes, proceed to step S35, otherwise, proceed to step S36;

[0041] S35: Process the traffic message according to the behavior field corresponding to the rule;

[0042] S36: Process the traffic message according to the system default rule behavior field.

[0043] Furthermore, the tree algorithm search fields include source address, destination address, protocol number, source port number, and destination port number, and the tree algorithm search fields of large and small rule trees are different.

[0044] Beneficial effects of the present invention:

[0045] (1) The present invention splits the original single rule tree into a large rule tree that does not care about the tree compilation time but has a very large rule capacity, and a small rule tree that focuses on the tree compilation time but has a limited rule capacity. The present invention dynamically adjusts the position where the rules are added and adjusts the network traffic message rule matching mode to perform series matching on the two rule trees to ensure that the rules in the two rule trees are valid at the same time. This ensures that when the number of rules is much larger than the device flow table space capacity, the problem of the long effective time of the newly added rules affected by the massive flow table rules is solved by using a high-performance tree search algorithm.

[0046] (2) The present invention can effectively reduce the investment cost of network equipment in high-performance, massive flow table rule scenarios by splitting the original single rule tree into a large rule tree that does not care about the tree building compilation time but has a very large rule capacity, and a small rule tree that focuses on the tree building compilation time but has a limited rule capacity. In addition, by setting the upper limit value and the lower limit value of the rule merging of the small rule tree, it can not only avoid the risk of the tree building time being greater than the maximum tolerable time for the rule to take effect, but also reduce the resource occupation caused by the frequent tree building of the large rule tree, thereby improving work efficiency.

[0047] (3) The present invention compares the capacity occupancy value δ of all current rule entries with the preset upper limit value δ x A comparison is performed, and the current total number of rule entries is compared with the upper limit of direct addition. By combining two groups of data of different categories for analysis, an accurate judgment can be made on whether the current number of rule entries exceeds the upper limit of direct addition, and a decision is made based on the judgment result on which group of rule trees the subsequent newly added rule entries will be added to, thereby ensuring that the effective time of the subsequent newly added rule entries will not be greatly affected, and achieving the effect of accelerating the effectiveness of the rules when the number of rules is far greater than the capacity of the device flow table space.

[0048] (4) The present invention combines two groups of different types of data for analysis, and can make an accurate judgment on whether the current number of rule entries exceeds the upper limit of direct addition. Through such a setting, when the rule tree compilation time in the network device is at risk of exceeding the maximum tolerable time for the rule to take effect, by judging whether the current number of rule entries in the large rule tree exceeds the upper limit of direct addition, it can be judged whether the effectiveness speed of the current large rule tree is normal. When it is judged that the effectiveness speed of the current large rule tree is slow, each subsequent newly added rule falls into the small rule tree, so that the newly added rule can take effect quickly, solving the problem that when using a high-performance tree search algorithm, the massive flow table rules affect the effectiveness time of the newly added rules.

[0049] (5) The present invention merges all current rule entries of the small rule tree into the rule configuration of the large rule tree when it is determined that the number of current rule entries of the small rule tree exceeds the lower limit of rule merging, and replaces the original running copy of the large rule tree in the original rule matching process with the running copy of the large rule tree, and finally deletes the replaced copy of the large rule tree. Through such a setting, it can be ensured that the small rule tree will not have the problem of rule overflow affecting the effective time of the newly added rules, thereby ensuring that when the number of rules is much larger than the capacity of the device flow table space, the time for the rules to take effect can still be kept at a faster state. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] The present invention will be further described below in conjunction with the accompanying drawings.

[0051] Figure 1 It is a flowchart of a large and small tree algorithm in a massive flow table in the present invention that allows newly added flow table rules to take effect quickly;

[0052] Figure 2 is a conceptual diagram of the rule adding process in the present invention;

[0053] Figure 3 is a flow chart of the process of adding rules in the present invention;

[0054] Figure 4 is a flow chart of the judgment process in S15 of the present invention;

[0055] Figure 5 is a conceptual diagram of the rule merging process in the present invention;

[0056] Figure 6 is a flow chart of the process of rule merging in the present invention;

[0057] Figure 7 is a conceptual diagram of the rule matching process in the present invention;

[0058] Figure 8 It is a flow chart of the rule matching process in the present invention. DETAILED DESCRIPTION

[0059] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0060] See also Figure 1 - Figure 8 As shown, in one embodiment, the present application provides a large and small tree algorithm for quickly taking effect on newly added flow table rules in a massive flow table, and the algorithm includes:

[0061] S1: Add rules. According to the upper limit of the rule entries in the rule tree, determine whether the time for rebuilding the tree exceeds the maximum tolerance time for the rule to take effect, and decide to which rule tree the rule will be added.

[0062] S2: rule merging, the timer loop checks the current number of rule entries in the small rule tree, and automatically merges the rule entries in the small rule tree into the large rule tree when the current number of rule entries in the small rule tree exceeds the lower limit of rule merging;

[0063] S3: rule matching, based on the fields in the input network traffic message, serially search in the large and small rule trees through the tree search algorithm, so that all the rules in the large and small rule trees are in effect;

[0064] Through the above technical solution, when this embodiment is used, firstly, according to the upper limit value of the rule entries in the large and small rule trees, it is confirmed whether the tree reconstruction time exceeds the maximum tolerance time for the rule to take effect, and it is decided to which rule tree the rule is added to, so as to ensure that the tree reconstruction time required for the newly added rule is less than the maximum tolerance time for the rule to take effect, and then the current number of rule entries in the small rule tree is checked through a timer loop, and when the current number of rule entries in the small rule tree exceeds the lower limit value of the rule merger, the rule entries in the small rule tree are automatically merged into the large rule tree, so as to ensure that the small rule tree will not have rule overflows that affect the effective time of the newly added rules, and finally, according to the fields in the input network traffic message, the large and small rule trees are serially searched through the tree class search algorithm, so that the rules in the large and small rule trees are all in effect;

[0065] Through such settings, it can split the original single rule tree into a large rule tree that does not care about the tree compilation time but has a large rule capacity, and a small rule tree that focuses on the tree compilation time but has a limited rule capacity. It can also dynamically adjust the position where the rules are added, and adjust the network traffic message rule matching mode to match the two rule trees in series to ensure that the rules in the two rule trees are valid at the same time. This ensures that when the number of rules is much larger than the device flow table space capacity, the problem of the long time it takes for new rules to take effect due to the large number of flow table rules can be solved by using a high-performance tree search algorithm.

[0066] See also Figure 2 and Figure 3 As shown, the process of adding rules in S1 includes:

[0067] S11: Create two rule trees with different capacities, a large tree and a small tree. The capacity of the small rule tree is set to a value that the tree building time required when the rules are fully configured is less than or equal to the maximum tolerance time for the large tree rules to take effect. The capacity of the large rule tree is the maximum capacity that the corresponding hardware can carry.

[0068] S12: Set the large rule tree to directly add the upper limit value, that is, after exceeding the upper limit value, the tree building time will be greater than the maximum tolerance time for the rule to take effect;

[0069] S13: Setting the upper limit and lower limit of rule merging of the small rule tree, wherein the upper limit of rule merging indicates that rule merging needs to be performed immediately after exceeding the upper limit, and the lower limit of rule merging indicates that rule merging will not be performed if the lower limit is lower than the lower limit;

[0070] S14: After receiving the newly added flow table rule, parse out the five-element field required by the rule tree algorithm, and search for the newly added rule entry in the large and small rule trees according to the tree type search algorithm. If there are duplicate rules, return to add the rule duplication and the rule addition is completed. Otherwise, proceed to step S15;

[0071] S15: When there are no duplicate rules, determine whether the number of current rule entries in the large rule tree exceeds the upper limit of direct addition;

[0072] Through the above technical solution, this embodiment provides a process of adding rules. First, two rule trees with different capacities, a large tree and a small tree, are created. The capacity of the small rule tree is set to a tree building time less than or equal to the maximum tolerance time for the large tree rules to take effect when the rules are fully configured. The capacity of the large rule tree is the maximum capacity that the corresponding hardware can carry. Then, the upper limit value of the direct addition of the large rule tree is set, that is, the tree building time will be greater than the maximum tolerance time for the rules to take effect after exceeding the upper limit value.

[0073] Then, the upper limit and lower limit of rule merging of small rule trees are set. The upper limit of rule merging indicates that rule merging needs to be performed immediately after exceeding the upper limit, otherwise there is a risk that the tree building time will be greater than the maximum tolerance time for the rule to take effect. The lower limit of rule merging indicates that rule merging will not be performed if it is lower than the lower limit, thereby reducing the resource occupation caused by frequent tree building of large rule trees. Finally, after receiving the newly added flow table rules, the five-element field required by the rule tree algorithm is parsed, and the newly added rule entries are searched in the large and small rule trees according to the tree type search algorithm. If there are duplicate rules, the rule duplication is added and the rule addition is completed. If there are no duplicate rules, it is determined whether the current number of rule entries in the large rule tree exceeds the upper limit of direct addition.

[0074] Through such settings, by splitting the original single rule tree into a large rule tree that does not care about the compilation time of the tree building but has a very large rule capacity, and a small rule tree that focuses on the compilation time of the tree building but has a limited rule capacity, the investment cost of network equipment in high-performance, massive flow table rule scenarios can be effectively reduced. In addition, by setting the upper limit and lower limit of rule merging of small rule trees, not only can the risk of the tree building time being greater than the maximum tolerable time for the rule to take effect be avoided, but also the resource occupation caused by the frequent tree building of large rule trees can be reduced, thereby improving work efficiency.

[0075] The judgment process in S15 includes:

[0076] By formula Calculate and obtain the capacity occupancy value δ of all current rule entries;

[0077] Among them, i is any rule entry, n is the total number of rule entries in the current large rule tree, dx i is the packet size of the ith rule entry, dx b dx i The standard value of the above standard value can be selected and set according to the allowable error in the empirical data, jm i is the encryption level of the i-th rule entry, jm y is the default encryption level, ds iis the impact coefficient of packet loss of the ith rule entry, which is set according to empirical fitting; sl is the number of nodes in the current large rule tree; μ is the impact coefficient of rule complexity, which is set according to empirical fitting;

[0078] Through the above technical solution, this embodiment provides a capacity occupancy value δ of all current rule entries. Obviously, the higher the data packet size and encryption level of the i-th rule entry, and the fewer the number of nodes in the current large rule tree, the greater the capacity occupancy value of all current rule entries. Conversely, when the data packet size and encryption level of the i-th rule entry are lower, and the more the number of nodes in the current large rule tree is, the smaller the capacity occupancy value of all current rule entries is. Through this calculation method, the usage ratio of all rule entries in the current large rule tree can be reflected, thereby providing accurate data for subsequent judgment of whether the current number of rule entries in the large rule tree exceeds the upper limit of direct addition.

[0079] The judgment process in S15 further includes:

[0080] By comparing the capacity occupancy value δ of all current rule entries with the preset capacity occupancy value δ x Perform a comparison and compare the current total number of rule entries with the upper limit value added directly;

[0081] If the current total number of rule entries is greater than the upper limit of direct addition, the new rules will be added directly to the small rule tree configuration;

[0082] If the current total number of rule entries is less than the upper limit of adding directly, and δ≥δ x , determine that the capacity occupancy value of all current rule entries is high, and add the new rules directly to the small rule tree configuration;

[0083] If the current total number of rule entries is less than the upper limit of adding directly, and δ<δ x , determine that the capacity occupancy value of all current rule entries is low, and add the new rules to the large rule tree configuration;

[0084] Through the above technical solution, this embodiment compares the capacity occupancy value δ of all current rule entries with the preset upper limit value δ x Compare and compare the current total number of rule entries with the upper limit of direct addition. By combining two groups of data of different categories for analysis, it is possible to make an accurate judgment on whether the current number of rule entries exceeds the upper limit of direct addition, and decide which group of rule trees to add the subsequently added rule entries to based on the judgment result, thereby ensuring that the effective time of the subsequently added rule entries will not be greatly affected, and achieving the effect of accelerating the effectiveness of the rules when the number of rules is far greater than the capacity of the device flow table space;

[0085] It should be noted that the above preset capacity occupancy value δx The maximum capacity that can be carried by the corresponding hardware can be fitted and set based on the large rule tree.

[0086] See also Figure 2 and Figure 4 As shown, the judgment process in S15 also includes:

[0087] S151: When the number of current rule entries in the big rule tree does not exceed the upper limit of direct addition, and the capacity occupancy value of all current rule entries is less than the preset capacity occupancy value, the newly added rule is directly added to the big rule tree configuration, the big rule tree counter is updated, and the big rule tree is recompiled to make the newly added rule take effect, and the rule addition is completed;

[0088] S152: When the number of current rule entries in the large rule tree exceeds the upper limit of direct addition, or does not exceed the upper limit of direct addition but the capacity occupancy value of all rule entries is greater than the preset capacity occupancy value, the newly added rule is added to the small rule tree configuration, the small rule tree counter is updated, and the small rule tree is recompiled to make the newly added rule effective;

[0089] S153: Determine whether the number of rule entries in the small rule tree exceeds the upper limit of rule merging. If so, trigger the rule merging process and complete the rule adding. If not, directly complete the rule adding.

[0090] Through the above technical solution, by combining two groups of different categories of data for analysis, it is possible to make an accurate judgment on whether the current number of rule entries exceeds the upper limit of direct addition. By such a setting, when the rule tree compilation time in the network device is at risk of exceeding the maximum tolerance time for the rule to take effect, by judging whether the current number of rule entries in the large rule tree exceeds the upper limit of direct addition, it is possible to judge whether the effectiveness speed of the current large rule tree is normal, and when it is judged that the effectiveness speed of the current large rule tree is slow, each subsequent newly added rule will fall into the small rule tree, so that the newly added rule can take effect quickly, solving the problem of massive flow table rules affecting the effectiveness time of the newly added rules when using high-performance tree search algorithms.

[0091] See also Figure 5 and Figure 6 As shown, the process of rule merging in S2 includes:

[0092] S21: Create a rule merging timer and check whether the number of current rule entries in the small rule tree exceeds the rule merging lower limit. If not, perform a loop judgment. Otherwise, proceed to step S22.

[0093] S22: merge all current rule entries of the small tree into the rule configuration of the large rule tree to form a new large rule tree configuration;

[0094] S23: Create a big rule tree running copy according to the new big rule tree configuration;

[0095] S24: After the big rule tree running copy is compiled, the big rule tree running original in the original rule matching process is replaced with the big rule tree running copy, so that the big rule tree running copy becomes the running original, and the running original and copy replacement is completed;

[0096] S25: Delete the replaced large rule tree copy to release memory space, and the rule merging is completed;

[0097] Through the above technical solution, this embodiment creates a rule merging timer and checks whether the current number of rule entries in the small rule tree exceeds the rule merging lower limit. If not, a loop judgment is performed. If yes, all current rule entries in the small tree are merged into the rule configuration of the large rule tree to form a new large rule tree configuration, and a large rule tree running copy is created according to the new large rule tree configuration. After the compilation of the large rule tree running copy is completed, the large rule tree running original in the original rule matching process is replaced with the large rule tree running copy, so that the large rule tree running copy becomes the running original, and the running original copy is replaced. Finally, the replaced large rule tree copy is deleted to release memory space, and the rule merging is completed;

[0098] By merging all current rule entries of the small rule tree into the rule configuration of the large rule tree when it is determined that the number of current rule entries in the small rule tree exceeds the lower limit of rule merging, and replacing the original running copy of the large rule tree in the original rule matching process with the running copy of the large rule tree, and finally deleting the replaced copy of the large rule tree, such settings can ensure that the small rule tree will not have rule overflows that affect the effective time of new rules, thereby ensuring that when the number of rules is far greater than the capacity of the device flow table space, the time for the rules to take effect can still be faster.

[0099] See also Figure 7 and Figure 8 As shown, the rule matching process in S3 includes:

[0100] S31: Parse the input network traffic message, and parse out the five-element field required by the rule tree search algorithm from the traffic message;

[0101] S32: searching the field by the tree algorithm parsed from the traffic message, and matching the rules in the large rule tree by using the tree search algorithm to determine whether the rule is matched. If yes, proceed to step S33; otherwise, proceed to step S34.

[0102] S33, processing the traffic message according to the behavior field corresponding to the rule;

[0103] S34: Searching for small tree rules, searching fields by tree algorithm parsed from traffic packets, and matching rules in small rule trees using tree search algorithms to determine whether the rules match. If yes, proceed to step S35, otherwise, proceed to step S36;

[0104] S35: Process the traffic message according to the behavior field corresponding to the rule;

[0105] S36: Process the traffic message according to the system default rule behavior field;

[0106] Through the above technical solution, this embodiment first parses the input network traffic message, parses the five-element field required by the rule tree search algorithm from the traffic message, and then uses the tree algorithm search field parsed from the traffic message to match the rules in the large rule tree, and determines whether the rule is hit. If the rule is hit, the traffic message is processed according to the behavior field corresponding to the rule, otherwise, the small tree rule is searched, the tree algorithm search field parsed from the traffic message is used, and the tree search algorithm is used to match the rules in the small rule tree to determine whether the rule is hit. If the rule is hit, the traffic message is processed according to the behavior field corresponding to the rule, otherwise, the traffic message is processed according to the system default rule behavior field;

[0107] Through such settings, serial searches in the large and small rule trees are performed through the tree class search algorithm, so that the rules in the large and small rule trees are in effect, thereby ensuring that the large and small rule trees can be used normally, and then ensuring that in subsequent use, even if the number of rules is far greater than the device flow table space capacity, the speed at which the rules take effect can be guaranteed.

[0108] The tree algorithm search fields include source address, destination address, protocol number, source port number, and destination port number, and the tree algorithm search fields of large and small rule trees are different;

[0109] Through the above technical solution, when in use, by determining different tree algorithm search fields for size rule trees, these fields are defined in the header of the data packet, which can ensure that data can be correctly and efficiently transmitted from one node to another.

[0110] The above is a detailed description of an embodiment of the present invention, but the content is only a preferred embodiment of the present invention and cannot be considered to limit the scope of implementation of the present invention. All equivalent changes and improvements made within the scope of the present invention should still fall within the scope of the patent coverage of the present invention.

Claims

1. A large and small tree algorithm that allows newly added flow table rules to take effect quickly in massive flow tables, characterized in that: The algorithm includes: S1: Add rules. According to the upper limit of the rule entries in the rule tree, determine whether the time for rebuilding the tree exceeds the maximum tolerance time for the rule to take effect, and decide to which rule tree the rule will be added. S2: rule merging, the timer loop checks the current number of rule entries in the small rule tree, and automatically merges the rule entries in the small rule tree into the large rule tree when the current number of rule entries in the small rule tree exceeds the lower limit of rule merging; S3: rule matching, based on the fields in the input network traffic message, serial search is performed in the large and small rule trees through the tree search algorithm, so that all the rules in the large and small rule trees are in effect.

2. According to claim 1, a large and small tree algorithm for quickly taking effect on newly added flow table rules in a massive flow table is characterized in that: The process of adding rules in S1 includes: S11: Create two rule trees with different capacities, a large tree and a small tree. The capacity of the small rule tree is set to a value that the time required to build the tree when the rules are fully configured is less than or equal to the maximum tolerance time for the large tree rules to take effect. The capacity of the large rule tree is the maximum capacity that the corresponding hardware can carry. S12: Set the large rule tree to directly add the upper limit value, that is, after exceeding the upper limit value, the tree building time will be greater than the maximum tolerance time for the rule to take effect; S13: Setting the upper limit and lower limit of rule merging of the small rule tree, wherein the upper limit of rule merging indicates that rule merging needs to be performed immediately after exceeding the upper limit, and the lower limit of rule merging indicates that rule merging will not be performed if the lower limit is lower than the lower limit; S14: After receiving the newly added flow table rule, parse out the five-element field required by the rule tree algorithm, and search for the newly added rule entry in the large and small rule trees according to the tree type search algorithm. If there are duplicate rules, return to add the rule duplication and the rule addition is completed. Otherwise, proceed to step S15; S15: When there are no duplicate rules, determine whether the number of current rule entries in the large rule tree exceeds the upper limit of direct addition.

3. According to claim 2, a large and small tree algorithm for quickly taking effect on newly added flow table rules in a massive flow table is characterized in that: The judgment process in S15 includes: By formula Calculate and obtain the capacity occupancy value δ of all current rule entries; Among them, i is any rule entry, n is the total number of rule entries in the current large rule tree, dx i is the packet size of the ith rule entry, dx b dx i The standard value of jm i is the encryption level of the i-th rule entry, jm y is the default encryption level, ds i is the impact coefficient of packet loss of the ith rule entry, which is set according to empirical fitting; sl is the number of nodes in the current large rule tree; μ is the impact coefficient of rule complexity, which is set according to empirical fitting.

4. According to claim 3, a large and small tree algorithm for quickly taking effect on newly added flow table rules in a massive flow table is characterized in that: The judgment process in S15 further includes: By comparing the capacity occupancy value δ of all current rule entries with the preset capacity occupancy value δ x Perform a comparison and compare the current total number of rule entries with the upper limit value added directly; If the current total number of rule entries is greater than the upper limit of direct addition, the new rules will be added directly to the small rule tree configuration; If the current total number of rule entries is less than the upper limit of adding directly, and δ≥δ x , determine that the capacity occupancy value of all current rule entries is high, and add the new rules directly to the small rule tree configuration; If the current total number of rule entries is less than the upper limit of adding directly, and δ<δ x , determine that the capacity occupancy value of all current rule entries is low, and add the new rules to the large rule tree configuration.

5. According to claim 4, a large and small tree algorithm for quickly taking effect on newly added flow table rules in a massive flow table is characterized in that: The judgment process in S15 further includes: S151: When the number of current rule entries in the big rule tree does not exceed the upper limit of direct addition, and the capacity occupancy value of all current rule entries is less than the preset capacity occupancy value, the newly added rule is directly added to the big rule tree configuration, the big rule tree counter is updated, and the big rule tree is recompiled to make the newly added rule take effect, and the rule addition is completed; S152: When the number of current rule entries in the large rule tree exceeds the upper limit of direct addition, or does not exceed the upper limit of direct addition but the capacity occupancy value of all rule entries is greater than the preset capacity occupancy value, the newly added rule is added to the small rule tree configuration, the small rule tree counter is updated, and the small rule tree is recompiled to make the newly added rule effective; S153: Determine whether the number of rule entries in the small rule tree exceeds the upper limit of rule merging. If so, trigger the rule merging process and complete the rule adding. If not, directly complete the rule adding.

6. According to claim 5, a large and small tree algorithm for quickly taking effect on newly added flow table rules in a massive flow table is characterized in that: The process of rule merging in S2 includes: S21: Create a rule merging timer and check whether the number of current rule entries in the small rule tree exceeds the rule merging lower limit. If not, perform a loop judgment. Otherwise, proceed to step S22. S22: merge all current rule entries of the small tree into the rule configuration of the large rule tree to form a new large rule tree configuration; S23: Create a big rule tree running copy according to the new big rule tree configuration; S24: After the big rule tree running copy is compiled, the big rule tree running original in the original rule matching process is replaced with the big rule tree running copy, so that the big rule tree running copy becomes the running original, and the running original and copy replacement is completed; S25: Delete the replaced large rule tree copy, release memory space, and complete the rule merging.

7. According to claim 6, a large and small tree algorithm for quickly taking effect on newly added flow table rules in a massive flow table is characterized in that: The rule matching process in S3 includes: S31: Parse the input network traffic message, and parse out the five-element field required by the rule tree search algorithm from the traffic message; S32: searching the field by the tree algorithm parsed from the traffic message, and matching the rules in the large rule tree by using the tree search algorithm to determine whether the rule is matched. If yes, proceed to step S33; otherwise, proceed to step S34. S33, processing the traffic message according to the behavior field corresponding to the rule; S34: Searching for small tree rules, searching fields by tree algorithm parsed from traffic packets, and matching rules in small rule trees using tree search algorithms to determine whether the rules match. If yes, proceed to step S35, otherwise, proceed to step S36; S35: Process the traffic message according to the behavior field corresponding to the rule; S36: Process the traffic message according to the system default rule behavior field.

8. According to claim 7, a large and small tree algorithm for quickly taking effect on newly added flow table rules in a massive flow table is characterized in that: The tree algorithm search fields include source address, destination address, protocol number, source port number, and destination port number, and the tree algorithm search fields of large and small rule trees are different.

Citation Information

Patent Citations

  • Rule update method for three-folded content addressable memory message classification

    CN101035062A

  • Data packet classification method based on multiple decision trees

    CN113810311A

  • IP quintuple matching method and system under high-capacity rule

    CN117336240A

  • Data stream classifying method

    CN1494278A

  • Batch incremental update

    US20140279850A1