Space management method and device for routing table, program product and network equipment

By determining the space management unit to be inserted based on the length of the mask to be inserted in the routing table, the problem of low efficiency in the routing table operation in the prior art is solved, and efficient routing table entry insertion and space management are realized.

CN119484378AActive Publication Date: 2025-02-18TP-LINK
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411676818.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-21
Publication Date
2025-02-18
Estimated Expiration
2044-11-21

AI Technical Summary

Technical Problem

In the prior art, when the space management unit corresponding to the mask length of the routing table entry to be inserted is insufficient, a large number of table entry movements are required, resulting in low operating efficiency of the routing table.

Method used

By determining the space management unit to be inserted in the routing table based on the length of the mask to be inserted, if there is no inserted routing table entry that is greater than the length of the mask to be inserted, the free space management unit with the smallest index will be indexed. Determine as the space management unit to be inserted; if there is an inserted routing table entry that is greater than the length of the code to be inserted, the corresponding inserted space management unit is determined as the space management unit to be inserted, and the above steps are performed recursively until it does not exist. An inserted routing entry that is greater than the length of the mask to be inserted.

Benefits of technology

When inserting routing table entries, each mask length larger than the mask length to be inserted only needs to move one routing table entry, which greatly improves the operation efficiency of the routing table, and the inserted space management unit in the routing table is continuous space helps improve space utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119484378A_ABST
    Figure CN119484378A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of data communication, and particularly relates to a routing table space management method and device, a computer program product and network equipment. The method comprises the following steps: determining a to-be-inserted space management unit of a to-be-inserted routing table item in a routing table based on the length of a to-be-inserted mask; wherein the length of the mask to be inserted is the length of the mask of the routing table item to be inserted, the space management unit of the routing table comprises each continuous inserted space management unit and / or each continuous free space management unit, and the inserted space management units are in one-to-one correspondence with the inserted routing table items; and inserting the to-be-inserted routing table item into the to-be-inserted space management unit.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of data communication technology, and in particular, relates to a method, device, computer program product and network equipment for spatial management of a routing table. Background Art

[0002] With the rapid development of the Internet and the continuous expansion of network scale, network devices such as network devices and switches need to process more and more routing information. The storage and management of routing information is one of the key factors in the performance of network devices. Traditional routing tables are usually implemented using data structures such as hash tables or binary search trees, but these structures have performance bottlenecks when processing large-scale routing tables, especially in scenarios where routing information needs to be quickly found and updated.

[0003] Ternary Content Addressable Memory (TCAM) is a special memory that can perform lookup operations with constant time complexity, so it is widely used in the implementation of routing tables of high-speed network devices. However, the space management method of TCAM routing tables in the prior art requires a large number of table entries to be moved to obtain free space when the space management unit corresponding to the mask length of the routing table entry to be inserted is insufficient, resulting in low operation efficiency of the routing table. Summary of the invention

[0004] In view of this, embodiments of the present application provide a method, apparatus, computer program product, and network device for spatial management of a routing table to solve the problem of low operating efficiency of routing tables in the prior art.

[0005] A first aspect of an embodiment of the present application provides a method for managing routing table space, which may include:

[0006] Based on the mask length to be inserted, determining the space management unit to be inserted in the routing table of the routing table entry to be inserted; wherein the mask length to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each continuous inserted space management unit and / or each continuous free space management unit, and the inserted space management unit corresponds to the inserted routing table entry one by one;

[0007] Inserting the routing table entry to be inserted into the space management unit to be inserted;

[0008] The step of determining a space management unit to be inserted into the routing table for the routing table entry to be inserted based on the length of the mask to be inserted includes:

[0009] If there is no inserted routing table entry whose mask length is greater than the mask length to be inserted, determining the free space management unit with the smallest index as the space management unit to be inserted;

[0010] If there is an inserted routing table entry whose mask length is greater than the mask length to be inserted, the inserted space management unit corresponding to the inserted routing table entry whose mask length is greater than the mask length to be inserted and whose index is the smallest is determined as the space management unit to be inserted, and the inserted routing table entry whose mask length is greater than the mask length to be inserted and whose index is the smallest is determined as the updated routing table entry to be inserted, and the process returns to executing the step of determining the space management unit to be inserted in the routing table of the routing table entry to be inserted based on the mask length to be inserted and its subsequent steps, until there is no inserted routing table entry whose mask length is greater than the mask length to be inserted.

[0011] A second aspect of an embodiment of the present application provides a space management device for a routing table, which may include:

[0012] A determination module, configured to determine, based on a mask length to be inserted, a space management unit to be inserted in a routing table into which the routing table entry to be inserted is to be inserted; wherein the mask length to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each continuous inserted space management unit and / or each continuous free space management unit, and the inserted space management unit corresponds one-to-one to the inserted routing table entry;

[0013] An inserting module, used for inserting the routing table entry to be inserted into the space management unit to be inserted;

[0014] The determination module comprises:

[0015] A first determining submodule, configured to determine the free space management unit with the smallest index as the space management unit to be inserted if there is no inserted routing table entry whose mask length is greater than the mask length to be inserted;

[0016] The second determination submodule is used to determine the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index as the space management unit to be inserted if there is an inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index, and determine the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index as the updated routing table entry to be inserted, and return to execute the step of determining the space management unit to be inserted in the routing table of the routing table entry to be inserted based on the mask length to be inserted and its subsequent steps, until there is no inserted routing table entry with a mask length greater than the mask length to be inserted.

[0017] A third aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any of the above-mentioned routing table space management methods are implemented.

[0018] The fourth aspect of an embodiment of the present application provides a network device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the network device implements the steps of any one of the above-mentioned routing table space management methods.

[0019] A fifth aspect of an embodiment of the present application provides a computer program product, including a computer program, and when the computer program is run, any of the above-mentioned routing table space management methods is executed.

[0020] Compared with the prior art, the embodiments of the present application have the following beneficial effects: the embodiments of the present application determine the space management unit to be inserted into the routing table in which the routing table entry to be inserted is based on the mask length to be inserted; wherein the mask length to be inserted is the mask length of the routing table entry to be inserted, the space management unit of the routing table includes each consecutive inserted space management unit and / or each consecutive free space management unit, and the inserted space management unit corresponds one-to-one to the inserted routing table entry; the routing table entry to be inserted is inserted into the space management unit to be inserted; the method of determining the space management unit to be inserted into the routing table in which the routing table entry to be inserted is based on the mask length to be inserted, including: if there is no already inserted space management unit with a mask length greater than the mask length to be inserted, When inserting a routing table entry, the free space management unit with the smallest index is determined as the space management unit to be inserted; if there is an inserted routing table entry with a mask length greater than the mask length to be inserted, the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index is determined as the space management unit to be inserted, and the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index is determined as the updated routing table entry to be inserted, and the step of determining the space management unit to be inserted in the routing table of the routing table entry to be inserted based on the mask length to be inserted and its subsequent steps are returned to execute, until there is no inserted routing table entry with a mask length greater than the mask length to be inserted. When inserting routing table items, the embodiment of the present application only needs to move one routing table item for each mask length that is larger than the mask length to be inserted, which greatly improves the operating efficiency of the routing table; and the inserted space management units in the routing table are continuous spaces, and the inserted space management units correspond one-to-one to the inserted routing table items, so that the inserted routing table items in the routing table can be arranged tightly and continuously, which helps to improve the space utilization of the routing table. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0022] Figure 1 This is a first schematic diagram of a routing table in an embodiment of the present application;

[0023] Figure 2 A second schematic diagram of a routing table in an embodiment of the present application;

[0024] Figure 3 A flowchart of an embodiment of a method for spatial management of a routing table in an embodiment of the present application;

[0025] Figure 4 A third schematic diagram of a routing table in an embodiment of the present application;

[0026] Figure 5 A fourth schematic diagram of a routing table in an embodiment of the present application;

[0027] Figure 6 This is a fifth schematic diagram of a routing table in an embodiment of the present application;

[0028] Figure 7 A sixth schematic diagram of a routing table in an embodiment of the present application;

[0029] Figure 8 A seventh schematic diagram of a routing table in an embodiment of the present application;

