Storing MAC address table entries

CN119072913AActive Publication Date: 2024-12-03NEW H3C TECH CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202380008539.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2024-12-03
Estimated Expiration
2043-03-31

AI Technical Summary

Technical Problem

In the existing technology, searching the MAC address hash table for storage locations based on a fixed search order can easily lead to hash conflicts, and the storage space is unevenly utilized, resulting in an increased chance of hash conflicts.

Method used

Use multiple hash tables, each hash table sets a unique hash algorithm, dynamically adjust the search priority, search for free storage locations from high to low, and search recursively when hash conflicts, reducing the highest priority hash The search priority of the table increases the priority of other hash tables to ensure dynamic changes in the search order.

Benefits of technology

It effectively reduces hash conflicts, achieves more even utilization of the storage space of the hash table, improves storage efficiency, and avoids uneven storage problems caused by fixed search orders.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119072913A_ABST
    Figure CN119072913A_ABST
Patent Text Reader

Abstract

The invention provides network equipment, an embodiment of the network equipment for storing MAC address table entries, and the MAC address table entries learned by the network equipment. Calculating a hash value based on the hash algorithm of each hash table and the keyword of the MAC address table item; wherein each hash table has a unique hash algorithm. The network equipment checks the state of the storage position indicated by the corresponding Hash value of each Hash table in sequence from high to low according to the search priority of each Hash table based on the search priority of each Hash table; storing the MAC address table item in the searched first idle storage position; and reducing the hash table pointed by the highest lookup priority to the lowest lookup priority, and respectively improving the lookup priority of each of the other hash tables by one level.
Need to check novelty before this filing date? Find Prior Art

Description

Store MAC address entries Background Art

[0001] Network devices learn MAC address entries based on the source MAC (Media Access Control) address of received Ethernet packets. They perform a hash calculation on the MAC address entry's key to obtain a hash value that indicates a storage location in the hash table. If the storage location indicated by the hash value is free, the MAC address entry is stored in the corresponding location using a (key, value) data structure. A hash collision occurs if another MAC address entry is already stored in the location indicated by the hash value. BRIEF DESCRIPTION OF THE DRAWINGS

[0002] FIG1 is a schematic diagram of a method for storing MAC address entries according to an embodiment of the present disclosure;

[0003] 2A-2D are schematic diagrams of storing MAC address entries according to an embodiment of the present disclosure;

[0004] 3A-3E are schematic diagrams of storing MAC address entries according to an embodiment of the present disclosure;

[0005] FIG4 is a schematic diagram of a device for storing MAC address entries according to an embodiment of the present disclosure;

[0006] FIG5 is a schematic diagram of a device for storing MAC address entries according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0007] The present disclosure is described below with reference to a number of examples shown in the accompanying drawings.

[0008] Among the terms used, the term "including" means including but not limited to; the term "comprising" means including but not limited to; the term "based on" means based on at least a part thereof. In addition, the term "a" is intended to mean one of a specific component.

[0009] FIG1 is a schematic diagram of a method for storing MAC address entries according to an embodiment of the present disclosure. The method includes:

[0010] Process 101: obtain the learned MAC address table entry.

[0011] Process 102: Calculate a hash value based on the hash algorithm of each hash table and the key of the MAC address table entry; wherein each hash table has a unique hash algorithm.

[0012] Process 103 : Based on the search priority of each hash table, the state of the storage location indicated by the corresponding hash value of each hash table is checked in descending order of search priority.

[0013] Process 104: store the MAC address entry in the first free storage location found.

[0014] Process 105 : lower the hash table pointed to by the highest search priority to the lowest search priority, and increase the search priority of each of the other hash tables by one level.

[0015] The beneficial effect of the embodiment shown in FIG1 is that the search order of searching for storage spaces storing MAC address entries on multiple hash tables changes dynamically, avoiding a fixed search order.

[0016] To reduce hash conflicts in the MAC address hash table, the network device provides multiple hash tables to store MAC address table entries. Each hash table is stored in a storage block and is set with a unique hash algorithm. When the network device adds a MAC address table entry, it first calculates the hash value of the MAC address table entry based on the hash algorithm of the first storage block; when a hash conflict occurs in the first storage block, a new hash value is calculated based on the hash algorithm of the second storage block. If the storage location of the second storage block indicated by the new hash value is also occupied, the hash calculation is continued based on the hash algorithm of the next storage block, and the free storage location is recursively searched in sequence. Alternatively, the network device calculates multiple hash values ​​based on the hash algorithm set for each hash table, and searches for free storage locations starting from the hash table of the first storage block.

