A method and apparatus for forwarding a route

By using multi-level index table storage and step-by-step matching, the problem of excessive computing resources during routing and forwarding is solved, achieving efficient route selection and data transmission.

CN116896531BActive Publication Date: 2026-06-26DUXIAOMAN TECH (BEIJING) CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
DUXIAOMAN TECH (BEIJING) CO LTD
Filing Date
2023-06-16
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In existing technologies, the need to calculate the matching length of all routing entries during the routing forwarding process leads to excessively high time costs and computational resources, resulting in low routing forwarding efficiency and data transmission efficiency.

Method used

A multi-level index table is used to store the routing database. By matching the field value of the destination IP address with the value of the index table array element at each level, the target route is generated and forwarded, thus avoiding the calculation of global routing entries.

Benefits of technology

It improves routing and forwarding efficiency, reduces time costs, and enhances data transmission efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116896531B_ABST
    Figure CN116896531B_ABST
Patent Text Reader

Abstract

The application discloses a routing forwarding method and device, and relates to the technical field of network routing. The specific implementation of the method comprises the following steps: receiving one or more communication requests; wherein the communication request comprises a destination IP address; matching the value of each field of the destination IP address with the array element value of each index table in a routing database step by step, and determining the matching result of each field; wherein the matching result comprises the same, different or empty; in the case that the matching result is different, determining a target index table corresponding to the matching result; generating a target route according to the target index table and the matching array of at least one index table before the target index table, and forwarding the communication request by using the target route. The implementation can quickly and accurately match the target route, improve the routing selection and forwarding efficiency, and improve the data transmission efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network routing technology, and in particular to a routing forwarding method and apparatus. Background Technology

[0002] Devices in a network communicate and connect based on a unified communication protocol (such as the IP protocol) to exchange data. When devices communicate, the router accepts communication requests sent from the source device's source IP address interface and forwards them to the destination IP address, enabling the destination device to receive the communication data.

[0003] In existing communication processes, during routing and forwarding, routers typically need to perform a bitwise AND operation on each routing entry and the destination IP address according to the routing table's routing entry hierarchy, in descending order. The number of "1" values ​​in the result determines the match length, and the routing entry with the longest match length is selected as the best route for forwarding.

[0004] However, with the proliferation of network devices, calculating the matching length of all routing entries and comparing the maximum matching length to determine the best route requires high time and computing resources, resulting in low routing forwarding efficiency and consequently low data transmission efficiency. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide a routing forwarding method and apparatus that can solve the problem of low routing forwarding efficiency, which in turn leads to low data transmission efficiency.

[0006] To achieve the above objectives, according to one aspect of the present invention, a routing forwarding method is provided, comprising:

[0007] Receive one or more communication requests; wherein the communication request includes a destination IP address;

[0008] The values ​​of each field of the destination IP address are matched with the array element values ​​of each level of the index table in the routing database to determine the matching result of each field; wherein the matching result includes the same, different, or empty;

[0009] If the matching results are different, determine the target index table corresponding to the matching results;

[0010] A target route is generated based on the matching array of the target index table and at least one level of index tables preceding the target index table, and the communication request is forwarded using the target route.

[0011] According to another aspect of the present invention, a routing forwarding device is provided, comprising:

[0012] A receiving module is configured to receive one or more communication requests; wherein the communication request includes a destination IP address;

[0013] The matching module is used to match the values ​​of each field of the destination IP address with the array element values ​​of each level of the index table in the routing database to determine the matching result of each field; wherein the matching result includes the same, different, or empty;

[0014] The data processing module is used to determine the target index table corresponding to the matching result when the matching results are different;

[0015] The generation module is used to generate a target route based on the matching array of the target index table and at least one level index table preceding the target index table, and to forward the communication request using the target route.

[0016] According to another aspect of the present invention, an electronic device is provided, comprising:

[0017] Processor; and

[0018] Stored program memory,

[0019] The program includes instructions that, when executed by the processor, cause the processor to perform the forwarding method of the route.

[0020] According to another aspect of the present invention, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to perform a forwarding method of the route.

[0021] One embodiment of the above invention has the following advantages or beneficial effects: because it adopts a technique of creating a multi-level index table during storage, storing the values ​​of the second to fourth fields and the mask value hierarchically according to the comparison result of the mask value and the maximum mask value of each field; and locating the index position according to the value of the first to third fields of the destination IP address during forwarding, matching the field value and the array element value of the index position level by level, and combining the target route based on different matching results, it overcomes the technical problem that the calculation and comparison of all route entries requires high time cost and computing resources, resulting in low forwarding efficiency and low data transmission efficiency. Thus, it achieves the technical effect of quickly and accurately matching the target route, improving routing selection and forwarding efficiency, and improving data transmission efficiency. Attached Figure Description

[0022] Further details, features, and advantages of the invention are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:

[0023] Figure 1 This is a schematic diagram of the main flow of the routing forwarding method according to an embodiment of the present invention;

[0024] Figure 2 This is a schematic diagram of the main flow of the method for determining the index table according to an embodiment of the present invention;

[0025] Figure 3 This is a schematic diagram of a multi-level index table according to an embodiment of the present invention;

[0026] Figure 4 This is a schematic diagram of the main flow of the target route generation method according to an embodiment of the present invention;

[0027] Figure 5 This is a schematic diagram of the main modules of a routing forwarding device according to an embodiment of the present invention;

[0028] Figure 6 This is a structural block diagram of an exemplary electronic device suitable for implementing embodiments of the present invention. Detailed Implementation

[0029] Embodiments of the present invention will now be described in more detail with reference to the accompanying drawings. While some embodiments of the invention are shown in the drawings, it should be understood that the invention can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the invention. It should be understood that the accompanying drawings and embodiments are for illustrative purposes only and are not intended to limit the scope of protection of the invention.

[0030] It should be understood that the various steps described in the method embodiments of the present invention may be performed in different orders and / or in parallel. Furthermore, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present invention is not limited in this respect.

[0031] The term "comprising" and its variations as used herein are open-ended, meaning "including but not limited to". The term "based on" means "at least partially based on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments". Definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc., used in this disclosure are only used to distinguish different devices, modules, or units, and are not intended to limit the order of functions performed by these devices, modules, or units or their interdependencies.

[0032] It should be noted that the terms "a" and "a plurality of" used in this disclosure are illustrative rather than restrictive, and those skilled in the art should understand that, unless otherwise expressly indicated in the context, they should be understood as "one or more".