[0030] Fig. 9 This is an eighth schematic diagram of a routing table in an embodiment of the present application;

[0031] Fig.10 This is a ninth schematic diagram of a routing table in an embodiment of the present application;

[0032] Fig.11 This is a tenth schematic diagram of a routing table in an embodiment of the present application;

[0033] Fig.12 This is an eleventh schematic diagram of a routing table in an embodiment of the present application;

[0034] Fig.13 This is a twelfth schematic diagram of a routing table in an embodiment of the present application;

[0035] Fig.14 This is a thirteenth schematic diagram of a routing table in an embodiment of the present application;

[0036] Fig.15This is a fourteenth schematic diagram of a routing table in an embodiment of the present application;

[0037] Fig.16 This is a fifteenth schematic diagram of a routing table in an embodiment of the present application;

[0038] Fig.17 A flowchart of an embodiment of deleting a routing table entry in an embodiment of the present application;

[0039] Fig.18 This is a sixteenth schematic diagram of a routing table in an embodiment of the present application;

[0040] Fig.19 This is a seventeenth schematic diagram of a routing table in an embodiment of the present application;

[0041] Fig. 20 This is an eighteenth schematic diagram of a routing table in an embodiment of the present application;

[0042] Fig.21 This is a nineteenth schematic diagram of a routing table in an embodiment of the present application;

[0043] Fig. 22 This is the twentieth schematic diagram of a routing table in an embodiment of the present application;

[0044] Fig.23 This is a twenty-first schematic diagram of a routing table in an embodiment of the present application;

[0045] Fig.24 This is a twenty-second schematic diagram of a routing table in an embodiment of the present application;

[0046] Fig.25 A structural diagram of an embodiment of a space management device for a routing table in an embodiment of the present application;

[0047] Fig.26 This is a schematic block diagram of a network device in an embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to make the purpose, features, and advantages of the invention of this application more obvious and easy to understand, the technical solutions in the embodiments of this application will be clearly and completely described below in conjunction with the drawings in the embodiments of this application. Obviously, the embodiments described below are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0049] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0050] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0051] It should be further understood that the term “and / or” used in the specification and appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

[0052] As used in this specification and the appended claims, the term "if" may be interpreted as "when" or "upon" or "in response to determining" or "in response to detecting," depending on the context. Similarly, the phrases "if it is determined" or "if [described condition or event] is detected" may be interpreted as meaning "upon determination" or "in response to determining" or "upon detection of [described condition or event]" or "in response to detecting [described condition or event]," depending on the context.

[0053] In addition, in the description of the present application, the terms "first", "second", "third", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0054] With the rapid development of the Internet and the continuous expansion of network scale, network devices such as network devices and switches need to process more and more routing information. The storage and management of routing information is one of the key factors in the performance of network devices. Traditional routing tables are usually implemented using data structures such as hash tables or binary search trees, but these structures have performance bottlenecks when processing large-scale routing tables, especially in scenarios where routing information needs to be quickly found and updated.

[0055] Ternary Content Addressable Memory (TCAM) is a special memory that can perform lookup operations with constant time complexity, so it is widely used in the implementation of routing tables of high-speed network devices. However, the space management method of TCAM routing tables in the prior art requires a large number of table entries to be moved to obtain free space when the space management unit corresponding to the mask length of the routing table entry to be inserted is insufficient, resulting in low operation efficiency of the routing table.

[0056] In view of this, embodiments of the present application provide a method, apparatus, computer program product, and network device for spatial management of a routing table to solve the problem of low operating efficiency of routing tables in the prior art.

[0057] It should be noted that the execution subject of the method of the present application is a network device, specifically, a switch or a router.

[0058] The routing table of the embodiment of the present application may include various space management units, and the index of each space management unit increases from small to large; specifically, each space management unit can be divided into various continuous inserted space management units and various continuous free space management units; wherein, the inserted space management unit caches the inserted routing table items, and each inserted space management unit stores an inserted routing table item, that is, the inserted space management unit and the inserted routing table item correspond one to one; the free space management unit does not store the inserted routing table items, that is, the free space management unit is a free space management unit that has not been occupied, so that the inserted space management unit and the free space management unit of the routing table in the embodiment of the present application are compact and complete, and there is no situation where the inserted space management unit and the free space management unit are staggered. When a new routing table item needs to be inserted, there will be no situation where there is free space but the new routing table item cannot be inserted, thereby improving the space utilization of the routing table.

[0059] As an example, the routing table in the embodiment of the present application can be as follows: Figure 1 As shown, the space management units corresponding to index 0 to index N are N+1 inserted space management units, and the space management units corresponding to index N+1 to index M are (M-(N+1))+1 free space management units; each of the N+1 inserted space management units stores an inserted routing table entry. In this example, the inserted space management unit with index 0 stores inserted routing table entry 3, the inserted space management unit with index 1 stores inserted routing table entry 4, the inserted space management unit with index 2 stores inserted routing table entry 1, ..., the inserted space management unit with index N stores inserted routing table entry 20.

[0060] In the embodiment of the present application, the index of the routing table increases from small to large, and the mask length of the stored inserted routing table entry also increases from small to large. Figure 2, the index of the routing table increases from small to large, and the mask length of the stored inserted routing table items also increases from small to large. Among them, the inserted space management units corresponding to indexes 0 to 3 store inserted routing table items with a mask length of 0, the inserted space management units corresponding to indexes 4 to 6 store inserted routing table items with a mask length of 1, the inserted space management units corresponding to indexes 7 to 11 store inserted routing table items with a mask length of 2, and the inserted space management units corresponding to indexes 12 to 13 store inserted routing table items with a mask length of 3...

[0061] When querying routing table items, you can query from the inserted routing table items with larger indexes to the inserted routing table items with smaller indexes. When the first query is successful, the query process can be ended and the inserted routing table items with the required mask length can be obtained without traversing and querying each inserted routing table item in the routing table, thereby improving the query speed.

[0062] The following will describe in detail an embodiment of a method for spatial management of a routing table in an embodiment of the present application based on the process of inserting and deleting routing table entries.

[0063] See also Figure 3 In an embodiment of the present application, an embodiment of a method for managing a routing table space may include steps S301 to S304:

[0064] Step S301: Determine the space management unit to be inserted into the routing table in which the routing table entry to be inserted is to be inserted based on the length of the mask to be inserted.

[0065] In the embodiment of the present application, the routing table item to be inserted into the routing table may be referred to as the routing table item to be inserted, and the mask length of the routing table item to be inserted may be referred to as the mask length to be inserted. Before inserting the routing table item to be inserted into the routing table, the mask length to be inserted may be calculated, and the position where the routing table item to be inserted should be inserted in the routing table may be determined based on the mask length to be inserted.

[0066] Here, the position where the routing table entry to be inserted should be inserted in the routing table may be referred to as a space management unit to be inserted.

[0067] If there is no inserted routing table entry in the routing table whose mask length is greater than the mask length to be inserted, the free space management unit with the smallest index may be determined as the space management unit to be inserted.

[0068] For example, see Figure 4, the mask length to be inserted is 26, and there are only inserted routing table entries with a mask length of 16 and inserted routing table entries with a mask length of 24 in the routing table, that is, there are no inserted routing table entries with a mask length greater than 26; at this time, the free space management unit with the smallest index can be determined as the space management unit to be inserted, that is, the free space management unit with an index of 7 can be determined as the space management unit to be inserted.

[0069] For another example, there is no inserted routing table entry in the routing table, that is, the routing table entry to be inserted is the first routing table entry that needs to be inserted into the routing table. At this time, the free space management unit with the smallest index can be determined as the space management unit to be inserted; in this example, since there is no inserted routing table entry in the routing table, the free space management unit with the smallest index is also the space management unit with the smallest index (the space management unit corresponding to the index of 0), such as Figure 5 shown.

[0070] If there is an inserted routing table entry whose mask length is greater than the mask length to be inserted, the inserted space management unit corresponding to the inserted routing table entry whose mask length is greater than the mask length to be inserted and whose index is the smallest can be determined as the space management unit to be inserted.

