CN119299368B - Route matching method, device, equipment, network card and computer program product - Google Patents
Route matching method, device, equipment, network card and computer program product Download PDFInfo
- Publication number
- CN119299368B CN119299368B CN202411825159.7A CN202411825159A CN119299368B CN 119299368 B CN119299368 B CN 119299368B CN 202411825159 A CN202411825159 A CN 202411825159A CN 119299368 B CN119299368 B CN 119299368B
- Authority
- CN
- China
- Prior art keywords
- data
- node
- link
- data structure
- dictionary tree
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Classifications
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/48—Routing tree calculation
-
- H—ELECTRICITY
- H04—ELECTRIC COMMUNICATION TECHNIQUE
- H04L—TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
- H04L45/00—Routing or path finding of packets in data switching networks
- H04L45/74—Address processing for routing
- H04L45/745—Address table lookup; Address filtering
- H04L45/748—Address table lookup; Address filtering using longest matching prefix
Landscapes
- Engineering & Computer Science (AREA)
- Computer Networks & Wireless Communication (AREA)
- Signal Processing (AREA)
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The embodiment of the invention relates to the technical field of networks, and particularly provides a route matching method, a device, equipment, a network card and a computer program product. The routing matching method comprises the steps of obtaining data to be processed, determining a dictionary tree for matching the data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least one link node, data corresponding to the link data structure at least comprises a query address of a destination link node and address data corresponding to the link data structure, querying the dictionary tree, obtaining target matching data corresponding to the data to be processed, and determining a routing forwarding rule corresponding to the data to be processed based on the target matching data. In the embodiment, when the dictionary tree is utilized to perform the matching operation on the data to be processed, the link data structure in the dictionary tree is used as an integral node to perform the matching operation, so that the efficiency of accessing the dictionary tree is effectively improved.
Description
Technical Field
The present invention relates to the field of network technologies, and in particular, to a route matching method, device, equipment, network card, and computer program product.
Background
Route Matching (Route Matching) is a key concept in network communications, which refers to deciding how a packet should be forwarded to its destination according to a specific rule or policy. Currently, the route matching operation is often implemented through a dictionary tree, as shown in fig. 1, where the highest node in the dictionary tree is the starting position (corresponding rule x), ", is used to identify that the current node has no configuration rule. Then, when the first bit in the data to be matched is 0, the node is jumped to the node at the lower left (the node has a corresponding rule a,0 x), when the first bit in the data to be matched is 1, the node is jumped to the node at the lower right (the node has a corresponding rule d,1 x), then, the matching of longer rules is carried out according to the subsequent bit in the data to be matched, and so on, the last node can be queried according to each bit in the data to be matched, and then the hit rules are stopped and returned.
However, the process of performing the route matching operation by using the dictionary tree has the defect that each node in the dictionary tree needs to perform the rule query operation, so that the node query times in the dictionary tree are high, and the performance of route matching can be reduced.
Disclosure of Invention
The embodiment of the invention provides a route matching method, a device, equipment, a network card and a computer program product, which can improve the quality and efficiency of route matching.
In a first aspect, an embodiment of the present invention provides a route matching method, including:
Acquiring data to be processed;
Determining a dictionary tree for matching the data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least one link node, and the data corresponding to the link data structure at least comprises a query address of a terminal link node and address data corresponding to the link data structure;
And querying the dictionary tree, obtaining target matching data corresponding to the data to be processed, and determining a routing forwarding rule corresponding to the data to be processed based on the target matching data.
In a second aspect, an embodiment of the present invention provides a route matching device, including:
the first acquisition module is used for acquiring data to be processed;
the first determining module is used for determining a dictionary tree for matching the data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least two link nodes, and the data corresponding to the link data structure at least comprises a query address of a terminal link node and address data corresponding to the link data structure;
The first processing module is used for inquiring the dictionary tree, obtaining target matching data corresponding to the data to be processed, and determining a routing forwarding rule corresponding to the data to be processed based on the target matching data.
In a third aspect, an embodiment of the present invention provides an electronic device, including a memory and a processor, where the memory is configured to store one or more computer instructions, and the one or more computer instructions implement the route matching method in the first aspect when executed by the processor.
In a fourth aspect, an embodiment of the present invention provides a computer storage medium storing a computer program, where the computer program causes a computer to implement the route matching method in the first aspect.
In a fifth aspect, embodiments of the present invention provide a computer program product comprising a computer readable storage medium storing computer instructions which, when executed by one or more processors, cause the one or more processors to perform the steps in the route matching method as set out in the first aspect above.
In a sixth aspect, an embodiment of the present invention provides a network card, including:
The processing module is used for acquiring data to be processed;
The rule storage module is in communication connection with the processing module, and stores a dictionary tree for matching the data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least two link nodes, and data corresponding to the link data structure at least comprises a query address of a terminal link node and address data corresponding to the link data structure;
the processing module is further configured to determine, through the rule storage module, a dictionary tree for matching the data to be processed, query the dictionary tree, obtain target matching data corresponding to the data to be processed, and determine a routing forwarding rule corresponding to the data to be processed based on the target matching data.
The route matching method, device, equipment, network card and computer program product provided by the embodiment of the invention determine the dictionary tree for matching the data to be processed by acquiring the data to be processed, inquire the dictionary tree, acquire target matching data corresponding to the data to be processed, and determine the route forwarding rule corresponding to the data to be processed based on the target matching data, because the dictionary tree comprises a link data structure which is a single branch structure formed by at least one link node, therefore, when the dictionary tree is utilized to carry out matching operation on data to be processed, the link data structure can be used as an integral node to carry out data matching operation, so that the number of query nodes in the dictionary tree and the number of node query times on the dictionary tree are reduced, the efficiency of route matching operation and the quality and efficiency of access to the dictionary tree can be improved, the accuracy and reliability of determining the route forwarding rule corresponding to the data to be processed are ensured, and the practicability of the method is further ensured.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions of the prior art, the following description will briefly explain the drawings used in the embodiments or the description of the prior art, and it is obvious that the drawings in the following description are some embodiments of the present invention, and other drawings can be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic diagram of a dictionary tree provided in a related art embodiment;
Fig. 2 is a schematic diagram of a route matching method according to an embodiment of the present invention;
fig. 3 is a schematic flow chart of a route matching method according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a dictionary tree according to an embodiment of the present invention;
fig. 5 is a flow chart of another route matching method according to an embodiment of the present invention;
FIG. 6 is a schematic diagram I of node deletion for a dictionary tree according to an embodiment of the present invention;
FIG. 7 is a second schematic diagram of node deletion for a dictionary tree according to an embodiment of the present invention;
fig. 8 is a flow chart of another route matching method according to an embodiment of the present invention;
FIG. 9 is a schematic diagram of node addition to a dictionary tree according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a route matching device according to an embodiment of the present invention;
Fig. 11 is a schematic structural diagram of an electronic device corresponding to the route matching device provided in the embodiment shown in fig. 10;
fig. 12 is a schematic structural diagram of a network card according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention more apparent, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention, and it is apparent that the described embodiments are some embodiments of the present invention, but not all embodiments of the present invention. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
The terminology used in the embodiments of the invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention. As used in this application and the appended claims, the singular forms "a," "an," and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise, the "plurality" generally includes at least two, but does not exclude the case of at least one.
It should be understood that the term "and/or" as used herein is merely one way of describing the association of associated devices, meaning that there may be three relationships, e.g., A and/or B, and that there may be three cases where A exists alone, while A and B exist alone. In addition, the character "/" herein generally indicates that the associated device is an "or" relationship.
The words "if", as used herein, may be interpreted as "at" or "when" or "in response to a determination" or "in response to a detection", depending on the context. Similarly, the phrase "if determined" or "if detected (stated condition or event)" may be interpreted as "when determined" or "in response to determination" or "when detected (stated condition or event)" or "in response to detection (stated condition or event), depending on the context.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a product or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such product or system. Without further limitation, an element defined by the phrase "comprising one of the elements" does not exclude the presence of additional identical elements in a commodity or system comprising the element.
In addition, the sequence of steps in the method embodiments described below is only an example and is not strictly limited.
Term interpretation:
the longest prefix match (Longest Prefix Match, abbreviated as LPM) is applied to network equipment such as routers and switches.
Dictionary tree (trie tree) is a tree-shaped data structure used to retrieve data in a set of strings. the trie tree implements elements in the LPM algorithm that are either just 0 or 1.
Nodes, each internal node in the dictionary tree.
The link data structure is a self-defined structure and can be a direct connection structure crossing invalid nodes.
The data packet serial number Packet Sequence Numbers, PSN for short, is used for marking the serial number allocated in hardware of the data packet.
In order to facilitate understanding of specific implementation processes and implementation effects of the route matching method, apparatus, device, network card and computer program product in this embodiment, the following briefly describes the related art:
First, a brief description of the implementation principle of the dictionary tree is provided, and the routing rules and data configured are shown in the following table 1:
Based on the above table data, a corresponding dictionary tree may be generated, as shown in fig. 1, where the dictionary tree includes a plurality of nodes, then rule matching operation may be performed based on a longest prefix matching (Longest Prefix Match, abbreviated as LPM) algorithm and the dictionary tree, where the highest node in the dictionary tree is a starting position (corresponding rule x) and is used to identify that the current node does not have a rule configured, then, when a first bit in the data to be matched is 0, a node at the bottom left (the node has a corresponding rule a,0 x), when the first bit in the data to be matched is 1, a node at the bottom right (the node has a corresponding rule d,1 x), then, longer rule matching may be performed according to a subsequent bit in the data to be matched, and so on, and then, a hit rule may be stopped and returned according to each bit in the data to be matched, for example, when the data to be processed is "0011", a hit rule b is reached, and when the data to be processed is 1000.
However, when rule matching is performed by using the above-mentioned dictionary tree, there is a disadvantage in that the dictionary tree includes a plurality of nodes, each of which needs to perform a rule matching operation, so that the number of times of queries required for the rule matching operation is large, resulting in a decrease in the performance of route matching.
In order to solve the above-mentioned technical problems, this embodiment provides a route matching method, apparatus, device, network card and computer program product, and referring to fig. 2, the execution body of the route matching method is a route matching apparatus 200, and the route matching apparatus 200 is communicatively connected to a client 100 and a processing device 300, so as to obtain data to be processed through the client 100, and then the data to be processed can be forwarded to the processing device 300 for corresponding data processing operation. When the route matching device 200 is implemented as a cloud server, the route matching method can be executed at a cloud end, and a plurality of computing nodes (cloud servers) can be deployed at the cloud end, wherein each computing node has processing resources such as computation, storage and the like. At the cloud, a service may be provided by multiple computing nodes, although one computing node may provide one or more services. The cloud may provide the service by providing a service interface to the outside, and the user invokes the service interface to use the corresponding service. The service interface includes a software development kit (Software Development Kit, abbreviated as SDK), an application program interface (Application Programming Interface, abbreviated as API), and the like.
The route matching device 200 is a device that can provide route matching operation in a network virtual environment, and generally refers to a device that performs information planning and route matching operation by using a network. In a physical implementation, the route matching device 200 may be any device capable of providing a computing service, responding to a route matching request, and performing a route matching operation, where the device may be integrated on a preset device, for example, may be a cluster server, a conventional server, a cloud host, a virtual center, and so on. The route matching device 200 mainly includes a processor, a hard disk, a memory, a system bus, and the like, and is similar to a general computer architecture.
The client 100 may be implemented as a cell phone, a personal computer PC, a tablet computer, a setup application, etc. Further, the basic structure of the client 100 may include at least one processor. The number of processors depends on the configuration and type of client 100. The client 100 may also include Memory that may be volatile, such as random access Memory (Random Access Memory, RAM) or non-volatile, such as Read-Only Memory (ROM), flash Memory, etc., or both. The memory typically stores an Operating System (OS), one or more application programs, program data, and the like. In addition to the processing unit and memory, the client 100 also includes some basic configurations, such as a network card chip, an IO bus, a display component, and some peripheral devices. Alternatively, some peripheral devices may include, for example, a keyboard, a mouse, a stylus, a printer, etc. Other peripheral devices are well known in the art and are not described in detail herein.
In the present embodiment described above, the client 100 and the route matching apparatus 200, and the route matching apparatus 200 and the processing device 300 are connected by a network, which may be a wireless or wired network connection. If the client 100 is in communication connection with the route matching device 200, and the route matching device 200 is in communication connection with the processing device 300, the network system of the mobile network may be any of 2G (GSM), 2.5G (GPRS), 3G (WCDMA, TD-SCDMA, CDMA2000, UTMS), 4G (LTE), 4g+ (lte+), wiMax, 5G, 6G, and the like.
The client 100 is configured to enable a user to apply to start, call, or implement a data processing operation, and specifically, the client 100 may generate and obtain data to be processed, where in some examples, the data to be processed may be obtained through a man-machine interaction operation or a voice interaction operation, and in order to enable a corresponding data processing operation, the data to be processed may be sent to the route matching device 200, so that the route matching device 200 performs the corresponding data processing operation on the data to be processed.
The route matching device 200 is communicatively connected to the client 100, and is configured to obtain data to be processed sent by the client 100, and after obtaining the data to be processed, determine a dictionary tree for matching the data to be processed, where the dictionary tree includes at least one link data structure, that is, the number of link data structures may be one or more, and specifically, the link data structure is a single branch structure formed by at least one link node, and the data corresponding to the link data structure at least includes a query address of a destination link node and address data corresponding to the link data structure.
After determining the dictionary tree for matching the data to be processed, performing a matching operation on the data to be processed based on the dictionary tree, that is, querying the dictionary tree to obtain target matching data corresponding to the data to be processed, determining a routing forwarding rule corresponding to the data to be processed based on the target matching data, and then performing a forwarding processing operation on the data to be processed based on the routing forwarding rule, for example, sending the data to be processed to the processing device 300 based on the routing forwarding rule, so that the processing device 300 can perform a corresponding processing operation on the data to be processed. Therefore, when the dictionary tree is utilized to determine the matching rule of the data to be processed, the dictionary tree comprises the link data structure, the link data structure is a single branch structure formed by at least one link, and the data corresponding to the link data structure at least comprises the query address of the destination link node and the address data corresponding to the link data structure.
Some embodiments of the present invention are described in detail below with reference to the accompanying drawings. In the case where there is no conflict between the embodiments, the following embodiments and features in the embodiments may be combined with each other. In addition, the sequence of steps in the method embodiments described below is only an example and is not strictly limited.
Fig. 3 is a schematic flow chart of a route matching method according to an embodiment of the present invention, and referring to fig. 3, this embodiment provides a route matching method, where an execution body of the method is a route matching device, and the route matching device may be implemented as software, or a combination of software and hardware, where the route matching device is implemented as hardware, it may be various electronic devices with route matching capability, and where the route matching device is implemented as software, it may be installed in the electronic device illustrated above. In some examples, the route matching device can be realized as a network card, and the route matching method based on the route matching device comprises the following steps:
Step S301, obtaining data to be processed.
Step S302, determining a dictionary tree for matching data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least two link nodes, and data corresponding to the link data structure at least comprises a query address of a terminal link node and address data corresponding to the link data structure.
Step S303, inquiring the dictionary tree, obtaining target matching data corresponding to the data to be processed, and determining a routing forwarding rule corresponding to the data to be processed based on the target matching data.
The specific implementation process and implementation effect of each step are described in detail below:
Step S301, obtaining data to be processed.
When the data processing requirement exists, the route matching device can be enabled to acquire the data to be processed, wherein the data to be processed can be a message to be processed or the data to be processed can be acquired through analysis processing of the message to be processed, and at the moment, the acquiring of the data to be processed can comprise the steps of acquiring the message to be processed, determining a destination IP address corresponding to the message to be processed, and performing binary conversion operation on the destination IP address to acquire the data to be processed corresponding to the message to be processed, so that the stable reliability of acquiring the data to be processed is effectively ensured.
Step S302, determining a dictionary tree for matching data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least two link nodes, and data corresponding to the link data structure at least comprises a query address of a terminal link node and address data corresponding to the link data structure.
After the data to be processed is obtained, in order to accurately implement the data processing operation, a dictionary tree for matching the data to be processed may be determined, where the dictionary tree may include different types of data structures, and the data structures may include a form or format of data organization, management, and storage in computer science, for example, the dictionary tree may include a node type data structure (hereinafter referred to as a node data structure) and a link type data structure (hereinafter referred to as a link data structure), where the node data structure may refer to a structure formed by a single node and two next-level nodes are corresponding to the single node, and the link data structure may refer to a single branch structure formed by at least one link node.
In some examples, the dictionary tree for matching the data to be processed may be obtained by analyzing the node data structure and the link data structure, and determining the dictionary tree for matching the data to be processed may include obtaining a plurality of node data structures and at least one link data structure for constructing the dictionary tree, and performing a data sort operation on the plurality of node data structures and the at least one link data structure, so that the dictionary tree for matching the data to be processed may be generated and determined.
In other examples, the dictionary tree for matching the data to be processed can be obtained through a preset device, and can also be obtained through a plurality of rule cache units in the gateway, and at the moment, determining the dictionary tree for matching the data to be processed can comprise determining a plurality of rule cache units in the network card for storing the dictionary tree, wherein the dictionary tree is stored in the plurality of rule cache units in a segment form, and determining the dictionary tree for matching the data to be processed through the plurality of rule cache units, so that the accuracy and the reliability of determining the dictionary tree are effectively ensured.
For the dictionary tree, the dictionary tree may include at least one link data structure, that is, the number of link data structures included in the dictionary tree is one or more, as shown in fig. 4, the link data structure is a single branch structure formed by at least one link node, when the link data structure is a single branch structure formed by 1 link node, the current link node for forming the link data structure is the destination link node, and when the link data structure is a single branch structure formed by two or more link nodes, the last link node for forming the link data structure is the destination link node. The data corresponding to the link data structure at least comprises the query address of the destination link node and the address data corresponding to the link data structure. It should be noted that the data corresponding to the link data structure may include not only the query address of the destination link node and the address data corresponding to the link data structure, but also rule configuration identifiers for identifying whether the link data structure configures forwarding rules, operation addresses hitting the current link data structure, structure types of the destination link node, and valid bit numbers of the address data. In general, the data corresponding to the linked data structure may include the element data in table 2 below:
The meaning of the above element data is as follows:
The method comprises the steps of (1) determining whether a forwarding rule is configured in a current link data structure or not according to a rule configuration identifier, wherein the rule configuration identifier is used for indicating whether the forwarding rule is configured in the current link data structure, and determining that the forwarding rule is configured in the current link data structure when the vld is 1;
action_addr is used for indicating that the operation address of the current link data structure is hit;
the type is used for indicating the structure type of the end point link node, when the type is 0, the structure type is indicated as a node data structure, and when the type is 1, the structure type is indicated as a link data structure;
addr, which is used for representing the query address corresponding to the destination link node, and if the query address is the address of the current node, indicating that the matching path has reached the maximum prefix matching operation;
data representing address data corresponding to the linked data structure;
mask, which is used to represent the valid bit number bit corresponding to the address data.
For the dictionary tree, the dictionary tree may include at least one link data structure and a plurality of node data structures connected with the at least one link data structure, wherein the node data structure is a structure corresponding to two next-level nodes, and for the link data structure and the node data structure, the link data structure may be located behind the node data structure, or the link data structure is located between the two node data structures, that is, the next-level node of the node data structure may be a node data structure, a link data structure or a null value, and the next-level node of the link data structure may be a node data structure, a link data structure or a null value.
In addition, for the node data structure, the corresponding data may at least include a rule configuration identifier for identifying whether the node data structure configures a forwarding rule, an operation address hitting the current node data structure, and a structure type and a query address corresponding to each of the two next-level nodes, where the node data structure corresponds to two next-level nodes, and therefore the data corresponding to the node data structure may include element data in the following table 3:
The meaning of the above element data is as follows:
The method comprises the steps of (1) determining whether a forwarding rule is configured in a current node data structure or not according to a rule configuration identifier, wherein the rule configuration identifier is used for indicating whether the forwarding rule is configured in the current node data structure, and determining that the forwarding rule is configured in the current node data structure when the vld is 1;
an action_addr is used for indicating that the operation address of the current node data structure is hit;
the left_type is used for representing the structure type of the next-stage node, when the left_type is 0, the structure type is indicated as a node data structure, and when the left_type is 1, the structure type is indicated as a link data structure;
The left_addr is used for representing the query address of the next-stage node, the query address can be accurately expressed based on the structure type of the next-stage node, and if the query address is the address of the current node, the matching path is indicated to reach the maximum prefix matching operation;
the right_type is used for representing the structure type of the next-level node, when the right_type is 0, the structure type is indicated as a node data structure, and when the right_type is 1, the structure type is indicated as a link data structure;
the right_addr is used for representing the query address of the next-level node, the query address can be accurately expressed based on the structure type of the next-level node, and if the query address is the address of the current node, the matching path is indicated to reach the maximum prefix matching operation.
Step S303, inquiring the dictionary tree, obtaining target matching data corresponding to the data to be processed, and determining a routing forwarding rule corresponding to the data to be processed based on the target matching data.
After the dictionary tree is obtained, analysis matching operation can be performed on the data to be processed based on the dictionary tree, specifically, the data to be processed can be queried from a starting query node of the dictionary tree and based on the link relation of each node of the dictionary tree, target matching data corresponding to the data to be processed is obtained, and a routing forwarding rule corresponding to the data to be processed is determined based on the target matching data. Because the dictionary tree comprises the link data structure, and the link data structure is a single branch structure formed by at least one link node, when the dictionary tree is utilized to carry out matching operation on data to be processed, the link data structure can be used as an integral node to carry out data matching operation, thus the efficiency of route matching operation can be improved, and the quality and the efficiency of accessing the dictionary tree can be effectively improved.
Because the dictionary tree comprises two types of data structures, namely a node data structure and a link data structure, different types of data structures can be correspondingly marked by different matching completions, in some examples, when the node data structure in the dictionary tree needs to be queried, querying the dictionary tree to obtain target matching data corresponding to the data to be processed can comprise querying the node data structure in the dictionary tree to obtain a query address of a next-stage node positioned behind the node data structure, wherein the type of the next-stage node is the node data structure or the link data structure, determining the current query address of the node data structure, and when the query address of the next-stage node is consistent with the current query address, determining the target matching data corresponding to the data to be processed based on the node data structure.
For the dictionary tree, the initial node type of the dictionary tree is often a node data structure, then the dictionary tree can be queried based on the node data structure, specifically, the node data structure in the dictionary tree can be queried, the next node behind the node data structure and the query address of the next node can be acquired based on the data corresponding to the node data structure, wherein the next node is of the node data structure or the link data structure, then the current query address of the node data structure can be determined, the current query address and the query address of the next node are analyzed and compared, when the query address of the next node is consistent with the current query address, the operation of the query dictionary tree at the moment is demonstrated to complete the longest prefix matching operation, then the target matching data corresponding to the data to be processed can be determined based on the current node data structure, the target matching data can be the operation address of the current node data structure, then the route matching rule corresponding to the data to be processed can be determined based on the obtained target matching data, and the reliability of the route matching rule is effectively ensured.
In other examples, when a link data structure in a dictionary tree needs to be queried, querying the dictionary tree to obtain target matching data corresponding to the data to be processed may include querying the link data structure in the dictionary tree, determining a current query address of the link data structure and a query address of a destination link node in the link data structure, and determining the target matching data corresponding to the data to be processed based on the link data structure when the query address of the destination link node is the same as the current query address.
Because the dictionary tree comprises the link data structure, in the process of carrying out route matching operation, the link data structure in the dictionary tree can be queried, then the current query address of the link data structure and the query address of the destination link node in the link data structure can be determined, the current query address of the link data structure and the query address of the destination link node are analyzed and compared, when the current query address of the link data structure is consistent with the query address of the destination link node, the operation of the query dictionary tree at the moment is proved to have completed the longest prefix matching operation, further, the target matching data corresponding to the data to be processed can be determined based on the current link data structure, the target matching data can be the operation address hitting the current link data structure, then the route matching rule corresponding to the data to be processed can be determined based on the obtained target matching data, and thus the accuracy and the reliability of determining the route matching rule are effectively ensured.
According to the route matching method, the dictionary tree used for matching the data to be processed is determined by acquiring the data to be processed, and the data to be processed is matched based on the dictionary tree, and because the dictionary tree comprises the link data structure which is a single branch structure formed by at least one link node, when the dictionary tree is queried, the link data structure can be used as an integral node for carrying out data matching operation, so that the number of query nodes in the dictionary tree and the node query times of the dictionary tree are reduced, the efficiency of route matching operation and the quality and the efficiency of accessing the dictionary tree are improved, the accuracy and the reliability of determining the route forwarding rule corresponding to the data to be processed are ensured, and the practicability of the method is further ensured.
Fig. 5 is a schematic flow chart of another route matching method according to an embodiment of the present invention, and on the basis of any one of the foregoing embodiments, referring to fig. 5, the present embodiment provides a technical solution for flexibly deleting a node in a dictionary tree, and specifically, the method in this embodiment may further include:
Step S501, obtaining nodes to be deleted aiming at the dictionary tree.
And step S502, when the node to be deleted is a node data structure, adjusting rule configuration identifiers and operation addresses corresponding to the node to be deleted so as to realize the deletion operation of the node to be deleted.
For the dictionary tree, a user can flexibly adjust the dictionary tree according to requirements, for example, when the node deletion requirement exists for the dictionary tree, the node to be deleted for the dictionary tree can be obtained, in some examples, the node to be deleted can be determined through man-machine interaction operation, or the node to be deleted can be determined through the aging information of the node, at the moment, the obtaining of the node to be deleted for the dictionary tree can comprise the steps of obtaining the aging information of each node in the dictionary tree, when the aging information identification node is an effective node, determining that the node corresponding to the aging information is a non-deleted node, and when the aging information identification node is an ineffective node, determining that the node corresponding to the aging information is the node to be deleted, so that the accuracy and the reliability of obtaining the node to be deleted are effectively realized.
For the dictionary tree, since the nodes with different structure types have different connection relations, after the node to be deleted is obtained, in order to stably implement the node deletion operation, the structure type of the node to be deleted may be identified first, and specifically, the structure type of the node to be deleted may be determined by analyzing and processing element data corresponding to the node to be deleted. Referring to fig. 6, when the node to be deleted is a node data structure, since the node data structure corresponds to two next-level nodes, in order to accurately implement the node deletion operation and reduce the influence degree of the node deletion operation on the dictionary tree as much as possible, the rule configuration identifier and the operation address corresponding to the node to be deleted can be adjusted to implement the node to be deleted.
In some examples, the adjustment through the rule configuration identifier and the operation address corresponding to the node to be deleted may include adjusting the rule configuration identifier to be used for identifying the first identifier not configured with the forwarding rule, and adjusting the operation address to be a null value, so that the node to be deleted is determined to be an invalid node through the adjusted rule configuration identifier and the operation address, that is, the deletion operation of the node to be deleted is equivalent to being realized.
Correspondingly, when the node to be deleted is a link data structure, whether the node to be deleted corresponds to a next level node can be identified, if the node to be deleted does not correspond to the next level node, the node to be deleted and the connection edges between the node to be deleted and other nodes can be directly deleted, as shown in fig. 7, when the node a in the dictionary tree is the node to be deleted, the edge a corresponding to the node a and the node a can be directly deleted, so that the node deleting operation of the dictionary tree is realized, and when the node to be deleted is the link data structure and the node to be deleted corresponds to the next level node, for example, when the node b is the node to be deleted, in order to reduce the influence degree of the deleting operation of the node on the dictionary tree as much as possible, the rule configuration identifier and the operation address corresponding to the node b to be deleted can be adjusted, so that the deleting operation of the node to be deleted is realized.
In this embodiment, by acquiring the node to be deleted for the dictionary tree, when the node to be deleted is a node data structure, the rule configuration identifier and the operation address corresponding to the node to be deleted are adjusted, so as to implement the deletion operation of the node to be deleted, effectively implement the flexible deletion operation of the nodes in the dictionary tree, and then perform the route matching operation based on the updated dictionary tree, thereby ensuring the accuracy and reliability of the route matching operation.
Fig. 8 is a flow chart of another route matching method according to an embodiment of the present invention, and on the basis of any one of the foregoing embodiments, referring to fig. 8, the present embodiment provides a technical solution for flexibly adding nodes in a dictionary tree, and specifically, the method in this embodiment may further include:
step S801, obtaining nodes to be added aiming at the dictionary tree.
Step S802, determining an adding position of a node to be added and at least one associated node which interacts with the node to be added in the dictionary tree.
Step 803, adding the node to be added to the dictionary tree based on the adding position, and adjusting partial data corresponding to at least one associated node to generate an adjusted dictionary tree.
For the dictionary tree, a user may perform an adding operation of a node to the dictionary tree according to a requirement, for example, when there is an increasing requirement for the node to the dictionary tree, a node to be added to the dictionary tree may be acquired, and in some examples, the node to be added may be determined through a man-machine interaction operation. After the node to be added is obtained, in order to accurately realize node adding operation, the adding position of the node to be added and at least one associated node which is interacted with the node to be added can be determined in the dictionary tree, wherein the adding position can be determined through man-machine interaction operation, the at least one associated node which is interacted with the node to be added can be determined through the structure information of the dictionary tree and the adding position of the node to be added, and therefore the accuracy and the reliability of determining the adding position of the node to be added and the at least one associated node are effectively ensured.
After determining the adding position of the node to be added and at least one associated node which is mutually influenced by the node to be added, the node to be added can be added into the dictionary tree based on the adding position, and in order to ensure the parameter expression accuracy of each node in the dictionary tree, partial data corresponding to the at least one associated node can be adjusted, so that an adjusted dictionary tree can be generated, and the node adding operation of the dictionary tree is effectively realized.
For example, as shown in fig. 9, after the adding position of the node a to be added is the node 9, since the node 9 of the adding position is the end node of the dictionary tree, based on the adding position and the structure of the dictionary tree, it may be determined that at least one associated node that interacts with the node a to be added may include the node 5 and the node 9, and then the above-mentioned partial data of the node 5 and the node 9 may be adjusted, where the partial data may include an operation address action_addr for indicating that the current link data structure is hit, a query address addr for indicating that the end link node corresponds, address data for indicating that the link data structure corresponds, a valid bit number mask for indicating that the address data corresponds, and so on, so that the node adding operation of the dictionary tree is implemented.
For example 2, after the adding location of the node b to be added is the node 10, since the node 10 of the adding location is an intermediate node of the dictionary tree, based on the above adding location and the structure of the dictionary tree, it may be determined that at least one associated node that interacts with the node b to be added may include the node 10, and then the above partial data of the node 10 may be adjusted, where the partial data may include a structure type for representing a destination link node, a structure type corresponding to each of two next-level nodes, and a query address (left_type, left_addr, right_type, and right_addr), from which it is known that different adding locations and structures of the dictionary tree may determine different associated nodes corresponding to the node to be added, so that the node adding operation of the dictionary tree is implemented.
In the embodiment, by acquiring the node to be added for the dictionary tree, determining the adding position of the node to be added and at least one associated node which is mutually influenced by the node to be added in the dictionary tree, adding the node to be added to the dictionary tree based on the adding position, adjusting partial data corresponding to the at least one associated node, generating the adjusted dictionary tree, effectively realizing node adding operation on the dictionary tree, and then carrying out route matching operation based on the adjusted dictionary tree, thereby ensuring the accuracy and reliability of the route matching operation.
Fig. 10 is a schematic structural diagram of a route matching device according to an embodiment of the present invention, and referring to fig. 10, this embodiment provides a route matching device, which may be used to execute the route matching method shown in fig. 3, and the route matching device may include:
A first acquiring module 11, configured to acquire data to be processed;
The first determining module 12 is configured to determine a dictionary tree for matching data to be processed, where the dictionary tree includes at least one link data structure, the link data structure is a single branch structure formed by at least two link nodes, and data corresponding to the link data structure at least includes a query address of a destination link node and address data corresponding to the link data structure;
the first processing module 13 is configured to query the dictionary tree, obtain target matching data corresponding to the data to be processed, and determine a routing forwarding rule corresponding to the data to be processed based on the target matching data.
In some examples, the data corresponding to the linked data structure further includes:
a rule configuration identifier for identifying whether the link data structure configures forwarding rules;
Hit the operation address of the current link data structure;
the structure type of the end point link node;
The number of valid bits of the address data.
In some examples, the dictionary tree further includes a plurality of node data structures connected to the at least one link data structure, the node data structures corresponding to two next level nodes.
In some examples, the data corresponding to the node data structure includes at least:
A rule configuration identifier for identifying whether the node data structure configures forwarding rules;
hit the operation address of the current node data structure;
the two next-stage nodes respectively correspond to the structure types and query addresses.
In some examples, the link data structure may be located after the node data structure, or the link data structure may be located between two node data structures.
In some examples, the first acquisition module 11 and the first processing module 13 in the present embodiment are configured to perform the following steps:
a first obtaining module 11, configured to obtain a node to be deleted for a dictionary tree;
And the first processing module 13 is configured to adjust the rule configuration identifier and the operation address corresponding to the node to be deleted when the node to be deleted is in the node data structure, so as to implement the deletion operation of the node to be deleted.
In some examples, when the first processing module 13 adjusts the rule configuration identifier and the operation address corresponding to the node to be deleted, the first processing module 13 is configured to execute adjustment of the rule configuration identifier to a first identifier for identifying that the forwarding rule is not configured, and adjust the operation address to a null value.
In some examples, the first acquisition module 11, the first determination module 12, and the first processing module 13 in the present embodiment are configured to perform the following steps:
A first obtaining module 11, configured to obtain a node to be added for the dictionary tree;
A first determining module 12, configured to determine, in the dictionary tree, an adding position of a node to be added and at least one associated node that interacts with the node to be added;
the first processing module 13 is configured to add the node to be added to the dictionary tree based on the adding position, and adjust a portion of data corresponding to at least one associated node, so as to generate an adjusted dictionary tree.
In some examples, when the first processing module 13 queries the dictionary tree to obtain target matching data corresponding to the data to be processed, the first processing module 13 is configured to perform querying a node data structure in the dictionary tree to obtain a query address of a next level node located after the node data structure, where the next level node is of a node data structure or a link data structure, determine a current query address of the node data structure, and determine target matching data corresponding to the data to be processed based on the node data structure when the query address of the next level node is consistent with the current query address.
In some examples, when the first processing module 13 queries the dictionary tree to obtain target matching data corresponding to the data to be processed, the first processing module 13 is configured to perform querying a link data structure in the dictionary tree, determining a current query address of the link data structure and a query address of a destination link node in the link data structure, and determining target matching data corresponding to the data to be processed based on the link data structure when the query address of the destination link node is the same as the current query address.
The apparatus of fig. 10 may perform the method of the embodiment of fig. 2-9, and reference is made to the relevant description of the embodiment of fig. 2-9 for parts of this embodiment not described in detail. The implementation process and the technical effect of this technical solution are described in the embodiments shown in fig. 2 to 9, and are not described herein.
In one possible design, the route matching device shown in fig. 10 may be implemented as an electronic device, which may be a controller, a personal computer, a server, a network card, etc., and as shown in fig. 11, the electronic device may include a first processor 21 and a first memory 22. The first memory 22 is used for storing a program for executing the route matching method provided in the embodiment shown in fig. 2 to 9 described above for the corresponding electronic device, and the first processor 21 is configured to execute the program stored in the first memory 22.
The program comprises one or more computer instructions, wherein the one or more computer instructions when executed by the first processor 21 are capable of performing the steps of obtaining data to be processed, determining a dictionary tree for matching the data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least one link node, the data corresponding to the link data structure at least comprises a query address of a destination link node and address data corresponding to the link data structure, querying the dictionary tree, obtaining target matching data corresponding to the data to be processed, and determining a routing forwarding rule corresponding to the data to be processed based on the target matching data.
Further, the first processor 21 is further configured to perform all or part of the steps in the embodiments shown in fig. 2-9.
The electronic device may further include a first communication interface 23 in a structure for the electronic device to communicate with other devices or a communication network.
In addition, an embodiment of the present invention provides a computer storage medium storing computer software instructions for an electronic device, which includes a program for executing the route matching method in the embodiment shown in fig. 2 to fig. 9.
Furthermore, embodiments of the present invention provide a computer program product comprising a computer-readable storage medium storing computer instructions that, when executed by one or more processors, cause the one or more processors to perform the steps in the route matching method in the method embodiments shown in FIGS. 2-9, described above.
Fig. 12 is a schematic structural diagram of a network card according to an embodiment of the present invention, and referring to fig. 12, this embodiment provides a network card, where the network card may execute the route matching method shown in fig. 3, and specifically, the network card may include:
A processing module 31, configured to obtain data to be processed;
The rule storage module 32 is in communication connection with the processing module 31, and the rule storage module 32 stores a dictionary tree for matching data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least two link nodes, and data corresponding to the link data structure at least comprises a query address of a terminal link node and address data corresponding to the link data structure;
the processing module 31 is further configured to determine, through the rule storage module 32, a dictionary tree for matching data to be processed, query the dictionary tree, obtain target matching data corresponding to the data to be processed, and determine a routing forwarding rule corresponding to the data to be processed based on the target matching data.
The number of the processing modules 31 included in the network card may be plural, for example: the plurality of processing modules 31 may include a processing module 0, a processing module 1..the processing module n-1, where the processing module 31 is configured to perform a route matching operation on data to be processed, and since the number of the processing modules 31 is plural, in different application scenarios, the processing modules 31 may have different loads, so as to ensure quality and efficiency of analysis processing on the data to be processed, the network card may further include a scheduling module 30, where the scheduling module 30 is communicatively connected to the multiple processing modules 31, and is configured to select a target processing module for performing analysis processing on data to be processed from the multiple processing modules 31, where selection logic of the processing modules 31 may be load balancing logic, so that accuracy and reliability of determining the target processing module are effectively ensured.
In particular, the specific implementation manner and implementation principle of each step executed by the processing module 31 and the rule storage module 32 are similar to those of the route matching method in the embodiment shown in fig. 3, and reference may be made to the statement content of the embodiment shown in fig. 3, and to the relevant description of the embodiment shown in fig. 3 for the details of this embodiment. The technical effects of this technical solution are described in the embodiment shown in fig. 3, and are not described here again.
In other examples, to improve the quality and efficiency of the data processing operation performed by the network card, the rule storage module 32 in the network card may include a plurality of rule buffer units 3201, the dictionary tree is stored in the plurality of rule buffer units 3201 in the form of fragments, and all the dictionary tree fragments in the plurality of rule buffer units 3201 may form a complete dictionary tree. In addition, in order to ensure the quality and efficiency of determining the dictionary tree for matching the data to be processed, each rule buffer unit 3201 may be correspondingly connected with a buffer scheduling unit 3202 in a communication manner, where the buffer scheduling unit 3202 is located between the processing module 31 and the rule buffer unit 3201, so that the processing module 31 may obtain the dictionary tree segments stored in the corresponding rule buffer unit 3201 through the buffer scheduling unit 3202, and in the process of performing the matching operation of the routing forwarding rule based on the dictionary tree, the matching operation of the routing forwarding rule based on the dictionary tree segments in the rule buffer units 3201 may be synchronized, so that the matching quality and efficiency of the routing forwarding rule may be effectively improved.
In still other examples, the number of data to be processed may be one or more, so as to ensure that the data to be processed is stably and sequentially subjected to the route matching operation, the processing module 31 in the network card in this embodiment may be further configured to generate a data packet sequence number corresponding to the data to be processed, where the data packet sequence number may be determined by the processing module 31 with respect to a data receiving time of the data to be processed, and then the data packet sequence number may be stored in association with the data to be processed.
In other examples, in order to accurately output the route matching rule after the matching operation on the data to be processed, the network card in this embodiment may further include an output order-preserving module 33 communicatively connected to the processing module 31, configured to cache the route matching rule corresponding to the data to be processed, and output the route matching rule according to the data packet sequence number of the data to be processed, so that it is effectively achieved that the route matching rule can be sequentially output according to the sequence corresponding to the data packet sequence number, and then the analysis processing operation can be performed on the data to be processed based on the sequentially output route matching rule, which is beneficial to improving the quality and efficiency of data processing.
In particular, when there is a route matching requirement of the data to be processed, the scheduling module 30 in the network card may obtain the data to be processed, where the data to be processed may refer to common information in a network packet, for example, a destination ip address, after the scheduling module 30 obtains the data to be processed, one target processing module 31 for analyzing and processing the data to be processed may be selected from the multiple processing modules 31, where the target processing module 31 may be a processing module 31 in an idle state or with a low load degree from the multiple processing modules 31, and after the target processing module 31 obtains the data to be processed, the data to be processed may be marked with a sequence number, where the sequence number is used to identify a receiving sequence of the data to be processed, that is, may be implemented as a packet sequence number PSN.
After the target processing module 31 obtains the data to be processed, a dictionary tree for matching the data to be processed may be determined by the rule storage module 32, then rule matching may be performed on the data to be processed based on the dictionary tree to determine a routing forwarding rule corresponding to the data to be processed and subjected to longest prefix matching, and then the routing forwarding rule may be sent to the output order keeping module 33 by the target processing module 31, so that the output order keeping module 33 may obtain the routing forwarding rule corresponding to the data to be processed and cache the routing forwarding rule. And then, the routing forwarding rule can be sequentially output based on the sequence number corresponding to the data to be processed, so that the output sequence of the routing forwarding rule is consistent with the receiving sequence corresponding to the data to be processed, and the quality and the efficiency of analyzing and processing the data to be processed are improved.
For example, the dictionary tree includes the data in the following two data tables (including table 4 and table 5), and then the matching operation is performed on the data to be processed based on the dictionary tree, specifically, determining the routing forwarding rule corresponding to the data to be processed may include the following processes:
For example, when the data to be processed is binary data "1000" with a significant bit of 4, the query flow of the routing forwarding rule of the data to be processed includes the following procedures:
1) Firstly, inquiring an entry address addr '0' of a fixed dictionary tree to obtain node data of the address 0, wherein the node is not configured with a forwarding rule, so that no rule is hit currently;
2) Based on the 1 st bit "1" in the data to be matched, inquiring the right branch of the dictionary tree, further inquiring the data "right_type" and "right_addr" corresponding to the right branch in the dictionary tree, determining that the next node is required to inquire the address as "2", analyzing the data corresponding to the inquiry address as "2" according to the node data structure, and determining that the operation address of the current hit rule is "3";
3) Based on the 2 nd bit "0" in the data to be matched, the left branch of the dictionary tree is queried, and then the left_type and the left_addr of the address "2" can be queried for analysis, the query address of the next node can be determined to be "5", and the returned data is analyzed according to the link data structure.
4) After obtaining a link data structure by inquiring an address '5', finding that the link data structure matches 2 bits, the data is '00', wherein the data is the same as the data of the 2 nd bit and the 3 rd bit in the data to be processed, namely that the routing forwarding rule of the link data structure is successfully matched, the execution address of the hit forwarding rule is '4', and meanwhile, as the next node address of the link data structure is '5', namely the link data structure is self, the fact that no longer rule can be matched later is shown, namely that the longest prefix matching operation is finished, if the next node address of the link data structure is not '5', the rule matching operation can be continuously searched for until the longest prefix matching operation is finished, and then the routing forwarding rule corresponding to the data to be processed can be obtained, and then the data to be processed can be forwarded based on the routing forwarding rule, so that the forwarding operation of the data to be processed is finished.
The network card provided by the embodiment effectively realizes the routing matching operation based on the dictionary tree formed by the node data structure and the link data structure, and at least one link node included in the link data structure can be used as an integral structure, so that the efficiency of the routing matching operation can be effectively improved when the dictionary tree is based on rule matching, and when the data of the dictionary tree is stored, the link structure data can be stored as a whole node data structure, so that the storage resources required by the dictionary tree can be reduced, in addition, the concurrent access operation of a plurality of operation cores and a plurality of rule cache units 3201 to the dictionary tree is realized through a plurality of processing modules 31 and a plurality of rule cache units 3201 configured in a gateway, the access bandwidth of the cache is effectively improved, and the data processing operation of the network card has the advantage of high processing bandwidth, so that the high performance development trend of hardware is facilitated, and the practicability of the scheme is further improved.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the embodiments of the present application are information and data authorized by the user or fully authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region, and provide a corresponding operation entry for the user to select authorization or rejection.
The apparatus embodiments described above are merely illustrative, wherein elements illustrated as separate elements may or may not be physically separate, and elements shown as elements may or may not be physical elements, may be located in one place, or may be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the objective of the embodiment. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
From the above description of the embodiments, it will be apparent to those skilled in the art that the embodiments may be implemented by adding necessary general purpose hardware platforms, or may be implemented by a combination of hardware and software. Based on such understanding, the foregoing aspects, in essence and portions contributing to the art, may be embodied in the form of a computer program product, which may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flowchart illustrations and/or block diagrams, and combinations of flows and/or blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks. These computer program instructions may also be loaded onto a computer or other programmable apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks. In one typical configuration, a computing device includes one or more processors (CPUs), input/output interfaces, network interfaces, and memory. The memory may include volatile memory in a computer-readable medium, random Access Memory (RAM) and/or nonvolatile memory, such as Read Only Memory (ROM) or flash memory (flash RAM). Memory is an example of computer-readable media.
Computer readable media, including both non-transitory and non-transitory, removable and non-removable media, may implement information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of storage media for a computer include, but are not limited to, phase change memory (PRAM), static Random Access Memory (SRAM), dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), read Only Memory (ROM), electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices, or any other non-transmission medium, which can be used to store information that can be accessed by a computing device. Computer-readable media, as defined herein, does not include transitory computer-readable media (transmission media), such as modulated data signals and carrier waves.
It should be noted that the above-mentioned embodiments are merely for illustrating the technical solution of the present invention, and not for limiting the same, and although the present invention has been described in detail with reference to the above-mentioned embodiments, it should be understood by those skilled in the art that the technical solution described in the above-mentioned embodiments may be modified or some technical features may be equivalently replaced, and these modifications or substitutions do not make the essence of the corresponding technical solution deviate from the spirit and scope of the technical solution of the embodiments of the present invention.
Claims (16)
1. A method of route matching, comprising:
Acquiring data to be processed;
Determining a dictionary tree for matching the data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least one link node, and the data corresponding to the link data structure at least comprises a query address of a destination link node and address data corresponding to the link data structure;
Querying the dictionary tree, obtaining target matching data corresponding to the data to be processed, and determining a routing forwarding rule corresponding to the data to be processed based on the target matching data;
the method for inquiring the dictionary tree to obtain target matching data corresponding to the data to be processed comprises the following steps:
querying a link data structure in the dictionary tree;
Determining a current query address of the link data structure and a query address of an end point link node in the link data structure;
And when the query address of the terminal link node is the same as the current query address, determining target matching data corresponding to the data to be processed based on the link data structure.
2. The method of claim 1, wherein the data corresponding to the link data structure further comprises:
a rule configuration identifier for identifying whether the link data structure configures forwarding rules;
Hit the operation address of the current link data structure;
the structure type of the end point link node;
The number of valid bits of the address data.
3. The method of claim 1, wherein the data corresponding to the node data structure comprises at least:
A rule configuration identifier for identifying whether the node data structure configures forwarding rules;
hit the operation address of the current node data structure;
the two next-stage nodes respectively correspond to the structure types and query addresses.
4. The method of claim 1, wherein the link data structure is located after the node data structure or the link data structure is located between two node data structures.
5. A method according to claim 2 or 3, characterized in that the method further comprises:
acquiring nodes to be deleted aiming at the dictionary tree;
And when the node to be deleted is in a node data structure, adjusting the rule configuration identifier and the operation address corresponding to the node to be deleted so as to realize the deletion operation of the node to be deleted.
6. The method of claim 5, wherein adjusting the rule configuration identifier and the operation address corresponding to the node to be deleted comprises:
and adjusting the rule configuration identifier to be a first identifier for identifying that forwarding rules are not configured, and adjusting the operation address to be a null value.
7. The method according to any one of claims 1-4, further comprising:
acquiring nodes to be added aiming at the dictionary tree;
Determining the adding position of the node to be added and at least one associated node which is interacted with the node to be added in the dictionary tree;
and adding the node to be added to the dictionary tree based on the adding position, and adjusting partial data corresponding to the at least one associated node to generate an adjusted dictionary tree.
8. The method according to any one of claims 1-4, wherein querying the dictionary tree to obtain target matching data corresponding to the data to be processed comprises:
Inquiring a node data structure in the dictionary tree to obtain an inquiry address of a next-level node positioned behind the node data structure, wherein the type of the next-level node is a node data structure or a link data structure;
determining a current query address of the node data structure;
and when the query address of the next-stage node is consistent with the current query address, determining target matching data corresponding to the data to be processed based on the node data structure.
9. A route matching device, comprising:
the first acquisition module is used for acquiring data to be processed;
The first determining module is used for determining a dictionary tree for matching the data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least two link nodes, and the data corresponding to the link data structure at least comprises a query address of a terminal link node and address data corresponding to the link data structure;
The first processing module is used for inquiring the dictionary tree, obtaining target matching data corresponding to the data to be processed, and determining a routing forwarding rule corresponding to the data to be processed based on the target matching data;
The first processing module is further configured to query a link data structure in the dictionary tree, determine a current query address of the link data structure and a query address of a destination link node in the link data structure, and determine target matching data corresponding to the data to be processed based on the link data structure when the query address of the destination link node is the same as the current query address.
10. A network card, comprising:
The processing module is used for acquiring data to be processed;
The rule storage module is in communication connection with the processing module, and stores a dictionary tree for matching the data to be processed, wherein the dictionary tree comprises at least one link data structure, the link data structure is a single branch structure formed by at least two link nodes, and data corresponding to the link data structure at least comprises a query address of a terminal link node and address data corresponding to the link data structure;
The processing module is further used for determining a dictionary tree for matching the data to be processed through the rule storage module, inquiring the dictionary tree, obtaining target matching data corresponding to the data to be processed, and determining a routing forwarding rule corresponding to the data to be processed based on the target matching data;
The processing module is further configured to query a link data structure in the dictionary tree, determine a current query address of the link data structure and a query address of a destination link node in the link data structure, and determine target matching data corresponding to the data to be processed based on the link data structure when the query address of the destination link node is the same as the current query address.
11. The network card of claim 10, wherein the number of processing modules is a plurality of, wherein the rule storage module includes a plurality of rule cache units, and wherein the dictionary tree is stored in the plurality of rule cache units in the form of fragments.
12. The network card of claim 10, wherein the processing module is further configured to:
generating a data packet serial number corresponding to the data to be processed;
and carrying out association storage on the data packet serial number and the data to be processed.
13. The network card of claim 12, wherein the network card further comprises:
And the output order-preserving module is in communication connection with the processing module and is used for caching the route matching rule corresponding to the data to be processed and outputting the route matching rule according to the data packet serial number of the data to be processed.
14. An electronic device comprising a memory and a processor, wherein the memory is configured to store one or more computer instructions, wherein the one or more computer instructions when executed by the processor implement the method of any of claims 1-8.
15. A computer storage medium storing a computer program which when executed by a computer performs the method of any one of claims 1 to 8.
16. A computer program product comprising a computer program which, when executed by a processor of an electronic device, causes the processor to perform the steps of the method of any of the preceding claims 1-8.
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411825159.7A CN119299368B (en) | 2024-12-11 | 2024-12-11 | Route matching method, device, equipment, network card and computer program product |
Applications Claiming Priority (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN202411825159.7A CN119299368B (en) | 2024-12-11 | 2024-12-11 | Route matching method, device, equipment, network card and computer program product |
Publications (2)
| Publication Number | Publication Date |
|---|---|
| CN119299368A CN119299368A (en) | 2025-01-10 |
| CN119299368B true CN119299368B (en) | 2025-03-11 |
Family
ID=94155205
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| CN202411825159.7A Active CN119299368B (en) | 2024-12-11 | 2024-12-11 | Route matching method, device, equipment, network card and computer program product |
Country Status (1)
| Country | Link |
|---|---|
| CN (1) | CN119299368B (en) |
Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107609032A (en) * | 2017-08-09 | 2018-01-19 | 联动优势科技有限公司 | A kind of matching process and electronic equipment |
| CN107862026A (en) * | 2017-10-31 | 2018-03-30 | 北京小度信息科技有限公司 | Date storage method and device, data query method and device, electronic equipment |
Family Cites Families (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107590258B (en) * | 2017-09-20 | 2020-04-28 | 杭州安恒信息技术股份有限公司 | Keyword matching method and device |
| CN109670163B (en) * | 2017-10-17 | 2023-03-28 | 阿里巴巴集团控股有限公司 | Information identification method, information recommendation method, template construction method and computing device |
| US10747783B2 (en) * | 2017-12-14 | 2020-08-18 | Ebay Inc. | Database access using a z-curve |
| CN112559717B (en) * | 2020-12-24 | 2024-08-30 | 北京百度网讯科技有限公司 | Search matching method, device, electronic device and storage medium |
| US12425341B2 (en) * | 2021-09-06 | 2025-09-23 | Ethernity Networks | Longest prefix matching |
| CN117539987A (en) * | 2023-10-24 | 2024-02-09 | 百度国际科技(深圳)有限公司 | A keyword search method, device, electronic equipment and medium |
| CN117473133A (en) * | 2023-10-27 | 2024-01-30 | 支付宝(杭州)信息技术有限公司 | A dense state data query method, device, storage medium and electronic equipment |
-
2024
- 2024-12-11 CN CN202411825159.7A patent/CN119299368B/en active Active
Patent Citations (2)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN107609032A (en) * | 2017-08-09 | 2018-01-19 | 联动优势科技有限公司 | A kind of matching process and electronic equipment |
| CN107862026A (en) * | 2017-10-31 | 2018-03-30 | 北京小度信息科技有限公司 | Date storage method and device, data query method and device, electronic equipment |
Also Published As
| Publication number | Publication date |
|---|---|
| CN119299368A (en) | 2025-01-10 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US11811660B2 (en) | Flow classification apparatus, methods, and systems | |
| US9077669B2 (en) | Efficient lookup methods for ternary content addressable memory and associated devices and systems | |
| CN109829287A (en) | Api interface permission access method, equipment, storage medium and device | |
| US9270636B2 (en) | Neighbor lookup operations in a network node | |
| CN111510478B (en) | Request processing method, device and system and electronic equipment | |
| CN105227386B (en) | For dividing the method, apparatus and system of population statistics online user number | |
| US11683316B2 (en) | Method and device for communication between microservices | |
| CN104579970B (en) | A policy matching device for IPv6 packets | |
| US20120078970A1 (en) | Performance of Hash Tables | |
| CN107679148A (en) | Session lookup method, device and the equipment of a kind of distributed file system | |
| US12132653B2 (en) | Method and device for processing routing table entries | |
| WO2015131720A1 (en) | Packet processing method and device | |
| CN110855810B (en) | NAT (network Address translation) conversion method and device, network security equipment and storage medium | |
| CN114338529B (en) | Five-tuple rule matching method and device | |
| CN119299368B (en) | Route matching method, device, equipment, network card and computer program product | |
| CN113572747B (en) | IP address processing method, device, storage medium and processor | |
| CN108111422B (en) | DPDK-based data high-speed multi-path forwarding method and device | |
| CN117453380B (en) | Cluster container group scheduling method, system and computer equipment | |
| CN113596098A (en) | Session retrieval method, device, equipment and computer-readable storage medium | |
| CN116600031B (en) | Message processing method, device, equipment and storage medium | |
| CN117749762B (en) | DNS access request processing method, device, equipment and storage medium | |
| CN115996203B (en) | Network traffic domain division method, device, equipment and storage medium | |
| US20160337232A1 (en) | Flow-indexing for datapath packet processing | |
| CN117579547A (en) | Message routing acceleration method, device, main equipment and medium | |
| CN111106982B (en) | Information filtering method and device, electronic equipment and storage medium |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| PB01 | Publication | ||
| PB01 | Publication | ||
| SE01 | Entry into force of request for substantive examination | ||
| SE01 | Entry into force of request for substantive examination | ||
| GR01 | Patent grant | ||
| GR01 | Patent grant |