[0033] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0034] IP address: A standardized address format defined by the IP protocol, used to assign a logical address to every device on a network. An IP address is a 32-bit binary number. This 32-bit binary number is divided into four parts, each with 8 bits. These parts are then converted to decimal values ​​and separated by delimiters to obtain the common IP address.

[0035] AND operation: A logical operation in which two data points are converted to binary and summed. The result of the AND operation is 1 if both binary numbers are 1, otherwise it is 0.

[0036] Subnetting: To facilitate communication between different broadcast domains, a standard IP network is usually assigned to a broadcast domain. By using subnet mask borrowing within the broadcast domain, a standard IP network can be divided into multiple subnets to be assigned to different devices within the broadcast domain to uniquely identify the device and improve the utilization of IP addresses.

[0037] A subnet mask consists of 32 consecutive 1s and 0s in binary format. The left side represents the network bits, indicated by binary '1's, with the number of '1's equal to the length of the network bits. The right side represents the host bits, indicated by binary '0's, with the number of '0's equal to the length of the host bits. Performing a bitwise AND operation between the subnet mask and the IP address yields the network address of each subnet.

[0038] Routing: Routing refers to the process by which a router receives a data packet from one interface, directs it according to its destination address, and forwards it to another interface.

[0039] Routing: The router compares various routes according to a preset algorithm and selects the best path to the destination. The selection criteria include longest match, priority, cost, bandwidth, etc.

[0040] The destination IP address of the data packet is divided into 4 segments, and the number of each segment is obtained. Starting from the first segment, the data at the corresponding position is precisely indexed and judged level by level in the storage space of the multi-level index table until the result is obtained. The indexing is performed at most 3 times to obtain the final result of the matching route entry, thus achieving efficient route selection.

[0041] In existing communication processes, after receiving a communication request, the router calculates all routes in its routing table based on the destination IP address, route priority, and other factors. It then selects the route with the longest matching length as the optimal route for forwarding. If no optimal route is found, the default route is used. However, the time cost of calculating and selecting all routes is too high, reducing service access efficiency and consequently impacting service processing efficiency.

[0042] The routing forwarding method of the present invention improves routing selection and forwarding efficiency, reduces time costs, and enhances business processing efficiency by changing the storage format of routes and constructing a multi-level index table, enabling rapid matching of target routes through step-by-step indexing during forwarding.

[0043] The present invention will now be described with reference to the accompanying drawings.

[0044] Figure 1 This is a schematic diagram of the main flow of the routing forwarding method according to an embodiment of the present invention, as shown below. Figure 1 As shown, the routing forwarding method of the present invention includes the following steps:

[0045] In this embodiment of the invention, the routing forwarding method of the present invention is executed by a router.

[0046] Step S101: Receive one or more communication requests; wherein the communication request includes a destination IP address.

[0047] In this embodiment of the invention, the data packet of the communication request includes a source IP address and a destination IP address; wherein, the source IP address refers to the IP address corresponding to the device that actively initiates the request during network communication, and the destination IP address refers to the IP address corresponding to the device that is requested during network communication.

[0048] In this embodiment of the invention, the destination IP address includes a first field, a second field, a third field, and a fourth field, which are separated by a first delimiter. For example, if the destination IP address is 10.251.15.17 and the first delimiter is ".", then the value of the first field is 10, the value of the second field is 251, the value of the third field is 15, and the value of the fourth field is 17.

[0049] Step S102: Match the values ​​of each field of the destination IP address with the array element values ​​of each level of the index table in the routing database to determine the matching result of each field; wherein, the matching result includes same, different or empty.

[0050] In this embodiment of the invention, the routing database stores a multi-level index table for multiple routes, including a first-level index table, a second-level index table, and a third-level index table. Each level index table stores multiple arrays, and each array includes two elements to represent the indexes of each level of the route.

[0051] Furthermore, the route includes a first field, a second field, a third field, a fourth field, and a mask field. The first to fourth fields are separated by a first delimiter, and the fourth field and the mask field are separated by a second delimiter, which is " / ". The first element of each array is the value of the second to fourth fields of the route, and the second element of the array is the value of the mask field of the route. For example, in the route 10.251.15.17 / 32, the first field value is "10", the second field value is "251", the third field value is "15", the fourth field value is "17", and the mask field value is "32".

[0052] Furthermore, in a multi-level index table, an array in a later-level index table corresponds to the first element value of an array in a previous-level index table. For any route's first to fourth fields, the value of the previous field can determine the storage location of the array corresponding to the next field in each level of the index table.

[0053] In this embodiment of the invention, since the storage location of the array for the next field in the index table can be determined based on the value of the preceding field of the destination IP address, the router can determine the storage location of the arrays corresponding to the second to fourth fields in the index table based on the values ​​of each of the first to third fields. Then, by comparing the values ​​of the second to fourth fields with the first element values ​​of each array in each level of the index table, the matching result for each IP address field can be determined. A matching result of "same" indicates that the value of the IP address field is the same as the first element value of one of the arrays at the corresponding storage location in the index table; a matching result of "different" indicates that the value of the IP address field is different from the first element values ​​of all the arrays at the corresponding storage location in the index table; and a matching result of "empty" indicates that no array exists at the corresponding storage location in the index table.

[0054] In embodiments of the present invention, such as Figure 2 As shown, the method for determining the index table of the present invention includes the following steps:

[0055] Step S201: Obtain one or more routes to be saved.

[0056] In an embodiment of the present invention, for example, multiple routes to be saved include 10.0.0.0 / 8, 10.250.8.0 / 21, 10.250.0.0 / 15, 10.251.0.0 / 16, 10.251.8.0 / 21, 10.251.12.0 / 22, and 10.251.15.16 / 28.

[0057] Step S202: Locate the first storage location in the first-level index table based on the value of the first field of the route to be stored.

[0058] In an embodiment of the present invention, for example, based on the value of 10 in the first field of multiple routes to be stored, such as 10.0.0.0 / 8, 10.250.8.0 / 21, 10.250.0.0 / 15, 10.251.0.0 / 16, 10.251.8.0 / 21, 10.251.12.0 / 22, and 10.251.15.16 / 28, the first storage location is located as the 10th storage bit in the first-level index table.

[0059] Step S203: Determine whether the value of the mask field of the route to be stored is 0. If yes, proceed to step S204; otherwise, proceed to step S205.

[0060] Step S204: Determine that the data in the first storage location is empty.