[0017] However, the mechanism of searching for free storage locations based on a fixed search order may cause the hash table with a higher search order to store significantly more MAC address entries and a greater chance of hash collision.

[0018] 2A-2D are schematic diagrams of storing MAC address entries provided by an embodiment of the present disclosure.

[0019] In Figure 2A , a storage medium of a network device, such as a TCAM (ternary content addressable memory), has four memory blocks 21-24 that store hash tables 1-4, respectively. Hash tables 1-4 are each configured with a unique hash algorithm and a preset search priority of 0-3, from high to low, with a hash bucket depth of 1. In Figure 2A , hash values ​​Hash0-Hash7 are used to indicate the storage location corresponding to each of Hash tables 1-4.

[0020] The network device learns the MAC address table entry 201 based on the source MAC address, VLAN (Virtual Local Area Network) and receiving port of a received Ethernet message, and calculates four hash values ​​according to the keywords (MAC address, VLAN) of the MAC address table entry 201 and the hash algorithms of hash tables 1-4, namely, hash value 3, hash value 1, hash value 0 and hash value 7.

[0021] Based on the search priorities of hash tables 1-4, the network device first checks the status of the storage location indicated by hash value 3 corresponding to hash table 1 in descending order and finds that the status is idle, and stores MAC address entry 201 in the idle storage location indicated by hash value 3 in hash table 1.

[0022] In FIG2B , after the network device adds the MAC address table entry 201 , it counts the storage rate of hash table 1, reduces the highest search priority 0 of hash table 1 to the lowest search priority 3, and increases the search priorities of hash tables 2-4 by one level, namely priority 0, priority 1, and priority 2 respectively.

[0023] The network device learns the MAC address table entry 202 based on the source MAC address, virtual local area network (VLAN) and receiving port of a received Ethernet message, and calculates four hash values ​​according to the keyword of the MAC address table entry 202 and the hash algorithms of the hash tables 1-4.

[0024] Based on the search priority of hash tables 1-4, the network device first checks the hash value corresponding to hash table 2 in descending order. For example, hash value 0 indicates that the storage location is idle, and stores MAC address table entry 202 in the idle storage location indicated by hash value 0 in hash table 2.

[0025] In FIG2C , after the network device adds the MAC address table entry 202, it counts the storage rate of hash table 2, reduces the highest search priority 0 of hash table 2 to the lowest search priority 3, and increases the search priorities of hash tables 3, 4, and 1 by one level, namely priority 0, priority 1, and priority 2, respectively.

[0026] The network device learns MAC address table entry 203 based on the source MAC address, virtual local area network (VLAN) and receiving port of a received Ethernet message, and calculates four hash values ​​according to the keyword of MAC address table entry 203 and the hash algorithms of hash tables 1-4.

[0027] Based on the search priority of hash tables 1-4, the network device first checks the hash value corresponding to hash table 3 in descending order. For example, hash value 4 indicates that the storage location is idle, and stores MAC address table entry 203 in the idle storage location indicated by hash value 4 in hash table 3.

[0028] In FIG2D , after the network device adds the MAC address table entry 203 , it counts the storage rate of hash table 3, reduces the highest search priority 0 of hash table 3 to the lowest search priority 3, and increases the search priorities of hash tables 4, 1, and 2 by one level, namely priority 0, priority 1, and priority 2, respectively.

[0029] The network device learns the MAC address table entry 204 based on the source MAC address, virtual local area network (VLAN) and receiving port of a received Ethernet message, and calculates four hash values ​​according to the keyword of the MAC address table entry 204 and the hash algorithms of the hash tables 1-4.

[0030] Based on the search priority of hash tables 1-4, the network device first checks the hash value corresponding to hash table 4 in order from high to low. For example, hash value 7 indicates that the storage location is idle, and stores MAC address table entry 204 in the idle storage location indicated by hash value 7 in hash table 4.

[0031] After the network device adds the MAC address table entry 204, it counts the storage rate of hash table 4, reduces the highest search priority 0 of hash table 4 to the lowest search priority 3, and increases the search priorities of hash tables 1-3 by one level, namely priority 0, priority 1, and priority 2 (not shown in Figure 2D).

[0032] In the embodiment shown in Figures 2A-2D, the search order of the network device in searching for free storage space among hash tables 1-4 is dynamic, so that the number of MAC address table entries stored in hash tables 1-4 of storage blocks 21-24 is more uniform, and the storage space of storage blocks 21-24 can be more fully utilized.

