A TCAM-based LPM routing lookup device and method

By combining hardware and software methods to manage the position of the routing table in TCAM, the problem of table entry movement and sorting in TCAM logical design is solved, the longest prefix matching route lookup is realized, the table lookup and forwarding performance is improved and the logical design is simplified.

CN118827542BActive Publication Date: 2026-02-24Chinese People's Liberation Army Cyberspace Force Information Engineering University
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410789917.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2026-02-24
Estimated Expiration
2044-06-19

AI Technical Summary

Technical Problem

In existing technologies, the TCAM logical design cannot implement entry movement and sorting, which makes it impossible to guarantee that the longest prefix mask is placed at a low address, affecting the efficiency of route lookup.

Method used

A combination of hardware and software is used to manage the position of the routing table in TCAM through a soft table recording module and a sorting module, ensuring that masks with the same prefix length are on the lower address, and guiding packet forwarding according to the longest prefix matching rule.

Benefits of technology

It implements the longest prefix matching route lookup, which improves the lookup and forwarding performance, simplifies the logic design, and saves hardware resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118827542B_ABST
    Figure CN118827542B_ABST
Patent Text Reader

Abstract

The application belongs to the technical field of Ethernet routing and discloses a TCAM-based LPM routing search device and method, which comprises a soft table recording module, a soft table sorting module and a TCAM table management module; the soft table recording module is used for maintaining the routing table information configured by a user through a soft table; the soft table is used for recording the position of the routing table information in the TCAM; the soft table sorting module is used for managing the front and back order of the routing table in the TCAM and ensuring that the routing tables with the same prefix length mask are arranged on the low address; and the TCAM table management module is used for guiding the message forwarding according to the longest prefix matching rule. The application ensures that the routing table with the longest prefix matching can be sorted in the position with high priority, and realizes the routing table search algorithm with the longest prefix matching.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of Ethernet routing technology, and in particular to an LPM route lookup device and method based on TCAM, wherein TCAM is used for route lookup and forwarding, and software maintains the matching order of the routing table. Background Technology

[0002] The Longest Prefix Match Algorithm (LPM) is a routing lookup mechanism that is used by default in almost all routers in the industry. When a router receives an IP packet, it compares the destination IP address of the packet bit-by-bit with all the routing entries in its local routing table until it finds the entry with the longest match. This is the Longest Prefix Match Algorithm.

[0003] Ternary Content Addressable Memory (TCAM) is a dedicated high-speed memory capable of searching content data within a single clock cycle. The "three states" refer to the memory's use of three different inputs (0, 1, and X) to store and retrieve data, where X represents the "unrelated" state. This allows TCAM to perform broader searches based on pattern matching; it can perform both exact and fuzzy matching searches.

[0004] RAM-based routing lookup schemes create a corresponding forwarding table entry for all IP addresses in RAM. When performing a routing lookup, only the destination IP address needs to be searched, and the corresponding routing information can be found in a single memory access. RAM lookup algorithms are simple, but the storage cost is high, the algorithm update is complex, and when the route changes, there are many table update units. In the worst case, updating a table entry requires operating 64K storage units.

[0005] The TCAM-based routing lookup scheme saves keyword entries of arbitrary length by saving keyword masks, where each entry is saved in the form of an 《address, mask》 pair: Assuming the length of the address keyword ranges from 1 to N, then the address and the mask each occupy N bits. For an entry with a keyword length of Y (1 < Y < N), the last W - Y bits of its address can be 0 or 1; the first Y bits of its mask are 1, and the remaining N - Y bits are 0. For example, assuming N is 5, then the address prefix 10* can be represented by <10000, 11000>. Since multiple entries may match the input keyword, TCAM stipulates that the entry with the lowest address among all matching entries is selected as the final result. To conform to the lookup of the longest prefix route, keywords with longer prefixes are stored at the lower addresses of TCAM, and keywords with shorter prefixes are stored at the higher addresses. The TCAM lookup algorithm has a fast query speed and is simple to implement, but TCAM has a high manufacturing cost, high power consumption, and high heat dissipation. The update operation of TCAM is relatively complex. When inserting a new entry, to ensure the longest prefix match in the future, entries with a prefix length longer than the new entry need to be moved.

[0006] Regarding the routing table lookup mechanism based on the longest prefix match, aiming at the current chip logic design limitations and the problem that the logic does not support the moving and sorting of entries, this patent proposes a method that uses software to maintain the matching order of the routing table and uses TCAM for routing lookup and forwarding, that is, a method combining software and hardware to implement the longest prefix match routing lookup algorithm. Compared with the RAM routing lookup scheme, the forwarding performance is greatly improved. Compared with the traditional TCAM lookup scheme, the logic design is simplified and the hardware resource consumption is reduced. Summary of the Invention