[0061] In an embodiment of the present invention, for example, the mask field values ​​of multiple routes to be stored, 10.0.0.0 / 8, 10.250.8.0 / 21, 10.250.0.0 / 15, 10.251.0.0 / 16, 10.251.8.0 / 21, 10.251.12.0 / 22, and 10.251.15.16 / 28, are non-zero, therefore the data in the corresponding first storage location is not empty.

[0062] Step S205: Determine whether the value of the mask field of the route to be stored is greater than the maximum mask value of the second field. If yes, proceed to step S206; otherwise, proceed to step S207.

[0063] In this embodiment of the invention, the maximum mask value of each field is determined by the product of the field's order value and the mask base value; wherein, the mask base value is 8. For example, the maximum mask value of the second field = 2 * 8 = 16, the maximum mask value of the third field = 3 * 8 = 24, the maximum mask value of the fourth field = 4 * 8 = 32, the mask field values ​​of the routes to be saved 10.250.8.0 / 21, 10.251.8.0 / 21, 10.251.12.0 / 22, and 10.251.15.16 / 28 are greater than the maximum mask value of the second field, 16, and the mask field values ​​of the routes to be saved 10.0.0.0 / 8, 10.250.0.0 / 15, and 10.251.0.0 / 16 are less than or equal to the maximum mask value of the second field, 16.

[0064] Step S206: Store the value of the second field of the route to be stored and the maximum mask value of the second field in the first storage location in the form of an array, and proceed to step S210.

[0065] In this embodiment of the invention, when the value of the mask field of the route to be stored is greater than the maximum mask value of the second field, the value of the second field and the maximum mask value of the second field of the route to be stored are stored in the first storage location in the form of an array; wherein, the value of the second field is the first element value of the array, and the maximum mask value of the second field is the second element value of the array. For example, the values ​​of the second field and the maximum mask value of the second field of the routes to be stored, 10.250.8.0 / 21, 10.251.8.0 / 21, 10.251.12.0 / 22, and 10.251.15.16 / 28, are stored in the first storage location in the form of arrays [250, 16] and [251, 16].

[0066] Step S207: Store the value of the second field of the route to be saved and the value of the mask field in the first storage location in the form of an array, and proceed to step S208.

[0067] In this embodiment of the invention, when the value of the mask field of the route to be stored is not greater than the maximum mask value of the second field, the values ​​of the second field and the mask field of the route to be stored are stored in the first storage location in the form of an array; wherein, the value of the second field is the first element value of the array, and the value of the mask field is the second element value of the array. For example, the values ​​of the second field and the mask field of the routes to be stored, 10.0.0.0 / 8, 10.250.0.0 / 15, and 10.251.0.0 / 16, are stored in the first storage location in the form of arrays [0,8], [250,15], and [251,16].

[0068] Furthermore, based on steps S206 and S207, after deduplication, the 10th storage bit of the first-level index table stores [0,8], [250,15], [250,16], and [251,16], as shown below. Figure 3 As shown.

[0069] Furthermore, the total number of storage bits in each level of the index table is the maximum value of an 8-bit binary number, 255; that is, each level of the index table includes 255 storage bits. It should be noted that the total number of storage bits in the index table can be selectively set according to actual needs.

[0070] Step S208: Determine whether the value of the second field of the route to be stored is 0. If yes, proceed to step S209; otherwise, proceed to step S210.

[0071] Step S209: Stop storage.

[0072] In this embodiment of the invention, when the value of the mask field is greater than the maximum mask value of the second field, it indicates that the value of the third field of the route to be stored exists, so the third field can continue to be judged. When the value of the mask field is less than or equal to the maximum mask value of the second field, according to the principle of "stop storing when the number encounters 0 and the value of the mask field is less than the maximum mask value of the field containing 0", it is necessary to judge whether the value of the second field is 0. If the value of the second field is 0, only the value of the second field needs to be stored, and there is no need to judge the fields after the second field. At this time, the value of the fields after the second field must also be the default field value, so storage is stopped directly. During subsequent route forwarding, the default field value can be used to fill the values ​​of the third and fourth fields after the second field. For example, if the value of the second field of the route to be stored 10.0.0.0 / 8 is 0, and the values ​​of the second fields of the routes to be stored 10.250.0.0 / 15 and 10.251.0.0 / 16 are not 0, then the storage of the route to be stored 10.0.0.0 / 8 is stopped.

[0073] In this embodiment of the invention, when the value of the mask field is greater than the maximum mask value of the third field, it indicates that the value of the fourth field of the route to be stored exists, so the fourth field can continue to be judged. When the value of the mask field is less than or equal to the maximum mask value of the third field, according to the principle of "stop storing when the number is 0 and the value of the mask field is less than the maximum mask value of the field containing 0", it is necessary to judge whether the value of the third field is 0. When the value of the third field is 0, only the value of the third field needs to be stored, and there is no need to judge the fields after the third field. At this time, the value of the fields after the third field must also be the default field value, so storage is stopped directly. In subsequent route forwarding, the default field value can be directly used to fill the value of the fourth field after the third field. For example, the value of the third field of routes 10.250.0.0 / 15 and 10.251.0.0 / 16 to be saved is 0, while the value of the third field of routes 10.250.8.0 / 21, 10.251.8.0 / 21 and 10.251.12.0 / 22 ​​to be saved is not 0. Therefore, routes 10.250.0.0 / 15 and 10.251.0.0 / 16 to be saved will stop being saved.

[0074] Step S210: Locate the second storage location in the second-level index table based on the value of the second field of the route to be stored.

[0075] In an embodiment of the present invention, for example, based on the value of the second field of the routes to be stored, 10.250.8.0 / 21, 10.251.8.0 / 21, 10.251.12.0 / 22, 10.251.15.16 / 28, 10.250.0.0 / 15, and 10.251.0.0 / 16, the corresponding second storage location is located as the 250th and 251st storage bits of the second-level index table.

[0076] Step S211: Determine whether the value of the mask field of the route to be saved is greater than the maximum mask value of the third field. If yes, proceed to step S212; otherwise, proceed to step S213.

[0077] Step S212: Store the value of the third field of the route to be saved and the maximum mask value of the third field in the second storage location in the form of an array, and proceed to step S215.

[0078] In an embodiment of the present invention, for example, if the value of the mask field of the route to be stored 10.251.15.16 / 28 is greater than the maximum mask value 24 of the third field, the value of the third field of the route to be stored 10.251.15.16 / 28 and the maximum mask value 24 of the third field are stored in the second storage location in the form of an array [15,24].

[0079] Step S213: Store the value of the third field of the route to be saved and the value of the mask field in the second storage location in the form of an array, and proceed to step S214.