[0033] The network device deletes the aged MAC address table entries in the hash tables 1-4 according to the MAC address table entry aging time or the table entry deletion instruction, and after deleting each MAC address table entry, counts the storage rate of the hash table that has executed the MAC address table entry deletion process.

[0034] Figures 3A-3E are schematic diagrams of storing MAC address entries according to an embodiment of the present disclosure. In Figure 3A, MAC address entry aging causes the number of MAC address entries stored in hash tables 1-4 to be uneven.

[0035] The network device learns the MAC address table entry 301 based on the source MAC address, virtual local area network (VLAN) and receiving port of a received Ethernet message, and calculates four hash values ​​according to the keyword of the MAC address table entry 301 and the hash algorithms of hash tables 1-4, such as hash value 0, hash value 2, hash value 5, and hash value 3.

[0036] The network device searches hash table 4 based on the search priority of hash tables 1-4 in descending order and finds that the storage location indicated by hash value 3 corresponding to hash table 4 is idle, and stores MAC address entry 301 in the idle storage location indicated by hash value 3 in hash table 4.

[0037] After adding the MAC address entry 301 , the network device counts the storage rate of the hash table 4 .

[0038] In FIG3B , the network device can calculate based on the storage rates of hash tables 1-4 that the number of stored MAC address entries has exceeded a specified number of MAC address entries.

[0039] The network device sorts hash tables 1-4 into hash table 2, hash table 3, hash table 1, and hash table 4 based on the order of low storage rate to high storage rate, and sets the highest search priority 0 to the lowest search priority 3 in sequence.

[0040] The network device learns the MAC address table entry 302 based on the source MAC address, virtual local area network (VLAN) and receiving port of a received Ethernet message, and calculates four hash values ​​according to the keyword of the MAC address table entry 302 and the hash algorithms of the hash tables 1-4.

[0041] The network device searches hash table 2 based on the search priorities of hash tables 1-4 in descending order and finds that the storage location indicated by hash value 2 is idle, and stores MAC address entry 302 in the idle storage location indicated by hash value 2 in hash table 2.

[0042] In Figure 3B, after the network device adds the MAC address table entry 302, it counts the storage rate of hash table 2 and calculates that the number of stored MAC address table entries in hash tables 1-4 still exceeds the specified number of MAC address table entries. The network device still sorts hash tables 1-4 in the order of low storage rate to high storage rate as hash table 2, hash table 3, hash table 1, and hash table 4, and sets the highest search priority 0 to the lowest search priority 3 in sequence.

[0043] In Figure 3B , the network device sorts hash tables with the same storage ratio to maintain the search priorities already set for these hash tables. Alternatively, in Figure 3C , when sorting hash tables 2 and 3 with the same storage ratio, the network device raises the search priority of hash table 3 by one level, such as priority 0, and sets hash table 2, which had the highest search priority in the previous search, to the lowest search priority of 1 among hash tables with the same storage ratio.

[0044] Or in Figure 3D, after the network device adds the MAC address table entry 301 to hash table 4, it calculates the storage rate of hash table 4, determines that the number of added MAC address table entries of hash tables 1-4 has exceeded the specified number of MAC address table entries, and divides hash table 2 and hash table 3 that are lower than the first storage rate threshold into priority search group 31, and divides hash table 1 and hash table 4 that are higher than the first storage rate threshold but lower than the second storage rate threshold into next search priority group 32, and based on the order from low storage rate to high storage rate, hash table 2, hash table 3, hash table 1, and hash table 4 are set to the highest search priority 0 to the lowest search priority 3 in sequence.

[0045] The network device in FIG3D calculates four hash values ​​based on the learned keyword of MAC address table entry 302 and the hash algorithms of hash tables 1-4. The network device first searches group 31 in descending order based on the search priorities of hash tables 1-4. Within group 31, the network device first finds the storage location indicated by hash value 2 in hash table 2, which has the highest search priority. The network device determines that the storage location is free and stores MAC address table entry 302 in the free storage location indicated by hash value 2 in hash table 2.

[0046] In Figure 3E , after the network device adds MAC address entry 302 to hash table 2 in group 31, it calculates the storage rate of hash table 2. The network device determines that the number of added MAC address entries in hash tables 1-4 exceeds the specified number of MAC address entries. It then raises the search priority of the remaining hash tables 3 in group 31 by one level, to priority 0, and sets the search priority of hash table 2 in group 31 to the lowest search priority within the group, namely priority 1. The priorities of hash tables 1 and 4 in group 32 remain unchanged. In this way, the four hash tables in groups 31 and 32 are set from highest to lowest search priority, in order of lowest storage rate.

