Data storage method and device, equipment and medium
Through multi-hash algorithm and data iterative processing, the problem of low storage space utilization caused by hash conflicts in the FDB table is solved, and efficient utilization of storage space is achieved to ensure that new data can be stored.
Patent Information
- Application Number
- CN202411173736.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-26
- Publication Date
- 2024-12-17
AI Technical Summary
The storage space utilization rate in the existing FDB table is low due to hash conflicts, and new data cannot be inserted into the occupied hash index location, resulting in the storage space being unable to be effectively utilized.
Multiple hash algorithms are used to generate multiple storage locations, and when multiple hash indexes are occupied, the stored data is gradually judged and moved to free up free space to improve storage space utilization.
Through multi hash algorithms and data iterative processing, the storage space utilization of FDB tables is effectively improved, ensuring that new data can be stored and avoiding storage conflicts.
Smart Images

Figure CN119155227A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data storage method, device, equipment and medium. Background Art
[0002] Usually, the media access control (MAC) address of a network device can be used to uniquely identify the network device. During data forwarding, the network device can search the forwarding database (FDB) table based on the MAC address and the virtual local area network (VLAN) to determine the forwarding exit of the data traffic.
[0003] At present, the FDB table exists in the organizational structure of a hash table. Hash addressing has the advantages of being fast and efficient. However, hash conflicts may occur during the hash addressing process. The hash algorithm may generate the same hash index for multiple different keywords. When the hash index position in the FDB table is occupied, data cannot be inserted, thereby reducing the storage space utilization of the FDB table. Summary of the invention
[0004] The present application provides a data storage method, apparatus, device and medium, which can improve the utilization rate of the storage space of the FDB table.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, the present application provides a data storage method, the method comprising:
[0007] Acquire data to be stored, wherein the data to be stored includes a correspondence between a MAC address to be stored, a VLAN identifier to be stored, and a forwarding egress to be stored;
[0008] Generate a plurality of storage locations corresponding to the data to be stored according to the MAC addresses to be stored and the VLAN identifiers to be stored;
[0009] Determine whether there is an idle storage location among the multiple storage locations corresponding to the data to be stored, and obtain a first determination result;
[0010] If the first judgment result indicates that there is no free storage location among the multiple storage locations corresponding to the data to be stored, it is determined whether there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, to obtain a second judgment result;
[0011] If the second judgment result indicates that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, the target data is moved from the target location to other locations for storage, and the data to be stored is stored in the target location.
[0012] Optionally, the determining whether there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, to obtain a second determination result, includes:
[0013] If there is an idle storage location among the multiple storage locations corresponding to the data to be stored, a second judgment result is obtained that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
[0014] Optionally, the method further includes:
[0015] If there is no free storage position in the multiple storage positions corresponding to each of the multiple storage positions corresponding to the data to be stored, a second judgment result is obtained that there is no target data stored in the multiple storage positions corresponding to the data to be stored that can be moved to other positions for storage.
[0016] Optionally, the method further includes:
[0017] If the second judgment result indicates that there is no target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, a reminder is given that there is a storage conflict.
[0018] Optionally, the determining whether there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, to obtain a second determination result, includes:
[0019] If t is less than the reference iteration number, and there is no free storage location in the multiple storage locations of the tth round, then multiple storage locations of the t+1th round are determined according to the data in the multiple storage locations of the tth round, where t is the current iteration number and t is an integer greater than 1;
[0020] If t is less than the reference number of iterations, and there is an idle storage location among the multiple storage locations of the tth round, a second judgment result is obtained that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
[0021] Optionally, the method further includes:
[0022] If t is greater than or equal to the reference number of iterations, and there are no idle storage locations in the multiple storage locations of the tth round, a second judgment result is obtained that there is no target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored.
[0023] Optionally, generating a plurality of storage locations corresponding to the data to be stored according to the MAC address to be stored and the VLAN identifier to be stored includes:
[0024] The MAC addresses to be stored and the VLAN identifiers to be stored are processed respectively by using multiple hash algorithms to obtain multiple storage locations corresponding to the data to be stored.
[0025] In a second aspect, the present application provides a data storage device, the device comprising:
[0026] An acquisition module, used for acquiring data to be stored, wherein the data to be stored includes a correspondence between a MAC address to be stored, a VLAN identifier to be stored, and a forwarding egress to be stored;
[0027] A generating module, used for generating a plurality of storage locations corresponding to the data to be stored according to the MAC address to be stored and the VLAN identifier to be stored;
[0028] A first judgment module, used to judge whether there is an idle storage location among the multiple storage locations corresponding to the data to be stored, and obtain a first judgment result;
[0029] A second judgment module is used to judge whether there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, if the first judgment result indicates that there is no free storage location among the multiple storage locations corresponding to the data to be stored, to obtain a second judgment result;
[0030] A storage module is used to move the target data from the target location for storage to other locations, and store the data to be stored in the target location if the second judgment result indicates that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
[0031] In a third aspect, the present application provides a computing device, including a memory and a processor;
[0032] One or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the computing device executes the method as described in any one of the first aspects.
[0033] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method as described in any one of the first aspects.
[0034] It can be seen from the above technical solution that the present application has at least the following beneficial effects:
[0035] The present application provides a data storage method, in which data to be stored is first obtained, and the data to be stored may include a corresponding relationship between a MAC address to be stored, a VLAN identifier to be stored, and a forwarding port to be stored. Then, based on the MAC address to be stored and the VLAN identifier to be stored, multiple storage locations corresponding to the data to be stored are generated, and it is first determined whether there is an idle storage location in the multiple storage locations corresponding to the data to be stored. If there is no idle storage location, it is further determined whether there is template data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored. If there is, the target data is moved from the target location to other locations for storage, and the data to be stored is stored in the target location. It can be seen that in this method, since one data corresponds to multiple storage locations, when the multiple storage locations corresponding to the data to be stored are all occupied, it can be determined again whether the multiple storage locations corresponding to the data stored at the occupied storage locations are occupied, and so on, it is determined whether there is an idle location. If there is, the stored data can be moved in sequence, thereby freeing up storage space for the data to be stored. In this way, the utilization rate of the storage space of the FDB table can be improved.
[0036] It should be understood that the description of technical features, technical solutions, beneficial effects or similar language in this application does not imply that all features and advantages can be realized in any single embodiment. On the contrary, it is understood that the description of features or beneficial effects means that specific technical features, technical solutions or beneficial effects are included in at least one embodiment. Therefore, the description of technical features, technical solutions or beneficial effects in this specification does not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions and beneficial effects described in the present embodiment can also be combined in any appropriate manner. Those skilled in the art will understand that the embodiment can be realized without one or more specific technical features, technical solutions or beneficial effects of a specific embodiment. In other embodiments, additional technical features and beneficial effects can also be identified in a specific embodiment that does not embody all embodiments. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A flowchart of a data storage method provided in an embodiment of the present application;
[0038] Figure 2A schematic diagram of a situation 1 provided in an embodiment of the present application;
[0039] Figure 3 A schematic diagram of a situation 2 provided in an embodiment of the present application;
[0040] Figure 4 A schematic diagram of a situation 3 provided in an embodiment of the present application;
[0041] Figure 5 A schematic diagram of an FDB table provided in an embodiment of the present application;
[0042] Figure 6 A schematic diagram of another FDB table provided in an embodiment of the present application;
[0043] Figure 7 A schematic diagram of another FDB table provided in an embodiment of the present application;
[0044] Figure 8 A schematic diagram of the process of moving target data in an embodiment of the present application;
[0045] Fig. 9 A schematic diagram of a data storage device provided in an embodiment of the present application;
[0046] Fig.10 A schematic diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] The terms "first", "second", "third", etc. in the specification of this application and the accompanying drawings are used to distinguish different objects rather than to limit a specific order.
[0048] In the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0049] MAC address can be used to uniquely identify network devices (such as switches). Data forwarding of network devices is based on MAC address and VLAN ID to search FDB table, thereby determining the forwarding exit of data traffic. As shown in Table 1 below, this table is a schematic diagram of an FDB table provided in an embodiment of the present application.
[0050] Hash index MAC Address VLAN ID Forwarding export Index 1 Address 1 Logo 1 Exit 1 Index 2 Address 2 Logo 2 Exit 2 … … … …
[0051] Among them, address 1, identifier 1 and exit 1 can be called a table entry. The larger the capacity of the FDB table, the greater the forwarding capacity of the layer 2 network device that the network device can carry. With the evolution of large layer 2 networks in data centers, the requirements for the capacity of the FDB table of network devices are getting higher and higher. In some cases, the capacity of the FDB table is very large, but it cannot store many table entries. How to improve the utilization of the storage space of the FDB table is a technical problem that needs to be solved.
[0052] At present, the addressing of the FDB table of the network device adopts hash addressing, which has the advantages of being fast and efficient, and is often used for operations such as inserting, deleting and searching large amounts of data. However, hash addressing may have the problem of hash conflicts, that is, the hash function may generate the same hash index for multiple different keywords. If the storage location corresponding to the hash index of the new data is occupied, the new data cannot be stored. For example, the MAC address of the new data is address 3 and the VLAN ID is ID 3. After processing the address 3 and ID 3 through the hash function, the hash index obtained is index 1. As shown in Table 1 above, index 1 is occupied, which will cause the new data to be unable to be inserted into the storage location corresponding to index 1, that is, the new data cannot be stored.
[0053] In view of this, the embodiment of the present application provides a data storage method, which adopts a multi-hash algorithm to improve the utilization rate of the storage space of the FDB table. In this way, multiple hash indexes can be generated for the same keyword (MAC address + VLAN identifier). In this way, even if the storage location corresponding to the hash index calculated for the new data is occupied, the next hash index of the new data can be calculated until there is an idle storage location, and the new data is stored in the idle storage location. If the storage locations corresponding to multiple hash indexes are all occupied, the data at the occupied storage location is further hashed to obtain the next hash index of the data at the occupied storage location. If the storage location corresponding to the next hash index is empty, it indicates that the data at the occupied storage location can be moved to other locations for storage, and so on. In this way, it is determined whether the data at the occupied storage location has data that can be moved to other locations for storage. If so, the data that can be moved to other locations for storage is moved in sequence, and finally the new data is inserted into the FDB table.
[0054] In order to make the technical solution of the present application clearer and easier to understand, the technical solution of the present application is described in detail below with reference to the accompanying drawings. Figure 1As shown, the figure is a flow chart of a data storage method provided by an embodiment of the present application. The method can be applied to a network device, which can be a switch. The method includes:
[0055] S101. A network device obtains data to be stored.
[0056] The data to be stored includes the corresponding relationship between the MAC address to be stored, the VLAN identifier to be stored, and the forwarding egress to be stored.
[0057] The implementation of this application does not specifically limit the way in which the network device obtains the data to be stored. The focus of the embodiments of this application is on how the network device stores the data to be stored. Therefore, the way in which the network device obtains the data to be stored includes but is not limited to active learning and user configuration.
[0058] S102: The network device generates a plurality of storage locations corresponding to the data to be stored according to the MAC addresses to be stored and the VLAN identifiers to be stored.
[0059] In an embodiment of the present application, after the network device obtains the data to be stored, it can generate multiple storage locations corresponding to the data to be stored based on the MAC address to be stored and the VLAN identifier to be stored in the data to be stored.
[0060] In some embodiments, the network device may use a multi-hash algorithm to process the MAC address to be stored and the VLAN identifier to be stored, thereby obtaining multiple hash indexes corresponding to the MAC address to be stored and the VLAN identifier to be stored, each hash index corresponding to a storage location, thereby obtaining multiple storage locations corresponding to the data to be stored. An example is given in which the multi-hash algorithm may include three hash algorithms, and the three hash algorithms include a first hash algorithm, a second hash algorithm, and a third hash algorithm.
[0061] In an embodiment of the present application, the network device can use the first hash algorithm, the second hash algorithm and the third hash algorithm respectively to process the above-mentioned MAC addresses to be stored and the VLAN identifiers to be stored, and then obtain the hash indexes corresponding to the respective algorithms.
[0062] It should be noted that in actual application, the network device does not determine the hash indexes corresponding to all hash algorithms at once, but determines the hash index corresponding to each hash algorithm one by one. In the process of determining one by one, it is also necessary to determine whether the storage location corresponding to the determined hash index is idle. If it is idle, stop determining the hash index. If there is no idle state, continue to determine the hash index corresponding to the next hash algorithm, thereby improving computing efficiency and reducing resource waste.
[0063] S103: The network device determines whether there is an idle storage location among the multiple storage locations corresponding to the data to be stored.
[0064] If a first judgment result is obtained that there is an idle storage location among the multiple storage locations corresponding to the data to be stored, S104 is executed; if a first judgment result is obtained that there is no idle storage location among the multiple storage locations corresponding to the data to be stored, S105 is executed.
[0065] In some embodiments, continuing with the above example, the network device may first use the first hash algorithm to process the MAC address to be stored and the VLAN identifier to be stored, thereby obtaining a first hash index, and then based on the first hash index, determine the corresponding storage location in the FDB table. If the storage location is idle, a first judgment result is obtained that there is an idle storage location among the multiple storage locations corresponding to the data to be stored. If the storage location is occupied, the network device then uses the second hash algorithm to process the MAC address to be stored and the VLAN identifier to be stored, thereby obtaining a second hash index, and then based on the second hash index, determines whether the corresponding storage location in the FDB table is idle. By analogy, if there are no idle storage locations, a first judgment result is obtained that there are no idle storage locations among the multiple storage locations corresponding to the data to be stored.
[0066] S104: The network device stores the data to be stored in an idle storage location.
[0067] If the first judgment result indicates that there is an idle storage location among the multiple storage locations corresponding to the data to be stored, the network device may directly store the data to be stored in the idle storage location.
[0068] S105. The network device determines whether there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
[0069] If a second judgment result is obtained that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, execute S106; if a second judgment result is obtained that there is no target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, execute S107.
[0070] If the first judgment result indicates that there are no free storage locations in the multiple storage locations corresponding to the data to be stored, the network device can determine whether there is target data stored in the multiple storage locations corresponding to the data to be stored that can be moved to other locations for storage, and obtain a second judgment result.
[0071] Among them, the target data that can be moved to other locations for storage can be defined as follows:
[0072] Case 1: If there is an idle storage location among the multiple storage locations corresponding to data that has been stored in the FDB table, the data that has been stored in the FDB table is the target data.
[0073] For ease of understanding, the following is an example of situation 1 with reference to the accompanying drawings. Figure 2 As shown, the figure is a schematic diagram of a situation 1 provided by an embodiment of the present application. It can be seen from the figure that the indexes of the data D0 to be stored are H1, H2 and H3, and the storage locations corresponding to H1, H2 and H3 are all occupied. D1 is the data stored in the storage location corresponding to index H1 in the FDB table. The network device can perform multi-hash algorithm processing on D1 to obtain indexes H1, H4 and H5. It can be seen that the storage location corresponding to index H5 is idle, that is, there is an idle storage location among the multiple storage locations corresponding to the stored D1, and D1 can be the target data.
[0074] Case 2: If there are no free storage locations in the multiple storage locations corresponding to a piece of data that has been stored in the FDB table, but there are free storage locations in the multiple storage locations corresponding to the next layer of data corresponding to the piece of data that has been stored in the FDB table, then the piece of data that has been stored in the FDB table is the target data. The next layer of data corresponding to the piece of data refers to the data stored in the multiple storage locations corresponding to the piece of data.
[0075] For ease of understanding, the following is an example of situation 2 with reference to the accompanying drawings. Figure 3As shown, the figure is a schematic diagram of a situation 2 provided by an embodiment of the present application. It can be seen from the figure that the indexes of the data D0 to be stored are H1, H2 and H3, and the storage locations corresponding to H1, H2 and H3 are all occupied, D1 is the data stored in the storage location corresponding to the index H1 in the FDB table, and the storage locations corresponding to the indexes H1, H4 and H5 corresponding to the stored data D1 are all occupied. The network device can determine the next layer of data of the data D1 (including D4 and D5, and D4 is used as an example here) D4 is processed by a multi-hash algorithm to obtain indexes H4, H6 and H7, and the storage location corresponding to index H7 is idle, that is, there is an idle storage location in the multiple storage locations corresponding to the next layer of data D4 corresponding to the data D1 stored in the FDB table, and D1 can be the target data.
[0076] Case 3: If there are no free storage locations in the multiple storage locations corresponding to data that has been stored in the FDB table, but there are no free storage locations in the multiple storage locations corresponding to the next layer of data that has been stored in the FDB table, then it is determined that there are no free storage locations in the multiple storage locations corresponding to the next layer of data until the number of iterations is greater than or equal to the layer threshold. If a free storage location is found, the data that has been stored in the FDB table is the target data.
[0077] For ease of understanding, the following is an example of situation 3 with reference to the accompanying drawings. Figure 4 As shown, the figure is a schematic diagram of a situation 3 provided in an embodiment of the present application. Among them, the number of iteration layers refers to the number of times the network device has performed multi-hash algorithm processing on the stored data. In the embodiment of the present application, the number of iteration layers can be the sum of the number of data D1, data D4...data Dn. The layer threshold can be pre-set. The higher the layer threshold, the greater the storage space utilization of the FDB table, but more computing resources are required for calculation and search. The lower the layer threshold, the smaller the storage space utilization of the FDB table, but it can save computing resources. In some embodiments, in order to neutralize the utilization of storage space and computing resources, the layer threshold can be set to 3 layers.
[0078] In this embodiment, assuming that the sum of the number of the above-mentioned data D1, data D4...data Dn is less than the layer number threshold, since the storage location corresponding to the index value Hn+2 of the data Dn is idle, that is, the network device can find the idle storage location (the storage location corresponding to the index Hn+2) before the iteration number of layers is greater than or equal to the layer number threshold, then the data D0 that has been stored in the FDB table is the target data.
[0079] The target data is introduced above. Combined with the above introduction to the target data, the following describes in detail how the network device determines whether there is target data that can be moved to other locations for storage among the data stored in multiple storage locations corresponding to the data to be stored.
[0080] In some embodiments, different judgment methods may be used for the above different situations.
[0081] For the above situation 1, if there is an idle storage location among the multiple storage locations corresponding to the data in the multiple storage locations corresponding to the data to be stored, the network device obtains a second judgment result that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored. If there is no idle storage location among the multiple storage locations corresponding to each of the data in the multiple storage locations corresponding to the data to be stored, a second judgment result is obtained that there is no target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
[0082] Continue to see Figure 2 , the data in the multiple storage locations corresponding to the data to be stored D0 may be D1, D2 and D3, and it is necessary to further determine whether there are free storage locations in the multiple storage locations corresponding to D1 (including the storage locations corresponding to indexes H1, H4 and H5), the storage locations corresponding to D2 and the storage locations corresponding to D3. If so, the network device obtains a second judgment result that there is target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored; if not, the network device obtains a second judgment result that there is no target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored.
[0083] For the above-mentioned cases 2 and 3, the network device can obtain the current number of iterations (denoted as t). If the current number of iterations is less than the reference number of iterations, and there are no free storage locations in the multiple storage locations of the tth round, then the multiple storage locations of the t+1th round are determined based on the data in the multiple storage locations of the tth round, where t is an integer greater than 1; if the current number of iterations is less than the parameter number of iterations, and there are free storage locations in the multiple storage locations of the tth round, then a second judgment result is obtained that there are target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored. If the current number of iterations is greater than or equal to the reference number of iterations, and there are no free storage locations in the multiple storage locations of the tth round, then a second judgment result is obtained that there are no target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored.
[0084] The current number of iterations may refer to the number of iteration layers described above, and the reference number of iterations may be a layer threshold, taking t=2 as an example, and the reference number of iterations as 3. Figure 5 , which is a schematic diagram of an FDB table provided in an embodiment of the present application.
[0085] In this example, the multiple storage locations of the second round are storage locations corresponding to indexes H4, H6 and H7, which are all occupied, and then based on the data in these storage locations, multiple storage locations of the third round are determined. Specifically, the network device selects any one index from indexes H6 and H7 except index H4 corresponding to the storage location where the data of the second round is located. For example, if the selected index is H6, then multiple storage locations of the third round (storage locations corresponding to indexes H6, H8 and H10) are determined based on data D6 of the storage location corresponding to index H6.
[0086] Continue to see Figure 3 In this example, the multiple storage locations of the second round are storage locations corresponding to indexes H4, H6 and H7, wherein the storage location corresponding to index H7 is in an idle state, that is, there is an idle storage location.
[0087] Let's take another example. Take t=3 and the number of reference iterations as 3. Figure 6 , which is a schematic diagram of another FDB table provided in an embodiment of the present application. In this example, the current iteration number is equal to the reference iteration number, and there is no free storage location in the multiple storage locations of the third round (the storage locations corresponding to indexes H6, H8 and H10).
[0088] It should be noted that the embodiment of the present application does not specifically limit the way in which the network device determines the next round of data. In some examples, see Figure 7 , which is a schematic diagram of another FDB table provided by an embodiment of the present application. In indexes H4 and H5 corresponding to D1 (it has been introduced above that the index H1 of the storage location where D1 is already located needs to be excluded), firstly, according to the data D4 of the storage location corresponding to index H4, multiple storage locations corresponding to data D4 (storage locations corresponding to indexes H4, H6 and H7) are determined. If none of the multiple storage locations corresponding to data D4 are free, then according to the data D5 of the storage location corresponding to index H5 parallel to index H4, multiple storage locations corresponding to data D5 (storage locations corresponding to indexes H5, H9 and H10) are determined. If none of the multiple storage locations corresponding to data D5 are free, then according to the data D6 of the storage location corresponding to index H6, and so on.
[0089] In some other embodiments, see Figure 7, in the indexes H4 and H5 corresponding to D1 (it has been mentioned above that the index H1 of the storage location where D1 is already located needs to be excluded), based on the data D4 in the storage location corresponding to index H4, determine the multiple storage locations corresponding to the data D4 (the storage locations corresponding to indexes H4, H6 and H7), and when none of the multiple storage locations corresponding to the data D4 are idle, determine the data D6 in the storage location corresponding to index H6, and so on.
[0090] S106: The network device moves the target data from the target location to another location for storage, and stores the data to be stored in the target location.
[0091] like Figure 8 As shown, this figure is a schematic diagram of the process of moving target data in an embodiment of the present application. When the network device determines that the storage location corresponding to index 10 is idle, the data D6 can be first moved from the storage location corresponding to index H6 to the storage location corresponding to index H10, and then the data D4 can be moved from the storage location corresponding to index H4 to the storage location corresponding to index H6, and then the data D1 can be moved from the storage location corresponding to index H1 to the storage location corresponding to index H4, and finally the data D0 to be stored is stored in the storage location corresponding to index H1. In this example, the storage location corresponding to index H1 can be the target location, and the storage location corresponding to index H4 can be other locations.
[0092] S107. The network device reminds that there is a storage conflict.
[0093] When there is no target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, the network device may prompt that there is a storage conflict, thereby prompting the user that the FDB table is full and needs to be processed in time.
[0094] Based on the above description, the embodiment of the present application provides a data storage method, which adopts a multi-hash algorithm to improve the utilization rate of the storage space of the FDB table. In this way, multiple hash indexes can be generated for the same keyword (MAC address + VLAN identifier). In this way, even if the storage location corresponding to the hash index calculated for the new data is occupied, the next hash index of the new data can be calculated until there is an idle storage location, and the new data is stored in the idle storage location. If the storage locations corresponding to multiple hash indexes are all occupied, the data at the occupied storage location is further hashed to obtain the next hash index of the data at the occupied storage location. If the storage location corresponding to the next hash index is empty, it indicates that the data at the occupied storage location can be moved to other locations for storage, and so on. In this way, it is determined whether the data at the occupied storage location has data that can be moved to other locations for storage. If so, the data that can be moved to other locations for storage is moved in sequence, and finally the new data is inserted into the FDB table.
[0095] Combination of the above Figures 1 to 8 The data storage method provided in the embodiment of the present application is introduced in detail. The device and equipment provided in the embodiment of the present application will be introduced in conjunction with the accompanying drawings.
[0096] like Fig. 9 As shown, this figure is a schematic diagram of a data storage device provided in an embodiment of the present application, the device comprising:
[0097] An acquisition module 901 is used to acquire data to be stored, wherein the data to be stored includes a correspondence between a MAC address to be stored, a VLAN identifier to be stored, and a forwarding egress to be stored;
[0098] A generating module 902, configured to generate a plurality of storage locations corresponding to the data to be stored according to the MAC address to be stored and the VLAN identifier to be stored;
[0099] A first judgment module 903 is used to judge whether there is an idle storage location among the multiple storage locations corresponding to the data to be stored, and obtain a first judgment result;
[0100] A second judgment module 904 is configured to, if the first judgment result indicates that there is no free storage location in the multiple storage locations corresponding to the data to be stored, determine whether there is target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored, to obtain a second judgment result;
[0101] Storage module 905 is used to move the target data from the target location to other locations for storage and store the data to be stored in the target location if the second judgment result indicates that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
[0102] Optionally, the second judgment module 904 is specifically used to obtain a second judgment result that there is target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored if there is an idle storage location in the multiple storage locations corresponding to the data in the multiple storage locations corresponding to the data to be stored.
[0103] Optionally, the second judgment module 904 is also used to obtain a second judgment result that there is no target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored, if there is no free storage location in the multiple storage locations corresponding to each data in the multiple storage locations corresponding to the data to be stored.
[0104] Optionally, the device further comprises a reminder module, which is used to remind that there is a storage conflict if the second judgment result indicates that there is no target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
[0105] Optionally, the second judgment module 904 is specifically used to determine the multiple storage locations of the t+1th round based on the data in the multiple storage locations of the tth round if t is less than the reference number of iterations and there are no free storage locations among the multiple storage locations of the tth round, where t is the current number of iterations and t is an integer greater than 1; if t is less than the reference number of iterations and there are free storage locations among the multiple storage locations of the tth round, a second judgment result is obtained that the data stored in the multiple storage locations corresponding to the data to be stored contains target data that can be moved to other locations for storage.
[0106] Optionally, the second judgment module 904 is also used to obtain a second judgment result that there is no target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored if t is greater than or equal to the reference number of iterations and there are no free storage locations in the multiple storage locations of the tth round.
[0107] The generating module 902 is specifically configured to process the MAC address to be stored and the VLAN identifier to be stored respectively through multiple hash algorithms to obtain multiple storage locations corresponding to the data to be stored.
[0108] The data storage device according to the embodiment of the present application may correspond to executing the method described in the embodiment of the present application, and the above-mentioned other operations and / or functions of each module / unit of the data storage device are respectively to implement Figure 1 For the sake of brevity, the corresponding processes of each method in the illustrated embodiment are not described in detail here.
[0109] The present application also provides a computing device. The server may be a network device, such as a switch. The computing device is specifically used to implement the following Fig. 9 Functionality of the data storage device in the illustrated embodiment.
[0110] like Fig.10 As shown, this figure is a schematic diagram of a computing device provided in an embodiment of the present application, such as Fig.10 As shown, computing device 1000 includes bus 1001, processor 1002, communication interface 1003 and memory 1004. Processor 1002, memory 1004 and communication interface 1003 communicate with each other via bus 1001.
[0111] The bus 1001 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0112] The processor 1002 may be any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0113] The communication interface 1003 is used for communicating with the outside.
[0114] The memory 1004 may include a volatile memory, such as a random access memory (RAM). The memory 1004 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD).
[0115] The memory 1004 stores executable codes, and the processor 1002 executes the executable codes to perform the aforementioned data storage method.
[0116] Specifically, in implementing Fig. 9 In the case of the embodiment shown, and Fig. 9 When each module or unit of the data storage device described in the embodiment is implemented by software, the execution Fig. 9 The software or program code required for the functions of each module / unit in the system may be partially or completely stored in the memory 1004. The processor 1002 executes the program code corresponding to each unit stored in the memory 1004 and executes the aforementioned data storage method.
[0117] The embodiment of the present application also provides a computer-readable storage medium. The computer-readable storage medium can be any available medium that can be stored by a computing device or a data storage device such as a data center containing one or more available media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state hard disk). The computer-readable storage medium includes instructions that instruct the computing device to execute the above-mentioned data storage method.
[0118] The embodiment of the present application further provides a computer program product, which includes one or more computer instructions. When the computer instructions are loaded and executed on a computing device, the process or function described in the embodiment of the present application is generated in whole or in part.
[0119] The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer or data center to another website, computer or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0120] When the computer program product is executed by a computer, the computer executes any of the aforementioned data storage methods. The computer program product may be a software installation package, and when any of the aforementioned data storage methods is required, the computer program product may be downloaded and executed on a computer.
[0121] The descriptions of the processes or structures corresponding to the above-mentioned figures have different emphases. For parts that are not described in detail in a certain process or structure, please refer to the relevant descriptions of other processes or structures.
[0122] The above description is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application.
Claims
1. A data storage method, It is characterized in that The method comprises: Acquire data to be stored, wherein the data to be stored includes a correspondence between a MAC address to be stored, a VLAN identifier to be stored, and a forwarding egress to be stored; Generate a plurality of storage locations corresponding to the data to be stored according to the MAC addresses to be stored and the VLAN identifiers to be stored; Determine whether there is an idle storage location among the multiple storage locations corresponding to the data to be stored, and obtain a first determination result; If the first judgment result indicates that there is no free storage location among the multiple storage locations corresponding to the data to be stored, it is determined whether there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, to obtain a second judgment result; If the second judgment result indicates that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, the target data is moved from the target location to other locations for storage, and the data to be stored is stored in the target location.
2. The method according to claim 1, It is characterized in that The determining whether there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, and obtaining a second determination result, includes: If there is an idle storage location among the multiple storage locations corresponding to the data to be stored, a second judgment result is obtained that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
3. The method according to claim 2, It is characterized in that The method further comprises: If there is no free storage position in the multiple storage positions corresponding to each of the multiple storage positions corresponding to the data to be stored, a second judgment result is obtained that there is no target data stored in the multiple storage positions corresponding to the data to be stored that can be moved to other positions for storage.
4. The method according to claim 1, It is characterized in that The method further comprises: If the second judgment result indicates that there is no target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, a reminder is given that there is a storage conflict.
5. The method according to claim 1, It is characterized in that The determining whether there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, and obtaining a second determination result, includes: If t is less than the reference iteration number, and there is no free storage location in the multiple storage locations of the tth round, then multiple storage locations of the t+1th round are determined according to the data in the multiple storage locations of the tth round, where t is the current iteration number and t is an integer greater than 1; If t is less than the reference number of iterations, and there is an idle storage location among the multiple storage locations of the tth round, a second judgment result is obtained that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
6. The method according to claim 5, It is characterized in that The method further comprises: If t is greater than or equal to the reference number of iterations, and there are no idle storage locations in the multiple storage locations of the tth round, a second judgment result is obtained that there is no target data that can be moved to other locations for storage in the data stored in the multiple storage locations corresponding to the data to be stored.
7. The method according to claim 1, It is characterized in that The step of generating a plurality of storage locations corresponding to the data to be stored according to the MAC address to be stored and the VLAN identifier to be stored comprises: The MAC addresses to be stored and the VLAN identifiers to be stored are processed respectively by using multiple hash algorithms to obtain multiple storage locations corresponding to the data to be stored.
8. A data storage device, It is characterized in that The device comprises: An acquisition module, used for acquiring data to be stored, wherein the data to be stored includes a correspondence between a MAC address to be stored, a VLAN identifier to be stored, and a forwarding export to be stored; A generating module, used for generating a plurality of storage locations corresponding to the data to be stored according to the MAC address to be stored and the VLAN identifier to be stored; A first judgment module, used to judge whether there is an idle storage location among the multiple storage locations corresponding to the data to be stored, and obtain a first judgment result; A second judgment module is used to judge whether there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored, if the first judgment result indicates that there is no free storage location among the multiple storage locations corresponding to the data to be stored, to obtain a second judgment result; A storage module is used to move the target data from the target location for storage to other locations, and store the data to be stored in the target location if the second judgment result indicates that there is target data that can be moved to other locations for storage among the data stored in the multiple storage locations corresponding to the data to be stored.
9. A computing device, It is characterized in that including memory and processor; One or more computer programs are stored in the memory, and the one or more computer programs include instructions; when the instructions are executed by the processor, the computing device executes the method as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium is used to store a computer program, and the computer program is used to execute the method according to any one of claims 1 to 7.