[0080] In this embodiment of the invention, for example, if the values ​​of the mask field of the routes to be stored, 10.250.8.0 / 21, 10.251.8.0 / 21, 10.251.12.0 / 22, 10.250.0.0 / 15, and 10.251.0.0 / 16, are less than the maximum mask value of the third field, 24, then the values ​​of the third field and the mask field of the routes to be stored, 10.250.8.0 / 21, 10.251.8.0 / 21, 10.251.12.0 / 22, 10.250.0.0 / 15, and 10.251.0.0 / 16, are stored in the second storage location in the form of arrays [8,21], [8,21], [12,22], [0,15], and [0,16].

[0081] Furthermore, based on steps S212 and S213, the 250th storage bit of the second-level index table stores [8,21] and [0,15], and the 251st storage bit stores [8,21], [12,22], [0,16], and [15,24], as shown below. Figure 3 As shown.

[0082] Step S214: Determine whether the value of the third field of the route to be stored is 0. If yes, proceed to step S209; otherwise, proceed to step S215.

[0083] Step S215: Locate the third storage location in the third-level index table based on the value of the third field of the route to be stored.

[0084] In an embodiment of the present invention, for example, based on the value of the third field of the routes to be stored, 10.251.15.16 / 28, 10.250.8.0 / 21, 10.251.8.0 / 21, and 10.251.12.0 / 22, the corresponding third storage locations are located as the 15th, 8th, and 12th storage bits of the third-level index table.

[0085] Step S216: Determine whether the value of the mask field of the route to be saved is greater than the maximum mask value of the fourth field. If yes, proceed to step S217; otherwise, proceed to step S218.

[0086] Step S217: Store the value of the fourth field of the route to be stored and the maximum mask value of the fourth field in the third storage location in the form of an array, and proceed to step S209.

[0087] Step S218: Store the value of the fourth field of the route to be saved and the value of the mask field in the third storage location in the form of an array, and proceed to step S209.

[0088] In an embodiment of the present invention, for example, if the value of the mask field of the routes to be stored, 10.251.15.16 / 28, 10.250.8.0 / 21, 10.251.8.0 / 21, and 10.251.12.0 / 22, is less than the maximum mask value of the fourth field, 32, then the values ​​of the fourth field and the mask field of the routes to be stored, 10.251.15.16 / 28, 10.250.8.0 / 21, 10.251.8.0 / 21, and 10.251.12.0 / 22, are stored in the third storage location in the form of arrays [16,28], [0,21], [0,21], and [0,22].

[0089] Furthermore, based on steps S217 and S218, the 15th storage bit of the third-level index table stores [16,28], the 8th storage bit stores [0,21], and the 12th storage bit stores [0,22], as shown below. Figure 3 As shown.

[0090] In this embodiment of the invention, once the value of the fourth field is stored, it indicates that the route to be stored has been determined, and the first-level index table to the third-level index table is generated.

[0091] In this embodiment of the invention, the index table generation method of the present invention, based on the principles of classification and multi-level indexing, compares the values ​​of the mask fields and the maximum mask values ​​of the non-mask fields of each route to be stored with the values ​​of the mask fields and the mask values ​​of each route to be stored in the form of an array, and pre-stores them in the multi-level index table. Thus, when adding route entries, a multi-level index is constructed, so that the target route of the communication request can be determined by indexing level by level in the subsequent route forwarding process, which greatly reduces the routing time and improves the routing forwarding efficiency and data communication efficiency.

[0092] In another embodiment of the present invention, since the router can divide the routes to be stored according to the required number of subnets, when the obtained routes to be stored do not include the mask field, the router can store the subnetting results of the routes to be stored in the first-level index table to the third-level index table according to the values ​​of the second to fourth fields and the number of bits in the subnet mask. Furthermore, during the subsequent target route generation process, the router can arbitrarily combine the target routes according to the subnetting results to forward communication requests. Accordingly, the route forwarding method of the present invention includes:

[0093] Based on the number of bits in the subnet mask, the routes to be stored are divided into subnets and stored in the first-level index table to the third-level index table respectively. Specifically:

[0094] The values ​​of the second to fourth fields of the route to be stored are converted into binary to obtain the first to third conversion results;

[0095] Permuting the first to third transformation results yields the corresponding first to third permutation results.

[0096] The first to third permutation results are converted to decimal to obtain the subnetting results of the routes to be stored. The subnetting values ​​corresponding to the second to fourth fields in the subnetting results are stored in the first to third level index tables respectively.

[0097] Further, the permutation of the first transformation result to the third transformation result includes:

[0098] Following a right-to-left order, replace each digit 1 in the first conversion result to the third conversion result, except for the first digit 1, with the digit 0.

[0099] The subnetting result of obtaining the route to be stored includes:

[0100] The fourth to sixth conversion results of the decimal conversion are compared with the values ​​of the second to fourth fields respectively, and the fourth to sixth conversion results that are less than or equal to the values ​​of the second to fourth fields are determined.

[0101] The fourth to sixth transformation results, whose values ​​are less than or equal to those of the second to fourth fields, and the values ​​of the second to fourth fields are combined to form the subnet partitioning result.

[0102] For example, if the subnet mask is 32 bits and the route to be saved is 10.251.15.17, the values ​​of the second to fourth fields of the route to be saved, 10.251.15.17, are converted to binary. The first to third conversion results are 11111011, 00001111, and 00010001, respectively.

[0103] Starting from right to left, replace each digit 1 in 11111011 with a digit 0, except for the first digit 1. The first replacement results include 11111010, 11111000, 11110000, 11100000, 11000000, and 10000000. Converting the first replacement results to decimal, the fourth conversion results include 250, 248, 240, 224, 192, and 128. Then determine the digits less than or equal to the second digit. The fourth transformation results of segment value 251, 250, 248, 240, 224, 192, 128, are combined with the value of the second field 251 to obtain 251, 250, 248, 240, 224, 192, 128. The arrays [10,251], [10,250], [10,248], [10,240], [10,224], [10,192], [10,128] composed of the segment value and the value of the first field are stored in the first-level index table.

[0104] Starting from right to left, replace each digit 1 in 00001111 with a digit 0, except for the first digit 1. The resulting second replacements are 00001110, 00001100, and 00001000. Convert these second replacements to decimal, resulting in the fifth replacements 14, 12, and 8. Determine the fifth replacements 14, 12, and 8 that are less than or equal to the value 15 in the third field. Combine these with the value 15 in the third field to obtain 15, 14, 12, and 8. Then, create arrays [251,15], [251,14], [251,12], and [251, 15], composed of the partition values ​​of the third and second fields. [8], [250,15], [250,14], [250,12], [250,8], [248,15], [248,14], [248,12], [248,8], [240,15], [240,14], [240,12], [240,8], [224,15], [224,14], [224,12], [224,8], [192,15], [192,14], [192,12], [192,8], [128,15], [128,14], [128,12], [128,8] are stored in the second-level index table.