[0007] Aiming at the problem that the logic in TCAM does not implement sorting and moving, and cannot ensure that the longest prefix mask is placed at the lower address, the present invention proposes a TCAM-based LPM routing lookup device and method, which includes a way to manage the matching order of the routing table by software, so as to ensure that the masks with longer lengths in the TCAM table can be placed at the lower addresses and are preferentially selected during lookup, meeting the routing table lookup mechanism of the longest prefix match.

[0008] To achieve the above object, the present invention adopts the following technical solutions:

[0009] On the one hand, the present invention proposes a TCAM-based LPM routing lookup device, including: a soft table recording module, a soft table sorting module, and a TCAM table management module;

[0010] The soft table recording module is used to maintain the routing table information configured by the user through the soft table; the soft table is used to record the position of the routing table information in TCAM;

[0011] The soft table sorting module is used to manage the order of routing tables in TCAM, ensuring that routing tables with the same prefix long mask are placed at lower addresses.

[0012] The TCAM table management module is used to guide packet forwarding based on the longest prefix matching rule.

[0013] Furthermore, when new routing table information is added, the soft table sorting module executes the following process:

[0014] First, scan the soft table to determine the position M of the route table with the relatively shorter mask and the position N of the route table with the longer mask among all route tables in the soft table that have the same prefix as the route table configured by the current user.

[0015] Then scan the soft table between M and N to see if there are any empty spaces;

[0016] If there is a vacant location P', send the current routing table to location P' in TCAM and update the soft table;

[0017] If there is no empty space, scan M to the position E of the soft table where the shortest mask is stored, and determine whether there is an empty space between M and E.

[0018] If there is a spare position P", move the routing table at position P"-1 to P", then delete the routing table at position P"-1, until the current routing table is moved to position M. Then send the current routing table to position M of TCAM and update the soft table.

[0019] If there is no empty space, scan N to the position S of the soft table where the longest mask is stored, and determine whether there is an empty space between N and S.

[0020] If there is a spare position P”', move the routing table at position P”'+1 to P”', then delete the routing table at position P”'+1, until the current routing table is moved to position N, then send the current routing table to position N of TCAM and update the soft table;

[0021] If there are no available spaces, it indicates that the soft table space is insufficient.

[0022] Another aspect of this invention proposes an LPM route lookup method based on TCAM, comprising:

[0023] The routing table information configured by the user is maintained through a soft table; the soft table is used to record the position of the routing table information in the TCAM table;

[0024] Manage the order of routing tables in TCAM, ensuring that routing tables with the same prefix long mask are placed at lower addresses;

[0025] Message forwarding is guided by the longest prefix matching rule.

[0026] Furthermore, when new routing table information is added, the method includes:

[0027] First, scan the soft table to determine the position M of the route table with the relatively shorter mask and the position N of the route table with the longer mask among all route tables in the soft table that have the same prefix as the route table configured by the current user.

[0028] Then scan the soft table between M and N to see if there are any empty spaces;

[0029] If there is a vacant location P', send the current routing table to location P' in TCAM and update the soft table;

[0030] If there is no empty space, scan M to the position E of the soft table where the shortest mask is stored, and determine whether there is an empty space between M and E.

[0031] If there is a spare position P", move the routing table at position P"-1 to P", then delete the routing table at position P"-1, until the current routing table is moved to position M. Then send the current routing table to position M of TCAM and update the soft table.

[0032] If there is no empty space, scan N to the position S of the soft table where the longest mask is stored, and determine whether there is an empty space between N and S.

[0033] If there is a spare position P”', move the routing table at position P”'+1 to P”', then delete the routing table at position P”'+1, until the current routing table is moved to position N, then send the current routing table to position N of TCAM and update the soft table;

[0034] If there are no available spaces, it indicates that the soft table space is insufficient.

[0035] Compared with the prior art, the present invention has the following beneficial effects:

[0036] This invention, based on practical considerations, leverages the advantages of TCAM in quickly implementing table lookup and forwarding, and uses software to maintain a soft table to ensure that the longest prefix matching routing table is ordered in a high-priority position, thus implementing a longest prefix matching routing table lookup algorithm. The advantages are as follows:

[0037] 1) From the user's perspective, the configuration process of this invention is transparent to the user;

[0038] 2) Compared to software implementation, this invention saves CPU resources and improves table lookup forwarding speed;

[0039] 3) Compared with the TCAM algorithm implementation, this invention simplifies the complexity of the logic design. Attached Figure Description

[0040] Figure 1 This is a schematic diagram of the structure of an LPM route lookup device based on TCAM according to an embodiment of the present invention;

[0041] Figure 2 Add one of the routing procedures to the embodiments of the present invention;

[0042] Figure 3 Add a second routing process to the embodiments of the present invention;

[0043] Figure 4 This is a flowchart of an LPM route lookup method based on TCAM according to an embodiment of the present invention. Detailed Implementation