[0071] For example, the length of the mask to be inserted is 16. At this time, there are already inserted routing table entries with a mask length of 16, an inserted routing table entry with a mask length of 24, and an inserted routing table entry with a mask length of 26 in the routing table. Figure 6 As shown; the inserted routing table items with a mask length greater than 16 in the routing table are the inserted routing table items with a mask length of 24 and the inserted routing table items with a mask length of 26; the inserted space management unit corresponding to the inserted routing table item with the smallest index is the inserted space management unit with an index of 4, therefore, the inserted space management unit with an index of 4 can be determined as the space management unit to be inserted.

[0072] Step S302: insert the routing table entry to be inserted into the space management unit to be inserted.

[0073] In an embodiment of the present application, the routing table item to be inserted can be inserted into the space management unit to be inserted. Afterwards, the inserted routing table item with a mask length greater than the mask length to be inserted and the smallest index can be determined as the updated routing table item to be inserted, and the above process can be repeated to insert the updated routing table item to be inserted until there is no inserted routing table item with a mask length greater than the mask length to be inserted in the routing table. If there is no inserted routing table item with a mask length greater than the mask length to be inserted, the free space management unit with the smallest index can be determined as the space management unit to be inserted, and the routing table item to be inserted can be inserted into the space management unit to be inserted, and then the insertion process can be terminated.

[0074] For example, see Figure 4 , the free space management unit with index 7 is determined as the space management unit to be inserted. After the routing table entry to be inserted is inserted into the free space management unit with index 7, if there is no inserted routing table entry in the routing table whose mask length is greater than the mask length to be inserted, the insertion process can be terminated.

[0075] For another example, see Figure 5 Before inserting the routing table item to be inserted into the routing table, there is no inserted routing table item in the routing table, that is, there is no inserted routing table item whose mask length is greater than the mask length to be inserted. At this time, the routing table item to be inserted can be directly inserted into the free space management unit with an index of 0, and the insertion process is terminated.

[0076] After the routing table entry to be inserted is updated, if there are still inserted routing table entries whose mask length is greater than the mask length to be inserted in the routing table, it is necessary to refer to the above process to re-determine the space management unit to be inserted and perform the corresponding insertion process.

[0077] For example, see Figure 6 , the inserted space management unit with index 4 is determined as the space management unit to be inserted, then the routing table item to be inserted can be inserted into the inserted space management unit with index 4, and then the routing table item to be inserted can be updated to the original inserted routing table item with index 4; at this time, the mask length to be inserted is 24, because there are still inserted routing table items with mask length greater than 24 in the routing table, that is, the inserted routing table items with mask length of 26; therefore, the inserted space management unit corresponding to the inserted routing table item with mask length of 26 and the smallest index (that is, the inserted space management unit with index 7) can be confirmed It is determined as the updated space management unit to be inserted, and the original inserted routing table item with index 4 is inserted into the inserted space management unit with index 7; then, the routing table item to be inserted can be updated to the original inserted routing table item with index 7; at this time, since there is no inserted routing table item with a mask length greater than 26; therefore, the free space management unit with the smallest index (that is, the free space management unit with index 12) can be determined as the updated space management unit to be inserted; then, the inserted space management unit with index 7 can be inserted into the free space management unit with index 12, and the process ends.

[0078] For another example, see Figure 6, the routing table item to be inserted is inserted into the inserted space management unit with an index of 7; afterwards, the routing table item to be inserted can be updated to the original inserted routing table item with an index of 7, and the mask length to be inserted is updated to 26. At this time, since there is no inserted routing table item with a mask length greater than 26 in the routing table, the free space management unit with the smallest index can be determined as the updated space management unit to be inserted, and the updated routing table item to be inserted can be inserted into the free space management unit with an index of 12. After that, the process can be ended.

[0079] The above process will continue until the routing table entry to be inserted is inserted into the free space management unit with the smallest index. This process will be described below with reference to a specific example.

[0080] In a specific example, see Figure 7 , the mask length to be inserted is 16, and there are inserted routing table items with mask length greater than 16 in the routing table. At this time, the inserted space management unit corresponding to the inserted routing table item with mask length greater than the mask length to be inserted and the smallest index can be determined as the space management unit to be inserted, that is, the inserted space management unit with index 4 and mask length 24 can be determined as the space management unit to be inserted; thereafter, the routing table item to be inserted can be inserted into the space management unit to be inserted.

[0081] After the routing table entry to be inserted is inserted into the space management unit to be inserted, it can be referred to as the inserted routing table entry 13. Figure 8 As shown, after that, the routing table item to be inserted can be updated to the inserted routing table item 5. At this time, there are already inserted routing table items with a mask length greater than 24 in the routing table. Therefore, the already inserted routing table item 5 can be inserted into the already inserted space management unit corresponding to the already inserted routing table item with a mask length greater than 24 and the smallest index, that is, the already inserted routing table item 5 can be inserted into the already inserted space management unit with an index of 7 and a mask length of 26. After that, the routing table item to be inserted can be updated to the already inserted routing table item 8, and the mask length to be inserted can be updated to 26; at this time, there are no already inserted routing table items with a mask length greater than 26 in the routing table. Therefore, the free space management unit with the smallest index (that is, the free space management unit with an index of 12) can be determined as the space management unit to be inserted, and the already inserted routing table item 8 can be inserted into the free space management unit with an index of 12.

[0082] After that, you can end the process and get Fig.10 The routing table is shown.

[0083] It can be seen that when inserting routing table entries, each mask length that is larger than the mask length to be inserted only needs to move one routing table entry, and the time complexity is O(1). The operation efficiency will not decrease as the number of inserted routing table entries increases, which helps to maintain the efficient operation performance of the routing table.

[0084] For example, in the above example, when inserting a routing table entry with a mask length of 16, the inserted routing table entries with a mask length greater than 16 are the inserted routing table entries with a mask length of 24 and the inserted routing table entries with a mask length of 26. During the insertion process, only one inserted routing table entry with a mask length of 24 and one inserted routing table entry with a mask length of 26 need to be moved.

[0085] In an embodiment of the present application, the index of the starting position and the index of the ending position of the inserted routing table items of each mask length in the routing table can also be recorded. In addition, the index of the next free space management unit (that is, the free space management unit with the smallest index) can also be recorded to manage the routing table.

[0086] In a specific implementation of the embodiment of the present application, the index of the starting position of each inserted routing table item of each mask length in the routing table can be recorded in the array lpm_start, and the index of the ending position of each inserted routing table item of each mask length in the routing table can be recorded in the array lpm_end. The index of the starting position of the inserted routing table item with a mask length of m in the routing table is an item in the array lpm_start, specifically lpm_start[m]; the index of the ending position of the inserted routing table item with a mask length of m in the routing table is an item in the array lpm_end, specifically lpm_end[m]; and the index of the next free space management unit (i.e., the free space management unit with the smallest index) can be recorded as free. Here, lpm_start, lpm_end and free can be referred to as management information of the routing table.

[0087] The following will explain the process of inserting the routing table entry to be inserted in combination with the specific settings of lpm_start[m], lpm_end[m] and free.

[0088] Before managing the routing table, the management information of the routing table can be initialized; specifically, during initialization, the values ​​stored in lpm_start and lpm_end can be set to preset illegal values ​​to indicate that there are no inserted routing table entries of any mask length in the routing table; in addition, the index free of the next free space management unit can be set to the minimum value of the index (i.e., 0); wherein, the illegal value can be set according to actual needs, and the embodiment of the present application does not specifically limit this; here, the illegal value can be set to -1, and the management information of the initialized routing table can be as follows:

[0089] lpm_start = -1;

[0090] lpm_end = -1;

[0091] free=0;

[0092] Afterwards, if you need to insert a routing table entry with a mask length of 24, you can query lpm_start and lpm_end, and find out that lpm_start

[24] = -1 and lpm_end

[24] = -1; because lpm_start

[24] and lpm_end

[24] both store illegal values, it can be determined that there is no inserted routing table entry with a mask length of 24 in the routing table at this time.

[0093] Afterwards, the items after lpm_start

[24] in lpm_start can be traversed, and the items after lpm_end

[24] in lpm_end can be traversed. It is found that the items after lpm_start

[24] and lpm_end