[0105] Following a right-to-left order, replace each digit 1 in 00010001 except the first digit 1 with a digit 0. The resulting third replacement result includes 00010000. Convert 00010000 to decimal to obtain the sixth conversion result 16. Determine the sixth conversion result 16 that is less than or equal to the value 17 in the fourth field. Combine it with the value 17 in the fourth field to obtain 17 and 16. Store the arrays [15,17], [15,16], [14,17], [14,16], [12,17], [12,16], [8,17], and [8,16], composed of the partition values ​​of the fourth field and the partition values ​​of the third field, into the third-level index table.

[0106] Step S103: If the matching results are different, determine the target index table corresponding to the matching results.

[0107] In this embodiment of the invention, the router matches the values ​​of the second to fourth fields of the destination IP address with the values ​​of the first element of the array in the first to third level index tables through a pre-constructed multi-level index table, and determines the matching result of the second to fourth fields.

[0108] Step S104: Generate a target route based on the matching array of the target index table and at least one level index table preceding the target index table, and use the target route to forward the communication request.

[0109] In this embodiment of the invention, depending on the different matching results, the router determines the target route in a corresponding manner based on the default route, the target index table corresponding to the matching result, the matching array of the index table before the target index table, the value of the first field of the destination IP address, the value of the field corresponding to the matching result, the value of the field before the field corresponding to the matching result, and the default field value, so as to forward the communication request.

[0110] In embodiments of the present invention, such as Figure 4 As shown, the target route generation method of the present invention includes the following steps:

[0111] Step S401: Locate the first storage location in the first-level index table based on the value of the first field of the destination IP address.

[0112] In an embodiment of the present invention, for example, if the destination IP address is 10.251.15.17, the first storage location in the first-level index table is the 10th storage bit based on the value 10 of the first field.

[0113] Step S402: Determine whether the array at the first storage location is empty. If yes, proceed to step S403; otherwise, proceed to step S405.

[0114] In this embodiment of the invention, the router determines whether at least one array exists in the first storage location; that is, the router determines whether the array in the first storage location is empty. For example, the 10th storage bit of the first-level index table is not empty.

[0115] Step S403: Determine that the matching result of the second field is empty.

[0116] In this embodiment of the invention, if the array in the first storage location is empty, the router determines that the matching result of the second field is empty.

[0117] Step S404: Use the default route as the target route.

[0118] In this embodiment of the invention, the default route refers to a pre-configured default route stored in the routing database, used to select a route for forwarding communication requests when the router cannot match an available route for the destination IP address. If the matching result of the second field is empty, the router will use the default route as the target route to forward the communication request. The default route is 0.0.0.0 / 0.

[0119] Step S405: Determine whether the value of the second field is the same as the value of the first element of each array in the first storage location. If yes, proceed to step S406; otherwise, proceed to step S417.

[0120] In an embodiment of the present invention, for example, the value 251 of the second field of the destination IP address 10.251.15.17 is the same as the first element value of [251,16] in the 10th storage bit of the first-level index table.

[0121] Step S406: Determine that the matching result of the second field is the same.

[0122] In this embodiment of the invention, if the value of the second field is the same as the first element value of any array in the first storage location, the router determines that the matching result of the second field is the same, and the matching value is the matching array in the first storage location that matches the value of the second field. For example, it is confirmed that the matching result of the second field of the destination IP address 10.251.15.17 is the same.

[0123] Step S407: Locate the second storage location in the second-level index table based on the value of the second field of the destination IP address.

[0124] In an embodiment of the present invention, for example, based on the value 251 of the second field of the destination IP address 10.251.15.17, the second storage location in the second-level index table is located as the 251st storage bit.

[0125] Step S408: Determine whether the array at the second storage location is empty. If yes, proceed to step S409; otherwise, proceed to step S412.

[0126] In an embodiment of the present invention, for example, the 251st storage bit of the second-level index table is not empty.

[0127] Step S409: Determine that the matching result of the third field or the fourth field is empty.

[0128] Step S410: The index table preceding the index table corresponding to the empty matching result is taken as the target index table.

[0129] In this embodiment of the invention, when the matching result of the third field is empty, the first-level index table of the second-level index table where the matching result of the third field is empty is determined as the target index table corresponding to the matching result of the third field being empty; when the matching result of the fourth field is empty, the first-level index table of the third-level index table where the matching result of the fourth field is empty is determined as the target index table corresponding to the matching result of the fourth field being empty.

[0130] Step S411: Generate the target route based on the value of the first field, the matching array of the target index table, and the value of at least one field preceding the field where the matching result is empty.

[0131] In this embodiment of the invention, when the matching result of the third field is empty, a target route is generated based on the value of the first field, the matching array of the first-level index table, and the value of the second field; when the matching result of the fourth field is empty, a target route is generated based on the value of the first field, the matching array of the second-level index table, the value of the second field, and the value of the third field. Specifically:

[0132] Step S4101: Determine the value of at least one field of the target route based on the value of at least one field preceding the field where the matching result is empty.

[0133] In this embodiment of the invention, if the matching result of the third field is empty, the value of the second field is determined to be the value of the second field of the target route; if the matching result of the fourth field is empty, the value of the second field is determined to be the value of the second field of the target route and the value of the third field is the value of the third field of the target route.

[0134] Step S4102: Use the second element value of the matching array of the target index table as the value of the mask field of the target route.

[0135] In this embodiment of the invention, when the matching result of the third field is empty, the second element value of the matching array of the second field is used as the value of the mask field of the target route; when the matching result of the fourth field is empty, the second element value of the matching array of the third field is used as the value of the mask field of the target route.

[0136] Step S4103: Concatenate the value of the first field, the value of at least one field of the target route, the default field value, and the value of the mask field of the target route to obtain the target route.

[0137] In this embodiment of the invention, since the target route also includes a first field, a second field, a third field, a fourth field, and a mask field, when the number of fields with empty matching results for the destination IP address is determined, the default field value is used as the value of the field with empty matching results and the fields following it. The target route is obtained by concatenating the value of the first field, the value of at least one field of the target route, the default field value of the field with empty matching results, the default field value of the field following the field with empty matching results, and the value of the mask field of the target route. The default field value is 0.