[0047] In the above embodiment, the number of storage blocks in the network device and the number of entries recorded in the hash table of the storage blocks are intended to describe that the present disclosure uniformly stores MAC address entries in multiple hash tables, and are not used to limit the protection scope of the present disclosure.

[0048] In the above embodiment, the keywords of the MAC address table entry include the MAC address and the VLAN, and such keywords are not used to limit the scope of protection of the present disclosure. The keywords of the MAC address table entry stored by the network device according to the above embodiment may also be the MAC address, or the MAC address and the virtual forwarding instance (VSI) of the VPN network, or the MAC address and other information indicating the forwarding domain.

[0049] Figure 4 is a schematic diagram of a device for storing MAC address table entries according to an embodiment of the present disclosure. Device 40 includes multiple network interfaces 41, a switch 42, a processor 43, and a non-transitory computer-readable medium 44 storing processor-executable instructions. Switch 42, processor 43, and non-transitory computer-readable medium 44 communicate with each other via a bus.

[0050] The switching device 42 may execute Ethernet messages based on MAC address entries, delete stored MAC address entries according to the aging time of the MAC address entries, and learn MAC address entries according to the source MAC addresses of received Ethernet messages.

[0051] The switching device 42 may be implemented by hardware (e.g., a processor of an application-specific integrated circuit (ASIC)) or by a combination of software and hardware, which is not specifically limited in the embodiment of the present invention. The table entry storage medium 421 of the switching device 42 has multiple storage blocks 422, and the hash table stored in each storage block 422 is set with a unique hash algorithm.

[0052] The switching device 42 learns the MAC address table entries based on the Ethernet messages received by any interface of the network interface 41; calculates a hash value based on the hash algorithm of each hash table and the keyword of the MAC address table entry; checks the status of the storage location indicated by the corresponding hash value of each hash table in order from high to low search priority based on the search priority of each hash table; stores the MAC address table entry in the first free storage location found; reduces the hash table pointed to by the highest search priority to the lowest search priority, and increases the search priority of each other hash table by one level.

[0053] The search priority of each hash table in each storage block 422 of the switching device 42 is a preset search priority. Alternatively, the search priority of each hash table in each storage block 422 of the switching device 42 is the search priority modified after the previous MAC address table entry addition process.

[0054] The switching device 42 further counts the storage rate of each hash table after each MAC address entry is added; or counts the storage rate of each hash table after each MAC address entry is deleted.

[0055] The switching device 42 further determines that all hash tables have stored more than a specified number of MAC address entries; and sets the highest search priority to the lowest search priority for all hash tables in order from low storage rate to high storage rate.

[0056] Figure 5 is a schematic diagram of a device for storing MAC address table entries according to an embodiment of the present disclosure. Device 50 includes multiple network interfaces 51, a switch 52, a processor 53, and a non-transitory computer-readable medium 54 storing processor-executable instructions. Switch 52, processor 53, and non-transitory computer-readable medium 54 communicate with each other via a bus.

[0057] The switching device 52 can be implemented by hardware or by a combination of software and hardware. The entry storage medium 521 of the switching device 52 has multiple storage blocks 522 and the hash table stored in each storage block 522 is set with a unique hash algorithm.

[0058] Each storage block 522 of the switching device 52 stores a hash table and is set with a unique hash algorithm; MAC address table entries are learned based on Ethernet messages received by any network interface of the network interface 51; the processor 53 executes the processor executable instructions recorded in the non-transitory machine-readable storage medium 54 to perform the following processing: obtain the MAC address table entry, calculate a hash value based on the hash algorithm of each hash table and the keyword of the MAC address table entry; wherein, each hash table has a unique hash algorithm; based on the search priority of each hash table, check the status of the storage location indicated by the corresponding hash value of each hash table in order from high to low search priority; store the MAC address table entry in the first free storage location found; reduce the hash table pointed to by the highest search priority to the lowest search priority, and increase the search priority of each other hash table by one level.

[0059] The processor 53 executes the processor executable instructions of the non-transitory machine-readable medium 54 to set the search priority of each hash table in each storage block 522 to be a preset search priority; or, the search priority modified after the previous MAC address table entry addition process.

[0060] The switching device 53 executes the processor executable instructions of the non-transitory machine-readable medium 54 to further count the storage rate of each hash table after each MAC address entry addition process; or count the storage rate of each hash table after each MAC address entry deletion process.