[24] are all illegal values. Therefore, it can be determined that there is no inserted routing table item in the routing table whose mask length is greater than the mask length to be inserted. Therefore, the free space management unit with the smallest index can be determined as the space management unit to be inserted.

[0094] The free space management unit with the smallest index is the next free space management unit free. At this time, the value of free is 0. Therefore, the free space management unit with an index of 0 can be determined as the space management unit to be inserted.

[0095] After that, the routing table entry to be inserted can be inserted into the free space management unit with index 0; and, according to the routing table entry to be inserted, the index lpm_start

[24] of the start position of the inserted routing table entry corresponding to the mask length to be inserted and the index lpm_end

[24] of the end position can be updated; in addition, since the space management unit with index 0 has stored the inserted routing table entry after the routing table entry to be inserted is inserted, it is also necessary to increase the next free space management unit free by one unit; the management information of the updated partial routing table can be as follows:

[0096] lpm_start

[24] = 0;

[0097] lpm_end

[24] = 0;

[0098] free=1;

[0099] After the routing table entry to be inserted is inserted into the routing table, it can be recorded as the inserted routing table entry 1. Then, after the routing table entry to be inserted is inserted, the routing table can be as follows: Fig.11 As shown, at this time, the space management unit with index 0 stores the inserted routing table entry 1, lpm_start

[24] and lpm_end

[24] both point to the space management unit with index 0, and the next free space management unit free points to the space management unit with index 1.

[0100] Afterwards, if it is necessary to insert a routing table entry with a mask length of 24 again, the index lpm_start

[24] of the start position of the inserted routing table entry corresponding to the mask length of 24 and the index lpm_end

[24] of the end position can be queried, and the items after lpm_start

[24] and lpm_end

[24] can be traversed to determine that there is no inserted routing table entry with a mask length greater than 24 in the routing table; therefore, the free space management unit with the smallest index can be determined as the space management unit to be inserted, that is, the free space management unit with an index of 1 pointed to by free can be determined as the space management unit to be inserted.

[0101] Afterwards, the routing table entry to be inserted can be inserted into the space management unit to be inserted, and lpm_start

[24] , lpm_end

[24] and free are updated. The management information of the updated partial routing table can be as follows:

[0102] lpm_start

[24] = 1;

[0103] lpm_end

[24] = 0;

[0104] free=2;

[0105] After the routing table entry to be inserted is inserted into the routing table, it can be recorded as the routing table entry 2 that has been inserted. Then, after the routing table entry to be inserted is inserted, the routing table can be as follows: Fig.12 As shown, at this time, the space management unit with index 0 stores the inserted routing table entry 1, the space management unit with index 1 stores the inserted routing table entry 2, lpm_start

[24] points to the space management unit with index 1, lpm_end

[24] points to the space management unit with index 0, and the next free space management unit free points to the space management unit with index 2.

[0106] Afterwards, it is necessary to insert a routing table entry with a mask length of 26. At this time, lpm_start

[26] and lpm_end

[26] can be queried to determine that there is no inserted routing table entry with a mask length of 26 in the routing table. Afterwards, the items after lpm_start

[26] and lpm_end

[26] can be traversed to determine that there is no inserted routing table entry with a mask length greater than 26. Therefore, the free space management unit with the smallest index can be determined as the space management unit to be inserted, that is, the free space management unit with an index of 2 pointed to by free can be determined as the space management unit to be inserted.

[0107] Afterwards, the routing table entry to be inserted can be inserted into the space management unit to be inserted, and lpm_start

[26] , lpm_end

[26] and free are updated. The management information of the updated partial routing table can be as follows:

[0108] lpm_start

[24] = 1;

[0109] lpm_end

[24] = 0;

[0110] lpm_start

[26] = 2;

[0111] lpm_end

[26] = 2;

[0112] free=3.

[0113] After the routing table entry to be inserted is inserted into the routing table, it can be recorded as the routing table entry 3 that has been inserted. Then, after the routing table entry to be inserted is inserted, the routing table can be as follows: Fig.13 As shown, at this time, the space management unit with index 0 stores the inserted routing table entry 1, the space management unit with index 1 stores the inserted routing table entry 2, the space management unit with index 3 stores the inserted routing table entry 3, lpm_start

[26] and lpm_end

[26] both point to the space management unit with index 2, and the next free space management unit free points to the space management unit with index 3.

[0114] Afterwards, it is necessary to insert a routing table entry with a mask length of 16. At this time, lpm_start

[16] and lpm_end

[16] can be queried to determine whether there is an inserted routing table entry with a mask length of 16 in the routing table. Afterwards, the items after lpm_start

[16] and lpm_end

[16] can be traversed to determine whether there is an inserted routing table entry with a mask length greater than 16. At this time, the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than 16 and the smallest index can be determined as the space management unit to be inserted, that is, the space management unit pointed to by lpm_end

[24] can be determined as the space management unit to be inserted.

[0115] Afterwards, the routing table entry to be inserted can be inserted into the space management unit to be inserted, and lpm_start

[16] , lpm_end

[16] , lpm_start

[24] , and lpm_end

[24] are updated. The management information of the updated partial routing table can be as follows:

[0116] lpm_start

[16] = 0;

[0117] lpm_end

[16] = 0;

[0118] lpm_start

[24] = 1;

[0119] lpm_end

[24] = 1;

[0120] lpm_start

[26] = 2;

[0121] lpm_end

[26] = 2;

[0122] free=3;

[0123] After the routing table entry to be inserted is inserted into the routing table, it can be recorded as the routing table entry 4 that has been inserted. Then, after the routing table entry to be inserted is inserted, the routing table can be as follows: Fig.14 As shown, at this time, the space management unit with index 0 stores the inserted routing table entry 4, the space management unit with index 1 stores the inserted routing table entry 2, and the space management unit with index 3 stores the inserted routing table entry 3. Both lpm_start

[16] and lpm_end

[16] point to the space management unit with index 0, both lpm_start

[24] and lpm_end

[24] point to the space management unit with index 1, both lpm_start

[26] and lpm_end

[26] point to the space management unit with index 2, and the next free space management unit free points to the space management unit with index 3.

[0124] After inserting the inserted routing table item 4, the inserted routing table item 1 can be updated to the routing table item to be inserted, and the mask length to be inserted can be updated to 24. At this time, the items after lpm_start

[24] and lpm_end

[24] can be queried to determine whether there are inserted routing table items with a mask length greater than 24, and the inserted routing table item 1 can be inserted into the inserted space management unit corresponding to the inserted routing table item with a mask length greater than 24 and the smallest index, that is, the inserted routing table item 1 can be inserted into the space management unit pointed to by lpm_end

[26] .

[0125] After inserting the inserted routing table entry 1 into the space management unit pointed to by lpm_end

[26] , lpm_start

[24] , lpm_end

[24] , lpm_start

[26] , and lpm_end

[26] can be updated, and the management information of the updated partial routing table can be as follows:

[0126] lpm_start

[16] = 0;

[0127] lpm_end

[16] = 0;

[0128] lpm_start

[24] = 2;

[0129] lpm_end

[24] = 1;

[0130] lpm_start

[26] = -1;

[0131] lpm_end

[26] = -1;

[0132] free=3;

[0133] The routing table after inserting the inserted routing table entry 1 into the space management unit pointed to by lpm_end

[26] can be Fig.15 As shown, lpm_start

[24] points to the space management unit with index 2, lpm_end

[24] points to the space management unit with index 1, and the inserted routing table entry 1 has been inserted into the space management unit with index 2.

[0134] Afterwards, the routing table entry to be inserted can be updated to the inserted routing table entry 3, and the mask length to be inserted can be updated to 26; at this time, the items after lpm_start

[26] and lpm_end

[26] can be queried to determine that there is no inserted routing table entry with a mask length greater than 26. Therefore, the inserted routing table entry 3 can be inserted into the free space management unit with the smallest index, that is, the inserted routing table entry 3 can be inserted into the space management unit pointed to by free.

[0135] After inserting the inserted routing table entry 3 into the space management unit pointed to by free, lpm_lp_start

[26] , lpm_end

[26] and free can be updated, and the management information of the updated partial routing table can be as follows:

[0136] lpm_start

[16] = 0;

[0137] lpm_end