[0138] Furthermore, if the matching result of the third field is empty, the values ​​of the third and fourth fields are the default field values. The target route is obtained by concatenating the value of the first field, the value of the second field of the target route, the default field value of the third field, the default field value of the fourth field, and the value of the mask field of the target route. If the matching result of the fourth field is empty, the value of the fourth field is the default field value. The target route is obtained by concatenating the value of the first field, the values ​​of the second and third fields of the target route, the default field value of the fourth field, and the value of the mask field of the target route.

[0139] Step S412: Determine whether the value of the third field is the same as the value of the first element of each array in the second storage location. If yes, proceed to step S413; otherwise, proceed to step S417.

[0140] In an embodiment of the present invention, for example, it is determined that the value 15 of the third field of the destination IP address 10.251.15.17 is the same as the first element value of [15,24] in the 251st storage bit of the second-level index table.

[0141] Step S413: Locate the third storage location in the third-level index table based on the value of the third field of the destination IP address.

[0142] In an embodiment of the present invention, for example, based on the value 15 of the third field of the destination IP address 10.251.15.17, the third storage location in the third-level index table is located as the 15th storage bit.

[0143] Step S414: Determine whether the array at the third storage location is empty. If yes, proceed to step S409; otherwise, proceed to step S415.

[0144] In an embodiment of the present invention, for example, the 15th storage bit of the third-level index table is not empty.

[0145] Step S415: Determine whether the value of the fourth field is the same as the value of the first element of each array in the third storage location. If yes, proceed to step S416; otherwise, proceed to step S417.

[0146] In an embodiment of the present invention, for example, the value 17 of the fourth field of the destination IP address 10.251.15.17 is different from the value of the first element of each array in the 15th storage bit of the third-level index table.

[0147] Step S416: Generate the target route based on the values ​​of the first field, the second field, the third field, the fourth field, and the matching array of the fourth field.

[0148] Step S4161: Use the second element value of the matching array as the value of the mask field of the target route.

[0149] In this embodiment of the invention, if the value of the fourth field is the same as the value of the first element of each array in the third storage location, the value of the second element of the matching array of the fourth field is used as the value of the mask field of the target route.

[0150] Step S4162: Concatenate the values ​​of the first field, the second field, the third field, the fourth field, and the mask field of the target route to obtain the target route.

[0151] Step S417: Determine that the matching results of the second field, the third field, or the fourth field are different.

[0152] In an embodiment of the present invention, for example, it is determined that the matching result of the fourth field of the destination IP address 10.251.15.17 is different.

[0153] Step S418: Use the index table corresponding to the different matching results as the target index table.

[0154] In this embodiment of the invention, when the matching results of the second field are different, the first-level index table is used as the target index table corresponding to the different matching results of the second field; when the matching results of the third field are different, the second-level index table is used as the target index table corresponding to the different matching results of the third field; when the matching results of the fourth field are different, the third-level index table is used as the target index table corresponding to the different matching results of the fourth field. For example, the third-level index table is used as the target index table for the destination IP address 10.251.15.17.

[0155] Step S419: Generate the target route based on the matching array of the target index table and at least one level index table preceding the target index table.

[0156] Step S4191: Determine the value of the field corresponding to the different matching results of the target route based on the maximum value of the first element of each array included in the storage location of the target index table corresponding to the different matching results.

[0157] In this embodiment of the invention, when the matching results of the second field are different, the value of the second field of the target route is determined according to the maximum value of the first element of each array included in the first storage location of the first-level index table; when the matching results of the third field are different, the value of the third field of the target route is determined according to the maximum value of the first element of each array included in the second storage location of the second-level index table; when the matching results of the fourth field are different, the value of the fourth field of the target route is determined according to the maximum value of the first element of each array included in the third storage location of the third-level index table. For example, based on the first element value of 16 in [16,28] at the 15th storage location of the third-level index table, the value of the fourth field of the target route with destination IP address 10.251.15.17 is determined to be 16.

[0158] Step S4192: Use the second element value of the array corresponding to the maximum value as the value of the mask field of the target route.

[0159] In this embodiment of the invention, when the matching results of the second field are different, the second element value of the array corresponding to the maximum value of the first element value at the first storage location in the first-level index table is used as the value of the mask field of the target route; when the matching results of the third field are different, the second element value of the array corresponding to the maximum value of the first element value at the second storage location in the second-level index table is used as the value of the mask field of the target route; when the matching results of the fourth field are different, the second element value of the array corresponding to the maximum value of the first element value at the third storage location in the third-level index table is used as the value of the mask field of the target route. For example, the second element value 28 of the array [16,28] corresponding to 16 is used as the value of the mask field of the target route for the destination IP address 10.251.15.17.

[0160] Step S4193: Concatenate the value of the first field, the value of the field corresponding to the different matching result of the target route, and the value of the mask field of the target route to obtain the target route.

[0161] In this embodiment of the invention, since the target route also includes a first field, a second field, a third field, a fourth field, and a mask field, when it is determined that the matching result of the destination IP address is a different field, the default field value is used as the value of the remaining fields after the different matching result. The target route is obtained by concatenating the value of the first field, the value of the field before the field corresponding to the different matching result, the value of the field corresponding to the different matching result of the target route, the default field value of the remaining fields, and the value of the mask field of the target route. The default field value is 0.

[0162] Furthermore, if the matching results of the second field are different, the values ​​of the third and fourth fields are default field values. Since there are no other fields before the second field except the first field, the values ​​of the fields before the second field are ignored, and the values ​​of the first field, the second field of the target route, the default field value of the third field, the default field value of the fourth field, and the mask field of the target route are concatenated to obtain the target route. If the matching results of the third field are different, the value of the fourth field is a default field value. The values ​​of the first field, the second field, the third field of the target route, the default field value of the fourth field, and the mask field of the target route are concatenated to obtain the target route. If the matching results of the fourth field are different, since the fourth field is the last field, there are no default field values ​​after the fourth field. The values ​​of the first field, the second field, the third field, the fourth field of the target route, and the mask field of the target route are concatenated to obtain the target route. For example, by concatenating the values ​​of the first field (10) of the destination IP address 10.251.15.17, the second field (251) of the destination IP address 10.251.15.17, the third field (15) of the destination IP address 10.251.15.17, the fourth field (16) of the destination route, and the mask field (28) of the destination route, we get the destination route 10.251.15.16 / 28 for the destination IP address 10.251.15.17.

[0163] In this embodiment of the invention, when multiple arrays in the target index table can match the matching field, the method further includes:

[0164] Either one can be chosen as the matching array; or, based on the order value of the matching field and the mask base value, a matching array can be selected from the target index table, specifically:

[0165] The mask range of the matching field is determined based on the order value of the matching field and the base value of the mask;

[0166] In the target index table, the array corresponding to the second element value belonging to the mask interval is selected as the matching array.

[0167] In this embodiment of the invention, the mask interval is determined based on the product of the sequence value of the matching field and the base value of the mask; wherein, the initial value of the mask field is 1. For example, the sequence value of the first field is 1, the sequence value of the second field is 2, the sequence value of the third field is 3, and the sequence value of the fourth field is 4. Starting from 1, the mask interval of the first field is [1,8], the mask interval of the second field is [9,16], the mask interval of the third field is [17,24], and the mask interval of the second field is [25,32].

[0168] Furthermore, for example, if the target index table is a first-level index table, and there are multiple matching arrays [251,16][251,21][251,7] in the first-level index table, and the matching field is the second field, then the matching array is [251,16].

[0169] Furthermore, it is preferable to use an array whose second element value is equal to the product of the order value of the matching field and the base value of the mask as the matching array. For example, it is preferable to use an array whose second element value is equal to 8, 16, 24, etc. as the matching array.

[0170] In this embodiment of the invention, the target route generation method of the present invention performs segmentation processing based on the destination IP address, locates the target route level by level starting from the first-level index table, and combines the target routes. The best target route can be accurately matched with at most 3 indexes, realizing fast route selection. It does not require complex calculation and comparison of all route entries, which can improve the forwarding efficiency of communication requests and improve data transmission efficiency.

[0171] In this embodiment of the invention, the routing forwarding method of the present invention matches the values ​​of each field of the destination IP address of the communication request with the array element values ​​of each level of the index table in the routing database level by level. The target route is generated according to the matching results. By using the ideas of classification and multi-level indexing, multi-level phonetic symbols are constructed when adding route entries, so that the target route can be determined by indexing the destination IP address level by level, thereby reducing storage costs, improving the simplicity and clarity of storage, reducing the time consumption and time cost of data forwarding, and improving routing forwarding efficiency.

[0172] Figure 5 This is a schematic diagram of the main modules of a routing forwarding device according to an embodiment of the present invention, such as... Figure 5 As shown, the routing forwarding device 500 of the present invention includes:

[0173] The receiving module 501 is used to receive one or more communication requests; wherein the communication request includes a destination IP address.

[0174] The matching module 502 is used to match the values ​​of each field of the destination IP address with the array element values ​​of each level of the index table in the routing database to determine the matching result of each field; wherein the matching result includes the same, different or empty.

[0175] The data processing module 503 is used to determine the target index table corresponding to the matching result when the matching results are different.

[0176] The generation module 504 is used to generate a target route based on the matching array of the target index table and at least one level index table preceding the target index table, and to forward the communication request using the target route.

[0177] An exemplary embodiment of the present invention also provides an electronic device, including: at least one processor; and a memory communicatively connected to the at least one processor. The memory stores a computer program executable by the at least one processor, the computer program being executed by the at least one processor to cause the electronic device to perform a method according to an embodiment of the present invention.

[0178] An exemplary embodiment of the present invention also provides a non-transitory computer-readable storage medium storing a computer program, wherein the computer program, when executed by a computer's processor, is used to cause the computer to perform a method according to an embodiment of the present invention.

[0179] An exemplary embodiment of the present invention also provides a computer program product, including a computer program, wherein, when executed by a computer's processor, the computer program is used to cause the computer to perform a method according to an embodiment of the present invention.

[0180] refer to Figure 6 The present invention will now be described in the form of a structural block diagram of an electronic device 600 that can serve as a server or client of the present invention, which is an example of a hardware device that can be applied to various aspects of the present invention. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.

[0181] like Figure 6 As shown, the electronic device 600 includes a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 606 into a random access memory (RAM) 603. The RAM 603 may also store various programs and data required for the operation of the device 600. The computing unit 601, ROM 602, and RAM 603 are interconnected via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.

[0182] Multiple components in electronic device 600 are connected to I / O interface 605, including: input unit 606, output unit 607, storage unit 608, and communication unit 609. Input unit 606 can be any type of device capable of inputting information to electronic device 600. Input unit 606 can receive input digital or character information and generate key signal inputs related to user settings and / or function control of electronic device. Output unit 607 can be any type of device capable of presenting information and may include, but is not limited to, a display, speaker, video / audio output terminal, vibrator, and / or printer. Storage unit 604 may include, but is not limited to, disk and optical disk. Communication unit 609 allows electronic device 600 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks, and may include, but is not limited to, modems, network cards, infrared communication devices, wireless communication transceivers and / or chipsets, such as Bluetooth™ devices, WiFi devices, WiMa6 devices, cellular communication devices, and / or the like.

[0183] The computing unit 601 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, a digital signal processor (DSP), and any suitable processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above. For example, in some embodiments, methods 100, 200, and 400 may be implemented as computer software programs tangibly contained in a machine-readable medium, such as storage unit 608. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 600 via ROM 602 and / or communication unit 609. In some embodiments, the computing unit 601 may be configured to perform methods 100, 200, and 400 by any other suitable means (e.g., by means of firmware).

[0184] The program code used to implement the methods of the present invention can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general-purpose computer, special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the program code causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code can be executed entirely on the machine, partially on the machine, as a standalone software package partially on the machine and partially on a remote machine, or entirely on a remote machine or server.

[0185] In the context of this invention, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. Machine-readable media can include, but are not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0186] As used herein, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, device, and / or apparatus (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including machine-readable media that receive machine instructions as machine-readable signals. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0187] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device for displaying information to the user (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor); and a keyboard and pointing device (e.g., a mouse or trackball) through which the user provides input to the computer. Other types of devices can also be used to provide interaction with the user; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including sound input, voice input, or tactile input).

[0188] The systems and technologies described herein can be implemented in computing systems that include backend components (e.g., as a data server), or computing systems that include middleware components (e.g., an application server), or computing systems that include frontend components (e.g., a user computer with a graphical user interface or web browser through which a user can interact with embodiments of the systems and technologies described herein), or any combination of such backend, middleware, or frontend components. The components of the system can be interconnected via digital data communication of any form or medium (e.g., a communication network). Examples of communication networks include local area networks (LANs), wide area networks (WANs), and the Internet.