[0061] The switching device 53 executes the processor executable instructions of the non-transitory machine-readable medium 54 to determine that all hash tables have stored more than a specified number of MAC address table entries; based on the order of low storage rate to high storage rate, set the highest search priority to the lowest search priority for all hash tables in sequence.

[0062] The above description is only a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present disclosure should be included in the scope of protection of the present disclosure.

Claims

1. A method for storing MAC address entries, It is characterized in that The method comprises: Get the learned MAC address table entries; Calculating a hash value based on the hash algorithm of each hash table and the keyword of the MAC address table entry; wherein each hash table has a unique hash algorithm; Based on the search priority of each of the hash tables, checking the state of the storage location indicated by the corresponding hash value of each of the hash tables in order from high to low search priority; Store the MAC address entry in the first free storage location found; The hash table pointed to by the highest search priority is reduced to the lowest search priority, and the search priority of each of the other hash tables is increased by one level.

2. The method according to claim 1, It is characterized in that The search priority of each of the hash tables is a preset search priority.

3. The method according to claim 1, It is characterized in that The search priority of each hash table is the search priority modified after the previous MAC address table entry addition process.

4. The method according to claim 1, It is characterized in that The method further comprises: Counting the storage rate of each hash table after each MAC address entry addition process; The storage rate of each hash table after each MAC address entry deletion process is counted.

5. The method according to claim 1, It is characterized in that The method further comprises: Determining that all of the hash tables have stored MAC address entries exceeding a specified number; Based on the order from low storage rate to high storage rate, all hash tables are set from highest search priority to lowest search priority.

6. A device for storing MAC addresses, It is characterized in that The device comprises a plurality of network interfaces and a switching device having a plurality of storage blocks; A hash table stored in each of the storage blocks is set with a unique hash algorithm; The switching device learns a MAC address table entry based on an Ethernet message received by any of the network interfaces; calculates a hash value based on a hash algorithm of each hash table and a keyword of the MAC address table entry; Based on the search priority of each hash table, the status of the storage location indicated by the corresponding hash value of each hash table is checked in order from high to low search priority; the MAC address table entry is stored in the first free storage location found; the hash table pointed to by the highest search priority is reduced to the lowest search priority, and the search priority of each other hash table is increased by one level.

7. The device according to claim 6, It is characterized in that The search priority of each of the hash tables is a preset search priority.

8. The device according to claim 6, It is characterized in that The search priority of each hash table is the search priority modified after the previous MAC address table entry addition process.

9. The device according to claim 6, It is characterized in that The switching device further counts the storage rate of each hash table after each MAC address entry addition process; and counts the storage rate of each hash table after each MAC address entry deletion process.

10. The device according to claim 6, It is characterized in that The switching device further determines that all the hash tables have stored MAC address entries exceeding a specified number; and sets a highest search priority to a lowest search priority for all the hash tables in order from a low storage rate to a high storage rate.

11. A device for storing MAC addresses, It is characterized in that The device includes a plurality of network interfaces, a switching device having a plurality of storage blocks, a processor, and a non-transitory machine-readable medium recording processor-executable instructions; each storage block of the switching device stores a hash table and is set with a unique hash algorithm; The switching device learns MAC address table entries based on Ethernet messages received by any network interface; The processor executes the processor executable instructions recorded in the non-transitory machine-readable storage medium to perform the following processing: obtaining the MAC address table entry, and calculating a hash value based on the hash algorithm of each hash table and the keyword of the MAC address table entry; wherein each of the hash tables has a unique hash algorithm; Based on the search priority of each of the hash tables, checking the state of the storage location indicated by the corresponding hash value of each of the hash tables in order from high to low search priority; Store the MAC address entry in the first free storage location found; The hash table pointed to by the highest search priority is reduced to the lowest search priority, and the search priority of each of the other hash tables is increased by one level.

12. The device according to claim 11, It is characterized in that The processor executes processor-executable instructions of a non-transitory machine-readable medium to perform the method of any one of claims 2-5.

Citation Information

Patent Citations

  • Apparatus and method for hash table storage, searching

    CN101604337A

  • Hash table-based and extended memory-based high-performance IPv6 address searching method

    CN101827137A

  • Method and device for managing Hash table

    CN102073733A

  • Table entry adding, deleting and searching method of hash table and hash table storage device

    CN102194002A

  • Method and device for processing table items based on Hash table

    CN102682116A