Method and device for adjusting decision tree for message classification
By providing decision tree adjustment methods based on the MbitCuts algorithm, dynamically adding and deleting rules in the decision tree, the problem of slow decision tree reconstruction process in the existing technology is solved, and the decision tree is quickly updated and the processing of network equipment is improved. Performance and user experience.
Patent Information
- Application Number
- CN202210458377.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-28
- Publication Date
- 2025-02-14
- Estimated Expiration
- 2042-04-28
AI Technical Summary
The existing MbitCuts algorithm cannot support the dynamic addition and removal of rules in the decision tree, resulting in the need to rebuild the entire decision tree when the rules change, which is slow and affects the user experience.
Provide a decision tree adjustment method for message classification. By obtaining the rules to be added or deleted, using the MbitCuts algorithm to determine the appropriate leaf nodes, and judge whether the decision tree structure needs to be adjusted based on the BINTH value and BSS value, dynamically add or Delete rules without rebuilding the entire decision tree.
Without affecting the worst-match performance of the existing decision tree, dynamic addition and deletion of rules in the decision tree are implemented, and the decision tree is quickly updated, which improves the processing performance and user experience of network devices.
Smart Images

Figure CN115037695B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a method and device for adjusting a decision tree for message classification. Background Art
[0002] At present, in modern complex network management, message classification is an important basic function. Advanced software message classification methods usually use certain algorithms to improve message matching performance while reducing memory usage. For example, the MbitCuts algorithm is one of the above algorithms. Compared with traditional algorithms, the MbitCuts algorithm reduces memory usage and memory access performance by an average of 39% and 87%, respectively.
[0003] The MbitCuts algorithm consists of two aspects: on the one hand, it organizes the matching rules into a decision tree through a certain cutting algorithm; on the other hand, it queries the decision tree. The following takes "matching the IP protocol number of the message" as an example to briefly introduce the implementation process of MbitCuts.
[0004] There are three existing protocol number matching rules, namely: Rule 1: protocol number 38; Rule 2: protocol number 46; Rule 3: protocol number 54 or 62. The above protocol numbers are converted into binary bits as follows: Rule 1: 00100110; Rule 2: 0010 1110; Rule 3: 0011*110. 0 represents 0 bits; 1 represents 1 bit; * represents a wildcard, which can be either 0 bits or 1 bits.
[0005] First, calculate the bit separation set (BSS) value of each bit. This value indicates the strength of distinguishing the matching rule set. The larger the value, the more it can distinguish the rule set. In simple terms, for a certain bit, the BSS value = the number of rules with 0 bits in this bit * the number of rules with 1 bits in this bit. Among them, the wildcard * is not included in the calculation of the BSS value.
[0006] As mentioned above, each rule includes 8 bits. The BSS values of Bit0-Bit7 are shown in Table 1 below.
[0007] Table 1 BSS value of each bit in the first round.
[0008] bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 0 0 0 2 1 0 0 0
[0009] After the first round of calculation, the bit corresponding to the maximum value of BSS is obtained from Table 1, that is, Bit3. Bit3 is used as the characteristic bit, and the above rules are cut to generate the initial decision tree (the root node stores the characteristic bit mask (Bitmask) 0001 0000 for matching). Figure 1 As shown, Figure 1 This is the initial decision tree generated when Bit3 is used as the feature bit.
[0010] According to the above ideas, MbitCuts can continue to filter out the characteristic bits of the cutting rules from the remaining bits. However, it is not possible to continuously filter out the characteristic bits. When to stop filtering the characteristic bits, MbitCuts analyzes the following two factors from the perspectives of memory usage and performance:
[0011] 1)SPFAC: Spatial factor. The spatial factor is a predefined value. The larger the value, the faster the matching performance. However, the larger the memory usage. The calculation method is as follows:
[0012]
[0013] Where m represents the number of characteristic bits of the cutting rule; 2 m Indicates the number of leaf nodes; N i Represents the number of rules in each leaf node; N represents the number of rules in the original rule set of the parent node.
[0014] 2) BINTH value: the threshold of the number of rules contained in the leaf node. The BINTH value is also a predefined value. The smaller the value, the shorter the decision tree height, the fewer rules the leaf node contains, and the faster the matching performance. However, the memory usage is larger. When the number of rules contained in the leaf node with the largest number of rules is not greater than the BINTH value, the feature bit of the screening cutting rule is terminated.
[0015] Combined with the above example, set the BINTH value to 1. For the initial decision tree, further screening of feature bits is required. Exclude Bit3 and calculate the BSS values of the remaining 7 bits. At this time, the BSS value of Bit4 is the maximum. According to the above rules, cut Bit3 and Bit4 together to obtain the final decision tree (the root node saves the feature bit mask (Bitmask) 0001 1000 for matching). Figure 2 As shown, Figure 2 The final decision tree generated when Bit3 and Bit4 are used as feature bits.
[0016] In summary, the existing MbitCuts algorithm has the following deficiencies in the process of generating decision trees: The MbitCuts algorithm cannot support the dynamic addition and deletion of rules in the decision tree. Once a rule changes, the existing decision tree needs to be destroyed and a new decision tree needs to be created with the updated rules. When there are large-scale rules in the decision tree, the entire tree must be recreated just because one or several rules are added, deleted, or modified. The reconstruction process is slow and may affect other existing rules. In particular, in the field of routing switching, whitelisting users through message classification, or fault protection path switching, the overall reconstruction of the decision tree has low processing performance, affecting the user experience. Summary of the invention
[0017] In view of this, the present application provides a method and device for adjusting a decision tree for message classification, so as to make up for the above-mentioned shortcomings of the MbitCuts algorithm and realize dynamic addition and deletion of rules in the decision tree without affecting the worst matching performance of the existing decision tree.
[0018] In a first aspect, the present application provides a method for adjusting a decision tree for message classification, which is applied to a network device, and the method includes:
[0019] Get the rules to be added;
[0020] According to the MbitCuts algorithm, determining, from the first decision tree, a leaf node that can store the rule to be added;
[0021] When the to-be-added rule is pre-stored in the leaf node, determining whether the number of rules currently stored in the leaf node is greater than the BINTH value;
[0022] If the number of rules currently stored in the leaf node is greater than the BINTH value, the rule to be added is stored in the parent node of the leaf node, and a first number of bits is determined;
[0023] Calculate the BSS value of each bit in the first number of bits;
[0024] Determining whether to obtain a characteristic bit from the first number of bits according to the BSS value of each bit;
[0025] If a characteristic bit is obtained from the first number of bits, determining whether the leaf node meets a preset reconstruction condition;
[0026] If not satisfied, the rule to be added is stored in the parent node;
[0027] Taking the parent node as the root node, a subtree of the parent node is constructed.
[0028] In a second aspect, the present application provides a device for adjusting a decision tree for message classification, which is applied to a network device, and the device includes:
[0029] An acquisition unit, used for acquiring rules to be added;
[0030] A first determining unit, configured to determine, from the first decision tree, a leaf node that can store the rule to be added according to the MbitCuts algorithm;
[0031] A first judgment unit, used for judging whether the number of rules currently stored in the leaf node is greater than a BINTH value when the to-be-added rule is pre-stored in the leaf node;
[0032] A second determining unit, configured to store the rule to be added in the parent node of the leaf node and determine a first number of bits if the number of rules currently stored in the leaf node is greater than the BINTH value;
[0033] A calculation unit, configured to calculate a BSS value of each bit in the first number of bits;
[0034] A second judgment unit, configured to judge whether to obtain a characteristic bit from the first number of bits according to the BSS value of each bit;
[0035] a third judgment unit, configured to judge whether the leaf node satisfies a preset reconstruction condition if a characteristic bit is obtained from the first number of bits;
[0036] The adding unit is further used for, if not satisfied, storing the rule to be added in the parent node;
[0037] The construction unit is further used to construct a subtree of the parent node with the parent node as the root node.
[0038] In a third aspect, the present application provides a network device, including a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor, and the processor is prompted by the machine-executable instructions to execute the method provided in the first aspect of the present application.
[0039] Therefore, by applying the decision tree adjustment method and device for message classification provided in the present application, the network device obtains the rules to be added; according to the MbitCuts algorithm, from the first decision tree, the network device determines the leaf node that can store the rules to be added; when the rules to be added are pre-stored in the leaf node, the network device determines whether the number of rules currently stored in the leaf node is greater than the BINTH value; if greater, the network device stores the rules to be added in the parent node of the leaf node, and determines a first number of bits; the network device calculates the BSS value of each bit in the first number of bits; according to the BSS value of each bit, the network device determines whether to obtain the characteristic bit from the first number of bits; if obtained, the network device determines whether the leaf node meets the preset reconstruction conditions; if not, the network device stores the rules to be added in the parent node; the network device uses the parent node as the root node to construct a subtree of the parent node.
[0040] In this way, without affecting the worst matching performance of the existing decision tree, the existing slow process of rebuilding the decision tree, low processing performance, and poor user experience are solved. Dynamic addition and deletion of rules in the decision tree are achieved, and the decision tree is quickly updated to ensure the performance of network equipment. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 The initial decision tree generated when bit3 is used as the feature bit;
[0042] Figure 2 The final decision tree generated when bit3 and bit4 are used as feature bits;
[0043] Figure 3 A flowchart of a method for adjusting a decision tree for message classification provided in an embodiment of the present application;
[0044] Figure 4 A structural diagram of a decision tree adjustment device for message classification provided in an embodiment of the present application;
[0045] Figure 5 The network device hardware structure provided in the embodiment of the present application. DETAILED DESCRIPTION
[0046] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0047] The terms used in this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used in this article refers to and includes any or all possible combinations of one or more corresponding listed items.
[0048] It should be understood that although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0049] The following is a detailed description of the adjustment method of the decision tree for message classification provided in the embodiment of the present application. Figure 3 , Figure 3 A flowchart of a method for adjusting a decision tree for message classification provided in an embodiment of the present application. The method is applied to a network device, which may be a switch, a router, etc. The method for adjusting a decision tree for message classification provided in an embodiment of the present application may include the following steps.
[0050] Step 310: Obtain the rules to be added.
[0051] Specifically, the network device includes a rule set, and the rule set includes a plurality of original rules. The plurality of original rules are used to construct a first decision tree.
[0052] The network device constructs a first decision tree according to the plurality of original rules. It is understandable that the construction of the first decision tree can be implemented according to the existing MbitCuts algorithm, which will not be repeated here.
[0053] At this time, the administrator pre-adds a new rule to the first decision tree, and sends the rule to be added to the network device in the form of a command line.
[0054] The network device obtains the rule to be added. Take "IP protocol number matching of the message" as an example. The rule to be added is: protocol number 38. Convert the protocol number into binary bit form, which is:
[0055] Rules to be added: 0010 0110.
[0056] Step 320: According to the MbitCuts algorithm, determine, from the first decision tree, a leaf node that can store the rule to be added.
[0057] Specifically, according to the description of step 310, after the network device obtains the rule to be added, it runs the MbitCuts algorithm to determine, from the first decision tree, a leaf node that can store the rule to be added.
[0058] Furthermore, the network device may search for at least one leaf node from the first decision tree according to the existing BitIndexing method.
[0059] The existing BitIndexing method can be briefly described as: perform an "AND" operation on the binary form of the rule to be added and the mask of the characteristic bits included in the non-leaf node in the first decision tree. After the "AND" operation, the operation value of the bit set to "1" in the mask is placed at the end of the all-0 data to obtain a binary code. Convert the binary code into a decimal number. The decimal number is the subscript of the leaf node. Determine the leaf node corresponding to the subscript from the leaf nodes in the next layer of the non-leaf node.
[0060] Step 330: When the to-be-added rule is pre-stored in the leaf node, it is determined whether the number of rules currently stored in the leaf node is greater than the BINTH value.
[0061] Specifically, according to the description of step 320, after the network device determines at least one leaf node from the first decision tree, the network device pre-stores the rules to be added in the leaf node.
[0062] It is understandable that, at this time, the network device does not actually store the to-be-added rule in the leaf node, but only increases the number of rules stored in the leaf node by 1.
[0063] The network device determines whether the number of rules currently stored in the leaf node is greater than the BINTH value, where the BINTH value is a preset value, which may be 1, 2, 3, etc.
[0064] For example, the number of rules stored in the leaf node is 2. At this time, the network device pre-stores the rules to be added in the leaf node, and the number of rules currently stored in the leaf node is 3.
[0065] If the number of rules currently stored in the leaf node is greater than the BINTH value, the network device executes step 340.
[0066] Optionally, if the number of rules currently stored in the leaf node is less than the BINTH value, the network device stores the rules to be added in the leaf node and the parent node of the leaf node.
[0067] In an embodiment of the present application, the network device stores the to-be-added rule in each non-leaf node included in the path from the root node to the leaf node, for example, the parent node of the leaf node, the parent node of the parent node, etc. until the parent node is the root node.
[0068] Step 340: If the number of rules currently stored in the leaf node is greater than the BINTH value, the rule to be added is stored in the parent node of the leaf node, and a first number of bits is determined.
[0069] Specifically, according to the description of step 330, the network device determines whether the number of rules currently stored in the leaf node is greater than the BINTH value.
[0070] If the number of rules currently stored in the leaf node is greater than the BINTH value, the network device stores the rules to be added in the parent node of the leaf node and determines the first number of bits.
[0071] Optionally, the specific process of the network device determining the first number of bits is as follows: the network device obtains a first mask of characteristic bits stored in the parent node and a second mask of characteristic bits stored in all non-leaf nodes on the path from the parent node to the root node. The network device determines the remaining bits in the first mask and the second mask that are not used as characteristic bits. The network device uses the remaining bits as the first number of bits.
[0072] For example, the mask of the feature bits stored in the root node (non-leaf node) is 0001 1000; the mask of the feature bits stored in the next layer of child nodes of the root node (non-leaf nodes, child nodes) is 0000 0011; the mask of the feature bits stored in the next layer of child nodes of the child node (non-leaf nodes, grandchild nodes) is 1100 0000; the next layer of child nodes of the grandchild nodes are leaf nodes.
[0073] In the above example, the parent node of the leaf node is the grandchild node, the parent node of the grandchild node is the child node, and the parent node of the child node is the root node. In the above three non-leaf nodes, there are a total of 6 feature bits displayed in the mask, that is, the bit set to "1" in each mask is the feature bit, so in this example, the feature bit is 1101 1011.
[0074] The network device obtains the remaining bits in the mask that are not used as characteristic bits, and uses the remaining bits as the first number of bits. In the above example, the first number of bits obtained by the network device is 2.
[0075] Step 350: Calculate the BSS value of each bit in the first number of bits.
[0076] Specifically, according to the description of step 340, after the network device obtains the first number of bits, the network device calculates the BSS value of each bit respectively according to the existing BSS value calculation method.
[0077] The existing BSS value is calculated as follows: BSS value = the number of rules whose bit is 0*the number of rules whose bit is 1.
[0078] The wildcard character * is not included in the calculation of the BSS value.
[0079] Step 360: Determine whether to obtain a characteristic bit from the first number of bits according to the BSS value of each bit.
[0080] Specifically, according to the description of step 350, after the network device calculates the BSS value of each bit, it determines whether to obtain the characteristic bit from the first number of bits.
[0081] If the characteristic bit is obtained from the first number of bits, the network device executes step 370 .
[0082] Optionally, if the characteristic bit is not obtained from the first number of bits, the network device stores the rule to be added in the leaf node and the parent node of the leaf node.
[0083] In the embodiment of the present application, the network device stores the to-be-added rule in each non-leaf node included in the path from the root node to the leaf node, for example, the parent node of the leaf node, the parent node of the parent node, etc. until the parent node is the root node.
[0084] It is understandable that the network device determines whether to obtain the characteristic bit from the first number of bits according to the existing method of selecting the characteristic bit according to the BSS value. That is, the network device compares the sizes of the BSS values and selects the bit corresponding to the maximum value in the BSS value as the characteristic bit.
[0085] Step 370: If characteristic bits are obtained from the first number of bits, determine whether the leaf node meets a preset reconstruction condition.
[0086] Specifically, according to the description of step 360, if the characteristic bit is obtained from the first number of bits, the network device determines whether the leaf node meets the preset reconstruction condition.
[0087] If the leaf node does not meet the preset reconstruction condition, the network device executes step 380.
[0088] Optionally, the above-mentioned preset reconstruction conditions specifically include: the leaf node is the root node, or; the parent node of the leaf node is the root node, or; the leaf node is at the bottom layer in the first decision tree.
[0089] In an embodiment of the present application, if the leaf node does not meet any of the above-mentioned preset reconstruction conditions, the network device executes step 380.
[0090] Optionally, if the leaf node meets any one of the preset reconstruction conditions, the network device adds the rule to be added to the rule set, constructs a second decision tree according to the added rule set, and deletes the first decision tree.
[0091] It is understandable that the process of the network device constructing the second decision tree may refer to the process of constructing a decision tree using the existing MbitCuts algorithm, which will not be repeated here.
[0092] Step 380: If not satisfied, store the rule to be added in the parent node.
[0093] Specifically, according to the description of step 370, if the leaf node does not meet any of the preset reconstruction conditions, the network device stores the rule to be added in the parent node. At this time, the number of rules in the parent node is increased by 1.
[0094] Step 390: Using the parent node as the root node, construct a subtree of the parent node.
[0095] Specifically, according to the description of step 380, since the number of rules in the parent node has changed, the network device uses the parent node as the root node and constructs a subtree of the parent node using the changed number of rules in the parent node.
[0096] It is understandable that the process of the network device constructing the subtree of the parent node can refer to the process of constructing the decision tree by the existing MbitCuts algorithm, which will not be repeated here.
[0097] Through the above steps, suppose N rules are added to an original decision tree Tree0 to create Tree1, Tree2, Tree3, ... N .
[0098] Usually, because when creating a Tree m+1 , the above process will not increase the height of the original decision tree. m+1 The overall matching performance of m The matching performance of the new decision tree rule is not better than that of Tree m Difference.
[0099] In special cases, when rebuilding a subtree with the parent node of the current leaf node as the root node, the height of the entire original decision tree may increase. However, the created subtree is also created according to the MbitCuts algorithm to ensure that the new decision tree is the optimal decision tree.
[0100] Final result: The worst matching performance of the decision tree is: Tree0 = Tree1 = Tree = ... = Tree N .
[0101] The average matching performance of the decision tree is: Tree0≈Tree1≈Tree2≈…≈Tree N .
[0102] In special cases, the new decision tree (including the created subtree) is the optimal tree that conforms to the MbitCuts algorithm, and its performance is better or worse than the original decision tree.
[0103] Therefore, by applying the decision tree adjustment method and device for message classification provided in the present application, the network device obtains the rules to be added; according to the MbitCuts algorithm, from the first decision tree, the network device determines the leaf node that can store the rules to be added; when the rules to be added are pre-stored in the leaf node, the network device determines whether the number of rules currently stored in the leaf node is greater than the BINTH value; if greater, the network device stores the rules to be added in the parent node of the leaf node and determines a first number of bits; the network device calculates the BSS value of each bit in the first number of bits; according to the BSS value of each bit, the network device determines whether to obtain the characteristic bit from the first number of bits; if obtained, the network device determines whether the leaf node meets the preset reconstruction conditions; if not, the network device stores the rules to be added in the parent node; the network device uses the parent node as the root node to construct a subtree of the parent node.
[0104] In this way, without affecting the worst matching performance of the existing decision tree, the existing slow process of rebuilding the decision tree, low processing performance, and poor user experience are solved. Dynamic addition and deletion of rules in the decision tree are achieved, and the decision tree is quickly updated to ensure the performance of network equipment.
[0105] Optionally, in the embodiment of the present application, a process of deleting existing rules from the first decision tree is also included.
[0106] Specifically, the administrator deletes an old rule in advance in the first decision tree, and sends the rule to be deleted to the network device in the form of a command line.
[0107] The network device obtains the rule to be deleted. Take "IP protocol number matching of the message" as an example. The rule to be deleted is: protocol number 38. The protocol number is converted into binary bit form, which is:
[0108] Rules to be deleted: 0010 0110.
[0109] After the network device obtains the rule to be deleted, it runs the MbitCuts algorithm to determine, from the first decision tree, a leaf node that can store the rule to be deleted.
[0110] Furthermore, the network device may search for at least one leaf node from the first decision tree according to the existing BitIndexing method.
[0111] The above has briefly described the existing BitIndexing method, which will not be repeated here.
[0112] From the leaf nodes, the network device determines a first rule that is the same as the rule to be deleted, and deletes the first rule.
[0113] It should be noted that at least one rule is stored in the leaf node. When the network device determines the first rule, it needs to perform an exact match, that is, a bit-by-bit match, and each bit must be matched equally before the rule can be deleted.
[0114] For example, three rules are stored in the leaf node, namely: Rule1: 1100 0001; Rule2: 00100110; Rule3: 1010 0001. When the network device determines the first rule, it matches the rule to be deleted with the above three rules bit by bit, and determines that Rule2 is the same as the rule to be deleted, then Rule2 is the first rule. The network device deletes Rule2 from the leaf node.
[0115] Optionally, in an embodiment of the present application, after the network device deletes the corresponding rules from the leaf node, it also judges the number of rules stored in the leaf node, the number of rules stored in each brother node of the leaf node, and the number of nodes in the layer where the leaf node is located to reduce the height of the decision tree.
[0116] Specifically, after the network device deletes the corresponding rule from the leaf node, the network device obtains the number of rules currently stored in the leaf node and the number of rules currently stored in each brother node belonging to the same parent node as the leaf node.
[0117] The network device determines whether the numbers of the rules obtained above are all the first value (the first value is 0).
[0118] If the number of rules stored in the leaf node and the number of rules stored in each sibling node are both the first value, that is, the leaf node and each sibling node do not store any rules, the network device updates the parent node of the leaf node to a new leaf node and releases the memory occupied by the leaf node and each sibling node.
[0119] Furthermore, after the network device updates the parent node of the leaf node to a new leaf node, that is, there are no other leaf nodes in the layer where the leaf node is located, at this time, the height of the decision tree is reduced by 1.
[0120] According to the above description, suppose from an original decision tree Tree N After deleting N rules in succession, we get Tree N-1 、Tree N-2 、Tree N-3 …Tree0, its matching performance comparison is as follows:
[0121] The worst matching performance of the decision tree is: Tree N-1 ≤Tree N-2 ≤Tree N-3 ≤…≤Tree0.
[0122] The average matching performance of the decision tree is: N-1 ≤Tree N-2 ≤Tree N-3 ≤…≤Tree0.
[0123] In summary, the method for adjusting the decision tree for message classification provided by the embodiment of the present application can achieve, including but not limited to:
[0124] 1) During the link fault protection process, the packet forwarding path switching performance is significantly improved and the packet loss rate is reduced.
[0125] For example, in the case of 4K (1K = 1024) ACL matching rules, link failure protection is performed on the same service flow through policy routing (Policy Based Route, PBR for short). When the route of a certain link fails, triggering linkage deletion of an ACL matching rule and switching to a backup link, the decision tree adjustment method for message classification provided in the embodiment of the present application dynamically adjusts the performance of the decision tree to a single-digit millisecond level, and is 10 to 15 times faster than the performance of the overall reconstruction decision tree, and the packet loss rate is reduced by 10 to 15 times.
[0126] The test data are shown in Tables 2 and 3 below.
[0127] Table 2 Dynamically adjusted decision tree
[0128]
[0129]
[0130] Table 3 Overall reconstruction decision tree
[0131] Packet sending rate (unit: fps) 4,464,285 5,208,333 Total number of packets sent 100,000,000 100,000,000 Total number of received packets (normal) 99,995,115 95,134,520 Total number of received packets (failover) 99,788,231 93,416,128 Total number of lost packets / packet loss rate 206,884 / 0.207% 1,718,392 / 1.718% Switching performance (unit: milliseconds) 46.3 330
[0132] 2) Accelerate the online process of legitimate terminals. For example, when there are a large number of online terminals and a new user comes online, or when a large number of terminals come online at the same time, the controller automatically generates ACL rules for terminal information and sends them to the access device as a whitelist for network devices to filter the messages sent by the terminals. The adjustment method of the decision tree for message classification provided in the embodiment of the present application can accelerate the release of messages sent by legitimate terminals and improve the user online experience.
[0133] Based on the same inventive concept, the embodiment of the present application also provides an adjustment device for a decision tree for message classification corresponding to the adjustment method for a decision tree for message classification. Figure 4 , Figure 4 An adjustment device for a decision tree for message classification provided in an embodiment of the present application comprises:
[0134] An acquisition unit 410 is used to acquire a rule to be added;
[0135] A first determining unit 420 is used to determine, from the first decision tree, a leaf node that can store the rule to be added according to the MbitCuts algorithm;
[0136] A first judging unit 430 is used to judge whether the number of rules currently stored in the leaf node is greater than a BINTH value when the to-be-added rule is pre-stored in the leaf node;
[0137] A second determining unit 440 is configured to store the rule to be added in the parent node of the leaf node if the number of rules currently stored in the leaf node is greater than the BINTH value, and determine a first number of bits;
[0138] A calculation unit 450, configured to calculate a BSS value of each bit in a first number of bits;
[0139] A second judging unit 460 is configured to judge whether to obtain a characteristic bit from the first number of bits according to the BSS value of each bit;
[0140] A third judgment unit 470 is used to judge whether the leaf node meets a preset reconstruction condition if a characteristic bit is obtained from the first number of bits;
[0141] An adding unit 480, configured to store the rule to be added in the parent node if the condition is not satisfied;
[0142] The construction unit 490 is used to construct a subtree of the parent node with the parent node as the root node.
[0143] Optionally, the adding unit 480 is further configured to store the rule to be added in the leaf node and the parent node if the number of rules currently stored in the leaf node is less than the BINTH value;
[0144] If the characteristic bit is not obtained from the first number of bits, the rule to be added is stored in the leaf node and the parent node.
[0145] Optionally, the construction unit 490 is further used to, if satisfied, construct a second decision tree according to a rule set including the rule to be added, and delete the first decision tree, the rule set including the original rule, and the original rule is used to construct the first decision tree.
[0146] Optionally, the second determining unit 440 is specifically configured to obtain a first mask of the characteristic bits stored in the parent node and a second mask of the characteristic bits stored in all non-leaf nodes on the path from the parent node to the root node;
[0147] Determine the remaining bits in the first mask and the second mask that are not used as feature bits;
[0148] The remaining bits are used as the first number of bits.
[0149] Optionally, the preset reconstruction condition specifically includes:
[0150] The leaf node is a root node, or;
[0151] The parent node of the leaf node is the root node, or;
[0152] The leaf nodes are at the bottom layer of the first decision tree.
[0153] Optionally, the acquisition unit 410 is further used to acquire a rule to be deleted;
[0154] The first determining unit 420 is further configured to determine, from the first decision tree, a leaf node that can store the rule to be deleted according to the MbitCuts algorithm;
[0155] The device further includes: a deleting unit (not shown in the figure), which is used to determine a first rule that is the same as the rule to be deleted from the leaf nodes, and delete the first rule.
[0156] Optionally, the device further includes: a fourth judgment unit (not shown in the figure), configured to judge whether the number of rules stored in the leaf node and the number of rules stored in each brother node belonging to the same parent node as the leaf node are both the first value;
[0157] A release unit (not shown in the figure) is used to update the parent node of the leaf node to a new leaf node and release the memory occupied by the leaf node and the brother nodes if the number of rules stored in the leaf node and the number of rules stored in each brother node belonging to the same parent node as the leaf node are both first values.
[0158] Therefore, by applying the decision tree adjustment method and device for message classification provided in the present application, the network device obtains the rules to be added; according to the MbitCuts algorithm, from the first decision tree, the network device determines the leaf node that can store the rules to be added; when the rules to be added are pre-stored in the leaf node, the network device determines whether the number of rules currently stored in the leaf node is greater than the BINTH value; if greater, the network device stores the rules to be added in the parent node of the leaf node and determines a first number of bits; the network device calculates the BSS value of each bit in the first number of bits; according to the BSS value of each bit, the network device determines whether to obtain the characteristic bit from the first number of bits; if obtained, the network device determines whether the leaf node meets the preset reconstruction conditions; if not, the network device stores the rules to be added in the parent node; the network device uses the parent node as the root node to construct a subtree of the parent node.
[0159] In this way, without affecting the worst matching performance of the existing decision tree, the existing slow process of rebuilding the decision tree, low processing performance, and poor user experience are solved. Dynamic addition and deletion of rules in the decision tree are achieved, and the decision tree is quickly updated to ensure the performance of network equipment.
[0160] Based on the same inventive concept, the embodiment of the present application also provides a network device, such as Figure 5 As shown, it includes a processor 510, a transceiver 520 and a machine-readable storage medium 530, the machine-readable storage medium 530 stores machine-executable instructions that can be executed by the processor 510, and the processor 510 is prompted by the machine-executable instructions to execute the decision tree adjustment method for message classification provided in the embodiment of the present application. Figure 4 The adjustment device for the decision tree for message classification shown in FIG. Figure 5 The network device hardware structure shown is implemented.
[0161] The computer-readable storage medium 530 may include a random access memory (RAM) or a non-volatile memory (NVM), such as at least one disk storage. Optionally, the computer-readable storage medium 530 may also be at least one storage device located away from the processor 510.
[0162] The processor 510 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.
[0163] In the embodiment of the present application, the processor 510 reads the machine executable instructions stored in the machine-readable storage medium 530, and the machine executable instructions enable the processor 510 itself and the transceiver 520 to execute the adjustment method of the decision tree for message classification described in the aforementioned embodiment of the present application.
[0164] In addition, an embodiment of the present application provides a machine-readable storage medium 530, which stores machine-executable instructions. When called and executed by the processor 510, the machine-executable instructions prompt the processor 510 itself and the calling transceiver 520 to execute the decision tree adjustment method for message classification described in the aforementioned embodiment of the present application.
[0165] The implementation process of the functions and effects of each unit in the above-mentioned device is specifically described in the implementation process of the corresponding steps in the above-mentioned method, and will not be repeated here.
[0166] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the present application scheme. A person of ordinary skill in the art can understand and implement it without paying any creative work.
[0167] As for the adjustment device of the decision tree for message classification and the machine-readable storage medium embodiment, since the method contents involved are basically similar to the aforementioned method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0168] The above description is only a preferred embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the scope of protection of the present application.
Claims
1. A method for adjusting a decision tree for message classification, characterized in that: Applied to a network device, the method comprises: Get the rules to be added; According to the MbitCuts algorithm, determining, from the first decision tree, a leaf node that can store the rule to be added; When the to-be-added rule is pre-stored in the leaf node, it is determined whether the number of rules currently stored in the leaf node is greater than a BINTH value, where the BINTH value represents a threshold value of the number of rules contained in the leaf node; If the number of rules currently stored in the leaf node is greater than the BINTH value, the rule to be added is stored in the parent node of the leaf node, and a first number of bits is determined; Calculate a bit separation set BSS value for each bit in the first number of bits; Determining whether to obtain a characteristic bit from the first number of bits according to the bit separation set BSS value of each bit; If a characteristic bit is obtained from the first number of bits, determining whether the leaf node meets a preset reconstruction condition; If not satisfied, the rule to be added is stored in the parent node; Taking the parent node as the root node, a subtree of the parent node is constructed.
2. The method according to claim 1, characterized in that The method further comprises: If the number of rules currently stored in the leaf node is less than the BINTH value, the rule to be added is stored in the leaf node and the parent node; If the characteristic bit is not obtained from the first number of bits, the rule to be added is stored in the leaf node and the parent node.
3. The method according to claim 1, characterized in that The method further comprises: If satisfied, a second decision tree is constructed according to a rule set including the rule to be added, and the first decision tree is deleted, the rule set including the original rule, and the original rule is used to construct the first decision tree.
4. The method according to claim 1, characterized in that The determining of the first number of bits specifically includes: Obtain a first mask of the characteristic bits stored in the parent node and a second mask of the characteristic bits stored in all non-leaf nodes on the path from the parent node to the root node; Determine the remaining bits in the first mask and the second mask that are not used as feature bits; The remaining bits are used as the first number of bits.
5. The method according to claim 1, characterized in that The preset reconstruction conditions specifically include: The leaf node is a root node, or; The parent node of the leaf node is the root node, or; The leaf nodes are at the bottom layer of the first decision tree.
6. The method according to claim 1, characterized in that The method further comprises: Get the rules to be deleted; According to the MbitCuts algorithm, determining, from the first decision tree, a leaf node that can store the rule to be deleted; A first rule that is the same as the rule to be deleted is determined from the leaf nodes, and the first rule is deleted.
7. The method according to claim 6, characterized in that The method further comprises: Determine whether the number of rules stored in the leaf node and the number of rules stored in each brother node belonging to the same parent node as the leaf node are both the first value; If the number of rules stored in the leaf node and the number of rules stored in each brother node belonging to the same parent node as the leaf node are both the first value, the parent node of the leaf node is updated to a new leaf node, and the memory occupied by the leaf node and the brother nodes is released.
8. A decision tree adjustment device for message classification, characterized in that: The device is applied to a network device, and the device comprises: An acquisition unit, used to acquire the rules to be added; A first determining unit, configured to determine, from the first decision tree, a leaf node that can store the rule to be added according to an MbitCuts algorithm; A first judgment unit, used for judging whether the number of rules currently stored in the leaf node is greater than a BINTH value when the to-be-added rule is pre-stored in the leaf node, wherein the BINTH value represents a threshold value of the number of rules contained in the leaf node; A second determining unit, configured to store the rule to be added in the parent node of the leaf node and determine a first number of bits if the number of rules currently stored in the leaf node is greater than the BINTH value; A calculation unit, configured to calculate a bit separation set BSS value of each bit in the first number of bits; A second judgment unit is used to judge whether to obtain a characteristic bit position from the first number of bits according to the bit separation set BSS value of each bit position; a third judgment unit, configured to judge whether the leaf node satisfies a preset reconstruction condition if a characteristic bit is obtained from the first number of bits; an adding unit, configured to store the rule to be added in the parent node if the condition is not satisfied; A construction unit is used to construct a subtree of the parent node with the parent node as a root node.
9. The device according to claim 8, characterized in that The adding unit is further configured to store the to-be-added rule in the leaf node and the parent node if the number of rules currently stored in the leaf node is less than the BINTH value; If the characteristic bit is not obtained from the first number of bits, the rule to be added is stored in the leaf node and the parent node.
10. The device according to claim 8, characterized in that The construction unit is also used to, if satisfied, construct a second decision tree according to a rule set including the rule to be added, and delete the first decision tree, the rule set including the original rule, and the original rule is used to construct the first decision tree.
11. The device according to claim 8, characterized in that The second determining unit is specifically used to obtain a first mask of the characteristic bits stored in the parent node and a second mask of the characteristic bits stored in all non-leaf nodes on the path from the parent node to the root node; Determine the remaining bits in the first mask and the second mask that are not used as feature bits; The remaining bits are used as the first number of bits.
12. The device according to claim 8, characterized in that The preset reconstruction conditions specifically include: The leaf node is a root node, or; The parent node of the leaf node is the root node, or; The leaf nodes are at the bottom layer of the first decision tree.
13. The device according to claim 8, characterized in that The acquisition unit is also used to acquire the rule to be deleted; The first determining unit is further used to determine, according to the MbitCuts algorithm, from the first decision tree, a leaf node that can store the rule to be deleted; The device further includes: a deleting unit, configured to determine, from the leaf nodes, a first rule that is the same as the rule to be deleted, and delete the first rule.
14. The device according to claim 13, characterized in that The device also includes: A fourth judgment unit, used to judge whether the number of rules stored in the leaf node and the number of rules stored in each brother node belonging to the same parent node as the leaf node are both the first value; A release unit is used to update the parent node of the leaf node to a new leaf node and release the memory occupied by the leaf node and the brother nodes if the number of rules stored in the leaf node and the number of rules stored in the brother nodes belonging to the same parent node as the leaf node are both first values.
Citation Information
Patent Citations
Decision tree generation method and device, decision tree-based message classification method and device
CN102281196A
Decision-making result determination method, device and equipment
CN111242164A