Load balancing method and device, electronic equipment and medium
By configuring the message type CAM table and attribute table, and determining the target keyword template and hash algorithm strategy based on the input message, the problem of limited parsing capabilities of the switching chip during load balancing is solved, and more flexible and accurate hashing is achieved. value calculation.
Patent Information
- Application Number
- CN202411101604.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-10-15
AI Technical Summary
Existing switching chips are limited in parsing standard protocol fields during load balancing, and the keyword template selection is fixed and cannot adapt to different message types, resulting in limited information participation in calculations.
By configuring the message type CAM table and attribute table, the message type is determined based on the preset characteristic field information of the input message, and the target keyword template and hash algorithm strategy are selected to perform hash calculation to achieve load balancing.
It improves the flexibility of keyword templates and the accuracy of load balancing calculation results, lifts the limitations of chip parsing capabilities, and makes hash value calculations more flexible and accurate.
Smart Images

Figure CN118784579A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of network switching chip interaction design, and in particular relates to a load balancing method, device, electronic equipment and medium. Background Art
[0002] When performing load balancing, the switching chip parses the fields in the standard protocol and uses the keyword template to select the fields therein. However, the switching chip in the prior art can only parse the standard fields in the existing standard protocol. The selection of keywords is limited by the switching chip message field parsing capability and the keyword template of the switching chip. The traditional switching chip can only provide keyword templates based on five-element information, resulting in other information being unable to participate in complex balancing calculations; secondly, the keyword template of the prior art switching chip is limited by the switching chip's parsing capability when selecting the field information, and the keyword template is relatively fixed and cannot be applied to other field combinations of the message. Summary of the invention
[0003] The purpose of the present invention is to provide a load balancing method, device, electronic device and medium, which can solve the technical problems that the field information contained in the keyword template is limited by the parsing capability of the switching chip and the corresponding keyword template cannot be selected according to different message types.
[0004] In order to achieve the above object, a specific embodiment of the present invention provides a load balancing method, the method comprising:
[0005] Determine the corresponding message type and target keyword template according to the preset feature field information in the input message;
[0006] Based on the target keyword template, target field information is selected from the field information of the input message for hash calculation, so that the chip can perform load balancing based on the hash value of the hash calculation.
[0007] In one or more embodiments of the present invention, the method further comprises:
[0008] Configure a message type CAM table, wherein each entry in the message type CAM table includes a correspondence between a message type and preset feature field information;
[0009] The corresponding message type is determined according to the message type CAM table and the preset characteristic field information in the input message.
[0010] In one or more embodiments of the present invention, the method further comprises:
[0011] Configuring a plurality of message type attribute tables and keyword templates corresponding to each entry in the message type CAM table, wherein the message type attribute table includes index information of the keyword template corresponding to the message type;
[0012] Determine, according to the message type of the input message, a corresponding target message type attribute table in the multiple message type attribute tables;
[0013] According to the target message type attribute table, a corresponding target keyword template is indexed in the multiple keyword templates.
[0014] In one or more embodiments of the present invention, the message type attribute table further includes a hash algorithm strategy corresponding to the message type;
[0015] The method further comprises:
[0016] According to the message type of the input message, determining a corresponding target hash algorithm strategy in the multiple message type attribute tables;
[0017] Based on the target keyword template and the target hash algorithm strategy, target field information is selected from the field information of the input message for hash calculation, so that the chip can perform load balancing based on the hash value of the hash calculation.
[0018] In one or more embodiments of the present invention, the message type attribute table further includes a target keyword template mask corresponding to the message type;
[0019] The method further comprises:
[0020] Determining a corresponding target keyword template mask in the plurality of message type attribute tables according to the message type of the input message;
[0021] Based on the target keyword mask template and the target keyword template mask, target field information is selected from the field information of the input message for hash calculation, so that the chip can perform load balancing based on the hash value of the hash calculation.
[0022] In one or more embodiments of the present invention, the method further comprises:
[0023] Based on the first category field information and / or the second category field information, the message type is configured in the message type CAM table, the first category field information includes at least one of the MAC address, source IP address, destination IP address, protocol number, source port, destination port and MPLS label information, and the second category field information includes field information of a preset field range in the message.
[0024] In one or more embodiments of the present invention, the keyword template includes a corresponding field information number;
[0025] The method further comprises:
[0026] Parsing the first category field information and / or the second category field information in the input message, and writing them into a hash keyword container in sequence;
[0027] Based on the field number information corresponding to the target keyword template, target field information is selected from the hash keyword container.
[0028] In another aspect of the present invention, a load balancing device is provided, the device comprising:
[0029] The selection module is used to determine the corresponding message type and target keyword template according to the preset feature field information in the input message;
[0030] The calculation module is used to select target field information from the field information of the input message for hash calculation based on the target keyword template, so that the chip can perform load balancing based on the hash value of the hash calculation.
[0031] In another aspect of the present invention, an electronic device is provided, comprising: at least one processor; and a memory, wherein the memory stores instructions, and when the instructions are executed by the at least one processor, the at least one processor executes a load balancing method.
[0032] In another aspect of the present invention, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the load balancing method are implemented.
[0033] Compared with the prior art, the load balancing method of the embodiment of the present invention can determine the corresponding message type and target keyword template according to the preset characteristic field information in the input message, and then select the target field information from the field information of the input message according to the target keyword template to calculate the hash value, so that the chip can perform load balancing based on the hash value calculated by the hash, so that the calculation of the hash value is not limited by the chip's parsing capability; and the target field information includes field information of different categories, which further improves the flexibility of target field selection and the accuracy of load balancing calculation results. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the present invention, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0035] Figure 1 A flow chart of a load balancing method according to an embodiment of the present invention;
[0036] Figure 2 A schematic diagram of the target keyword selection architecture of the present invention;
[0037] Figure 3 It is a schematic diagram of the load balancing architecture of the present invention;
[0038] Figure 4 A schematic diagram of the hash value calculation architecture of the present invention;
[0039] Figure 5 A module diagram of a load balancing device according to another embodiment of the present invention;
[0040] Figure 6 This is a hardware structure diagram of a computing device according to another embodiment of the present invention. DETAILED DESCRIPTION
[0041] In order to enable those skilled in the art to better understand the technical solutions in the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0042] like Figure 1 As shown, a specific implementation of the load balancing method of the present invention is introduced. In this implementation, the method specifically includes the following steps:
[0043] S101. Determine a corresponding message type and a target keyword template according to preset characteristic field information in an input message.
[0044] In the embodiment of the present application, the load balancing calculation unit can parse the input message to obtain field information in the input message. The field information here may include first-category field information and second-category field information, the first-category field information may include at least one of a MAC address, a source IP address, a destination IP address, a protocol number, a source port, a destination port, and MPLS label information, and the second-category field information may include field information of a preset field range in the message.
[0045] The first type of field information can be regarded as standard field information, and the second type of field information can be regarded as message segmentation information. In different embodiments, the load balancing calculation unit can also parse other different standard field information and field information of multiple preset field ranges according to the needs of the actual application environment. For example, the load balancing calculation unit can use the first 96 bytes and 192 bytes of field information in the input message as the second type of field information, and this application does not limit this.
[0046] Mate Reference Figure 2 After parsing the input message, the load balancing calculation unit can write the obtained first-category field information and / or second-category field information into the hash keyword container in sequence. For example, the MAC address, source IP address, destination IP address, protocol number, source port, destination port, and MPLS label information can be numbered 0, 1, 2, ..., n-1 in sequence, and then the second-category field information can be numbered n, n+1, .... Among them, when numbering the second-category field information, the field can be divided into 2-byte units. For example, the field information of the first 192 bytes of the message can be numbered n, n+1, ..., n+95.
[0047] In one embodiment, the user can determine the message type by configuring the message type CAM table according to actual needs. Each entry in the message type CAM table includes a correspondence between the message type and the preset characteristic field information. The load balancing calculation unit can determine the corresponding message type according to the message type CAM table and the preset characteristic field information in the input message. Among them, the user configures the message type CAM table according to the needs, defines the message type, and establishes a correspondence between the message type and the preset characteristic field information of the input message; in this embodiment, the correspondence between the message type and the preset characteristic field information can be one or more message types corresponding to one or more preset characteristic field information; after completing the parsing of the input message, the load balancing calculation unit can determine the message type of the input message according to the correspondence between the preset characteristic information and the message type in the first category field information and / or the second category field information established in the above steps.
[0048] The user can configure multiple message type attribute tables and keyword templates corresponding to each entry in the message type CAM table according to actual needs. The message type attribute table includes index information of the keyword template of the corresponding message type. Among them, the user can pre-configure the correspondence between the message type attribute table and the preset characteristic field information in the first category field information and / or the second category field information. In this embodiment, one or more preset field information may correspond to one or more message type attribute tables; the load balancing calculation unit can determine the corresponding target message type attribute table in the multiple message type attribute tables of the corresponding message type according to the message type determined in the above steps and the correspondence between the preset characteristic field information and the message type attribute table obtained by parsing.
[0049] The user can configure multiple keyword templates in the message type CAM table according to actual needs, and pre-configure the index relationship between the keyword template and the preset feature field information in the message type attribute table. In the present embodiment, one or more preset field information may correspond to one or more keyword templates. Based on the target message type attribute table determined in the above steps, the load balancing calculation unit can index the corresponding target keyword template in multiple keyword templates based on the preset feature field information according to the index information of the keyword template of the corresponding message type in the target message type attribute table.
[0050] The message type attribute table also configures the hash algorithm strategy corresponding to the message type. The load balancing calculation unit determines the corresponding target hash algorithm strategy in multiple message type attribute tables based on the message type of the input message. In this embodiment, one or more message type attribute tables may correspond to one or more hash algorithm strategies.
[0051] S102 . Based on the target keyword template, target field information is selected from the field information of the input message for hash calculation, so that the chip can perform load balancing based on the hash value of the hash calculation.
[0052] Mate Reference Figure 3 In this embodiment, the load balancing calculation unit can select the target key field information according to the target keyword template obtained in the above steps. The target key field information here is the first type of field information and / or the second type of field information in the hash keyword container, wherein the first type of field information and / or the second type of field information are numbered when written into the hash keyword container, and the number of the first type of field information and / or the second type of field information in the hash keyword container corresponds to the corresponding field number information in the target keyword template.
[0053] When selecting field information, the load balancing calculation unit can select the target field information in the hash keyword container according to the number of fields preset in the target keyword template according to the actual needs. For example, the target keyword template is configured with field information with a total of 32 field numbers, that is, 32 fields can be used for hash calculation at the same time. The load balancing calculation unit selects 16 bytes of field information in the hash keyword container according to the number of each field. For example, in the hash value keyword container, the first type of field information and / or the second type of field information is in units of 2 bytes, then the load balancing calculation unit needs to select 8 first type field information and / or second type field information in the hash keyword container to write a numbered field information in the target keyword template. Finally, the load balancing calculation unit completes the writing of all numbered field information and outputs 512 bytes of target field information.
[0054] In one embodiment, a user can configure a target keyword template mask corresponding to a message type in a message type attribute table, and a load balancing calculation unit determines a corresponding target keyword template mask in a plurality of message type attribute tables according to the message type of an input message; in this embodiment, the target keyword template mask is configured to correspond one-to-one with a target keyword corresponding to a target keyword template, for example, if 32 numbered field information are configured in the target keyword template, then the target keyword template mask is also configured with 32 numbered mask information, and therefore the target keyword template mask generates 512 bytes of target mask information corresponding to 512 bytes of target field information according to the target keyword template.
[0055] In one embodiment, the load balancing calculation unit performs hash calculation based on the target field information, target mask information and target hash algorithm strategy in the above steps. According to the actual needs of the chip, hash calculation can be performed based on different numbers of field information. For example, hash calculation is performed based on the mask information of 512 bytes of generated target field information and 512 bytes of target mask information to obtain a hash value, so that the chip can perform load balancing based on the hash value of the hash calculation.
[0056] Mate Reference Figure 4 Multiple groups of load balancing calculation units can be designed in the chip. Each group of load balancing calculation units selects target field information based on different message types and target keyword templates and performs independent hash calculations. Each group of load balancing calculation units outputs at least one group of hash values. In different embodiments, the chip can design different numbers of load balancing calculation units according to the needs of the actual application environment. For example, 8 groups of load balancing calculation units are designed in the chip, and each group of load balancing calculation units outputs a 16-byte hash value, which constitutes a 128-byte hash value set in the chip. Other modules in the chip select appropriate hash values from the hash value set according to needs to participate in the load balancing calculation.
[0057] like Figure 5 As shown, a device for implementing a load balancing method provided in a specific embodiment of the present invention is introduced.
[0058] In an embodiment of the present invention, a load balancing device is provided, which includes a selection module 201 and a calculation module 202;
[0059] The selection module 201 is used to determine the corresponding message type and target keyword template according to the preset feature field information in the input message;
[0060] The calculation module 202 is used to select target field information from the field information of the input message for hash calculation based on the target keyword template, so that the chip can perform load balancing based on the hash value of the hash calculation.
[0061] Figure 6 According to an embodiment of the present specification, a hardware structure diagram of a computing device 30 for load balancing is shown. Figure 6 As shown, the computing device 30 may include at least one processor 301, a memory 302 (e.g., a non-volatile memory), a memory 303, and a communication interface 304, and the at least one processor 301, the memory 302, the memory 303, and the communication interface 304 are connected together via a bus 305. At least one processor 301 executes at least one computer-readable instruction stored or encoded in the memory 302.
[0062] It should be understood that the computer executable instructions stored in the memory 302, when executed, cause at least one processor 301 to perform the above combined operations in various embodiments of this specification. Figure 1-5 Describes the various operations and functions.
[0063] In the embodiments of the present specification, the computing device 30 may include, but is not limited to, a personal computer, a server computer, a workstation, a desktop computer, a laptop computer, a notebook computer, a mobile computing device, a smart phone, a tablet computer, a cellular phone, a personal digital assistant (PDA), a handheld device, a messaging device, a wearable computing device, a consumer electronic device, and the like.
[0064] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0065] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0066] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0067] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0068] It will be apparent to those skilled in the art that the invention is not limited to the details of the exemplary embodiments described above and that the invention can be implemented in other specific forms without departing from the spirit or essential features of the invention. Therefore, the embodiments should be considered exemplary and non-limiting in all respects, and the scope of the invention is defined by the appended claims rather than the foregoing description, and it is intended that all variations falling within the meaning and scope of the equivalent elements of the claims be included in the invention. Any reference numeral in a claim should not be considered as limiting the claim to which it relates.
[0069] In addition, it should be understood that although the present specification is described according to implementation modes, not every implementation mode contains only one independent technical solution. This description of the specification is only for the sake of clarity. Those skilled in the art should regard the specification as a whole. The technical solutions in each embodiment may also be appropriately combined to form other implementation modes that can be understood by those skilled in the art.
Claims
1. A load balancing method, characterized in that: The method comprises: Determine the corresponding message type and target keyword template according to the preset feature field information in the input message; Based on the target keyword template, target field information is selected from the field information of the input message for hash calculation, so that the chip can perform load balancing based on the hash value of the hash calculation.
2. The load balancing method according to claim 1, characterized in that: The method further comprises: Configure a message type CAM table, wherein each entry in the message type CAM table includes a correspondence between a message type and preset feature field information; The corresponding message type is determined according to the message type CAM table and preset characteristic field information in the input message.
3. The load balancing method according to claim 2, characterized in that: The method further comprises: Configuring a plurality of message type attribute tables and keyword templates corresponding to each entry in the message type CAM table, wherein the message type attribute table includes index information of the keyword template corresponding to the message type; Determine, according to the message type of the input message, a corresponding target message type attribute table in the multiple message type attribute tables; According to the target message type attribute table, a corresponding target keyword template is indexed in the multiple keyword templates.
4. The load balancing method according to claim 3, characterized in that: The message type attribute table also includes a hash algorithm strategy corresponding to the message type; The method further comprises: According to the message type of the input message, determining a corresponding target hash algorithm strategy in the multiple message type attribute tables; Based on the target keyword template and the target hash algorithm strategy, target field information is selected from the field information of the input message for hash calculation, so that the chip can perform load balancing based on the hash value of the hash calculation.
5. The load balancing method according to claim 3, characterized in that: The message type attribute table also includes a target keyword template mask corresponding to the message type; The method further comprises: Determining a corresponding target keyword template mask in the plurality of message type attribute tables according to the message type of the input message; Based on the target keyword mask template and the target keyword template mask, target field information is selected from the field information of the input message for hash calculation, so that the chip can perform load balancing based on the hash value of the hash calculation.
6. The load balancing method according to claim 2, characterized in that: The method further comprises: Based on the first category field information and / or the second category field information, the message type is configured in the message type CAM table, the first category field information includes at least one of the MAC address, source IP address, destination IP address, protocol number, source port, destination port and MPLS label information, and the second category field information includes field information of a preset field range in the message.
7. The load balancing method according to claim 6, characterized in that: The keyword template includes the corresponding field information number; The method further comprises: Parsing the first type of field information and / or the second type of field information in the input message, and writing them into a hash keyword container in sequence; Based on the field number information corresponding to the target keyword template, target field information is selected from the hash keyword container.
8. A load balancing device, characterized in that: The device comprises: The selection module is used to determine the corresponding message type and target keyword template according to the preset feature field information in the input message; The calculation module is used to select target field information from the field information of the input message for hash calculation based on the target keyword template, so that the chip can perform load balancing based on the hash value of the hash calculation.
9. An electronic device, characterized in that: include: at least one processor; and a memory storing instructions, which, when executed by the at least one processor, causes the at least one processor to execute the load balancing method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the load balancing method according to any one of claims 1 to 7 are implemented.
Citation Information
Cited By
ECMP-based message forwarding method, apparatus and device, and medium
CN122698500A
An ECMP-based message forwarding method, device, equipment and medium
CN122698500B
