Method and device for quickly searching routing table item, equipment and storage medium

Through the combination of hash address table and hash routing table, the problem of low efficiency in searching for routing table items in the existing technology is solved, and a certain method of efficient searching of routing table items is realized.

CN119854211APending Publication Date: 2025-04-18SCIVO TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510057099.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-14
Publication Date
2025-04-18

AI Technical Summary

Technical Problem

In the prior art, finding routing table entries requires multiple clock cycles and cannot be determined in advance, resulting in low packet processing efficiency in high-performance routing switching chips.

Method used

Using a hash address table collection and hash routing table, the routing table entry data of IP packets is quickly determined through two hash operations. The specific steps include: parsing the IP address of the IP message, performing reconstruction and hashing operations, and finding the hash address table and hash routing table to obtain routing table entries.

Benefits of technology

The search time is greatly shortened, so that the time of each search is determined, and does not change due to different routing table lengths, improving the processing efficiency of the routing switching chip.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119854211A_ABST
    Figure CN119854211A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of routing, and discloses a method, device and equipment for quickly searching routing table entries and a storage medium, and the method comprises the following steps: obtaining an IP message, and analyzing the IP message to obtain a destination IP address; performing AND calculation on the destination IP address and each mask corresponding to the Hash address table set to obtain a plurality of calculated network addresses, and performing Hash operation once at the same time to obtain a plurality of third Hash addresses; searching all the Hash address tables at the same time by taking the third Hash address as an address index, and selecting a hit item in the Hash address table set according to the priority of the mask length from large to small to obtain a destination network address of the IP message; performing secondary hash operation on the destination network address to obtain a fourth hash address; and checking the Hash routing table according to the fourth Hash address, and if the table item is valid, obtaining table item data of the routing table corresponding to the IP message. According to the method, the searching time can be greatly shortened, and the searching time of each time is determined.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of routing technology, and in particular relates to a method, device, equipment and storage medium for quickly searching routing table items. Background Art

[0002] In an IP network, a routing table is a data table stored in a router or networked computer. The routing table stores the path to a specific network address and contains topological information around the network. The establishment of the routing table is mainly based on the routing protocol. In a three-layer switch and router, the routing table needs to be stored in a dedicated switching chip or routing chip to quickly decide the forwarding path and output port of the input message.

[0003] In the prior art, searching the routing table according to the destination IP address of the input IP message requires a polling or n-tree-based method. For a large-scale network, the length of the routing table is usually large, and the length of the routing table varies greatly depending on the network topology. Therefore, for a routing switch chip, the number of clock cycles required to search the routing table is usually large and cannot be determined in advance. As network applications continue to increase the number and speed requirements of switching ports, quickly searching the routing table has become a difficulty in high-performance routing switch chips in message processing. Summary of the invention

[0004] The purpose of the present invention is to provide a method, device, equipment and storage medium for quickly searching routing table items, so as to solve the problem of how to quickly search routing tables in the prior art.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions: In a first aspect, the present invention provides a method for quickly searching for routing table entries, the method comprising: Obtaining an IP message and a pre-constructed hash address table set and a hash routing table, wherein the hash address table set includes a plurality of hash address tables, each hash address table includes a plurality of destination network addresses having the same mask length and a first hash address corresponding to each destination network address; the hash routing table includes each table item data in the target routing table and a corresponding second hash address; Parse the IP message to obtain the destination IP address of the IP message; The destination IP address is respectively ANDed with each mask corresponding to the hash address table set to obtain multiple calculated network addresses; Perform a hash operation on the multiple calculated network addresses at the same time to obtain multiple third hash addresses; Using the third hash address as the address index, all hash address tables are searched at the same time, and for the valid table entries found, a hit entry is selected in the hash address table set in a descending priority order of mask length to obtain the destination network address of the IP message; Perform a secondary hash operation on the destination network address to obtain a fourth hash address; The hash routing table is searched with the fourth hash address, and if the entry is valid, the entry data of the routing table corresponding to the IP message is obtained.

[0006] Preferably, the method further comprises: constructing a hash address table set, comprising: Obtaining a target routing table, wherein the target routing table at least includes a plurality of destination network addresses and a mask length corresponding to each destination network address; The multiple destination network addresses are grouped according to the mask length to obtain a plurality of destination network address groups; wherein the mask lengths corresponding to all destination network addresses in a destination network address group are the same; For each group of destination network address groups, each destination network address in the group of destination network address groups is used as an input of a first hash function, and the first hash function outputs a first hash address corresponding to each destination network address in the group of destination network address groups; Generate a hash address table corresponding to the group of destination network address groups based on each destination network address in the group of destination network address groups and a first hash address corresponding to each destination network address; A hash address table set is constructed based on the hash address tables corresponding to all destination network address groups.