[0044] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments:

[0045] like Figure 1 As shown, an LPM route lookup device based on TCAM includes three parts: a soft table recording module, a soft table sorting module, and a TCAM table management module. The soft table recording module is mainly used to maintain user-configured routing table information; the soft table records the position of the routing table information in the TCAM. The soft table sorting module is mainly used to manage the order of routing tables in the TCAM, ensuring that routing tables with the same prefix length mask are placed at lower addresses. The TCAM table management module is mainly used to guide packet forwarding according to the longest prefix matching rule.

[0046] Furthermore, such as Figure 2 , Figure 3 As shown, when new routing table information is added, the soft table sorting module executes the following process:

[0047] 1. First, scan the soft table to determine the position M of the route table with the relatively shorter mask and the position N of the route table with the longer mask among all route tables in the soft table that have the same prefix as the route table configured by the current user.

[0048] 2. Then scan the soft table between M and N to see if there are any empty spaces;

[0049] 2-1. If there is a spare location P', directly send the current routing table to location P' in TCAM and update the soft table;

[0050] 2-2. If there is no empty space, scan M to the end of the soft table, i.e., the soft table position E where the shortest mask is stored, and determine whether there is an empty space between M and E.

[0051] 2-2-1. If there is a spare position P", move the routing table at position P"-1 to P". The moving process is to first send the routing table at position P", then delete the routing table at position P"-1 to ensure that the traffic is not interrupted. Move to the vacant position M in sequence, then send the routing table sent by the current user to position M of TCAM and update the soft table.

[0052] 2-2-2 If there is no empty position, scan N to the beginning of the soft table, i.e., the soft table position S where the longest mask is stored, and determine whether there is an empty position between N and S.

[0053] 2-2-2-1. If there is a spare position P”', move the routing table at position P”'+1 to P”'. The moving process is to first send the routing table at position P”', and then delete the routing table at position P”'+1 to ensure that the traffic is not interrupted. Move to the vacated position N in sequence, and then send the routing table sent by the current user to position N of TCAM and update the soft table.

[0054] 2-2-2-2. If there are no free spaces, it means that the soft table space is insufficient.

[0055] Based on the above embodiments, such as Figure 4 As shown, this invention also proposes an LPM route lookup method based on TCAM, comprising:

[0056] The routing table information configured by the user is maintained through a soft table; the soft table is used to record the position of the routing table information in the TCAM table;

[0057] Manage the order of routing tables in TCAM, ensuring that routing tables with the same prefix long mask are placed at lower addresses;

[0058] Message forwarding is guided by the longest prefix matching rule.

[0059] Furthermore, when new routing table information is added, the method includes:

[0060] First, scan the soft table to determine the position M of the route table with the relatively shorter mask and the position N of the route table with the longer mask among all route tables in the soft table that have the same prefix as the route table configured by the current user.

[0061] Then scan the soft table between M and N to see if there are any empty spaces;

[0062] If there is a vacant location P', send the current routing table to location P' in TCAM and update the soft table;

[0063] If there is no empty space, scan M to the position E of the soft table where the shortest mask is stored, and determine whether there is an empty space between M and E.

[0064] If there is a spare position P", move the routing table at position P"-1 to P", then delete the routing table at position P"-1, until the current routing table is moved to position M. Then send the current routing table to position M of TCAM and update the soft table.

[0065] If there is no empty space, scan N to the position S of the soft table where the longest mask is stored, and determine whether there is an empty space between N and S.

[0066] If there is a spare position P”', move the routing table at position P”'+1 to P”', then delete the routing table at position P”'+1, until the current routing table is moved to position N, then send the current routing table to position N of TCAM and update the soft table;

[0067] If there are no available spaces, it indicates that the soft table space is insufficient.

[0068] To clearly illustrate the implementation process of this invention, two scenarios are constructed: one is to directly insert an empty table entry without updating the already issued table entries, and the other requires moving existing table entries. The currently issued routing table recorded in the soft table is shown in Table 1.

[0069] Table 1

[0070] Location IP address / mask 0 192.168.1.1 / 24 1 192.168.2.1 / 24 2 192.168.2.1 / 16 3 192.168.3.1 / 24 4 5 192.168.1.1 / 16 6 192.168.1.1 / 8 7 192.168.2.1 / 8 8 9

[0071] Scenario 1: A user configures a routing table with the following route: 192.168.1.1 / 20

[0072] 1. Check if the routing table to be configured already exists. Scan the routing table in the current soft table and compare the current IP address and subnet mask to see if they match.

[0073] 2. Scan the current soft table and find the longer mask 192.168.1.1 / 24 with the same prefix as the current one, with position 0 and the shorter mask 192.168.1.1 / 16 with position 5.