[0189] Computer systems can include clients and servers. Clients and servers are generally located far apart and typically interact through communication networks. Client-server relationships are created by computer programs running on the respective computers and having a client-server relationship with each other.

Claims

1. A routing forwarding method, characterized in that, include: Receive one or more communication requests; wherein the communication request includes a destination IP address; The values ​​of each field of the destination IP address are matched level by level with the array element values ​​of the index tables at each level of the routing database to determine the matching result for each field. The routing database stores multi-level index tables for multiple routes. Each level of the index table stores multiple arrays. Each route includes a first field, a second field, a third field, a fourth field, and a mask field. Each array includes two elements: the first element of each array is the value of the second to fourth fields of the route, and the second element is the value of the mask field of the route or the maximum mask value of the corresponding field. The maximum mask value of each field is determined by the product of the field's sequential value and the mask base value. For any first to fourth field of a route, the value of the preceding field determines the storage location of the array corresponding to the following field in the index tables at each level. The matching result includes identical, different, or empty. The method for determining the index tables at each level includes: obtaining one or more routes to be stored; locating the first to third storage locations in the first to third level index tables based on the values ​​of the first to third fields of the route to be stored; sequentially comparing the value of the mask field of the route to be stored with the maximum mask value of the second to fourth fields; if the value of the mask field of the route to be stored is greater than the maximum mask value, storing the values ​​of the second to fourth fields of the route to be stored and the maximum mask value of the second to fourth fields in the first to third storage locations in the form of an array; if the value of the mask field of the route to be stored is less than or equal to the maximum mask value, storing the values ​​of the second to fourth fields of the route to be stored and the mask field in the first to third storage locations in the form of an array. If the matching results are different, determine the target index table corresponding to the matching results; A target route is generated based on the matching array of the target index table and at least one level of index tables preceding the target index table, and the communication request is forwarded using the target route.

2. The routing forwarding method according to claim 1, characterized in that, The destination IP address includes a first field, a second field, a third field, and a fourth field; the step-by-step matching of the values ​​of each field of the destination IP address with the array element values ​​of each level of the index table in the routing database to determine the matching result of each field includes: Based on the value of the first field of the destination IP address, locate the first storage location in the first-level index table; Determine whether the array at the first storage location is empty. If the array at the first storage location is empty, determine that the matching result of the second field is empty, and use the default route as the target route.

3. The routing forwarding method according to claim 2, characterized in that, If the array at the first storage location is not empty, the method further includes: Based on the value of the second or third field of the destination IP address, locate the second storage location in the second-level index table and the third storage location in the third-level index table; The values ​​of the second to fourth fields are compared with the first element values ​​of each array at the first to third storage locations to determine the matching results of the second to fourth fields. If the matching results of the second to fourth fields are different, the index table corresponding to the different matching results shall be used as the target index table; The target route is generated based on the matching array of the target index table and at least one level of index tables preceding the target index table.

4. The routing forwarding method according to claim 3, characterized in that, Generating the target route based on the matching array of the target index table and at least one level of index tables preceding the target index table includes: Based on the maximum value of the first element of each array included in the storage location corresponding to the different matching results in the target index table, the value of the field corresponding to the different matching results in the target route is determined; The second element of the array corresponding to the maximum value is used as the value of the mask field of the target route; The target route is obtained by concatenating the value of the first field, the value of the field corresponding to the different matching result of the target route, and the value of the mask field of the target route.

5. The routing forwarding method according to claim 3, characterized in that, Before comparing the values ​​of the second to fourth fields with the first element values ​​of the arrays at the first to third storage locations, the method further includes: Determine whether the array from the second storage location to the third storage location is empty. If the array at the second storage location or the third storage location is empty, determine that the matching result of the third field or the fourth field is empty. Then, take the index table above the index table corresponding to the matching result where the third field or the fourth field is empty as the target index table. The target route is generated based on the value of the first field, the matching array of the target index table, and the value of at least one field preceding the field where the matching result is empty.

6. The routing forwarding method according to claim 5, characterized in that, The step of generating the target route based on the value of the first field, the matching array of the target index table, and the value of at least one field preceding the field where the matching result is empty includes: The value of at least one field of the target route is determined based on the value of at least one field preceding the field where the matching result is empty; Use the value of the second element of the matching array of the target index table as the value of the mask field of the target route; The target route is obtained by concatenating the value of the first field, the value of at least one field of the target route, the default field value, and the value of the mask field of the target route.

7. The routing forwarding method according to claim 1, characterized in that, Also includes: Determine if the values ​​of the second to fourth fields are 0. If the value of any field is 0, stop storing.

8. A routing forwarding device, characterized in that, include: A receiving module is configured to receive one or more communication requests; wherein the communication request includes a destination IP address; A matching module is used to match the values ​​of each field of the destination IP address with the array element values ​​of each level of the index table in the routing database to determine the matching result of each field. The routing database stores multi-level index tables for multiple routes. Each level of the index table stores multiple arrays. Each route includes a first field, a second field, a third field, a fourth field, and a mask field. Each array includes two elements. The first element of each array is the value of the second to fourth fields of the route, and the second element is the value of the mask field of the route or the maximum mask value of the corresponding field. The maximum mask value of each field is determined by the product of the field's sequential value and the mask base value. For any first to fourth field of a route, the value of the preceding field determines the storage location of the array corresponding to the following field in each level of the index table. The matching result includes identical values. If the values ​​are different or empty, determine the index tables at each level, including: obtaining one or more routes to be stored; locating the first to third storage locations in the first to third level index tables based on the values ​​of the first to third fields of the route to be stored; sequentially comparing the value of the mask field of the route to be stored with the maximum mask value of the second to fourth fields; if the value of the mask field of the route to be stored is greater than the maximum mask value, storing the values ​​of the second to fourth fields of the route to be stored and the maximum mask value of the second to fourth fields in the first to third storage locations in the form of an array; if the value of the mask field of the route to be stored is less than or equal to the maximum mask value, storing the values ​​of the second to fourth fields of the route to be stored and the mask field in the first to third storage locations in the form of an array. The data processing module is used to determine the target index table corresponding to the matching result when the matching results are different; The generation module is used to generate a target route based on the matching array of the target index table and at least one level index table preceding the target index table, and to forward the communication request using the target route.

9. An electronic device, comprising: processor; as well as Stored program memory, The program includes instructions that, when executed by the processor, cause the processor to perform the routing forwarding method according to any one of claims 1-7.

10. A non-transitory computer-readable storage medium storing computer instructions, wherein, The computer instructions are used to cause the computer to execute the routing forwarding method according to any one of claims 1-7.