[16] = 0;

[0138] lpm_start

[24] = 2;

[0139] lpm_end

[24] = 1;

[0140] lpm_start

[26] = 3;

[0141] lpm_end

[26] = 3;

[0142] free=4;

[0143] After inserting the inserted routing table entry 3 into the space management unit pointed to by free, the routing table can be as follows Fig.16 As shown, lpm_start

[26] and lpm_end

[26] both point to the space management unit with index 3, free points to the space management unit with index 4, and the inserted routing table entry 3 has been inserted into the space management unit with index 3. So far, there is no inserted routing table entry with a mask length greater than 26, so the process of inserting routing table entries can be ended.

[0144] The following is a detailed description of the process of deleting routing table entries. For details, please refer to Fig.17 In one embodiment of the present application, a process of deleting a routing table entry may include steps S1701 to S1704:

[0145] Step S1701: Based on the mask length to be deleted, determine the space management unit to be deleted and the overwritten routing table entry in the routing table to be deleted.

[0146] In an embodiment of the present application, the routing table entry to be deleted can be referred to as a routing table entry to be deleted, the mask length of the routing table entry to be deleted can be referred to as a mask length to be deleted, and the inserted space management unit corresponding to the routing table entry to be deleted can be referred to as a space management unit to be deleted.

[0147] In an embodiment of the present application, the routing table can be queried to determine the space management unit to be deleted. Specifically, the inserted routing table items in the routing table can be matched with the routing table items to be deleted to locate the position of the routing table items to be deleted.

[0148] Here, the inserted routing table items with the same mask length as the mask length to be deleted can be determined as the routing table items to be queried, and each routing table item to be queried can be matched with the routing table items to be deleted respectively until a successfully queried routing table item is obtained.

[0149] For example, if the mask length to be deleted is 16, and there are three inserted routing table items with a mask length of 16 in the routing table, namely, inserted routing table item 1, inserted routing table item 2, and inserted routing table item 3, then the inserted routing table item 1, the inserted routing table item 2, and the inserted routing table item 3 can be determined as the routing table items to be queried, and each routing table item to be queried can be matched with the routing table item to be deleted.

[0150] When querying the routing table items, each routing table item to be queried may be matched with the routing table item to be deleted according to the order of the corresponding index of the inserted space management unit from large to small.

[0151] Specifically, the query priority of each routing table item to be queried can be determined based on the index of the inserted space management unit corresponding to each routing table item to be queried; wherein the query priority of the routing table item to be queried is positively correlated with the index of the inserted space management unit corresponding to the routing table item to be queried.

[0152] For example, the routing table items to be queried are the inserted routing table item 3 corresponding to the inserted space management unit with an index of 5, the inserted routing table item 2 corresponding to the inserted space management unit with an index of 4, and the inserted routing table item 1 corresponding to the inserted space management unit with an index of 3. The routing table item to be queried with the largest index in the inserted space management unit corresponding to each of the routing table items to be queried is the inserted routing table item 3. Then the query priority of the inserted routing table item 3 can be set to the largest value; the routing table item to be queried with the second largest index in the inserted space management unit corresponding to each of the routing table items to be queried is the inserted routing table item 2. Then the query priority of the inserted routing table item 2 can be set to the second largest value; the routing table item to be queried with the smallest index in the inserted space management unit corresponding to each of the routing table items to be queried is the inserted routing table item 1. Then the query priority of the inserted routing table item 2 can be set to the smallest value.

[0153] Afterwards, each routing table item to be queried may be matched with the routing table item to be deleted respectively based on the matching priority of each routing table item to be queried, until a routing table item that is successfully queried is obtained.

[0154] For example, the query priorities of the routing table items to be queried from high to low are respectively the inserted routing table item 1, the inserted routing table item 2, and the inserted routing table item 3. Then, the routing table item to be queried with the highest query priority (i.e., the inserted routing table item 1) can be matched with the routing table item to be deleted first. If the match fails, the routing table item to be queried with the second highest query priority (i.e., the inserted routing table item 2) can be matched with the routing table item to be deleted. If the match fails, the routing table item to be queried with the lowest matching priority (i.e., the inserted routing table item 3) can be matched with the routing table item to be deleted.

[0155] When querying a routing table item, the mask length of the routing table item to be queried needs to be consistent with the mask length of the routing table item to be deleted, and the prefix of the routing table item to be queried needs to be consistent with the prefix of the routing table item to be deleted. Only then can it be considered that the corresponding routing table item to be deleted has been queried and the routing table item to be successfully queried is obtained.

[0156] For example, the routing table entry to be deleted is 10.20.20.20 / 24, and the routing table entries to be queried are 10.10.10.10 / 24 (routing table entry 1 has been inserted), 10.20.20.20 / 24 (routing table entry 2 has been inserted), and 10.30.30.30 / 24 (routing table entry 3 has been inserted); among them, only the mask length and prefix of the inserted routing table entry 2 match the corresponding contents of the routing table entry to be deleted, so only the inserted routing table entry 2 is used as the routing table entry with successful query.

[0157] In the embodiment of the present application, after the first successful match, the successfully matched routing table entry will be used as the successful query routing table entry, and the query process will end.

[0158] Afterwards, the inserted space management unit corresponding to the successfully queried routing table entry may also be used as the space management unit to be deleted.

[0159] In the embodiment of the present application, other inserted routing table entries can be used to cover the space management unit to be deleted, so as to delete the routing table entry to be deleted. Here, the inserted routing table entry used to cover the space management unit to be deleted can be called an overlay routing table entry.

[0160] Specifically, if there is an inserted routing table entry corresponding to an inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted, then the inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is the largest can be determined as the overwriting routing table entry.

[0161] For example, see Figure 4, the routing table item to be deleted is the inserted routing table item with index 1 and mask length 16, there are other inserted routing table items with mask length 16 in the routing table, and among the other inserted routing table items with mask length 16, there are inserted routing table items corresponding to the inserted space management units with index greater than 16, specifically the inserted routing table items corresponding to the inserted space management units with index 2 and the inserted routing table items corresponding to the inserted space management units with index 3, then the inserted routing table item corresponding to the inserted space management units with index 3 can be determined as the overwriting routing table item.

[0162] If there is no inserted routing table entry whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted, and there is an inserted routing table entry whose mask length is greater than the mask length to be deleted, then the inserted routing table entry corresponding to the inserted space management unit with the largest index and whose mask length is greater than the mask length to be deleted and closest to the mask length to be deleted is determined as the overwriting routing table entry.

[0163] For example, see Fig.18 , the routing table entry to be deleted is the inserted routing table entry corresponding to the inserted space management unit with index 0, the mask length of the inserted routing table entry is 16, there are no other inserted routing table entries with mask length 16 in the routing table, and there are inserted routing table entries with mask length greater than 16, specifically the inserted routing table entry corresponding to the inserted space management unit with index 1, the inserted routing table entry corresponding to the inserted space management unit with index 2, the inserted routing table entry corresponding to the inserted space management unit with index 3, and the inserted routing table entry corresponding to the inserted space management unit with index 4; among the above 4 inserted routing table entries, the inserted routing table entries whose mask lengths are closest to the mask lengths to be deleted are the inserted routing table entries corresponding to the inserted space management units with indexes 1 and 2, respectively, and the mask lengths of the two inserted routing table entries are both 24. At this time, the inserted routing table entry corresponding to the inserted space management unit with index 2 can be determined as the overwriting routing table entry.

[0164] If there is no inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted, and there is no inserted routing table entry whose mask length is greater than the mask length to be deleted, it can be determined that there is no overwriting routing table entry.

[0165] When it is determined that there is no overwriting routing table entry, the inserted routing table entry corresponding to the space management unit to be deleted can be directly deleted; specifically, the data of the space management unit to be deleted can be cleared; then, the deleted space management unit becomes the free space management unit with the smallest index.

