CN117294647A - Binary tree-based table lookup method, binary tree-based table lookup device, binary tree-based table lookup equipment, storage medium and vehicle - Google Patents

Binary tree-based table lookup method, binary tree-based table lookup device, binary tree-based table lookup equipment, storage medium and vehicle Download PDF

Info

Publication number
CN117294647A
CN117294647A CN202210689374.3A CN202210689374A CN117294647A CN 117294647 A CN117294647 A CN 117294647A CN 202210689374 A CN202210689374 A CN 202210689374A CN 117294647 A CN117294647 A CN 117294647A
Authority
CN
China
Prior art keywords
address
node
port
binary tree
target
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.)
Pending
Application number
CN202210689374.3A
Other languages
Chinese (zh)
Inventor
李吉生
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Co Wheels Technology Co Ltd
Original Assignee
Beijing Co Wheels Technology Co Ltd
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by Beijing Co Wheels Technology Co Ltd filed Critical Beijing Co Wheels Technology Co Ltd
Priority to CN202210689374.3A priority Critical patent/CN117294647A/en
Publication of CN117294647A publication Critical patent/CN117294647A/en
Pending legal-status Critical Current

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L45/00Routing or path finding of packets in data switching networks
    • H04L45/74Address processing for routing
    • H04L45/745Address table lookup; Address filtering

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Small-Scale Networks (AREA)

Abstract

The disclosure relates to a binary tree-based table lookup method, a binary tree-based table lookup device, binary tree-based table lookup equipment, binary tree-based medium and binary tree-based vehicle, wherein the binary tree-based table lookup method comprises the following steps: in the binary tree, an address stored in a first child node of a father node is smaller than an address stored in the father node, an address stored in a second child node of the father node is larger than the address stored in the father node, and data information is acquired, wherein the data information comprises information of a target address; querying the binary tree based on the target address, and continuously querying a first child node of a father node when the target address is smaller than a first address stored in the father node in the binary tree, or continuously querying a second child node of the father node when the target address is larger than the first address; and responding to the inquiry of the target node storing the target address, and acquiring a port corresponding to the target address from the target node. The query speed is improved by querying the port corresponding to the target address in the binary tree node.

Description