[0074] 3. Check if there is a spare position between position 0 and position 5, i.e., position 4;

[0075] 4. Send the current routing table 192.168.1.1 / 20 to be sent to position 4 in TCAM.

[0076] 5. Update the software table and complete the distribution. The routing information in the updated software table is shown in Table 2.

[0077] Table 2

[0078]

[0079]

[0080] Scenario 2: A user configures a routing table with the following address: 192.168.2.1 / 20

[0081] 1. Check if the routing table to be configured already exists. Scan the routing table in the current soft table and compare the current IP address and subnet mask to see if they match.

[0082] 2. Scan the current soft table and find the longer mask 192.168.2.1 / 24 at position 1 and the shorter mask 192.168.2.1 / 16 at position 2 in the routing table that has the same prefix as the current one;

[0083] 3. Are there any empty spaces between scan position 1 and position 2? No.

[0084] 4. Check if there is any empty space between positions 2 and 9, i.e., position 4;

[0085] 5. Send the routing table from location 3 to location 4 and update the soft table;

[0086] 6. Delete the routing table at location 3 and update the soft table;

[0087] 7. Send the routing table from location 2 to location 3 and update the soft table;

[0088] 8. Delete the routing table at location 2 and update the soft table;

[0089] 9. Send the current routing table 192.168.2.1 / 20 to location 2, update the soft table, and the routing information in the updated soft table is shown in Table 3.

[0090] Table 3

[0091] Location IP address / mask 0 192.168.1.1 / 24 1 192.168.2.1 / 24 2 192.168.2.1 / 20 3 192.168.2.1 / 16 4 192.168.3.1 / 24 5 192.168.1.1 / 16 6 192.168.1.1 / 8 7 192.168.2.1 / 8 8 9

[0092] The above description is only a preferred embodiment of the present invention. It should be noted that those skilled in the art can make several improvements and modifications without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A TCAM-based LPM routing lookup device, characterized in that, include: Soft table recording module, soft table sorting module, and TCAM table management module; The soft table recording module is used to maintain user-configured routing table information through a soft table; the soft table is used to record the location of the routing table information in the TCAM. The soft table sorting module is used to manage the order of routing tables in TCAM, ensuring that routing tables with the same prefix long mask are placed at lower addresses. The TCAM table management module is used to guide packet forwarding based on the longest prefix matching rule. When new routing table information is added, the soft table sorting module executes the following process: First, scan the soft table to determine the position M of the route table with the relatively shorter mask and the position N of the route table with the longer mask among all route tables in the soft table that have the same prefix as the route table configured by the current user. Then scan the soft table between M and N to see if there are any empty spaces; If there is a vacant location P', send the current routing table to location P' in TCAM and update the soft table; If there is no empty space, scan M to the position E of the soft table where the shortest mask is stored, and determine whether there is an empty space between M and E. If there is a spare position P'', move the routing table at position P''-1 to P'', then delete the routing table at position P''-1, until the current routing table is moved to position M. Then, send the current routing table to position M of TCAM and update the soft table. If there is no empty space, scan N to the position S of the soft table where the longest mask is stored, and determine whether there is an empty space between N and S. If there is a spare position P''', move the routing table at position P'''+1 to P''', then delete the routing table at position P'''+1, until the current routing table is moved to position N, then send the current routing table to position N of TCAM and update the soft table; If there are no available spaces, it indicates that the soft table space is insufficient.

2. A TCAM-based LPM route lookup method, characterized in that, include: The routing table information configured by the user is maintained through a soft table; The soft table is used to record the location of routing table information in TCAM; Manage the order of routing tables in TCAM, ensuring that routing tables with the same prefix long mask are placed at lower addresses; Message forwarding is guided by the longest prefix matching rule; When new routing table information is added, this method includes: First, scan the soft table to determine the position M of the route table with the relatively shorter mask and the position N of the route table with the longer mask among all route tables in the soft table that have the same prefix as the route table configured by the current user. Then scan the soft table between M and N to see if there are any empty spaces; If there is a vacant location P', send the current routing table to location P' in TCAM and update the soft table; If there is no empty space, scan M to the position E of the soft table where the shortest mask is stored, and determine whether there is an empty space between M and E. If there is a spare position P'', move the routing table at position P''-1 to P'', then delete the routing table at position P''-1, until the current routing table is moved to position M. Then, send the current routing table to position M of TCAM and update the soft table. If there is no empty space, scan N to the position S of the soft table where the longest mask is stored, and determine whether there is an empty space between N and S. If there is a spare position P''', move the routing table at position P'''+1 to P''', then delete the routing table at position P'''+1, until the current routing table is moved to position N, then send the current routing table to position N of TCAM and update the soft table; If there are no available spaces, it indicates that the soft table space is insufficient.

Citation Information

Patent Citations

  • Method and system for managing TCAM route list

    CN1859208A