A cache processing method and apparatus, a switching device, and a storage medium
By setting up a multi-level packet replication linked list and allocating cache values in the switching equipment, the problem of cache management in switch multicast is solved, and efficient release of cache and optimized utilization of resources are achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-04
- Publication Date
- 2026-04-21
AI Technical Summary
When a switch performs multicast, the buffer generated by packet replication is difficult to handle effectively, especially since the buffer release mechanism of a multi-level replication linked list is not reliable enough.
A multi-level message replication linked list is set up in the switching device. By pre-setting target nodes and intermediate nodes, the total cache value is allocated based on the replication quantity and cache value allocation strategy. The cache value is re-acquired and released when the message is sent, so as to achieve efficient cache management.
It effectively reduces the waste of message replication list resources, improves cache utilization efficiency, and optimizes resource management for multicast services.
Smart Images

Figure CN116320003B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of communication technology, and more specifically, to a buffer processing method, apparatus, switching device, and storage medium. Background Technology
[0002] Multicast, also known as multi-target broadcast, is a transmission method used in networks that allows a message to be delivered to a selected subset of all possible destinations, i.e., sending information to multiple explicitly specified addresses. Multicast is a method of communication between a sender and multiple receivers.
[0003] When performing multicast, switches need to replicate individual packets using a single replication list or a multi-level replication list. However, the buffering caused by packet replication is difficult to handle effectively. Summary of the Invention
[0004] The present invention aims to, for example, provide a caching method, apparatus, switching device, and storage medium that can at least partially solve the aforementioned technical problems.
[0005] The embodiments of the present invention can be implemented as follows:
[0006] In a first aspect, embodiments of the present invention provide a caching method applied to a switching device, wherein the switching device pre-stores a multi-level packet replication linked list, and at least one target node is preset on the first-level packet replication linked list; the method includes:
[0007] In response to the message replication command, based on the number of replications required for each level of the message replication linked list and the first preset cache value allocation strategy, the total cache value of the multi-level message replication linked list is allocated to each target node;
[0008] For each target node, during the replication process of each packet, the cache value allocated to the target node is distributed to each packet replicated in each level of the packet replication chain;
[0009] When each message is sent, the cache value allocated on each message is retrieved again, and the message copy cache is released based on the cache release policy.
[0010] Optionally, at least one intermediate node is preset on each level of the packet replication chain before the last level and after the first level. The step of allocating the total cache value of the multi-level packet replication chains to each target node based on the required replication quantity of each level and a first preset cache value allocation strategy includes:
[0011] For each target node, determine the intermediate node corresponding to the target node in the message replication chain at each level;
[0012] Count the number of times each intermediate node's corresponding message needs to be copied in its respective message replication chain;
[0013] Obtain the number of packets that have been copied from the target node in the last-level packet replication list;
[0014] Based on the number of packets and the number of times each packet corresponding to an intermediate node needs to be copied in its respective packet replication chain, the number of copies of the packet corresponding to each target node is obtained.
[0015] Based on the first preset cache value allocation strategy, the total cache value of the multi-level message replication linked list is allocated to each target node according to the replication quantity.
[0016] Optionally, the step of allocating the total cache value of the multi-level message replication linked list to each target node based on the number of replications required for each level of the message replication linked list and a first preset cache value allocation strategy includes:
[0017] Determine the relationship between the sum of all said copy counts and the total cache value;
[0018] If the sum of all the said replication counts equals the total cache value, then a cache value equal to the replication count corresponding to each of the target nodes is allocated to each of the target nodes.
[0019] Optionally, the step of allocating the cached value obtained from the target node to each packet replicated in each level of the packet replication chain includes:
[0020] Send the cached value allocated to the target node to the intermediate node connected to the target node;
[0021] The cached values obtained by the intermediate nodes are sequentially allocated to each packet copied in the current packet replication list, and the unallocated cached values on the intermediate nodes are sent to the intermediate nodes in the next level packet replication list, until they are allocated to the last level packet replication list.
[0022] The unallocated cache value on the last intermediate node is evenly distributed to the new packets copied from the last-level packet replication chain.
[0023] Optionally, determining the relationship between the sum of all the copy counts and the size of the cache value further includes:
[0024] If the sum of all the replication counts is less than the total cache value, then the final target node is determined from all the target nodes, and the final target node is the target node where the last message replication is performed.
[0025] In addition to the final target node, allocate the same number of cache values as the number of replications corresponding to each target node to each target node;
[0026] The remaining cached values are allocated to the final target node.
[0027] Optionally, the step of allocating the cached value obtained from the target node to each packet replicated in each level of the packet replication chain includes:
[0028] For the final target node, the cached value allocated to the final target node is sent to the intermediate node connected to the final target node;
[0029] The cached values obtained by the intermediate nodes are sequentially allocated to each packet copied in the current packet replication list, and the unallocated cached values on the intermediate nodes are sent to the intermediate nodes in the next level packet replication list, until they are allocated to the last level packet replication list.
[0030] Based on the second preset cache value allocation strategy, the unallocated cache value on the last intermediate node is allocated to the new message copied from the last-level message replication chain.
[0031] Optionally, the step of retrieving the cache value allocated on each sent message and releasing the message replication cache based on a cache release policy includes:
[0032] Retrieve and accumulate the cached value allocated on each sent message;
[0033] Determine whether the sum of the accumulated cached values equals the total cached value;
[0034] If so, the message copy cache is released.
[0035] Secondly, embodiments of the present invention provide a cache processing device applied to a switching device, wherein the switching device pre-stores a multi-level packet replication linked list, and at least one target node is preset on the first-level packet replication linked list; the cache processing device includes:
[0036] The first cache value allocation unit is used to respond to the message copying instruction and allocate the total cache value of the multi-level message copying linked list to each target node based on the number of copies required for each level of the message copying linked list and the first preset cache value allocation strategy.
[0037] The second cache value allocation unit is used to allocate the cache value allocated to the target node to each packet copied in each level of the packet copying chain during the process of copying each packet.
[0038] The message replication cache release unit is used to re-acquire the cache value allocated on each message being sent when each message is sent, and release the message replication cache based on the cache release policy.
[0039] Thirdly, embodiments of the present invention provide a switching device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of any of the methods described above.
[0040] Fourthly, embodiments of the present invention provide a computer-readable storage medium, the computer-readable storage medium including a computer program, wherein the computer program, when executed, controls a server where the computer-readable storage medium is located to implement the steps of any of the methods described above.
[0041] The beneficial effects of the embodiments of the present invention include, for example:
[0042] By setting a total cache value, during multi-level message replication, the total cache value is allocated to the new messages replicated in each level of the message replication chain. When a new message is sent, the allocated cache value is retrieved again, and based on the cache release policy, the cache generated during message replication is released, reducing the waste of message replication chain resources. Attached Figure Description
[0043] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0044] Figure 1 An architecture diagram of a switching device provided in an embodiment of the present invention;
[0045] Figure 2 A flowchart illustrating the steps of a caching method provided in an embodiment of the present invention;
[0046] Figure 3 This is a schematic diagram illustrating a multi-level message replication linked list replication method provided in an embodiment of the present invention.
[0047] Figure 4This is an architectural diagram of a cache processing device provided in an embodiment of the present invention.
[0048] Icons: 100-Switching device; 110-Memory; 120-Processor; 130-Communication module; 300-Buffer processing device; 301-First buffer value allocation unit; 302-Second buffer value allocation unit; 303-Message copy buffer release unit. Detailed Implementation
[0049] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0050] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0051] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0052] Furthermore, the terms "first" and "second" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0053] It should be noted that, where there is no conflict, the features in the embodiments of the present invention can be combined with each other.
[0054] With the rapid growth of network traffic, multicast services are becoming increasingly widespread. To maximize replication capabilities while considering chip implementation costs and controlling the release mechanism of packet buffers, switching chips have proposed the RCD (Retrieve Counting Delta) maintenance mechanism to release the buffer of a single replication list. However, for multi-level packet replication lists, there is currently no reliable buffer release mechanism.
[0055] Based on the above, embodiments of this specification provide a caching method, apparatus, switching device, and storage medium, which can effectively alleviate the aforementioned technical problems.
[0056] Please refer to Figure 1This is a block diagram of a switching device 100 provided in this application. The switching device 100 includes a memory 110, a processor 120, and a communication module 130. The memory 110, processor 120, and communication module 130 are electrically connected to each other directly or indirectly to realize data transmission or interaction. For example, these components can be electrically connected to each other through one or more communication buses or signal lines.
[0057] The memory 110 is used to store programs or data. The memory 110 may be, but is not limited to, random access memory (RAM), read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), etc.
[0058] The processor 120 is used to read / write data or programs stored in memory and to perform corresponding functions.
[0059] The communication module 130 is used to establish a communication connection between the server and other communication terminals through the network, and to send and receive data through the network.
[0060] It should be understood that, Figure 1 The structure shown is only a schematic diagram of the switching device 100. The switching device 100 may also include a... Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown. Figure 1 The components shown can be implemented using hardware, software, or a combination thereof.
[0061] Correspondingly, embodiments of the present invention provide a caching method applied to a switching device, wherein the switching device pre-stores multi-level packet replication lists, and at least one target node is preset on the first-level packet replication list; the method includes, for example, Figure 2 The following steps are shown:
[0062] Step S110: In response to the message replication instruction, based on the number of replications required for each level of the message replication linked list and the first preset cache value allocation strategy, the total cache value of the multi-level message replication linked list is allocated to each target node.
[0063] Step S120: For each target node, during the replication process of each packet, the cache value allocated to the target node is distributed to each packet replicated in each level of the packet replication chain.
[0064] Step S130: When each message is sent, re-acquire the cache value allocated on each message being sent, and release the message copy cache based on the cache release policy.
[0065] When replicating messages in a multi-level message replication list, replication proceeds sequentially according to the level of the replication list. Only after the first message in the current replication list has been replicated within that list will replication of the next message in the next level's replication list begin. Once the first message has been completely replicated, replication continues from the first-level replication list, copying the next message, until all messages have been replicated completely.
[0066] In step S110, in response to the message copying instruction, based on the number of copies required for each level of the message copying linked list and the first preset cache value allocation strategy, the total cache value of the multi-level message copying linked list is allocated to each target node.
[0067] Message replication instructions can be automatically issued by the switching device or issued by developers through interactive interfaces or other terminal devices. Target nodes exist only in the first-level message replication chain. Each target node corresponds to a message that needs to be replicated, and each target node corresponds to a different message. The total buffer value can be a preset value, which is greater than or equal to the total number of replicated messages that need to be sent. In other words, the total buffer value determines the total number of message replication operations that can be performed in the multi-level message replication chain. Upon receiving the message replication instruction, message replication in the multi-level message replication chain begins. When initiating message replication, the number of messages to be replicated for each target node in each level of the message replication chain can be determined. Then, based on the first preset buffer value allocation strategy, the total buffer value of the multi-level message replication chain is allocated according to this replication quantity, and the total buffer value is distributed to each target node.
[0068] Optionally, at least one intermediate node is preset on each level of the packet replication chain before the last level and after the first level. The step of allocating the total cache value of the multi-level packet replication chains to each target node based on the required replication quantity of each level and a first preset cache value allocation strategy includes:
[0069] For each target node, determine the intermediate node corresponding to the target node in the message replication chain at each level.
[0070] Count the number of times each message corresponding to an intermediate node needs to be copied in its respective message replication chain.
[0071] Obtain the number of packets that have been copied from the target node in the last-level packet replication list.
[0072] Based on the number of messages and the number of times each message corresponding to an intermediate node needs to be copied in its respective message replication chain, the number of copies of the message corresponding to each target node is obtained.
[0073] Based on the first preset cache value allocation strategy, the total cache value of the multi-level message replication linked list is allocated to each target node according to the replication quantity.
[0074] like Figure 3 As shown, besides the first-level and last-level message replication lists, each level of the message replication list contains one or more intermediate nodes. The intermediate nodes in the second-level message replication list are linked to the target nodes in the first-level list. The messages corresponding to the linked target nodes and intermediate nodes are identical. Each level of the message replication list containing intermediate nodes starts copying messages from the intermediate node. After copying, it notifies the intermediate nodes linked to that intermediate node in the next level to copy messages, and so on, until the intermediate node in the penultimate level has completed the required number of messages to be copied. Then, the intermediate node copies new messages to the last-level message replication list. The last-level message replication list completes the message replication of its level by using messages copied from the intermediate nodes in the previous level.
[0075] Therefore, for each target node, we can first determine how many intermediate nodes correspond to the target node in each level of the multi-level message replication chain (i.e., which intermediate nodes correspond to the same messages as the target node). Then, we count the number of messages replicated by each intermediate node corresponding to the target node (i.e., the number of times each message corresponding to an intermediate node needs to be replicated in its respective message replication chain), and add this to the number of times the message has been replicated in the last level of the message replication chain. This gives us the number of times the message corresponding to each target node needs to be replicated.
[0076] For example, in the first-level message replication chain, there are three target nodes A, B, and C. There are three intermediate nodes corresponding to target node A. The number of times the message corresponding to each intermediate node is replicated in its message replication chain is 5, 6, and 7, respectively. In the last-level message replication chain, the number of times the message is replicated is 3. Therefore, the number of replications corresponding to target node A is 21.
[0077] After obtaining the replication count for each target node, the total cache value of the multi-level message replication linked list can be allocated to each target node according to the replication count and the first preset cache value allocation strategy.
[0078] Optionally, the step of allocating the total cache value of the multi-level message replication linked list to each target node based on the number of replications required for each level of the message replication linked list and a first preset cache value allocation strategy includes:
[0079] Determine the relationship between the sum of all said replication counts and the total cache value.
[0080] If the sum of all the said replication counts equals the total cache value, then a cache value equal to the replication count corresponding to each of the target nodes is allocated to each of the target nodes.
[0081] The sum of the replication counts for all target nodes must either be less than or equal to the total cache value. When the sum of the replication counts for all target nodes equals the total cache value, a cache value equal to the replication count for each target node is allocated to that target node. However, when the number of packets to be replicated exceeds the total cache value, the multi-level packet replication list will stop replicating packets after the number of replicated packets equals the total cache value.
[0082] For example, if there are target nodes A, B, and C in the first-level message replication chain, with corresponding replication counts of 20, 30, and 40 respectively, and a total cache value of 90, then target node A is allocated 20 cache points, target node B is allocated 30 cache points, and target node C is allocated 40 cache points.
[0083] In step S120, for each target node, during the replication of each packet, the cache value allocated to the target node is distributed to each packet replicated in each level of the packet replication chain.
[0084] For each target node, in addition to the message replication in the first-level message replication chain, during the message replication process, whenever a new message is replicated, a portion of the cache value allocated on the target node is allocated to the new message.
[0085] Optionally, the step of allocating the cached value obtained from the target node to each packet replicated in each level of the packet replication chain includes:
[0086] The cached value allocated to the target node is sent to the intermediate node linked to the target node.
[0087] The cached values obtained by the intermediate nodes are sequentially allocated to each packet copied in the current packet replication list. Unallocated cached values on the intermediate nodes are sent to the intermediate nodes in the next level packet replication list, until they are allocated to the last level packet replication list.
[0088] The unallocated cache value on the last intermediate node is evenly distributed to the new packets copied from the last-level packet replication chain.
[0089] Specifically, the cached value allocated on the target node is first sent to the intermediate nodes linked to the target node in the next-level packet replication list. When an intermediate node starts packet replication, it distributes the cached value it received to each newly replicated packet in turn, with each packet receiving one cached value. After allocating one cached value to each newly replicated packet in this level of packet replication list, the intermediate node sends the remaining unallocated cached value to the intermediate nodes in the next-level packet replication list linked to it. The intermediate nodes that receive the cached value continue to distribute the cached value in the same way until it is distributed to the last level of the packet replication list.
[0090] After the intermediate node in the penultimate level message replication list completes the allocation of cached values in that level's list, it then distributes the remaining unallocated cached values evenly across each newly replicated message in the last level message replication list. Here, "evenly distributed" refers to the cached values allocated to each newly replicated message in the last level message replication list; each new message will be allocated a small amount of cached value. However, in the actual allocation process, it could be that for each new message replicated in the last level message replication list, a small amount of cached value is allocated to that new message.
[0091] Optionally, determining the relationship between the sum of all the copy counts and the size of the cache value further includes:
[0092] If the sum of all the replication counts is less than the total cache value, then the final target node is determined from all the target nodes, and the final target node is the target node for the last message replication.
[0093] In addition to the final target node, the same number of copies of the cache value corresponding to each target node are allocated to each target node.
[0094] The remaining cached values are allocated to the final target node.
[0095] In another scenario, if the total number of replications for all target nodes is less than the total buffer value, then the corresponding number of replications is allocated to each target node except the last one to be replicated (i.e., the final target node). Then, all remaining buffer values are allocated to the final target node. For example, if the total buffer value is 100, there are three target nodes X, Y, and Z, with Z being the final target node, and the replications for X, Y, and Z are 20, 30, and 40 respectively, then 20 buffer values are allocated to X, 30 to Y, and 50 to Z.
[0096] Optionally, the step of allocating the cached value obtained from the target node to each packet replicated in each level of the packet replication chain includes:
[0097] For the final target node, the cached value allocated to the final target node is sent to the intermediate node linked to the final target node.
[0098] The cached values obtained by the intermediate nodes are sequentially allocated to each packet copied in the current packet replication list. Unallocated cached values on the intermediate nodes are sent to the intermediate nodes in the next level packet replication list, until they are allocated to the last level packet replication list.
[0099] Based on the second preset cache value allocation strategy, the unallocated cache value on the last intermediate node is allocated to the new message copied from the last-level message replication chain.
[0100] When the total number of replications corresponding to all target nodes is less than the total cache value, the method of allocating cache values to target nodes (i.e., the second preset cache value allocation strategy) also differs. Taking the three target nodes X, Y, and Z as an example, the cache values for target nodes X and Y are first allocated according to the above cache value allocation method. For the final target node Z, during cache value allocation, all the cache values allocated to Z are first sent to the intermediate nodes linked to it in the second-level packet replication chain. Then, the cache value allocation for each level of the intermediate packet replication chain is completed sequentially according to the above allocation method. When an allocation is made to an intermediate node in the penultimate level message replication list, the intermediate node first allocates a small buffer value to each message replicated from the penultimate level message replication list corresponding to the intermediate node. Then, it allocates a small buffer value to each message replicated from the last level message replication list corresponding to the intermediate node. Finally, it allocates all remaining unallocated buffer values to the last newly replicated message in the last level message replication list. Alternatively, it first allocates a small buffer value to each newly replicated message in the last level message replication list in turn. When the last new message is replicated, it allocates all remaining unallocated buffer values to that message, thus completing the allocation of all buffer values.
[0101] When all cached values have been allocated, the switching device will send out each packet along with the cached values allocated to each packet. Step S130 is executed: when each packet is sent, the cached values allocated to each sent packet are retrieved again, and the packet copy cache is released based on the cache release policy.
[0102] When a cached value is taken out, the packet replication cache generated in the multi-level packet replication chain can be released based on the cache release strategy. For example, the cached values taken out can be counted, and when the cached values taken out reach a preset threshold, the packet replication cache generated in the multi-level packet replication chain can be released.
[0103] Optionally, the step of retrieving the cache value allocated on each sent message and releasing the message replication cache based on a cache release policy includes:
[0104] Retrieve and accumulate the cached value allocated to each sent message. Determine whether the sum of the accumulated cached values equals the total cached value.
[0105] If so, the message copy cache is released.
[0106] As an optional implementation, the cached values that were taken out can be retrieved again and sent back to the replication logic for summation. It is then determined whether the sum of the retrieved cached values equals the total cached value; if so, the message replication cache is released.
[0107] Based on the same inventive concept, such as Figure 4 As shown in the figure, an embodiment of the present invention provides a cache processing device 300, applied to a switching device. The switching device pre-stores a multi-level packet replication linked list, and at least one target node is preset on the first-level packet replication linked list. The cache processing device 300 includes:
[0108] The first cache value allocation unit 301 is used to allocate the total cache value of the multi-level message replication chain to each target node in response to the message replication instruction, based on the number of replications required for each level of the message replication chain and the first preset cache value allocation strategy.
[0109] The second cache value allocation unit 302 is used to allocate the cache value allocated to the target node to each message copied in each level of the message copying chain during the process of copying each message for each target node.
[0110] The message replication cache release unit 303 is used to re-acquire the cache value allocated on each message being sent when each message is sent, and release the message replication cache based on the cache release policy.
[0111] Regarding the aforementioned cache processing device 300, the specific functions of each unit have been described in detail in the embodiments of the cache processing method provided in this specification, and will not be elaborated upon here.
[0112] Based on the same inventive concept, embodiments of this specification provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of any of the methods of the aforementioned cache processing method.
[0113] The present invention has at least the following beneficial effects:
[0114] By setting a total cache value, during multi-level message replication, the total cache value is allocated to the new messages replicated in each level of the message replication chain. When a new message is sent, the allocated cache value is retrieved again, and based on the cache release policy, the cache generated during message replication is released, reducing the waste of message replication chain resources.
[0115] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in a block diagram and / or flowchart, and combinations of blocks in block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0116] In addition, the functional modules in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0117] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0118] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A caching method, characterized in that, The method is applied to a switching device, which pre-stores a multi-level packet replication linked list, with at least one target node pre-defined on the first-level packet replication linked list; the method includes: In response to the message replication command, based on the number of replications required for each level of the message replication linked list and the first preset cache value allocation strategy, the total cache value of the multi-level message replication linked list is allocated to each target node; For each target node, during the replication process of each packet, the cache value allocated to the target node is distributed to each packet replicated in each level of the packet replication chain; When each message is sent, the cache value allocated on each message is retrieved again, and the message copy cache is released based on the cache release policy.
2. The caching method as described in claim 1, characterized in that, At least one intermediate node is preset on each level of the message replication chain before the last level and after the first level. The allocation of the total cache value of the multi-level message replication chains to each target node based on the required replication quantity of each level and a first preset cache value allocation strategy includes: For each target node, determine the intermediate node corresponding to the target node in the message replication chain at each level; Count the number of times each intermediate node's corresponding message needs to be copied in its respective message replication chain; Obtain the number of packets that have been copied from the target node in the last-level packet replication list; Based on the number of messages and the number of times each message corresponding to an intermediate node needs to be copied in its respective message copying list, the number of copies of the message corresponding to each target node is obtained. Based on the first preset cache value allocation strategy, the total cache value of the multi-level message replication linked list is allocated to each target node according to the replication quantity.
3. The caching method as described in claim 2, characterized in that, The method of allocating the total cache value of the multi-level message replication linked list to each target node based on the required replication quantity of each level of the message replication linked list and the first preset cache value allocation strategy includes: Determine the relationship between the sum of all said copy counts and the total cache value; If the sum of all the said replication counts equals the total cache value, then a cache value equal to the replication count corresponding to each of the target nodes is allocated to each of the target nodes.
4. The caching method as described in claim 3, characterized in that, The step of allocating the cached value obtained from the target node to each packet replicated in each level of the packet replication chain includes: Send the cached value allocated to the target node to the intermediate node connected to the target node; The cached values obtained by the intermediate nodes are sequentially allocated to each packet copied in the current packet replication list, and the unallocated cached values on the intermediate nodes are sent to the intermediate nodes in the next level packet replication list, until they are allocated to the last level packet replication list. The unallocated cache value on the last intermediate node is evenly distributed to the new packets copied from the last-level packet replication chain.
5. The caching method as described in claim 3, characterized in that, The step of determining the relationship between the sum of all the copy counts and the size of the cache value further includes: If the sum of all the replication counts is less than the total cache value, then the final target node is determined from all the target nodes, and the final target node is the target node where the last message replication is performed. In addition to the final target node, allocate the same number of cache values as the number of replications corresponding to each target node to each target node; The remaining cached values are allocated to the final target node.
6. The caching method as described in claim 5, characterized in that, The step of allocating the cached value obtained from the target node to each packet replicated in each level of the packet replication chain includes: For the final target node, the cached value allocated to the final target node is sent to the intermediate node connected to the final target node; The cached values obtained by the intermediate nodes are sequentially allocated to each packet copied in the current packet replication list, and the unallocated cached values on the intermediate nodes are sent to the intermediate nodes in the next level packet replication list, until they are allocated to the last level packet replication list. Based on the second preset cache value allocation strategy, the unallocated cache value on the last intermediate node is allocated to the new message copied from the last-level message replication chain.
7. The caching method as described in claim 1, characterized in that, The step of retrieving the cache value allocated on each sent message and releasing the message replication cache based on the cache release policy includes: Retrieve and accumulate the cached value allocated on each sent message; Determine whether the sum of the accumulated cached values equals the total cached value; If so, the message copy cache is released.
8. A cache processing device, characterized in that, The device is applied to a switching equipment, which pre-stores a multi-level packet replication linked list, with at least one target node pre-set on the first-level packet replication linked list; the buffer processing device includes: The first cache value allocation unit is used to respond to the message copying instruction and allocate the total cache value of the multi-level message copying linked list to each target node based on the number of copies required for each level of the message copying linked list and the first preset cache value allocation strategy. The second cache value allocation unit is used to allocate the cache value allocated to the target node to each packet copied in each level of the packet copying chain during the process of copying each packet. The message replication cache release unit is used to re-acquire the cache value allocated on each message being sent when each message is sent, and release the message replication cache based on the cache release policy.
9. A switching device, characterized in that, include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor, when executing the program, implements the steps of the method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes a computer program that, when executed, implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Method and device for copying multicast message
CN102821045A
Transmission control protocol proxy method, storage medium and server
CN109688085A