Binary tree-based table lookup method, binary tree-based table lookup device, binary tree-based table lookup equipment, storage medium and vehicle
Technical Field
The present disclosure relates to the field of computer technologies, and in particular, to a binary tree-based table lookup method, apparatus, device, storage medium, and vehicle.
Background
Along with the development of internet technology, the application of the network switching special chip is more and more widespread, in the network switching special chip, the port corresponding to the target address is queried in the database, and the data is sent through the port, which has important significance. Currently, table lookup structures for implementing a query on data in a database are mainly divided into three types: binary tree table, hash table or hash table, content addressing table, wherein, binary tree table structure is simplest, but the speed of looking up is slower, therefore, how to improve the efficiency of querying the port corresponding to the target address in binary tree table is the technical problem to be solved.
Disclosure of Invention
In order to solve the technical problems, the present disclosure provides a binary tree-based table lookup method, a binary tree-based table lookup device, a binary tree-based table lookup apparatus, a binary tree-based table lookup device, a binary tree-based storage medium and a binary tree-based vehicle.
A first aspect of an embodiment of the present disclosure provides a binary tree-based table lookup method, the method including:
in the binary tree, an address stored in a first child node of a parent node is smaller than an address stored in the parent node, and an address stored in a second child node of the parent node is larger than an address stored in the parent node, the method comprising:
Acquiring data information, wherein the data information comprises information of a target address;
querying the binary tree based on the target address, and continuously querying a first child node of a father node when the target address is smaller than a first address stored in the father node in the binary tree, or continuously querying a second child node of the father node when the target address is larger than the first address;
and responding to the inquiry of the target node storing the target address, and acquiring a port corresponding to the target address from the target node.
A second aspect of embodiments of the present disclosure provides a binary tree based look-up table device, the device comprising:
in the binary tree, an address stored in a first child node of a parent node is less than an address stored in the parent node, and an address stored in a second child node of the parent node is greater than an address stored in the parent node, comprising:
the first acquisition module is used for acquiring data information, wherein the data information comprises information of a target address;
the query module is used for querying the binary tree based on the target address, and continuously querying a first child node of a father node when the target address is smaller than a first address stored in the father node in the binary tree, or continuously querying a second child node of the father node when the target address is greater than the first address;
And the second acquisition module is used for responding to the inquiry of the target node stored with the target address and acquiring a port corresponding to the target address from the target node.
A third aspect of the disclosed embodiments provides a computer device comprising a memory and a processor, and a computer program, wherein the memory stores the computer program, which when executed by the processor, implements a binary tree based look-up table method as in the first aspect described above.
A fourth aspect of the disclosed embodiments provides a computer readable storage medium having a computer program stored therein, which when executed by a processor, implements a binary tree based look-up method as in the first aspect described above.
A fifth aspect of the disclosed embodiments provides a vehicle comprising a memory and a processor, and a computer program, wherein the memory stores the computer program, which when executed by the processor, implements a binary tree based look-up method as in the first aspect described above.
Compared with the prior art, the technical scheme provided by the embodiment of the disclosure has the following advantages:
in the embodiment of the disclosure, an address stored in a first child node of any father node in a binary tree is smaller than an address stored in the father node, an address stored in a second child node of the father node is larger than an address stored in the father node, target address information to be queried in data information is obtained, the target address information is compared with a first address stored in a father node in a binary tree storage structure, when the target address is smaller than the first address stored in the father node, the comparison is continued in the first child node of the father node, when the target address is larger than the first address stored in the father node, the comparison is continued in the second child node of the father node until a binary tree node storing the target address information is found, a port corresponding to the target address is obtained according to the content stored in the node, and therefore, a node storing the target address information is quickly found in a shortest query path, and the speed of looking up the port information of the binary tree is further improved.
Drawings
The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the disclosure and together with the description, serve to explain the principles of the disclosure.
In order to more clearly illustrate the embodiments of the present disclosure or the solutions in the prior art, the drawings that are required for the description of the embodiments or the prior art will be briefly described below, and it will be obvious to those skilled in the art that other drawings can be obtained from these drawings without inventive effort.
FIG. 1 is a schematic diagram of a binary tree structure provided by an embodiment of the present disclosure;
FIG. 2 is a flow chart of a binary tree based lookup method provided by an embodiment of the present disclosure;
FIG. 3 is a flow chart of a method for querying a binary tree based on a target address provided by an embodiment of the present disclosure;
FIG. 4 is a flow chart of a method for querying a target address in a child node of a binary tree provided by an embodiment of the present disclosure;
fig. 5 is a flow chart of a method of creating and storing information in a binary tree node provided by an embodiment of the present disclosure;
FIG. 6 is a flow chart of a method of transmitting data provided by an embodiment of the present disclosure;
FIG. 7 is a schematic diagram of a binary tree-based lookup table device according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of a computer device according to an embodiment of the present disclosure.
Detailed Description
In order that the above objects, features and advantages of the present disclosure may be more clearly understood, a further description of aspects of the present disclosure will be provided below. It should be noted that, without conflict, the embodiments of the present disclosure and features in the embodiments may be combined with each other.
In the following description, numerous specific details are set forth in order to provide a thorough understanding of the present disclosure, but the present disclosure may be practiced otherwise than as described herein; it will be apparent that the embodiments in the specification are only some, but not all, embodiments of the disclosure.
It should be understood that the various steps recited in the method embodiments of the present disclosure may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the present disclosure is not limited in this respect.
It should be noted that in this document, relational terms such as "first" and "second" and the like are used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Moreover, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one … …" does not exclude the presence of other like elements in a process, method, article, or apparatus that comprises the element.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those of ordinary skill in the art will appreciate that "one or more" is intended to be understood as "one or more" unless the context clearly indicates otherwise.
Currently, table lookup structures for implementing a query on data in a database are mainly divided into three types: binary tree tables, hash tables or hash tables, content-addressed look-up tables. The binary tree table query method generates a binary tree structure according to the database to be queried, stores one data in the database to be queried in each node, and then compares the table to be queried with each node respectively to query the table items equal to the table to be queried. The hash table inquiry method maps a group of keywords to a limited address interval according to a set hash function H (key) and a conflict processing method, and takes the items of the keywords in the address interval as storage positions recorded in a table. The content addressing table look-up is to query all data of the whole table space at the same time, and one query is completed every clock period.
In the three table lookup modes, the binary tree table structure is the simplest, and after the tree structure corresponding to the database is generated, the binary tree table structure is sequentially searched downwards according to the size of the items to be checked, so that a hash function and a conflict processing algorithm in a hash table are not needed, and a comparison interconnection structure between the items to be checked and the internal table items in the content addressing table lookup is not needed. In the current network exchange special chip, a method of combining software and hardware is mostly adopted for realizing the binary tree lookup function, firstly, a special integrated circuit (Integrated Circuit, IC) chip sends data to a processing unit loaded with an ARM processor (Advanced RISC Machines, ARM) or other central processing units (Central Processing Unit, CPU), then the processing unit performs binary tree lookup and inquiry according to items to be checked, and sends the inquiry result to the special IC chip, wherein the generation and inquiry of the binary tree table are realized in the processing unit. However, during the use of this binary tree based look-up method, the applicant found that it still had the following problems: (1) If a processing unit is only used for processing the generation and inquiry of a binary tree table, the processing resource is wasted, and the design and manufacturing cost of the whole network switching equipment is increased; (2) With the progress of the special IC chip design technology and process, the processing speed of the special chip is faster and faster, and the efficiency of realizing the table look-up function in the processing unit is lower, thereby reducing the processing speed of the IC chip.
In summary, how to improve the speed of the table lookup method based on the binary tree is a technical problem to be solved.
In view of the above problems, embodiments of the present disclosure provide a binary tree-based table lookup method, apparatus, device, medium, and vehicle. The binary tree based look-up method is first described in connection with specific embodiments.
Fig. 1 is a schematic diagram of a binary tree according to an embodiment of the present disclosure. As shown in fig. 1, the structure includes nodes 110-116 storing address data, where each node may have at most two child nodes, where node 110 is a parent node with respect to node 111 and node 112, node 111 is a first child node with respect to node 110, node 112 is a second child node with respect to node 110, the address stored in the first child node 111 is less than the address stored in the parent node 110, the address stored in the second child node 112 is greater than the address stored in the parent node 110, node 111 is a parent node with respect to node 113 and node 114, node 113 is a first child node with respect to node 111, node 114 is a second child node with respect to node 111, the address stored in the first child node 113 is less than the address stored in the parent node 111, the address stored in the second child node 114 is greater than the address stored in the parent node 111, node 112 is a first child node with respect to node 115 and node 116, node 115 is a second child node with respect to node 112, the address stored in the first child node 115 is less than the address stored in the second child node 112.
Fig. 2 is a flowchart of a binary tree-based lookup method according to an embodiment of the present disclosure. The method may be performed by a binary tree based look-up device, which may be understood as a network switch chip or as part of the functional blocks in a network switch chip. Wherein the network switch chip includes, but is not limited to, a network switch chip in a communication system or time sensitive network (Timesensitive Network, TSN) of a vehicle.
As shown in fig. 2, the binary tree based look-up method may include the following steps.
S201, acquiring data information, wherein the data information comprises information of a target address.
The data information in the embodiments of the present disclosure may be data information in any format, where the data information may include one or more destination addresses, and in one implementation of the embodiments of the present disclosure, the data information may be illustratively carried in a packet.
The Destination Address in the embodiment of the present disclosure may be understood as a Destination hardware Address (Destination MAC (Medium/Media Access Control, MAC) Address, DMAC), which is a physical Address of Destination hardware of a message to be forwarded in network communication, and when a table lookup device receives a message request to be forwarded, a Destination port corresponding to the Destination Address is queried according to the Destination Address included in the message, and forwarding is performed based on the Destination port corresponding to the Destination Address, so as to implement communication between devices in the network.
The message may be understood as a data unit exchanged and transmitted in the network, and may include an attribute part and a data body part of the message, where the attribute part of the message may include a physical address of the target hardware, that is, a target address.
The data information in the embodiment of the disclosure may be data information obtained in real time according to a received message, for example, the table lookup device may extract data information including a physical address of the target hardware from the message received in real time, so that the table lookup device based on the binary tree may query a port corresponding to the address in the binary tree table.
S202, inquiring the binary tree based on the target address, and continuously inquiring in a first child node of a father node when the target address is smaller than a first address stored in the father node in the binary tree, or continuously inquiring in a second child node of the father node when the target address is larger than the first address.
In an embodiment of the present disclosure, an address stored in a first child node of a parent node in a binary tree is less than an address stored in the parent node, and an address stored in a second child node of the parent node is greater than an address stored in the parent node.
In the embodiment of the present disclosure, a tree may be understood as a set of multiple nodes with a hierarchical relationship, a binary tree may be understood as a tree structure of at most two child nodes (hereinafter referred to as a first child node and a second child node) of a node, and a node having a child node in the binary tree may also be referred to as a parent node of its child node. The first child node of the parent node may be understood as a child node storing an address smaller than the target address stored by the parent node, and the second child node may be understood as a child node storing an address larger than the address stored by the parent node. For convenience of understanding, in the embodiment of the present disclosure, a child node branching to the left of a parent node may be exemplarily used as a first child node, and a child node branching to the right of the parent node may be used as a second child node.
In the embodiment of the disclosure, after the table lookup device obtains the data information including the target address, a parent node may be selected in the binary tree to perform the query, for example, in fig. 1, the target address may be compared with the value of the first address stored in the parent node 110, and when the value of the target address to be queried is smaller than the value of the first address stored in the parent node 110 in the binary tree, the target address is queried in the first child node 111 of the parent node 110 in the binary tree, that is, the value of the target address is continuously compared with the value of the address stored in the first child node 111 of the parent node 110; when the value of the target address to be queried is greater than the value of the first address stored in the father node 110 in the binary tree, the target address is queried in the second child node 112 of the father node 110 in the binary tree, that is, the value of the target address is continuously compared with the value of the address stored in the second child node 112 of the father node 110, and so on, according to the query result of each time, the child node corresponding to the queried father node is used as the father node of the next query, and the query process is continuously performed until the binary tree node corresponding to the target address is found.
In an exemplary implementation manner of the embodiment of the present disclosure, a first parent node in a binary tree queried according to a target address may be a root node without a parent node, after the table lookup device obtains data information including the target address, the target address may be queried in the root node of the binary tree, the value of the target address and the value of the first address stored in the parent node of the binary tree are compared, and a child node to be queried in the next round is determined according to the comparison result.
S203, responding to the inquiry to the target node storing the target address, and acquiring a port corresponding to the target address from the target node.
In the embodiment of the disclosure, the data stored by the nodes in the binary tree may further include a port corresponding to the first address, where the port may be understood as a destination port of a message to be forwarded in network communication, and only if the destination physical address and the destination port of the destination sending address are known at the same time, the message may be sent to the correct destination sending address.
In the embodiment of the disclosure, when the lookup device queries a binary tree node with the value of the stored first address being the same as that of the target address, the binary tree node can be considered as the queried target node with the target address stored therein, and the port corresponding to the first address stored in the target node is taken as the port corresponding to the target address
According to the method and the device, the node of the binary tree is inquired according to the target address contained in the acquired data information in the binary tree, wherein the address stored in the first child node of the father node is smaller than the address stored in the father node, the address stored in the second child node of the father node is larger than the address stored in the father node, when the target address is smaller than the first address stored in the father node in the binary tree, the first child node of the father node is continuously inquired, or when the target address is larger than the first address of the father node, the second child node of the father node is continuously inquired until the target node with the target address stored therein is inquired, the port corresponding to the target address is obtained from the target node, and the port corresponding to the target address to be inquired can improve the speed of port inquiry.
In order to better understand the inventive concepts of the embodiments of the present disclosure, the technical solutions of the embodiments of the present disclosure are described below in conjunction with exemplary embodiments.
Fig. 3 is a flow chart of a method for querying a binary tree based on a target address provided by an embodiment of the present disclosure. As shown in fig. 3, on the basis of the above embodiment, the binary tree can be queried as follows.
S301, obtaining information of a flag bit of a father node in the binary tree.
In the embodiment of the present disclosure, a flag bit may be understood as a data bit for indicating a certain state or information, for example, in the embodiment of the present disclosure, the flag bit may be used to indicate whether data is stored in a current node, and whether there is information such as a child node. For example, the data type of the flag bit may be set according to needs, for example, when the status types represented by the flag bit are only two, the data type of the flag bit information may be 0 or 1, which is only illustrative and not only limited.
In the embodiment of the disclosure, the data stored by the nodes in the binary tree may include the information of the flag bit, and when the binary tree is queried based on the target address, the information of the flag bit of the father node to be queried may be acquired first.
S302, if the information indicated by the flag bit is effective, the first address stored in the father node is compared with the target address.
In the embodiment of the present disclosure, when the obtained flag bit information of the parent node is valid information in the parent node, the table lookup device responds to compare the value of the first address stored in the parent node with the value of the target address to be queried, and the comparison method is the same as the S202 principle, which is not described herein.
In an exemplary implementation manner of the embodiment of the present disclosure, the validity of information in the parent node may be understood as that the parent node stores the first address and the port data corresponding to the first address, where the information of the flag bit is used to indicate whether the parent node stores the first address and the port data corresponding to the first address. For example, in one embodiment, when the value of the flag bit information is 1, it may indicate that the parent node stores the first address and the port data corresponding to the first address, that is, the information in the parent node is valid, and further, the first address stored in the parent node is compared with the target address.
And S303, if the information indicated by the flag bit is invalid in the parent node, storing the information of the source address and the source port to the parent node, and setting the information indicated by the flag bit to be valid.
In the embodiment of the present disclosure, the data information may further include: source address and source port information. The Source Address may be understood as a Source hardware Address (SMAC), which is a Source physical Address of a message received in network communication, and the Source port may be understood as a Source port of a message received in network communication, which corresponds to the Source port.
In the embodiment of the disclosure, when the obtained flag bit information of the parent node is invalid, the table lookup device responds, a source address in the data information to be queried is used as a first address of the parent node, a source port in the data information to be queried is used as a port corresponding to the first address in the parent node, the first address and the port corresponding to the first address are stored in the parent node, and the information indicated by the flag bit of the parent node is set to be valid.
In the embodiment of the disclosure, a storage space may be allocated to each node in advance, where the size of the storage space is determined according to a target address to be stored in a node of a binary tree and a bit width required by a port, and all nodes in the binary tree have storage spaces with the same size.
In an exemplary implementation manner of the embodiment of the present disclosure, the invalidation of the information in the parent node may be understood that the first address and the port data corresponding to the first address are not stored in the parent node, where the information of the flag bit is used to indicate whether the first address and the port data corresponding to the first address are stored in the parent node. For example, in one embodiment, when the value of the flag bit information is 0, it may indicate that the parent node does not store the first address and the port data corresponding to the first address, that is, the information in the parent node is invalid, further, the source address in the data information to be queried is taken as the first address of the parent node, the source port in the data information to be queried is taken as the port corresponding to the first address in the parent node, the information indicated by the flag bit of the parent node is set to be valid, that is, the flag bit information is assigned to be 1, and the first address and the port and the flag bit information corresponding to the first address are stored in the parent node.
According to the method and the device for searching the binary tree, the obtained information of the flag bit of the father node in the binary tree is identified, when the information indicated by the flag bit is effective information in the father node, the response made by the table searching device is to compare the first address stored in the father node with the target address, when the information indicated by the flag bit is ineffective information in the father node, the response made by the table searching device is to store the source address and the information of the source port into the father node, and the information indicated by the flag bit is set to be effective, so that different operations are executed according to the situation corresponding to the father node in the binary tree, when the node in the binary tree does not comprise the target address to be searched, the source address and the source port are added into the node of the binary tree, and then the corresponding port can be found when the source address is used as the target address for searching next time, and the searching speed is further improved.
Fig. 4 is a flow chart of a method for querying a target address in a child node of a binary tree provided by an embodiment of the present disclosure. As shown in fig. 4, on the basis of the above embodiment, the binary tree can be queried as follows.
S401, when the target address is smaller than the first address, determining the address of the first child node based on the address of the parent node and the address offset of the first child node relative to the parent node, and inquiring in the first child node based on the address of the first child node.
In the embodiment of the disclosure, the address of the node may be understood as data representing the position of the node in the binary tree structure, and by way of example, the address of the first child node may be a sum of the address of the parent node of the first child node and the address offset of the first child node relative to its parent node.
In the embodiment of the disclosure, the address offset of the first child node relative to the parent node may be understood as an address difference between the address of the first child node and the address of the parent node corresponding to the first child node.
In the embodiment of the disclosure, when the target address is compared with the first address in the parent node and the result is that the target address is smaller than the first address in the parent node, determining the address of the first child node according to the address of the parent node and the address offset of the first child node relative to the parent node, and querying the target address in the first child node according to the obtained address of the first child node. For example, assume that the address of the parent node is addr m The address offset of the first child node relative to the parent node is addr_offset, and addr_offset is the address addr of the parent node m The sum with the fixed parameter 2' b10, i.e. addr_offset=addr m +2' b10, then when the target address is smaller than the first address in the parent node, address addr of the parent node m Summing with the address offset addr_offset to obtain the address addr of the first child node in the binary tree structure m+1 ,addr m+1 =addr m +addr_offset=2*addr m +2' b10, in which the target address is queried based on the obtained address of the first child node.
And S402, when the target address is larger than the first address, determining the address of the second child node based on the address of the father node and the address offset of the second child node relative to the father node, and inquiring in the second child node based on the address of the second child node.
In the embodiment of the disclosure, when the target address is compared with the first address in the parent node and the result is that the target address is greater than the first address in the parent node, determining the address of the second child node according to the address of the parent node and the address offset of the second child node relative to the parent node, and querying the target address in the second child node according to the obtained address of the second child node. For example, assume that the address of the parent node is addr m The address offset of the second child node relative to the parent node is addr_offset, and addr_offset is addr of the parent node m And fixed parameters2' b01, i.e. addr_offset=addr m +2' b01, then when the target address is greater than the first address in the parent node, address addr of the parent node m Summing with the address offset addr_offset to obtain the address addr of the second child node in the binary tree structure m+1 ’,addr m+1 ’=addr m +addr_offset=2*addr m +2' b01, in which the target address is queried based on the obtained address of the second child node.
According to the method and the device for inquiring the target address, the obtained result of inquiring the target address in the father node is judged, when the target address is smaller than the first address in the father node, the address of the first son node is determined based on the address of the father node and the address offset of the first son node relative to the father node, the inquiry of the target address is carried out in the first son node according to the obtained address of the first son node, when the target address is larger than the first address in the father node, the address of the second son node is determined based on the address of the father node and the address offset of the second son node relative to the father node, and the inquiry of the target address is carried out in the second son node according to the obtained address of the second son node, so that the next inquired son node address is determined according to the father node address, and the inquiry speed is further improved.
Fig. 5 is a flow chart of a method of creating and storing information in a binary tree node provided by an embodiment of the present disclosure. As shown in fig. 5, on the basis of the above-described embodiment, information can be created and stored in binary tree nodes by the following method.
S501, in response to not querying a target node storing the target address, creating a node for the target address in the binary tree.
In the embodiment of the disclosure, when a target node storing a first address identical to a target address is not yet queried after the target address is queried in all child nodes under a corresponding query path, determining a corresponding address in a binary tree structure according to the size of the target address, and creating a node for the target address on the corresponding address.
S502, storing information of the target address and a port corresponding to the target address into a created node based on a preset mapping relation between the target address and the port.
In the embodiment of the disclosure, since the target addresses and the ports are in one-to-one correspondence, after the target address information is obtained, the target addresses can be mapped based on the correspondence between the target addresses and the ports to obtain the port information, and the obtained port information and the corresponding target address information are stored in the nodes created in the corresponding positions to obtain the nodes containing the target addresses and the port information.
In an exemplary implementation manner of the embodiment of the present disclosure, when a target node storing a target address is not queried, a mapping relationship between the target address and a port may be obtained according to a mapping relationship between a source address and a source port included in other query requests.
According to the method and the device for inquiring the target address, the node is created for the target address in the binary tree in response to the fact that the target node stored with the target address is not inquired, the information of the target address and the port corresponding to the target address is stored in the created node based on the preset mapping relation between the target address and the port, the information containing the non-stored target address and the non-stored port can be added into the binary tree, and inquiring speed is improved in the subsequent inquiring process of the target address.
Fig. 6 is a flowchart of a method for transmitting data according to an embodiment of the present disclosure, and as shown in fig. 6, data may be transmitted according to the following method on the basis of the above-described embodiment.
In an embodiment of the present disclosure, the data information further includes data of the target transmission, and after the port corresponding to the target address is obtained from the target node, the method further includes:
s601, acquiring first state information of the port.
The first state information in the embodiments of the present disclosure may be understood as state information for characterizing whether the port is capable of normal communication.
In the embodiment of the disclosure, the table look-up device based on the binary tree can acquire the first state information for representing whether the port can normally communicate.
S602, based on the first state information, determining whether the port is a fault port.
In the embodiment of the disclosure, the table lookup device based on the binary tree may determine whether the port is a failed port that cannot perform normal communication according to the first state information after obtaining the first state information for characterizing whether the port can perform normal communication.
S603, if the port is not a fault port, transmitting the data through the port.
In the embodiment of the disclosure, the table look-up device based on the binary tree can transmit the data of the target transmission in the data information through the port after determining that the port is not the fault port.
According to the method and the device, whether the port is a fault port is determined by acquiring the first state information of the port, and when the port is not the fault port, data is transmitted through the port, and the state of the port can be further determined after the port corresponding to the target address is found in the binary tree through the method, so that when the port is not the fault port, the target data contained in the data information is transmitted through the port, and the data transmission efficiency is improved.
In some embodiments of the present disclosure, when the port is not a failed port, determining whether the port is an idle port according to the second status information of the port, transmitting the data through the port when the port is an idle port, and adding the data to a task queue of the port when the port is not an idle port.
The second state information in some embodiments of the present disclosure may be understood as being used to characterize whether there is data being transmitted through the port, and if not, the second state information is idle state information.
A task queue of a port in some embodiments of the present disclosure may be understood as a task queue formed by tasks waiting for data transmission through the port, and adding data to the task queue of the port may be creating a task for transmitting the data and adding the task to the task queue.
In some embodiments of the present disclosure, the table lookup device based on the binary tree may further obtain the second state information of the port after determining that the port is not a failed port, and determine whether the port is an idle port according to the second state information, after determining that the port is an idle port, transmit data included in the data information through the port, and when the port is not an idle port, add the data to a task queue of the port, for example, may directly add a task where the data is located to an end of the task queue, or may add a task where the data is located to an arbitrary position in the message queue according to an emergency degree, which is not limited herein.
According to the method and the device, whether the port is the idle port or not is determined according to the second state information of the port when the port is not the fault port, data is transmitted through the port when the port is the idle port, and the data is added to the task queue of the port when the port is not the idle port, so that after the idle busy state of the port is further determined, whether the data is directly transmitted or added to the task queue can be determined, and the data transmission efficiency is improved.
Fig. 7 is a schematic structural diagram of a lookup table device based on a binary tree according to an embodiment of the disclosure. The device can be understood as part of the functional modules in the network switch chip described above. As shown in fig. 7, in the binary tree, an address stored in a first child node of a parent node is smaller than an address stored in the parent node, and an address stored in a second child node of the parent node is larger than the address stored in the parent node, the binary tree-based look-up table device 700 includes: a first acquisition module 710, a query module 720, and a second acquisition module 730; the first obtaining module 710 is configured to obtain data information, where the data information includes information of a target address; a query module 720, configured to query the binary tree based on the target address, and when the target address is smaller than a first address stored in a parent node in the binary tree, continue query in a first child node of the parent node, or when the target address is greater than the first address, continue query in a second child node of the parent node; and the second obtaining module 730 is configured to obtain, in response to a query to a target node storing the target address, a port corresponding to the target address from the target node.
Optionally, the data information further includes: information of a source address and a source port; the query module comprises: the device comprises an acquisition unit, a comparison unit and a storage setting unit; the acquisition unit is used for acquiring the information of the flag bit of a father node in the binary tree; the comparison unit is used for comparing the first address stored in the father node with the target address if the information indicated by the flag bit is effective; the storage setting unit is configured to store the information of the source address and the source port to the parent node and set the information indicated by the flag bit to be valid, in response to the information indicated by the flag bit being invalid in the parent node.
Optionally, the query module 720 is configured to: when the target address is smaller than the first address, determining the address of the first child node based on the address of the father node and the address offset of the first child node relative to the father node, and inquiring in the first child node based on the address of the first child node; and when the target address is larger than the first address, determining the address of the second child node based on the address of the father node and the address offset of the second child node relative to the father node, and inquiring in the second child node based on the address of the second child node.
Optionally, the table look-up device 700 based on binary tree further includes a creating unit and an information storing unit; the creating unit is used for creating nodes for the target address in the binary tree in response to the fact that the target node storing the target address is not queried; the information storage unit is used for storing the information of the target address and the port corresponding to the target address into the created node based on the preset mapping relation between the target address and the port.
Optionally, the data information further includes data of the target transmission; the binary tree-based table look-up device 700 further includes a first state information obtaining unit, a determining unit and a non-fault port unit; the first state information acquisition unit is used for acquiring first state information of the port; the determining unit is configured to determine, based on the first status information, whether the port is a failed port; the non-faulty port unit is configured to transmit the data through the port when the port is not a faulty port.
Optionally, the non-fault port unit includes a second status information acquiring subunit, a transmitting subunit and an adding subunit; the second state information obtaining subunit is configured to determine, when the port is not a failed port, whether the port is an idle port according to second state information of the port; the transmission subunit is configured to transmit the data through the port when the port is an idle port; the adding subunit is configured to add the data to a task queue of the port when the port is not an idle port.
The binary tree-based table lookup device provided in this embodiment can execute the method described in any of the above embodiments, and the execution manner and the beneficial effects thereof are similar, and are not described herein again.
Fig. 8 shows a schematic structural diagram of a computer device according to an embodiment of the disclosure. The computer device provided in the embodiments of the present disclosure may be a process flow of the above method embodiment, as shown in fig. 8, where the computer device 800 includes: memory 810, processor 820, computer programs, and communications interface 830; wherein a computer program is stored in memory 810 and configured to be executed by processor 820 as described above with respect to binary tree based look-up methods.
In particular, the memory 810 may include mass storage for information or instructions. By way of example, and not limitation, memory 810 may comprise a Hard Disk Drive (HDD), floppy Disk Drive, flash memory, optical Disk, magneto-optical Disk, magnetic tape, or universal serial bus (Universal Serial Bus, USB) Drive, or a combination of two or more of these. Memory 810 may include removable or non-removable (or fixed) media, where appropriate. The memory 810 may be internal or external to the integrated gateway device, where appropriate. In a particular embodiment, the memory 810 is a non-volatile solid state memory. In a particular embodiment, the memory 810 includes random access memory (Random Access Memory, RAM). The RAM may be static RAM, dynamic RAM, or a combination of both, where appropriate.
Processor 820 may include a Central Processing Unit (CPU), or an application specific integrated circuit (Application Specific Integrated Circuit, ASIC), or may be configured as one or more integrated circuits that implement embodiments of the present application.
Processor 820 performs the steps of the binary tree based look-up method provided by embodiments of the present disclosure by reading and executing computer program instructions stored in memory 810.
The disclosed embodiments also provide a computer readable storage medium, which may store a computer program, which when executed by a processor, causes the processor to implement the binary tree based look-up table method provided by the disclosed embodiments.
The storage medium described above may, for example, include a memory 810 of computer program instructions executable by a processor 820 of a speech control device to perform the binary tree based look-up method provided by embodiments of the present disclosure. Alternatively, the storage medium may be a non-transitory computer readable storage medium, for example, a ROM, a random access memory (Random Access Memory, RAM), a Compact Disc ROM (CD-ROM), a magnetic tape, a floppy disk, an optical data storage device, and the like. The computer programs described above may be written in any combination of one or more programming languages, including an object oriented programming language such as Java, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code may execute entirely on the user's computing device, partly on the user's device, as a stand-alone software package, partly on the user's computing device, partly on a remote computing device, or entirely on the remote computing device or server.
The embodiment of the disclosure further provides a vehicle, which includes a memory, a processor, and a computer program, where the memory stores the computer program, and when the computer program is executed by the processor, the processes and effects in the foregoing embodiments of the disclosure may be implemented, which is not described herein.
The foregoing is merely a specific embodiment of the disclosure to enable one skilled in the art to understand or practice the disclosure. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown and described herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims (10)