[0007] Preferably, the method further comprises: constructing a hash routing table, comprising: Extract the destination network address of each entry in the target routing table; Using the destination network address of each entry data as the input of the second Hash function, the second Hash function outputs the second Hash address corresponding to the destination network address of each entry data; A hash routing table is generated based on each entry data of the target routing table and a second hash address corresponding to a destination network address of each entry data.

[0008] In a second aspect, the present invention provides a device for quickly searching for routing table entries, the device comprising: a network switching chip, the network switching chip comprising: a CPU module and a switching module, the CPU module being communicatively connected to the switching module; The CPU module is used to: construct a hash address table set and a hash routing table based on the target routing table, and send the hash address table set and the hash routing table to the switching module; wherein the hash address table set includes a plurality of hash address tables, each hash address table includes a plurality of destination network addresses with the same mask length and a first hash address corresponding to each destination network address; the hash routing table includes each table item data in the target routing table and a corresponding second hash address; The switching module is used to: obtain an IP message, parse the IP message, and obtain a destination IP address of the IP message; perform AND calculations on the destination IP address and each mask corresponding to a hash address table set to obtain multiple calculated network addresses; perform a hash operation on the multiple calculated network addresses at the same time to obtain multiple third hash addresses; use the third hash address as an address index to search all hash address tables at the same time, and for the valid table entries found, select a hit item in the hash address table set in a descending priority order of mask length to obtain the destination network address of the IP message; perform a second hash operation on the destination network address to obtain a fourth hash address; use the fourth hash address to search the hash routing table, and if the table entry is valid, obtain the table entry data of the routing table corresponding to the IP message.

[0009] Preferably, the network switching chip further comprises: a RAM module, and the hash address table set and the hash routing table are both stored in the RAM module.

[0010] Preferably, the network switching chip is a three-layer switching chip, a routing chip or an FPGA chip loaded with network switching function logic.

[0011] In a third aspect, the present invention provides an electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the above-mentioned method for quickly searching routing table entries when executing the computer program.

[0012] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-mentioned method for quickly searching for routing table entries.

[0013] Beneficial effects: 1. The present invention only needs two hash operation table lookups to determine the table entry data of the input IP message's routing table; therefore, not only the search time is greatly shortened, but also the search time for each time is fixed and will not differ due to the different lengths of the routing table; 2. Although there may be a large number of hash address tables, for specific application scenarios, the actual number of different mask lengths is only a few to a dozen, and the data content stored in each hash address table is only the network address itself, so the total memory occupied is not much. BRIEF DESCRIPTION OF THE DRAWINGS

[0014] The accompanying drawings are used to provide a further understanding of the embodiments of the present invention and constitute a part of the specification. Together with the following specific implementations, they are used to explain the embodiments of the present invention, but do not constitute a limitation on the embodiments of the present invention. In the accompanying drawings: Figure 1 It is a flow chart of a method for quickly searching routing table entries provided by an embodiment of the present invention; Figure 2 A schematic diagram of a target routing table provided in one embodiment of the present invention Figure 3 It is a schematic diagram of a hash address table with a mask length of 24 provided in one embodiment of the present invention; Figure 4 It is a schematic diagram of a hash address table with a mask length of 20 provided in one embodiment of the present invention; Figure 5 It is a schematic diagram of a hash address table with a mask length of 16 provided in one embodiment of the present invention; Figure 6 is a schematic diagram of a hash routing table provided in one embodiment of the present invention; Figure 7 The present invention is a block diagram of a device for quickly searching routing table entries provided in one embodiment of the present invention. DETAILED DESCRIPTION

[0015] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the present invention will be briefly introduced below in combination with the drawings and the description of the embodiments or the prior art. Obviously, the following description of the structure of the drawings is only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work. It should be noted that the description of these embodiments is used to help understand the present invention, but does not constitute a limitation of the present invention.

[0016] Embodiment 1 Figure 1 FIG. 1 is a flow chart of a method for quickly searching routing table entries provided by an embodiment of the present invention. Figure 1 As shown, this embodiment provides a method for quickly searching for routing table entries, the method comprising steps S10 to S70; before executing steps S10 to S70, it is necessary to provide a hash address table set and a hash routing table; therefore, the method comprises: constructing a hash address table set and constructing a hash routing table.