[0166] For example, see Fig.18 , the routing table entry to be deleted is the inserted routing table entry corresponding to the inserted space management unit with an index of 4, and the mask length to be deleted is 26; at this time, there is no inserted routing table entry with a mask length of 26 and the corresponding inserted space management unit index greater than 4 in the routing table, and there is no inserted routing table entry with a mask length greater than 26, then it can be determined that there is no overwriting routing table entry, and the inserted routing table entry corresponding to the space management unit to be deleted can be directly deleted; specifically, the data in the inserted space management unit with an index of 4 can be cleared, and then the space management unit with an index of 4 becomes the free space management unit with the smallest index.

[0167] Step S1702: Overwrite the space management unit to be deleted with the overwritten routing table entry.

[0168] In an embodiment of the present application, if there is an overriding routing table entry, the overriding routing table entry can be used to overwrite the routing table entry stored in the space management unit to be deleted to delete the routing table entry to be deleted; if there is no overriding routing table entry, the inserted routing table entry corresponding to the space management unit to be deleted can be directly deleted.

[0169] For example, see Fig.19 , the routing table entry to be deleted is the inserted routing table entry 1 corresponding to the inserted space management unit with index 0, and the mask length to be deleted is 16. At this time, it can be determined that there is no overwriting routing table entry, so the inserted routing table entry 1 can be directly deleted; specifically, the data in the inserted space management unit with index 0 can be cleared to realize the deletion of the inserted routing table entry 1.

[0170] For another example, see Fig. 20 , the routing table entry to be deleted is the inserted routing table entry 1 corresponding to the inserted space management unit with index 0, and the mask length to be deleted is 16. At this time, it can be determined that the covering routing table entry is the inserted routing table entry 2 corresponding to the inserted space management unit with index 1, and the mask length of the inserted routing table entry 2 is specifically 16, so the inserted routing table entry 2 can cover the space management unit to be deleted.

[0171] For another example, see Fig.21 , the routing table entry to be deleted is the inserted routing table entry 1 corresponding to the inserted space management unit with index 0, and the mask length to be deleted is 16. At this time, it can be determined that the covering routing table entry is the inserted routing table entry 2 corresponding to the inserted space management unit with index 1, and the mask length of the inserted routing table entry 2 is specifically 24, so the inserted routing table entry 2 can cover the space management unit to be deleted.

[0172] Since the overwriting routing table entry already exists in the routing table before overwriting, after the overwriting routing table entry overwrites the space management unit to be deleted, the overwriting routing table entry is stored in both space management units of the routing table, resulting in repeated storage of the overwriting routing table entry. At this time, the overwriting routing table entry needs to be deleted from the original space management unit to avoid repeated storage.

[0173] Specifically, the overriding routing table entry can be determined as the updated routing table entry to be deleted, and the step of determining the space management unit to be deleted and the overriding routing table entry in the routing table based on the mask length to be deleted and its subsequent steps can be returned to execute until it is determined that there is no overriding routing table entry.

[0174] As an example only, see Fig. 22 , when it is necessary to delete the inserted routing table item 1, it is determined that the covering routing table item is the inserted routing table item 4 corresponding to the inserted space management unit with an index of 3, then the inserted routing table item 4 can be used to cover the inserted routing table item 1, and then the inserted routing table item 4 corresponding to the inserted space management unit with an index of 3 can be determined as the updated routing table item to be deleted, and the mask length to be deleted is 16; at this time, there are inserted routing table items with a mask length greater than 16, then the inserted routing table item corresponding to the inserted space management unit with a mask length greater than 16 and closest to 16 and the largest index can be determined as the covering target routing table item, that is, the inserted routing table item 7 corresponding to the inserted space management unit with an index of 6 can be covered and determined as the covering routing table item, and the covering routing table item can be used to cover the inserted space management unit with an index of 3.

[0175] In the above example, after the inserted routing table entry 7 corresponding to the inserted space management unit with index 6 is used to overwrite the inserted routing table entry 4 corresponding to the inserted space management unit with index 3, the inserted routing table entry 7 corresponding to the inserted space management unit with index 6 can be updated to the space management unit to be deleted, and the mask length to be deleted is 24; at this time, it can be determined that there is no overwriting routing table entry, so the inserted routing table entry 7 corresponding to the inserted space management unit with index 6 can be directly deleted. Specifically, the data in the space management unit with index 6 can be cleared, and the space management unit with index 6 becomes the free space management unit with the smallest index, and then the process can be ended.

[0176] The process of deleting the routing table entries to be deleted will be described below in conjunction with the specific settings of the routing table management information (lpm_start, lpm_end, and free).

[0177] In a specific implementation, some management information of the routing table is as follows:

[0178] lpm_start

[16] = 0;

[0179] lpm_end

[16] = 0;

[0180] lpm_start

[24] = 2;

[0181] lpm_end

[24] = 1;

[0182] lpm_start

[26] = 4;

[0183] lpm_end

[26] = 3;

[0184] free=5;

[0185] See also Fig.23 , the routing table entry to be deleted is the inserted routing table entry 3 corresponding to the inserted space management unit with index 3, and the mask length to be deleted is 26. Since there is an inserted routing table entry 5 corresponding to the inserted space management unit with mask length equal to 26 and index greater than 3 in the routing table, the inserted routing table entry 5 can cover the inserted space management unit with index 3; at this time, the inserted routing table entry 5 corresponding to the inserted space management unit with index 4 can be updated to the routing table entry to be deleted, and the mask length to be deleted is 26. Since there is no inserted routing table entry with mask length greater than 26 in the routing table, it can be determined that there is no overwriting routing table entry, so the routing table entry to be deleted can be directly deleted. Specifically, the data of the inserted space management unit with index 4 can be cleared, and lpm_start

[26] , lpm_end

[26] and free can be updated. Some management information of the updated routing table is as follows:

[0186] lpm_start

[16] = 0;

[0187] lpm_end

[16] = 0;

[0188] lpm_start

[24] = 2;

[0189] lpm_end

[24] = 1;

[0190] lpm_start

[26] = 3;

[0191] lpm_end

[26] = 3;

[0192] free=4.

[0193] Afterwards, the process can be ended.

[0194] In another specific implementation, some management information of the routing table is as follows:

[0195] lpm_start

[16] = 0;

[0196] lpm_end

[16] = 0;

[0197] lpm_start

[24] = 2;

[0198] lpm_end

[24] = 1;

[0199] lpm_start

[26] = 3;

[0200] lpm_end

[26] = 3;

[0201] free=4.

[0202] See also Fig.24 , the routing table entry to be deleted is the inserted routing table entry 4 corresponding to the inserted space management unit with index 0, and the mask length to be deleted is 16. At this time, there is no inserted routing table entry corresponding to the inserted space management unit with mask length 16 and index greater than 0. Then, the inserted routing table entry 1 corresponding to the inserted space management unit with the largest index and mask length greater than 16 and closest to 16 can be used to overwrite the inserted space management unit corresponding to the inserted space management unit with index 0, and update lpm_start

[16] , lpm_start

[16] and lpm_end

[24] . The updated partial management information of the routing table is as follows:

[0203] lpm_start

[16] = -1;

[0204] lpm_end

[16] = -1;

[0205] lpm_start

[24] = 2;

[0206] lpm_end

[24] = 0;

[0207] lpm_start

[26] = 3;

[0208] lpm_end

[26] = 3;

[0209] free=4;

[0210] Afterwards, the inserted routing table item 1 corresponding to the inserted space management unit with index 2 can be updated to the routing table item to be deleted, and the mask length to be deleted is 24. At this time, there are inserted routing table items with mask length greater than 24 in the routing table, and the inserted routing table item corresponding to the inserted space management unit with the largest index and mask length greater than 24 and closest to 24 can be determined as the overlay routing table item, that is, the inserted routing table item 5 corresponding to the inserted space management unit with index 3 can be determined as the overlay routing table item. Afterwards, the overlay routing table item can be used to overwrite the inserted space management unit with index 2, and lpm_start

[24] and lpm_end

[26] can be updated. Part of the management information of the updated routing table is as follows:

[0211] lpm_start

[16] = -1;

[0212] lpm_end

[16] = -1;

[0213] lpm_start

[24] = 1;

[0214] lpm_end

[24] = 0;

[0215] lpm_start

[26] = 3;

[0216] lpm_end

[26] = 2;

[0217] free=4;