1. A binary tree-based lookup method, wherein in the binary tree, an address stored in a first child node of a parent node is smaller than an address stored in the parent node, and an address stored in a second child node of the parent node is larger than an address stored in the parent node, the method comprising:
Acquiring data information, wherein the data information comprises information of a target address;
querying the binary tree based on the target address, and continuously querying a first child node of a father node when the target address is smaller than a first address stored in the father node in the binary tree, or continuously querying a second child node of the father node when the target address is larger than the first address;
and responding to the inquiry of the target node storing the target address, and acquiring a port corresponding to the target address from the target node.
2. The method according to claim 1, wherein the data information further includes: information of a source address and a source port;
the querying the binary tree based on the target address includes:
acquiring information of a flag bit of a father node in the binary tree;
responding to the information indicated by the flag bit to be effective information in the father node, and comparing the first address stored in the father node with the target address;
and if the information indicated by the flag bit is invalid, storing the information of the source address and the source port to the father node, and setting the information indicated by the flag bit to be valid.
3. The method of claim 1 or 2, wherein the continuing the query in a first child node to a first parent node in the binary tree when the target address is less than a first address stored by the first parent node or in a second child node to the first parent node when the target address is greater than the first address comprises:
when the target address is smaller than the first address, determining the address of the first child node based on the address of the father node and the address offset of the first child node relative to the father node, and inquiring in the first child node based on the address of the first child node;
and when the target address is larger than the first address, determining the address of the second child node based on the address of the father node and the address offset of the second child node relative to the father node, and inquiring in the second child node based on the address of the second child node.
4. The method according to claim 1, wherein the method further comprises:
responsive to not querying a target node storing the target address, creating a node for the target address in the binary tree;
And storing the information of the target address and the port corresponding to the target address into the created node based on the preset mapping relation between the target address and the port.
5. The method according to any one of claims 1-4, wherein the data information further comprises data of the target transmission;
after the port corresponding to the target address is obtained from the target node, the method further includes:
acquiring first state information of the port;
determining whether the port is a failed port based on the first status information;
and if the port is not a fault port, transmitting the data through the port.
6. The method of claim 5, wherein transmitting the data through the port if the port is not a failed port comprises:
when the port is not a fault port, determining whether the port is an idle port according to second state information of the port;
transmitting the data through the port when the port is an idle port;
and when the port is not an idle port, adding the data into a task queue of the port.
7. A binary tree-based lookup apparatus, wherein in the binary tree, an address stored in a first child node of a parent node is smaller than an address stored in the parent node, and an address stored in a second child node of the parent node is larger than an address stored in the parent node, the apparatus comprising:
the first acquisition module is used for acquiring data information, wherein the data information comprises information of a target address;
the query module is used for querying the binary tree based on the target address, and continuously querying a first child node of a father node when the target address is smaller than a first address stored in the father node in the binary tree, or continuously querying a second child node of the father node when the target address is greater than the first address;
and the second acquisition module is used for responding to the inquiry of the target node stored with the target address and acquiring a port corresponding to the target address from the target node.
8. A computer device, comprising: a memory; a processor; a computer program; wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of any one of claims 1-6.
9. A computer readable storage medium, wherein a computer program is stored in the storage medium, which, when executed by a processor, implements a binary tree based look-up table method according to any of claims 1-6.
10. A vehicle, characterized by comprising: a memory; a processor; a computer program; wherein the computer program is stored in the memory and configured to be executed by the processor to implement the method of any one of claims 1-6.
CN202210689374.3A 2022-06-16 2022-06-16 Binary tree-based table lookup method, binary tree-based table lookup device, binary tree-based table lookup equipment, storage medium and vehicle Pending CN117294647A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210689374.3A CN117294647A (en) 2022-06-16 2022-06-16 Binary tree-based table lookup method, binary tree-based table lookup device, binary tree-based table lookup equipment, storage medium and vehicle

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210689374.3A CN117294647A (en) 2022-06-16 2022-06-16 Binary tree-based table lookup method, binary tree-based table lookup device, binary tree-based table lookup equipment, storage medium and vehicle

