ECMP-based message processing method, device, electronic device, and storage medium
By calculating the hash value and total weight in the ECMP group table entry, selecting the target ECMP member link for message forwarding, the problem of excessive consumption of ECMP member link resources in the existing technology is solved, and the cost of message processing is reduced effect.
Patent Information
- Application Number
- CN202211650688.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-21
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2042-12-21
AI Technical Summary
The existing ECMP-based message processing method requires consuming a large amount of ECMP member link resources, resulting in an increase in message processing cost.
By receiving the message sent by the device, determine its destination address, determine the corresponding ECMP group entry from the network chip, calculate the hash value of the message, and perform the touch operation based on the hash value and total weight to obtain the message Routing index determines the weight value of each ECMP member link in the ECMP group table entry, and thus selects the target ECMP member link for forwarding.
Reduces consumption of ECMP member links and reduces the cost of packet processing.
Smart Images

Figure CN115967674B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to an ECMP-based message processing method, device, electronic device and storage medium. Background Art
[0002] In the prior art, the ECMP-based message processing method is to configure multiple ECMP member links and set the weight ratio of multiple ECMP member links. When the weight of the ECMP member link is set to be large, too many ECMP member link resources will be consumed. For example, if 16 ECMP member links are set, and the weight ratio of multiple ECMP member links is 16:15:15...:1, then when forwarding a message, 16+15..+1=136 ECMP member link resources are required to achieve it. When the weight ratio of the ECMP member link is set to be larger, more ECMP member link resources need to be consumed.
[0003] Therefore, the ECMP-based message processing method in the prior art needs to consume a large number of ECMP member links, thereby increasing the message processing cost. Summary of the invention
[0004] The purpose of the present application is to provide an ECMP-based message processing method, device, electronic device and storage medium, which can reduce the consumption of ECMP member links and reduce the cost of message processing.
[0005] In order to achieve the above purpose, the technical solution adopted in the embodiment of the present application is as follows:
[0006] In a first aspect, an embodiment of the present application provides a message processing method based on ECMP, which is applied to a network chip, and the method includes:
[0007] receiving a message sent by a device and determining a destination address of the message;
[0008] Determine an ECMP group table entry corresponding to the destination address from the network chip;
[0009] Determining a total weight of the ECMP group entry;
[0010] Calculating a hash value of the message;
[0011] Based on the hash value and the total weight, a demodulation operation is performed on the hash value to obtain a routing index of the message;
[0012] Determine a weight value of each ECMP member link in the ECMP group table entry, wherein the ECMP group table entry includes multiple ECMP member links;
[0013] Determine a target ECMP member link from the ECMP group table entry based on each of the weight values and the routing index;
[0014] The message is forwarded based on the target ECMP member link.
[0015] In an optional implementation, the step of determining the total weight of the ECMP group entry includes:
[0016] Determine the weight ratio of each ECMP member link in the ECMP group table entry;
[0017] The sum of the weight proportions of all ECMP member links is taken as the total weight of the ECMP group entry.
[0018] In an optional implementation, the step of determining the target ECMP member link from the ECMP group table entry based on each of the weight values and the routing index includes:
[0019] Compare the routing index with the weight value corresponding to each of the ECMP member links in the ECMP group table entry;
[0020] When the routing index is less than the target weight value, the ECMP member link corresponding to the target weight value is used as the target ECMP member link; wherein the weight value of each ECMP member link is the sum of the weight proportion of the ECMP member link and the weight proportions of all ECMP member links preceding the ECMP member link.
[0021] In an optional implementation, the step of determining the target ECMP member link from the ECMP group table entry based on each of the weight values and the routing index includes:
[0022] Compare the routing index with the weight values corresponding to the ECMP member links in the ECMP group table entry in sequence, wherein the ECMP member links are sorted in ascending order according to the weight values;
[0023] When the routing index is smaller than a plurality of target weight values, the first ECMP member link corresponding to the weight value greater than the routing index is selected as the target ECMP member link.
[0024] In an optional implementation manner, the step of performing a demodulation operation on the hash value based on the hash value and the total weight to obtain the routing index of the message includes:
[0025] Determine a remainder of dividing the hash value by the total weight;
[0026] The remainder is used as a routing index for the message.
[0027] In an optional implementation, the step of calculating the hash value of the message includes:
[0028] Determine the destination address, source address, IP protocol, source port and destination port of the message;
[0029] Based on the destination address, source address, IP protocol, source port and destination port, a hash value of the message is calculated.
[0030] In a second aspect, an embodiment of the present application provides an ECMP message processing device, the device comprising:
[0031] A receiving module, used to receive a message sent by a device and determine a destination address of the message;
[0032] A first determination module, configured to determine an ECMP group table entry corresponding to the destination address from the network chip;
[0033] A second determination module is used to determine the total weight of the ECMP group table entry;
[0034] A calculation module, used to calculate the hash value of the message;
[0035] A sampling module, used for performing a sampling operation on the hash value based on the hash value and the total weight to obtain a routing index of the message;
[0036] A third determination module is used to determine the weight value of each ECMP member link in the ECMP group table entry, wherein the ECMP group table entry contains multiple ECMP member links;
[0037] A fourth determination module, configured to determine a target ECMP member link from the ECMP group table entry based on each of the weight values and the routing index;
[0038] A forwarding module is used to forward the message based on the target ECMP member link.
[0039] In a third aspect, an embodiment of the present application provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the ECMP message processing method when executing the computer program.
[0040] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the ECMP message processing method when executed by a processor.
[0041] This application has the following beneficial effects:
[0042] The present application receives a message sent by a device and determines the destination address of the message, determines an ECMP group table entry corresponding to the destination address from a network chip, determines the total weight of the ECMP group table entry, calculates a hash value of the message, performs a touch operation on the hash value based on the hash value and the total weight, obtains a routing index of the message, determines a weight value of each ECMP member link in the ECMP group table entry, wherein the ECMP group table entry contains multiple ECMP member links, determines a target ECMP member link from the ECMP group table entry based on each weight value and the routing index, and forwards the message based on the target ECMP member link, thereby reducing the consumption of ECMP member links. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0044] Figure 1 A block diagram of an electronic device provided in an embodiment of the present application;
[0045] Figure 2 One of the flow charts of a message processing method based on ECMP provided in an embodiment of the present application;
[0046] Figure 3 A second flowchart of a message processing method based on ECMP provided in an embodiment of the present application;
[0047] Figure 4 A flowchart of a method for processing messages based on ECMP provided in an embodiment of the present application is provided as a third one;
[0048] Figure 5 A structural block diagram of an ECMP-based message processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0049] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0050] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0051] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0052] In the description of the present application, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, it is based on the orientation or position relationship shown in the drawings, or is the orientation or position relationship in which the product of the invention is usually placed when used. It is only for the convenience of describing the present application and simplifying the description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present application.
[0053] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.
[0054] In the description of this application, it should also be noted that, unless otherwise clearly specified and limited, the terms "set", "install", "connect", and "connect" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.
[0055] After extensive research, the inventors found that the ECMP-based message processing method in the prior art consumes a large number of ECMP member links, increasing the cost of message processing.
[0056] In view of the discovery of the above problems, the present embodiment provides a message processing method, device, electronic device and storage medium based on ECMP, which can receive the message sent by the device and determine the destination address of the message, determine the ECMP group table item corresponding to the destination address from the network chip, determine the total weight of the ECMP group table item, calculate the hash value of the message, and based on the hash value and the total weight, perform a touch operation on the hash value to obtain the routing index of the message, and determine the weight value of each ECMP member link in the ECMP group table item, wherein the ECMP group table item contains multiple ECMP member links, based on each weight value and the routing index, determine the target ECMP member link from the ECMP group table item, and forward the message based on the target ECMP member link, thereby reducing the consumption of ECMP member links. The scheme provided in the present embodiment is elaborated in detail below.
[0057] This embodiment provides an electronic device that can process messages. In a possible implementation, the electronic device can be a user terminal, for example, the electronic device can be, but is not limited to, a server, a smart phone, a personal computer (PC), a tablet computer, a personal digital assistant (PDA), a mobile Internet device (MID), etc.
[0058] Please refer to Figure 1 , Figure 1 1 is a schematic diagram of the structure of the electronic device 100 provided in the embodiment of the present application. The electronic device 100 may also include Figure 1 More or fewer components as shown, or with Figure 1 Different configurations shown. Figure 1 Each component shown in the figure can be implemented by hardware, software or a combination thereof.
[0059] The electronic device 100 includes an ECMP-based message processing device 110 , a memory 120 , and a processor 130 .
[0060] The components of the memory 120 and the processor 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. The ECMP-based message processing device 110 includes at least one software function module that can be stored in the memory 120 in the form of software or firmware or solidified in the operating system (OS) of the electronic device 100. The processor 130 is used to execute the executable modules stored in the memory 120, such as the software function modules and computer programs included in the ECMP-based message processing device 110.
[0061] The memory 120 may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc. The memory 120 is used to store a program, and the processor 130 executes the program after receiving an execution instruction.
[0062] Please refer to Figure 2 , Figure 2 For application Figure 1 A flowchart of a message processing method based on ECMP of an electronic device 100 is provided, and the method including each step is described in detail below.
[0063] Step 201: Receive a message sent by a device and determine the destination address of the message.
[0064] Step 202: Determine the ECMP group table entry corresponding to the destination address from the network chip.
[0065] Step 203: Determine the total weight of the ECMP group entry.
[0066] Step 204: Calculate the hash value of the message.
[0067] Step 205: Based on the hash value and the total weight, a hash value is subjected to a touch operation to obtain a routing index of the message.
[0068] Step 206: Determine the weight value of each ECMP member link in the ECMP group table entry.
[0069] The ECMP group table entry includes multiple ECMP member links.
[0070] Step 207: Based on each weight value and the routing index, determine the target ECMP member link from the ECMP group table entry.
[0071] Step 208: Forward the message based on the target ECMP member link.
[0072] Before implementing this embodiment, the number of ECMP member links and the weight ratio of the ECMP member links in the ECMP group table entry in the network chip are set.
[0073] In one example, a network chip receives a message sent by a device, performs a protocol on the message, obtains field information of the message, and determines the destination address of the message from the field information of the message. Based on the destination address of the message, an ECMP group table item corresponding to the destination address is searched from the network chip, wherein the ECMP group table item includes an address, and the address in the ECMP group table item is used to match the destination address in the message, and the ECMP group table item includes multiple ECMP member links, each ECMP member link corresponds to a weight value, and the total weight of the ECMP group table item is determined based on the information of each ECMP member link. The hash value of the message is calculated based on the field information of the message, and a touch operation is performed based on the hash value of the message and the total weight of the ECMP group table item, and the value of the touch operation is used as the routing index of the message, and the routing index is matched with the weight value of each ECMP member link in the ECMP group table item, so as to determine a matching target ECMP member link from multiple ECMP member links, and forward the message based on the target ECMP member link.
[0074] The next hop is determined by determining the remainder of the hash value divided by the total weight, and using the remainder as the routing index of the message.
[0075] The implementation method of calculating the hash value of the message can be:
[0076] Determine the destination address, source address, IP protocol, source port and destination port of the message, and calculate the hash value of the message based on the destination address, source address, IP protocol, source port and destination port.
[0077] Exemplarily, the implementation method of determining the total weight of the ECMP group table entry may be: determining the weight ratio of each ECMP member link in the ECMP group table entry, and taking the sum of the weight ratios of all ECMP member links as the total weight of the ECMP group table entry. For example: the ECMP group table entry includes a first ECMP member link, a second ECMP member link, and a third ECMP member link. The weight ratio of the first ECMP member link is w0, the weight ratio of the second ECMP member link is w1, the weight ratio of the third ECMP member link is w2, and the total weight of the ECMP group table entry is w0+w1+w2.
[0078] The present application receives a message sent by a device and determines the destination address of the message, determines an ECMP group table entry corresponding to the destination address from a network chip, determines the total weight of the ECMP group table entry, calculates a hash value of the message, performs a touch operation on the hash value based on the hash value and the total weight, obtains a routing index of the message, determines a weight value of each ECMP member link in the ECMP group table entry, wherein the ECMP group table entry contains multiple ECMP member links, determines a target ECMP member link from the ECMP group table entry based on each weight value and the routing index, and forwards the message based on the target ECMP member link, thereby reducing the consumption of ECMP member links.
[0079] There are multiple implementations of how to determine the target ECMP member link from the ECMP group table entry based on the weight value and the routing index. In one implementation, Figure 3 As shown, the following steps are included:
[0080] Step 207-1: Compare the routing index with the weight value corresponding to each ECMP member link in the ECMP group table entry.
[0081] Capture 207-2: When the routing index is less than the target weight value, the ECMP member link corresponding to the target weight value is used as the target ECMP member link.
[0082] The weight value of each ECMP member link is the sum of the weight proportion of the ECMP member link and the weight proportion of all ECMP member links preceding the ECMP member link.
[0083] It should be noted that each ECMP member link in the ECMP group table entry corresponds to a weight ratio, and the weight value of each ECMP member link is determined based on the weight ratio of each ECMP member link.
[0084] For example, when the ECMP group table entry contains four ECMP member links, namely the first ECMP member link member0, the second ECMP member link member1, the third ECMP member link member2, and the fourth ECMP member link member3, and the weight ratio of the first ECMP member link member0, the second ECMP member link member1, the third ECMP member link member2, and the fourth ECMP member link member3 is set to 1:2:3:4.
[0085] The weight value of the first ECMP member link member0 is 1, the weight value of the second ECMP member link member1 is 1+2=3, the weight value of the third ECMP member link member2 is 1+2+3=6, and the weight value of the fourth ECMP member link is 1+2+3+4=10.
[0086] When the weight ratio is configured as 1:2:3:4, the weight value of the first ECMP member link is determined to be 1, the weight value of the second ECMP member link is 3, the weight value of the third ECMP member link is 6, and the weight value of the fourth ECMP member link is 10. By comparing whether the routing index is less than the above weight value, the final target ECMP member link can be determined. Compared with setting a weight range for each ECMP member link, the routing index is compared with the upper and lower limits of the weight range of each ECMP member link to determine the target ECMP member link. The method provided in the present application can reduce the matching logic of the hardware.
[0087] Compare the routing index with the weight value of each ECMP member link. For example, when the routing index is 7, compare 7 with the weight value 1 of member0. If the routing index is greater than the weight value of the first ECMP member link member0, obtain the weight value of the next second ECMP member link. Compare 7 with the weight value 3 of the second ECMP member link. If the routing index is greater than the weight value of the second ECMP member link member1, obtain the weight value of the next third ECMP member link. Compare 7 with the weight value 6 of the third ECMP member link. If the routing index is greater than the weight value of the third ECMP member link, obtain the weight value of the next fourth ECMP member link. Compare 7 with the weight value 10 of the fourth ECMP member link. If the routing index is less than the weight value of the fourth ECMP member link, use the weight value of the fourth ECMP member link as the target ECMP member link, and forward the message based on the fourth ECMP member link.
[0088] It should be noted that when comparing the next hop information with the weight value of each ECMP member link, when the routing index obtained each time is different, there is no need to add too many ECMP member links. For example, when the routing indexes are 1-9, when the routing indexes are 1 and 2, the message is forwarded through the second ECMP member link, when the routing indexes are 3-5, the message is forwarded through the third ECMP member link, and when the routing indexes are 6-9, the message is forwarded through the fourth ECMP member link, which can greatly reduce the consumption of ECMP member links in the ECMP group table.
[0089] In another example, during the message forwarding process, a modulo operation is performed on the hash value of the message to obtain the corresponding routing index, the ECMP group table entry corresponding to the destination address of the message is determined, the weight range of each ECMP member link in the ECMP group table entry is determined, the routing index is compared with the weight range of each ECMP member, the target weight range to which the routing index belongs is determined, and the ECMP member link corresponding to the target weight range is used as the target ECMP member link.
[0090] Another implementation method for determining the target ECMP member link from the ECMP group table entry based on each weight value and the routing index is as follows: Figure 4 As shown, the specific steps include:
[0091] Step 207-3: Compare the routing index with the weight value corresponding to each ECMP member link in the ECMP group table entry in sequence.
[0092] Among them, each ECMP member link is sorted from small to large according to the weight value.
[0093] Step 207 - 4 : When the routing index is smaller than multiple target weight values, the first ECMP member link corresponding to the weight value greater than the routing index is selected as the target ECMP member link.
[0094] In one example, the weight value of the first ECMP member link member0 is 1, the weight value of the second ECMP member link member1 is 1+2=3, the weight value of the third ECMP member link member2 is 1+2+3=6, and the weight value of the fourth ECMP member link is 1+2+3+4=10.
[0095] The routing index is compared with the weight value of each ECMP member link. For example, when the routing index is 4, 4 is compared with the weight values of member0, member1, member2, and member3 respectively, and it is determined that the weight values of member2 and member3 are greater than the routing index. In this case, member2 and member3 are determined as the target ECMP member links. At this time, if the routing index is less than multiple target ECMP member links, the first ECMP member link corresponding to the weight value greater than the routing index is determined, that is, member2 is the first ECMP member link greater than the routing index, and member2 is used as the target ECMP member link.
[0096] In another example, when there are multiple target ECMP member links, the minimum weight value among the weight values corresponding to the multiple target ECMP member links is determined as the target ECMP member link, and message forwarding is performed based on the ECMP member link corresponding to the minimum weight value.
[0097] In another example, the routing index is compared with the weight value of each ECMP member link. For example, when the routing index is 4, 4 is compared with the weight value of member0, the weight value of member1, the weight value of member2, and the weight value of member3 in sequence. When it is determined that the weight value of member2 is greater than the routing index, the comparison between the next hop and the weight value of the next ECMP member link is skipped, and the second ECMP member link member2 is used as the target ECMP member link.
[0098] It should be noted that the number of ECMP member links and the weight ratio of each ECMP member link can be flexibly set.
[0099] Exemplarily, the present application can be implemented by the following simulation program:
[0100] The ECMP group table entry is ECMP group 100, which corresponds to 4 ECMP member links, recorded as member0, member1, member2, and member3, and the corresponding weight ratios are 1:2:3:4 respectively.
[0101] The software configuration is as follows:
[0102] The total weight in the ECMP group table entry Ecmp Group is totalWeight=1+2+3+4=10, member0WeightMax=1, member1WeightMax=3, member2WeightMax=6, member0WeightMax is the weight value of member0, member1WeightMax is the weight value of member1, member2WeightMax is the weight value of member2, and member3 does not need to be configured. When the path index does not match the above three weight values, it must match the weight of member3, which can reduce the logic of one comparison.
[0103] The simulation program is:
[0104] #! / bin / python3
[0105] inputPacketNum=1233456
[0106] #configure parameters
[0107] memberNum=4#member numbermemberWeightArray=[1for i in range(memberNum)]memberWeightArray[0]=1#member 0weight
[0108] memberWeightArray[1]=2#member 1weight
[0109] memberWeightArray[2]=3#member 2weight
[0110] memberWeightArray[3]=4#member 3weight
[0111] memberWeightMin=memberWeightArray[memberNum-1]totalWeight=memberWeightArray[memberNum-1]memberWeightMaxArray=[0for i in range(memberNum)]
[0112] memberWeightMaxArray[0]=memberWeightArray[0]print("====Configuration information====")
[0113] print("Number of ecmp members =", memberNum)
[0114] print("Configured ratio =", end="")
[0115] for member in range(memberNum - 1):
[0116] print(memberWeightArray[member], ":", end="")
[0117] totalWeight = totalWeight + memberWeightArray[member]
[0118] if memberWeightMin > memberWeightArray[member]:
[0119] memberWeightMin = memberWeightArray[member]
[0120] if member == 0:
[0121] memberWeightMaxArray[member] = memberWeightArray[member]
[0122] else:
[0123] memberWeightMaxArray[member] = memberWeightMaxArray[member - 1] + memberWeightArray[member]
[0124] print(memberWeightArray[member + 1])
[0125] memberWeightMaxArray[member + 1] = totalWeight
[0126] memberPacketNumArray = [0 for i in range(memberNum)]
[0127] # Simulated packet input
[0128] for hashValue in range(1,inputPacketNum+1):
[0129] index=hashValue%totalWeight
[0130] #ECMP member selection
[0131] for i in range(memberNum):
[0132] if index <memberWeightMaxArray[i]:
[0133] memberPacketNumArray[i]=memberPacketNumArray[i]+1
[0134] break
[0135] print("====Measured information====")
[0136] print("Input Packet Number",inputPacketNum,sep='=')
[0137] #Get the number of messages with the lowest ratio
[0138] memberPacketNumMin=memberPacketNumArray[0]
[0139] for member in range(memberNum):
[0140] print("member",member,end="")
[0141] print("Number of messages", memberPacketNumArray[member], sep="="")
[0142] if memberPacketNumArray[member] <memberPacketNumMin:
[0143] memberPacketNumMin=memberPacketNumArray[member]
[0144] for member in range(memberNum):
[0145] if memberPacketNumArray[member] <memberPacketNumMin:
[0146] memberPacketNumMin=memberPacketNumArray[member]
[0147] print("Measured ratio =",end = "")
[0148] for member in range(memberNum-1):
[0149] print
[0150] (round(memberPacketNumArray[member] / memberPacketNumMin*memberWeightMin,2),":",end="")
[0151] print
[0152] (round(memberPacketNumArray[member+1] / memberPacketNumMin*memberWeightMin,2))
[0153] The execution effect is as follows:
[0154] ====Configuration Information====
[0155] Number of ecmp members = 4
[0156] Configuration ratio = 1:2:3:4
[0157] ====Measured Information====
[0158] Number of input messages = 1233456
[0159] Number of member 0 messages = 123345
[0160] Number of member 1 messages = 246692
[0161] Number of member 2 messages = 370038
[0162] Number of member 3 messages = 493381
[0163] Measured ratio = 1.0:2.0:3.0:4.0
[0164] Adjust the ratio and number of messages at will and take a look at the simulation effect: ====Configuration Information=====
[0165] Number of ecmp members = 4
[0166] Configuration ratio = 127:2:32:44
[0167] ====Measured Information====
[0168] Number of input messages = 352678member Number of messages in 0 = 218518member Number of messages in 1 = 3440member Number of messages in 2 = 55040member Number of messages in 3 = 75680
[0169] The measured ratio = 127.05:2.0:32.0:44.0. The number of members is increased and the ratio is adjusted. The simulation results are as follows: ====Configuration Information=====
[0170] Number of ecmp members = 6
[0171] Configuration ratio = 127:2:32:44:54:70
[0172] ====Measured Information====
[0173] Number of input messages = 2352678member Number of messages 0 = 908176member Number of messages 1 = 14302member Number of messages 2 = 228832member Number of messages 3 = 314644member Number of messages 4 = 386154
[0174] Number of member 5 messages = 500570
[0175] The measured ratio = 127.0:2.0:32.0:44.0:54.0:70.0
[0176] Please refer to Figure 5 The present application embodiment also provides a method for applying Figure 1 The ECMP-based message processing device 110 of the electronic device 100 includes:
[0177] The receiving module 111 is used to receive a message sent by a device and determine a destination address of the message;
[0178] A first determination module 112, configured to determine an ECMP group table entry corresponding to the destination address from the network chip;
[0179] A second determination module 113, configured to determine the total weight of the ECMP group entry;
[0180] A calculation module 114, configured to calculate a hash value of the message;
[0181] A sampling module 115, configured to perform a sampling operation on the hash value based on the hash value and the total weight to obtain a routing index of the message;
[0182] A third determination module 116 is used to determine a weight value of each ECMP member link in the ECMP group table entry, wherein the ECMP group table entry includes multiple ECMP member links;
[0183] A fourth determination module 117, configured to determine a target ECMP member link from the ECMP group table entry based on each of the weight values and the routing index;
[0184] The forwarding module 118 is configured to forward the message based on the target ECMP member link.
[0185] It should be noted that the basic principles and technical effects of the ECMP-based message processing device provided in this embodiment are the same as those of the above-mentioned ECMP-based message processing method embodiment. For the sake of brief description, for parts not mentioned in this embodiment, reference may be made to the corresponding contents in the above-mentioned method embodiment.
[0186] The present application also provides an electronic device 100, which includes a processor 130 and a memory 120. The memory 120 stores computer executable instructions, and when the computer executable instructions are executed by the processor 130, the ECMP-based message processing method is implemented.
[0187] The embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by the processor 130, the ECMP-based message processing method is implemented.
[0188] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to the multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or the flowchart, and the combination of boxes in the block diagram and / or the flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0189] In addition, each functional module in each embodiment of the present application can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a disk or an optical disk.
[0190] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0191] The above are only various implementations of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art who is familiar with the present technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A message processing method based on ECMP, applied to a network chip, characterized in that: The method comprises: receiving a message sent by a device and determining a destination address of the message; Determine an ECMP group table entry corresponding to the destination address from the network chip; Determining a total weight of the ECMP group entry; Calculating a hash value of the message; Based on the hash value and the total weight, a demodulation operation is performed on the hash value to obtain a routing index of the message; Determine the weight value of each ECMP member link in the ECMP group table entry, wherein the ECMP group table entry contains multiple ECMP member links, and the weight value of each ECMP member link is the sum of the weight proportion of the ECMP member link and the weight proportion of all ECMP member links preceding the ECMP member link; Determine a target ECMP member link from the ECMP group table entry based on each of the weight values and the routing index; Forwarding the message based on the target ECMP member link; The step of determining the total weight of the ECMP group entry includes: Determine the weight ratio of each ECMP member link in the ECMP group table entry; The sum of the weight proportions of all ECMP member links is taken as the total weight of the ECMP group entry.
2. The method according to claim 1, characterized in that The step of determining the target ECMP member link from the ECMP group table entry based on each of the weight values and the routing index comprises: Compare the routing index with the weight value corresponding to each of the ECMP member links in the ECMP group table entry; When the routing index is less than the target weight value, the ECMP member link corresponding to the target weight value is used as the target ECMP member link.
3. The method according to claim 1 or 2, characterized in that: The step of determining the target ECMP member link from the ECMP group table entry based on each of the weight values and the routing index comprises: Compare the routing index with the weight values corresponding to the ECMP member links in the ECMP group table entry in sequence, wherein the ECMP member links are sorted in ascending order according to the weight values; When the routing index is smaller than a plurality of target weight values, the first ECMP member link corresponding to the weight value greater than the routing index is selected as the target ECMP member link.
4. The method according to claim 1, characterized in that The step of performing a demoting operation on the hash value based on the hash value and the total weight to obtain the routing index of the message includes: Determine a remainder of dividing the hash value by the total weight; The remainder is used as a routing index for the message.
5. The method according to claim 1, characterized in that The step of calculating the hash value of the message includes: Determine the destination address, source address, IP protocol, source port and destination port of the message; Based on the destination address, source address, IP protocol, source port and destination port, a hash value of the message is calculated.
6. A message processing device based on ECMP, characterized in that: The device comprises: A receiving module, used to receive a message sent by a device and determine a destination address of the message; A first determination module, configured to determine an ECMP group table entry corresponding to the destination address from a network chip; A second determination module is used to determine the total weight of the ECMP group table entry; A calculation module, used to calculate the hash value of the message; A sampling module, used for performing a sampling operation on the hash value based on the hash value and the total weight to obtain a routing index of the message; A third determination module is used to determine the weight value of each ECMP member link in the ECMP group table entry, wherein the ECMP group table entry contains multiple ECMP member links, and the weight value of each ECMP member link is the sum of the weight proportion of the ECMP member link and the weight proportion of all ECMP member links preceding the ECMP member link; A fourth determination module, configured to determine a target ECMP member link from the ECMP group table entry based on each of the weight values and the routing index; A forwarding module, used for forwarding the message based on the target ECMP member link; The second determining module is specifically used for: Determine the weight ratio of each ECMP member link in the ECMP group table entry; The sum of the weight proportions of all ECMP member links is taken as the total weight of the ECMP group entry.
7. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method according to any one of claims 1 to 5 when executing the computer program.
8. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