[0218] Afterwards, the inserted routing table entry 5 corresponding to the inserted space management unit with index 3 can be updated to the routing table entry to be deleted, and the mask length to be deleted is 26. At this time, it can be determined that there is no overwriting routing table entry, so the routing table entry to be deleted can be directly deleted; specifically, the data of the inserted space management unit with index 3 can be cleared, and the space management unit with index 3 becomes the free space management unit with the smallest index. Afterwards, lpm_start

[26] and free can be updated. Part of the management information of the updated routing table is as follows:

[0219] lpm_start

[16] = -1;

[0220] lpm_end

[16] = -1;

[0221] lpm_start

[24] = 1;

[0222] lpm_end

[24] = 0;

[0223] lpm_start

[26] = 2;

[0224] lpm_end

[26] = 2;

[0225] free=3;

[0226] Afterwards, the process can be ended.

[0227] In the process of deleting routing table entries in the embodiment of the present application, when deleting routing table entries to be deleted, only one routing table entry needs to be moved for each mask length that is larger than the mask length to be deleted, and the time complexity is O(1). The operating efficiency will not decrease as the number of inserted routing table entries increases, which greatly improves the operating efficiency of the routing table.

[0228] In an embodiment of the present application, when performing route matching, matching can be performed in descending order according to the index of the inserted space management unit corresponding to the route table item; specifically, the matching priority of each inserted route table item can be determined based on the index of the inserted space management unit corresponding to each inserted route table item; here, the matching priority of the inserted route table item is positively correlated with the index of the inserted space management unit corresponding to the inserted route table item; that is, if the index of the inserted space management unit corresponding to the inserted route table item is larger, the matching priority corresponding to the inserted route table item is higher; if the index of the inserted space management unit corresponding to the inserted route table item is smaller, the matching priority corresponding to the inserted route table item is lower; thereafter, route matching can be performed in each inserted route table item based on the matching priority of each inserted route table item.

[0229] For example, in the routing table, there exists an inserted routing table item 1 corresponding to the inserted space management unit with an index of 1, an inserted routing table item 2 corresponding to the inserted space management unit with an index of 2, and an inserted routing table item 3 corresponding to the inserted space management unit with an index of 3; when performing route matching, the matching priority can be set in descending order according to the index of the corresponding inserted space management unit; here, the inserted routing table item with the largest index of the corresponding inserted space management unit is the inserted routing table item 3, so the matching priority of the inserted routing table item 3 can be set to the largest; the inserted routing table item with the second largest index of the corresponding inserted space management unit is the inserted routing table item 3, so the matching priority of the inserted routing table item 2 can be set to the second largest; here, the inserted routing table item with the smallest index of the corresponding inserted space management unit is the inserted routing table item 1, so the matching priority of the inserted routing table item 1 can be set to the largest.

[0230] Since the size of the index of the inserted space management unit in the routing table of the embodiment of the present application is positively correlated with the mask length, the larger the mask length of the routing table item, the larger the index of the inserted space management unit corresponding to the routing table item. Therefore, performing route matching in descending order according to the index of the corresponding inserted space management unit can comply with the principle of long mask priority matching. After the routing table item is matched for the first time, it can be determined that the routing table item is the routing table item with the longest mask length that meets the requirements, and there is no need to traverse the routing table, so that the routing table item can be efficiently matched.

[0231] In summary, the embodiment of the present application determines the space management unit to be inserted in the routing table of the routing table entry to be inserted based on the mask length to be inserted; wherein the mask length to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each continuous inserted space management unit and / or each continuous free space management unit, and the inserted space management unit corresponds to the inserted routing table entry one by one; the routing table entry to be inserted is inserted into the space management unit to be inserted; the determining the space management unit to be inserted in the routing table of the routing table entry to be inserted based on the mask length to be inserted includes: if there is no inserted routing table entry whose mask length is greater than the mask length to be inserted, then The free space management unit with the smallest index is determined as the space management unit to be inserted; if there is an inserted routing table entry with a mask length greater than the mask length to be inserted, the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index is determined as the space management unit to be inserted, and the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index is determined as the updated routing table entry to be inserted, and the step of determining the space management unit to be inserted in the routing table of the routing table entry based on the mask length to be inserted and its subsequent steps are returned to execute, until there is no inserted routing table entry with a mask length greater than the mask length to be inserted. In the embodiment of the present application, when inserting routing table entries, each mask length greater than the mask length to be inserted only needs to move one routing table entry, which greatly improves the operation efficiency of the routing table; and the inserted space management unit in the routing table is a continuous space, and the inserted space management unit corresponds one-to-one to the inserted routing table entry, so that the inserted routing table entries in the routing table can be arranged tightly and continuously, which helps to improve the space utilization of the routing table.

[0232] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0233] Corresponding to the space management method of a routing table described in the above embodiment, Fig.25A structural diagram of an embodiment of a routing table space management device provided in an embodiment of the present application is shown.

[0234] In an embodiment of the present application, a space management device for a routing table may include:

[0235] A determination module 2501 is used to determine the space management unit to be inserted into the routing table entry to be inserted based on the mask length to be inserted; wherein the mask length to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each continuous inserted space management unit and / or each continuous free space management unit, and the inserted space management unit corresponds to the inserted routing table entry one by one;

[0236] Insertion module 2502, used for inserting the routing table entry to be inserted into the space management unit to be inserted;

[0237] The determination module comprises:

[0238] A first determining submodule, configured to determine the free space management unit with the smallest index as the space management unit to be inserted if there is no inserted routing table entry whose mask length is greater than the mask length to be inserted;

[0239] The second determination submodule is used to determine the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index as the space management unit to be inserted if there is an inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index, and determine the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index as the updated routing table entry to be inserted, and return to execute the step of determining the space management unit to be inserted in the routing table of the routing table entry to be inserted based on the mask length to be inserted and its subsequent steps, until there is no inserted routing table entry with a mask length greater than the mask length to be inserted.

[0240] In a specific implementation of the embodiment of the present application, the space management device of the routing table further includes:

[0241] A unit and entry determination module, used to determine the space management unit to be deleted and the overriding routing table entry of the routing table entry to be deleted in the routing table based on the mask length to be deleted; wherein the mask length to be deleted is the mask length of the routing table entry to be deleted, and the overriding routing table entry is used to overwrite the space management unit to be deleted;

[0242] An overlay module, used to overlay the to-be-deleted space management unit with the overlay routing table entry;

[0243] The unit and table item determination module includes:

[0244] A third determination submodule is used to determine the inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted as the overlay routing table entry if there is an inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted;

[0245] a fourth determination submodule, for determining, if there is no inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted, and there is an inserted routing table entry whose mask length is greater than the mask length to be deleted, the inserted routing table entry corresponding to the inserted space management unit whose mask length is greater than the mask length to be deleted and closest to the mask length to be deleted and has the largest index as the overlay routing table entry;

[0246] a fifth determination submodule, for determining that the overlay routing table entry does not exist if there is no inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted, and there is no inserted routing table entry whose mask length is greater than the mask length to be deleted;

[0247] The return execution submodule is used to determine the overlay routing table entry as the updated routing table entry to be deleted, and return to execute the steps of determining the to-be-deleted space management unit and the overlay routing table entry machine in the routing table based on the mask length to be deleted and its subsequent steps, until it is determined that the overlay routing table entry does not exist.

[0248] In a specific implementation of the embodiment of the present application, the unit and table item determination module further includes:

[0249] The deleting submodule is used to delete the inserted routing table entry corresponding to the to-be-deleted space management unit when it is determined that the overlay routing table entry does not exist.

[0250] In a specific implementation of the embodiment of the present application, the unit and table item determination module further includes:

[0251] A query matching submodule, used for matching each routing table item to be queried with the routing table item to be deleted respectively, until a successful routing table item is obtained; wherein the routing table item to be queried is an inserted routing table item whose mask length is the same as the mask length to be deleted;

[0252] The unit determination submodule is used to determine the inserted space management unit corresponding to the successfully queried routing table entry as the space management unit to be deleted.

[0253] In a specific implementation of the embodiment of the present application, the query matching submodule includes:

[0254] A query priority determination unit, configured to determine the query priority of each of the routing table items to be queried based on the index of the inserted space management unit corresponding to each of the routing table items to be queried; wherein the query priority of the routing table item to be queried is positively correlated with the index of the inserted space management unit corresponding to the routing table item to be queried;