Publications (1)

Publication Number Publication Date
CN117294647A true CN117294647A (en) 2023-12-26

Family

ID=89252297

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210689374.3A Pending CN117294647A (en) 2022-06-16 2022-06-16 Binary tree-based table lookup method, binary tree-based table lookup device, binary tree-based table lookup equipment, storage medium and vehicle

Country Status (1)

Country Link
CN (1) CN117294647A (en)

Similar Documents

Publication Publication Date Title
WO2018099107A1 (en) Hash table management method and device, and computer storage medium
US5815664A (en) Address reporting device and method for detecting authorized and unauthorized addresses in a network environment
US10831612B2 (en) Primary node-standby node data transmission method, control node, and database system
CN107872486B (en) Communication method and device
CN108139966B (en) Method for managing address conversion bypass cache and multi-core processor
CN102843426B (en) Based on Web cache resources shared system and the method for intelligent father node
US20110188503A1 (en) Ethernet Forwarding Database Method
US20150113230A1 (en) Directory storage method and query method, and node controller
CN112860592B (en) Data caching method and device based on linked list, electronic equipment and storage medium
JP6724252B2 (en) Data processing method, storage system and switching device
US20140222906A1 (en) Method and system for domain name system based discovery of devices and objects
CN111314450B (en) Data transmission method and device, electronic equipment and computer storage medium
CN102571936B (en) Method, device and system for searching data
CN111245662B (en) Method and device for displaying network topology
TW583542B (en) NUMA page selection using coloring
CN105722040A (en) Service message transmission method, apparatus and system
CN107493309B (en) File writing method and device in distributed system
WO2014190700A1 (en) Method of memory access, buffer scheduler and memory module
CN117294647A (en) Binary tree-based table lookup method, binary tree-based table lookup device, binary tree-based table lookup equipment, storage medium and vehicle
WO2022206170A1 (en) Data processing method, server and system
CN107545026B (en) Method and device for realizing function of interface name analysis tree
WO2011160392A1 (en) Method and apparatus for name-list management
JP3570606B2 (en) Data retrieval apparatus and method
KR20040022231A (en) Method and device for identifying devices connected to a communication network
CN115934743B (en) File lock management method, system, equipment and computer readable 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