[0017] The construction of a hash address table set includes the following steps: Step a10: Obtain a target routing table, wherein the target routing table at least includes a plurality of destination network addresses and a mask length corresponding to each destination network address.

[0018] In this embodiment, the schematic diagram of the target routing table is as follows: Figure 2 As shown in the figure, the target routing table contains multiple entries. One entry includes multiple fields (i.e., entry data), such as the address field, the destination network / mask field, the next hop field, the outbound interface field, and the protocol field. In the destination network / mask field, taking the first entry as an example, the value of the destination network / mask field is 10.2.0.0 / 16, where 10.2.0.0 is the destination network address and 16 is the mask length.

[0019] Step a20: Grouping multiple destination network addresses according to the mask length to obtain several destination network address groups; wherein the mask lengths corresponding to all destination network addresses in one destination network address group are the same.

[0020] In this embodiment, Figure 2 For example, in Figure 2 In the target routing table, there are three destination network addresses with different mask lengths, namely, the destination network address with mask length (16), the destination network address with mask length (20), and the destination network address with mask length (24); therefore, according to the mask length, Figure 2 The destination network addresses in the destination routing table are divided into three groups; Figure 2 The target routing table only lists a part of the entries. The actual number of entries in the target routing table is much larger than Figure 2 The number of entries listed in .

[0021] Step a30: For each destination network address group, each destination network address in the destination network address group is used as an input of a first hash function, and the first hash function outputs a first hash address corresponding to each destination network address in the destination network address group.

[0022] In this embodiment, Figure 2 For example, the destination network addresses in the routing table are divided into three groups. The destination network addresses in each group are used as inputs of the first hash function. The first hash function can output a corresponding hash value, and the corresponding hash value is used as the first hash address (i.e. Figure 3-Figure 5 Hash address in ).

[0023] Step a40: Based on each destination network address in the destination network address group and a first hash address corresponding to each destination network address, a hash address table corresponding to the destination network address group is generated.

[0024] In this embodiment, Figure 2 For example, since the mask has three different lengths, three hash address tables can be generated, such as Figure 3-Figure 5 shown.

[0025] Step a50: construct a set of hash address tables based on the hash address tables corresponding to all the group destination network address groups; combine all the hash address tables together to obtain a set of hash address tables.

[0026] Among them, building a hash routing table includes the following steps: Step b10: Extract the destination network address of each entry in the target routing table.

[0027] Step b20: The destination network address of each table entry data is used as the input of the second hash function, and the second hash function outputs the second hash address corresponding to the destination network address of each table entry data; similarly, the destination network address of each table entry data in the target routing table is input into the second hash function, and the second hash function can output a corresponding hash value, and the corresponding hash value is used as the second hash address (i.e. Figure 6 Hash address in ).

[0028] Step b30: Generate a hash routing table based on the data of each entry in the target routing table and the second hash address corresponding to the destination network address of each entry; a schematic diagram of the hash routing table, such as Figure 6 shown.

[0029] After the hash address table set and the hash routing table are constructed, steps S10 to S70 are executed as follows: Step S10: Obtain an IP message and a pre-constructed hash address table set and a hash routing table, wherein the hash address table set includes multiple hash address tables, each hash address table contains multiple destination network addresses with the same mask length and a first hash address corresponding to each destination network address; the hash routing table contains a target routing table and each table item data in the target routing table and the corresponding second hash address.

[0030] Step S20: parse the IP message to obtain the destination IP address of the IP message.

[0031] Step S30: Calculate the destination IP address and the masks corresponding to the hash address table set to obtain multiple calculated network addresses.

[0032] Step S40: perform a hash operation on the multiple calculated network addresses at the same time to obtain multiple third hash addresses; in this embodiment, the multiple calculated network addresses are respectively input into the first hash function, and the first hash function outputs multiple corresponding hash values, and the multiple corresponding hash values ​​are multiple third hash addresses.

[0033] Step S50: using the third hash address as the address index, searching all hash address tables simultaneously, and selecting hit items in the hash address table set according to the priority order of mask length from large to small for the found valid table items, to obtain the destination network address of the IP message.