[0255] The query matching unit is used to match each routing table item to be queried with the routing table item to be deleted respectively based on the query priority of each routing table item to be queried, until the successfully queried routing table item is obtained.

[0256] In a specific implementation of the embodiment of the present application, the space management device of the routing table further includes:

[0257] A matching priority determination module, used to determine the matching priority of each inserted routing table item based on the index of each inserted routing table item; wherein the matching priority of the inserted routing table item is positively correlated with the index of the inserted space management unit corresponding to the inserted routing table item;

[0258] The route matching module is used to perform route matching in each inserted route table entry based on the matching priority of each inserted route table entry.

[0259] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices, modules and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0260] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0261] Fig.26 A schematic block diagram of a network device provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0262] like Fig.26 As shown, the network device 26 of this embodiment includes: a processor 260, a memory 261, and a computer program 262 stored in the memory 261 and executable on the processor 260. When the processor 260 executes the computer program 262, the steps in the above-mentioned embodiments of the space management method of each routing table are implemented, such as Figure 3Alternatively, when the processor 260 executes the computer program 262, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Fig.25 The functions of module 2501 to module 2502 are shown.

[0263] Exemplarily, the computer program 262 may be divided into one or more modules / units, which are stored in the memory 261 and executed by the processor 260 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 262 in the network device 26.

[0264] Those skilled in the art will understand that Fig.26 It is only an example of the network device 26 and does not constitute a limitation of the network device 26. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the network device 26 may also include input and output devices, network access devices, buses, etc.

[0265] The processor 260 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0266] The memory 261 may be an internal storage unit of the network device 26, such as a hard disk or memory of the network device 26. The memory 261 may also be an external storage device of the network device 26, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the network device 26. Further, the memory 261 may also include both an internal storage unit and an external storage device of the network device 26. The memory 261 is used to store the computer program and other programs and data required by the network device 26. The memory 261 may also be used to temporarily store data that has been output or is to be output.

[0267] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0268] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0269] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0270] In the embodiments provided in the present application, it should be understood that the disclosed devices / network equipment and methods can be implemented in other ways. For example, the device / network equipment embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0271] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0272] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0273] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable storage medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable storage medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable storage media do not include electric carrier signals and telecommunication signals.

[0274] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for spatial management of a routing table, characterized in that: include: Based on the mask length to be inserted, determining the space management unit to be inserted in the routing table of the routing table entry to be inserted; wherein the mask length to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each continuous inserted space management unit and / or each continuous free space management unit, and the inserted space management unit corresponds to the inserted routing table entry one by one; Inserting the routing table entry to be inserted into the space management unit to be inserted; The step of determining a space management unit to be inserted into the routing table for the routing table entry to be inserted based on the length of the mask to be inserted includes: If there is no inserted routing table entry whose mask length is greater than the mask length to be inserted, determining the free space management unit with the smallest index as the space management unit to be inserted; If there is an inserted routing table entry whose mask length is greater than the mask length to be inserted, the inserted space management unit corresponding to the inserted routing table entry whose mask length is greater than the mask length to be inserted and whose index is the smallest is determined as the space management unit to be inserted, and the inserted routing table entry whose mask length is greater than the mask length to be inserted and whose index is the smallest is determined as the updated routing table entry to be inserted, and the process returns to executing the step of determining the space management unit to be inserted in the routing table of the routing table entry to be inserted based on the mask length to be inserted and its subsequent steps, until there is no inserted routing table entry whose mask length is greater than the mask length to be inserted.

2. The method for spatial management of a routing table according to claim 1, characterized in that: Also includes: Based on the mask length to be deleted, determine the space management unit to be deleted and the overwriting routing table entry in the routing table; wherein the mask length to be deleted is the mask length of the routing table entry to be deleted; Overwriting the to-be-deleted space management unit with the overlay routing table entry; The process of determining the coverage routing table entry includes: If there is an inserted routing table entry corresponding to an inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted, then the inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is the largest is determined as the overlay routing table entry; If there is no inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted, and there is an inserted routing table entry whose mask length is greater than the mask length to be deleted, then the inserted routing table entry corresponding to the inserted space management unit with the largest index and whose mask length is greater than the mask length to be deleted and closest to the mask length to be deleted is determined as the overlay routing table entry; If there is no inserted routing table entry corresponding to the inserted space management unit whose mask length is the same as the mask length to be deleted and whose index is greater than the index of the space management unit to be deleted, and there is no inserted routing table entry whose mask length is greater than the mask length to be deleted, it is determined that the overlay routing table entry does not exist; The overlay routing table entry is determined as the updated routing table entry to be deleted, and the execution is returned to the step of determining the to-be-deleted space management unit and the overlay routing table entry in the routing table based on the to-be-deleted mask length and its subsequent steps until it is determined that the overlay routing table entry does not exist.

3. The method for spatial management of routing tables according to claim 2, characterized in that: Also includes: When it is determined that the overlay routing table entry does not exist, the inserted routing table entry corresponding to the to-be-deleted space management unit is deleted.

4. The method for spatial management of a routing table according to claim 2, characterized in that: The process of determining the space management unit to be deleted includes: Matching each routing table item to be queried with the routing table item to be deleted respectively until a successfully queried routing table item is obtained; wherein the routing table item to be queried is an inserted routing table item whose mask length is the same as the mask length of the routing table item to be deleted; The inserted space management unit corresponding to the successfully queried routing table entry is determined as the space management unit to be deleted.

5. The method for spatial management of routing tables according to claim 4, characterized in that: The step of matching each routing table entry to be queried with the routing table entry to be deleted respectively until a successfully queried routing table entry is obtained includes: Based on the index of the inserted space management unit corresponding to each of the routing table items to be queried, determine the query priority of each of the routing table items to be queried; wherein the query priority of the routing table item to be queried is positively correlated with the index of the inserted space management unit corresponding to the routing table item to be queried; Based on the query priority of each of the routing table items to be queried, each of the routing table items to be queried is matched with the routing table items to be deleted respectively, until the successfully queried routing table item is obtained.

6. The method for spatial management of a routing table according to any one of claims 1 to 5, characterized in that: Also includes: Based on the index of each inserted routing table entry, determining the matching priority of each inserted routing table entry; wherein the matching priority of the inserted routing table entry is positively correlated with the index of the inserted space management unit corresponding to the inserted routing table entry; Based on the matching priority of each inserted routing table entry, route matching is performed in each inserted routing table entry.

7. A space management device for a routing table, characterized in that: include: A determination module, configured to determine, based on a mask length to be inserted, a space management unit to be inserted in a routing table into which the routing table entry to be inserted is to be inserted; wherein the mask length to be inserted is the mask length of the routing table entry to be inserted, and the space management unit of the routing table includes each continuous inserted space management unit and / or each continuous free space management unit, and the inserted space management unit corresponds one-to-one to the inserted routing table entry; An inserting module, used for inserting the routing table entry to be inserted into the space management unit to be inserted; The determination module comprises: A first determining submodule, configured to determine the free space management unit with the smallest index as the space management unit to be inserted if there is no inserted routing table entry whose mask length is greater than the mask length to be inserted; The second determination submodule is used to determine the inserted space management unit corresponding to the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index as the space management unit to be inserted if there is an inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index, and determine the inserted routing table entry with a mask length greater than the mask length to be inserted and the smallest index as the updated routing table entry to be inserted, and return to execute the step of determining the space management unit to be inserted in the routing table of the routing table entry to be inserted based on the mask length to be inserted and its subsequent steps, until there is no inserted routing table entry with a mask length greater than the mask length to be inserted.

8. A computer program product, characterized in that The invention comprises a computer program, and when the computer program is executed, the method for spatial management of a routing table according to any one of claims 1 to 6 is executed.

9. A network device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the network device implements the steps of the method for spatial management of a routing table according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Route table space managing method, apparatus, switch and router

    CN101335706A

  • TCAM-based LPM routing lookup device and method

    CN118827542A

  • Method and apparatus for ternary content addressable memory (TCAM) table management

    US20020131432A1