[0034] As a further optimization of this embodiment, all hash address tables are searched at the same time using the third hash address as the address index, and for the valid table entries found, a hit item is selected in the hash address table set in a descending priority order of the mask length to obtain the destination network address of the IP message, including: Step S501: In the set of hash address tables, use the third hash address as the address index and check all hash address tables at the same time to determine whether the entry is valid; Step S502: If so, for the valid table entries found, a hit item is selected from the hash address table set in the order of priority from large to small mask length, and the hit item is the hit destination network address, and the hit destination network address is used as the destination network address corresponding to the IP message; if not, an invalid table entry prompt is generated, and the invalid table entry prompt is used to indicate that the forwarding path of the IP message is not within the provisions of the routing table.

[0035] Step S60: Perform a secondary hash operation on the destination network address corresponding to the destination IP address to obtain a fourth hash address; input the destination network address corresponding to the destination IP address into the second hash function, and the second hash function outputs a corresponding hash value, and the corresponding hash value is used as the fourth hash address.

[0036] Step S70: Look up the hash routing table with the fourth hash address, and if the entry is valid, obtain the entry data of the routing table corresponding to the IP message.

[0037] As a further optimization of this embodiment, the hash routing table is searched with the fourth hash address. If the entry is valid, the entry data of the routing table corresponding to the IP message is obtained, including: Step S701: In the hash routing table, search the hash routing table with the fourth hash address to determine whether the entry is valid; Step S702: If yes, extract the table entry data corresponding to the second hash address from the hash routing table, and use the extracted table entry data corresponding to the second hash address as the table entry data of the route corresponding to the IP message; if no, generate an invalid table entry prompt, and the invalid table entry prompt is used to indicate that the forwarding path of the IP message is not within the provisions of the routing table.

[0038] The present invention only needs two hash operation table lookups to determine the table entry data of the routing table of the input IP message; therefore, not only the lookup time is greatly shortened, but also the time for each lookup is fixed and will not differ due to different lengths of the routing table; and, although there may be a large number of hash address tables, for specific application scenarios, the actual different mask lengths are only a few to a dozen, and the data content stored in each hash address table is only the network address itself, so the total memory occupied is not much.

[0039] Embodiment 2 Figure 7 FIG. 1 is a block diagram of a device for quickly searching routing table entries provided by an embodiment of the present invention. Figure 7 As shown, the present embodiment provides that the device includes: a network switching chip, the network switching chip includes: a CPU module and a switching module, the CPU module is communicatively connected with the switching module; The CPU module is used to: construct a hash address table set and a hash routing table based on the target routing table, and send the hash address table set and the hash routing table to the switching module; wherein the hash address table set includes multiple hash address tables, each hash address table includes multiple destination network addresses with the same mask length and a first hash address corresponding to each destination network address; the hash routing table includes each table item data in the target routing table and the corresponding second hash address; the specific steps of constructing the hash address table set and the hash routing table based on the target routing table have been described in detail in Example 1, and therefore are not repeated one by one in this embodiment.

[0040] The switching module is used to: obtain an IP message, parse the IP message, and obtain a destination IP address of the IP message; perform AND calculations on the destination IP address and each mask corresponding to a hash address table set to obtain multiple calculated network addresses; perform a hash operation on the multiple calculated network addresses at the same time to obtain multiple third hash addresses; use the third hash address as an address index to search all hash address tables at the same time, and for the valid table entries found, select a hit item in the hash address table set in a descending priority order of mask length to obtain the destination network address of the IP message; perform a second hash operation on the destination network address to obtain a fourth hash address; use the fourth hash address to search the hash routing table, and if the table entry is valid, obtain the table entry data of the routing table corresponding to the IP message.

[0041] As a further optimization of this embodiment, the network switching chip further includes: a RAM (Random Access Memory) module, and the hash address table set and the hash routing table are both stored in the RAM module.

[0042] As a further optimization of this embodiment, the network switching chip is a three-layer switching chip, a routing chip, or an FPGA (Field-Programmable Gate Array) chip loaded with network switching function logic.

[0043] The present invention shortens the clock cycle of the chip searching for routing table items to within three cycles, and the number of clock cycles required for the search is determined; that is, since each hash address table search only takes 1 to 2 clock cycles, the present invention only needs two hash table searches to determine the routing table items of the input IP message, thus not only greatly shortening the search time, but also the time for each search is determined and will not differ due to different lengths of the routing table.

[0044] Embodiment 3 This embodiment also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method for quickly searching for routing table entries in the first embodiment when executing the computer program.

[0045] This embodiment further provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the method for quickly searching for routing table entries in the first embodiment is implemented.

[0046] The present invention only needs two hash operation table lookups to determine the routing table entry of the input IP message; therefore, not only the lookup time is greatly shortened, but also the time for each lookup is fixed and will not differ due to the different lengths of the routing table; and, although the number of first hash address tables may be large, for specific application scenarios, the actual different mask lengths are only a few to a dozen, and the data content stored in each hash address table is only the network address itself, so the total memory occupied is not much.

[0047] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program codes.

[0048] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0049] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A method for quickly searching for routing table entries, characterized in that: The method comprises: Obtaining an IP message and a pre-constructed hash address table set and a hash routing table, wherein the hash address table set includes a plurality of hash address tables, each hash address table includes a plurality of destination network addresses having the same mask length and a first hash address corresponding to each destination network address; the hash routing table includes each table item data in the target routing table and a corresponding second hash address; Parse the IP message to obtain the destination IP address of the IP message; The destination IP address is respectively ANDed with each mask corresponding to the hash address table set to obtain multiple calculated network addresses; Perform a hash operation on the multiple calculated network addresses at the same time to obtain multiple third hash addresses; Using the third hash address as the address index, all hash address tables are searched at the same time. For the valid table entries found, the hit items are selected in the hash address table set in the order of priority from large to small mask length to obtain the destination network address of the IP packet. Perform a secondary hash operation on the destination network address to obtain a fourth hash address; The hash routing table is searched with the fourth hash address, and if the entry is valid, the entry data of the routing table corresponding to the IP message is obtained.

2. The method for quickly searching routing table entries according to claim 1, characterized in that: The method further comprises: constructing a hash address table set, comprising: Obtaining a target routing table, wherein the target routing table at least includes a plurality of destination network addresses and a mask length corresponding to each destination network address; The multiple destination network addresses are grouped according to the mask length to obtain a plurality of destination network address groups; wherein the mask lengths corresponding to all destination network addresses in a destination network address group are the same; For each group of destination network address groups, each destination network address in the group of destination network address groups is used as an input of a first hash function, and the first hash function outputs a first hash address corresponding to each destination network address in the group of destination network address groups; Generate a hash address table corresponding to the group of destination network address groups based on each destination network address in the group of destination network address groups and a first hash address corresponding to each destination network address; A hash address table set is constructed based on the hash address tables corresponding to all destination network address groups.

3. The method for quickly searching routing table entries according to claim 1 or 2, characterized in that: The method further includes: constructing a hash routing table, including: Extract the destination network address of each entry in the target routing table; Using the destination network address of each entry data as the input of the second Hash function, the second Hash function outputs the second Hash address corresponding to the destination network address of each entry data; A hash routing table is generated based on each entry data of the target routing table and a second hash address corresponding to a destination network address of each entry data.

4. A device for quickly searching for routing table entries, characterized in that: The device comprises: a network switching chip, the network switching chip comprises: a CPU module and a switching module, the CPU module is communicatively connected with the switching module; The CPU module is used to: construct a hash address table set and a hash routing table based on the target routing table, and send the hash address table set and the hash routing table to the switching module; wherein the hash address table set includes a plurality of hash address tables, each hash address table includes a plurality of destination network addresses with the same mask length and a first hash address corresponding to each destination network address; the hash routing table includes each table item data in the target routing table and a corresponding second hash address; The switching module is used to: obtain an IP message, parse the IP message, and obtain a destination IP address of the IP message; perform AND calculations on the destination IP address and each mask corresponding to a hash address table set to obtain multiple calculated network addresses; perform a hash operation on the multiple calculated network addresses at the same time to obtain multiple third hash addresses; use the third hash address as an address index to search all hash address tables at the same time, and for the valid table entries found, select a hit item in the hash address table set in a descending priority order of mask length to obtain the destination network address of the IP message; perform a second hash operation on the destination network address to obtain a fourth hash address; use the fourth hash address to search the hash routing table, and if the table entry is valid, obtain the table entry data of the routing table corresponding to the IP message.

5. The device for quickly searching routing table entries according to claim 4, characterized in that: The network switching chip further includes a RAM module, in which the hash address table set and the hash routing table are both stored.

6. The device for quickly searching routing table entries according to claim 4, characterized in that: The network switching chip is a three-layer switching chip, a routing chip or an FPGA chip loaded with network switching function logic.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for quickly searching for routing table entries according to any one of claims 1 to 3 is implemented.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for quickly searching for routing table entries described in any one of claims 1 to 3 is implemented.