Hash traffic forwarding method and device
By combining the hash calculation results and available bandwidth in hash traffic forwarding to determine the forwarding weight and select the appropriate forwarding port, the problem of load imbalance in hash traffic forwarding is solved, achieving balanced forwarding of data flows and efficient use of resources. .
Patent Information
- Application Number
- CN202410853452.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-15
AI Technical Summary
There is a hash skew problem in hash traffic forwarding, which leads to unbalanced traffic load in network equipment. Some links carry too much traffic while other links are idle, causing network congestion and resource waste.
By obtaining the data flow information to be forwarded by the network device and the available bandwidth of multiple forwarding ports, hash calculation is performed based on the preset hash algorithm, and the forwarding weight is determined based on the available bandwidth, and the forwarding port with the largest weight is selected for data flow forwarding. Achieve balanced forwarding of data flows.
It effectively improves the load balancing of hash traffic forwarding, avoids the situation where some forwarding ports occupy too much bandwidth while other forwarding ports are idle, fully utilizes link resources, and improves network performance and throughput.
Smart Images

Figure CN118784574A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication bearer, and in particular to a hash traffic forwarding method and device. Background Art
[0002] In the field of communication bearer, network devices can determine the data forwarding path through hash calculation. Among them, the hash algorithm can map a binary value of any length to a smaller binary value of fixed length according to a certain hash function. This smaller binary value is called a hash value. The device can determine the port for data forwarding through mapping based on the calculated hash value.
[0003] In practical applications, the disadvantage of this approach is that hash skew may occur. For example, when the input fields of the hash calculation are unevenly distributed or affected by the hash algorithm itself, the hash calculation results will be concentrated in a specific range. As a result, the paths or links associated with the range will carry more data traffic, while other paths or links will carry less data traffic, resulting in unbalanced traffic load.
[0004] How to improve the load balancing of hash traffic forwarding is the technical problem to be solved by this application. Summary of the invention
[0005] The purpose of the embodiments of the present application is to provide a hash traffic forwarding method and device to improve the load balancing of hash traffic forwarding.
[0006] In a first aspect, a hash traffic forwarding method is provided, comprising:
[0007] Acquire information of data streams to be forwarded by a network device and available bandwidths of multiple forwarding ports in the network device;
[0008] Performing hash calculation on the information of the data stream based on a preset hash algorithm;
[0009] Determine the forwarding weights of the multiple forwarding ports respectively based on the hash calculation result and the available bandwidth of each forwarding port;
[0010] The data flow is forwarded through the forwarding port with the largest forwarding weight.
[0011] In a second aspect, a hash traffic forwarding device is provided, comprising:
[0012] An acquisition module, for acquiring information of a data stream to be forwarded by a network device and available bandwidths of a plurality of forwarding ports in the network device;
[0013] A calculation module, performing hash calculation on the information of the data stream based on a preset hash algorithm;
[0014] A determination module, which determines the forwarding weights of the plurality of forwarding ports respectively based on the hash calculation result and the available bandwidth of each forwarding port;
[0015] The forwarding module forwards the data flow through a forwarding port with the largest forwarding weight.
[0016] According to a third aspect, an electronic device is provided. The electronic device comprises a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps of the method according to the first aspect are implemented.
[0017] According to a fourth aspect, 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 method according to the first aspect are implemented.
[0018] In a fifth aspect, a computer program product is provided, which includes a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a computer to execute part or all of the steps of the method of the first aspect.
[0019] In an embodiment of the present application, first, the information of the data stream to be forwarded by the network device and the available bandwidth of multiple forwarding ports in the network device are obtained; then, a hash calculation is performed on the information of the data stream based on a preset hash algorithm; then, the forwarding weights of multiple forwarding ports are determined based on the hash calculation results and the available bandwidth of each forwarding port; finally, the data stream is forwarded through the forwarding port with the largest forwarding weight. Through the scheme provided by the embodiment of the present application, the forwarding weight is jointly determined according to the hash calculation results of the information of the data stream to be forwarded and the available bandwidth of multiple forwarding ports of the network device. The forwarding weight thus determined can express the bandwidth availability of the forwarding port to a certain extent, and can effectively realize balanced forwarding of data streams in a network device containing multiple forwarding ports. Avoid the situation where the bandwidth of some forwarding ports in the network device is too high while other forwarding ports are idle, thereby improving the load balancing of hash traffic forwarding. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0021] Figure 1 This is one of the flowcharts of a hash traffic forwarding method according to an embodiment of the present application;
[0022] Figure 2 This is the second flow chart of a hash traffic forwarding method according to an embodiment of the present application;
[0023] Figure 3 This is a flowchart of a hash traffic forwarding method according to an embodiment of the present application;
[0024] Figure 4 This is a fourth flow chart of a hash traffic forwarding method according to an embodiment of the present application;
[0025] Figure 5 This is a flowchart of a hash traffic forwarding method according to an embodiment of the present application;
[0026] Figure 6 This is the sixth flow chart of a hash traffic forwarding method according to an embodiment of the present application;
[0027] Figure 7 It is a structural diagram of a hash traffic forwarding device according to an embodiment of the present application. DETAILED DESCRIPTION
[0028] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application. The numbering of the drawings in this application is only used to distinguish the various steps in the scheme, and is not used to limit the execution order of the various steps. The specific execution order is subject to the description in the specification.
[0029] In the scenario where network devices forward data streams, if hash skew occurs, some network links will need to carry more traffic, while other network links will carry less traffic, resulting in unbalanced link loads. Furthermore, in the case of unbalanced network link loads, the load may be too large, exceeding the link design capacity limit, resulting in network congestion, increased latency, and decreased performance. At the same time, the idle rate of other network links is high, and link resources are not fully utilized, resulting in a waste of resources.
[0030] In order to solve the problems existing in the prior art, the embodiment of the present application provides a hash traffic forwarding method, the execution subject of the method can be a network device, or other devices with computing functions that are connected to the network device for communication. In the example of the present application, equal-cost multi-path routing (ECMP) is used as an example for explanation. Figure 1 As shown, the method provided in the embodiment of the present application includes the following steps:
[0031] S11: Acquire information about a data flow to be forwarded by a network device and available bandwidths of multiple forwarding ports in the network device.
[0032] In this step, the information of the data stream to be forwarded by the network device may include, for example, source IP (Internet Protocol) address, destination IP address, source port number, destination port number, etc. Various information of the data stream may be used as hash calculation fields to perform hash calculations in subsequent steps.
[0033] The above network device can be, for example, a switch, a router, or other device with a data forwarding function. A network device often has multiple forwarding ports, and different data streams can be forwarded through different forwarding ports. The network device can pre-allocate bandwidth to multiple forwarding ports. When data stream forwarding is not performed, the available bandwidth of each forwarding port is the pre-allocated bandwidth. When data stream forwarding is performed, the data stream needs to occupy at least a portion of the bandwidth of the port to achieve forwarding, and the available bandwidth refers to the unoccupied bandwidth.
[0034] S12: Perform hash calculation on the information of the data stream based on a preset hash algorithm.
[0035] In this step, the preset hash algorithm actually adopted can be set according to actual needs. The information of the data stream often has multiple fields. In the step of performing the hash calculation, a certain number of fields can be selected according to actual needs to perform the hash calculation. For example, the source IP address, destination IP address, source port number and destination port number can be used as four-tuple information to perform the hash calculation. Alternatively, on the basis of the above four-tuple information, the protocol type field is added as five-tuple information to perform the hash calculation. Alternatively, on the basis of the above five-tuple information, the service type and interface index are added as seven-tuple information to perform the hash calculation, etc.
[0036] Hash calculation specifically uses a preset hash algorithm to map the above multiple fields through a hash function to obtain a hash calculation result. For different devices, the results of hash calculation performed on the same data stream information using the same hash algorithm are the same. Among them, the results of hash calculation can be shared between different devices and can be used to achieve load balancing. For example, if multiple devices have the same hash calculation result, then the data packets can be evenly distributed to these devices to achieve load sharing.
[0037] S13: Determine the forwarding weights of the multiple forwarding ports respectively based on the hash calculation result and the available bandwidth of each forwarding port.
[0038] The above hash calculation result can represent the forwarding port obtained based on the hash calculation. Optionally, the hash calculation result can point to a forwarding port based on a preset mapping relationship. Alternatively, based on a preset forwarding strategy, the forwarding probability of each forwarding port is determined according to the hash calculation result. The forwarding probability can be expressed as a percentage, for example, to represent the probability of the above data flow being forwarded through each forwarding port.
[0039] The available bandwidth of each forwarding port can represent the resources of each forwarding port that can be used to forward data streams. The available bandwidth can be represented by an actual bandwidth value, or can be expressed as a percentage or other form. Among them, the available bandwidth expressed based on a percentage can, for example, refer to the ratio of the available bandwidth of the forwarding port to the total bandwidth of all forwarding ports of the network device.
[0040] In this step, the forwarding weights of the multiple forwarding ports are respectively determined based on the hash calculation results and the available bandwidth of each forwarding port, wherein the forwarding weight can integrate the tendency of the hash calculation results and the tendency of the available bandwidth, and not only considers the forwarding port pointed to by the hash calculation result, but also can coordinate according to the available bandwidth of each forwarding port, and realizes an objective and easy-to-compare expression in the form of forwarding weight, so as to facilitate the selection of the forwarding port that actually performs forwarding based on the forwarding weight in the subsequent steps.
[0041] S14: Forwarding the data flow through the forwarding port with the largest forwarding weight.
[0042] In this step, a forwarding port with the largest forwarding weight is selected from multiple forwarding ports to perform data flow forwarding. If the maximum forwarding weight corresponds to multiple forwarding ports, a preset rule can be used for further screening to determine the only forwarding port for forwarding the data flow. Alternatively, multiple forwarding ports corresponding to the maximum forwarding weight can also be used to collaboratively forward the above data flow.
[0043] In an embodiment of the present application, first, the information of the data stream to be forwarded by the network device and the available bandwidth of multiple forwarding ports in the network device are obtained; then, a hash calculation is performed on the information of the data stream based on a preset hash algorithm; then, the forwarding weights of multiple forwarding ports are determined based on the hash calculation results and the available bandwidth of each forwarding port; finally, the data stream is forwarded through the forwarding port with the largest forwarding weight. Through the scheme provided by the embodiment of the present application, the forwarding weight is jointly determined according to the hash calculation results of the information of the data stream to be forwarded and the available bandwidth of multiple forwarding ports of the network device. The forwarding weight thus determined can express the bandwidth availability of the forwarding port to a certain extent, and can effectively realize balanced forwarding of data streams in a network device containing multiple forwarding ports. Avoid the situation where the bandwidth of some forwarding ports in the network device is too high while other forwarding ports are idle, thereby improving the load balancing of hash traffic forwarding.
[0044] In the process of selecting forwarding ports, this solution introduces the available bandwidth of the port and considers the capacity of the network device outlet, so that high-bandwidth outlets have a higher advantage in weight calculation, avoiding the problem of traffic imbalance that may occur when only the hash calculation result is allocated. By comprehensively considering the link load and the hash algorithm results to determine the data flow forwarding path or link, it can balance network traffic forwarding, make full use of link resources, and help improve network performance and throughput.
[0045] Optionally, after forwarding the data stream, the remaining available bandwidth of each forwarding port is updated according to the actual amount of data sent, so that after receiving a new data stream to be forwarded, a port suitable for forwarding can be objectively and accurately selected according to the updated available bandwidth of multiple forwarding ports.
[0046] Based on the solution provided in the above embodiment, optionally, in the above step S13, the forwarding weights of the multiple forwarding ports are determined based on the hash calculation result and the available bandwidth of each forwarding port, such as Figure 2 As shown, including:
[0047] S21: Determine hash calculation weights of the multiple forwarding ports respectively based on the hash calculation results.
[0048] In this step, the hash calculation weights of each forwarding port can be determined according to the preset mapping rules based on the hash calculation results. The hash calculation results can point to one or more forwarding ports based on the preset mapping rules. If multiple forwarding ports are pointed to, the multiple forwarding ports pointed to can have different forwarding probabilities.
[0049] S22: Determine the available bandwidth weights of the multiple forwarding ports based on the available bandwidth of each forwarding port, wherein the available bandwidth weight of the target forwarding port is the ratio of the available bandwidth of the target forwarding port to the maximum value of the available bandwidth of the multiple forwarding ports, wherein the target forwarding port is any one of the multiple forwarding ports.
[0050] In this step, the available bandwidth and the available bandwidth weight may have a positive correlation. For example, the maximum available bandwidth may be determined from the available bandwidths of the multiple forwarding ports. Then, for any target forwarding port among the multiple forwarding ports, the available bandwidth of the target forwarding port itself is divided by the above-mentioned maximum available bandwidth to obtain the available bandwidth weight corresponding to the target forwarding port.
[0051] S23: Determine the forwarding weights of the multiple forwarding ports based on the hash calculation weight and the available bandwidth weight of each forwarding port, wherein the forwarding weight of the target forwarding port is the weighted sum of the hash calculation weight and the available bandwidth weight corresponding to the target forwarding port.
[0052] In this step, the above hash calculation weight and available bandwidth weight are integrated in a weighted sum manner, so as to express the forwarding weights corresponding to different forwarding ports in an objective numerical form.
[0053] For example, the forwarding weight w of the i-th forwarding port can be determined by the following formula (1-1): i :
[0054] w i =α*f(h)+β*b i / max(b1,..b n )
[0055] Among them, α is the weight coefficient corresponding to the hash calculation weight, and β is the weight coefficient corresponding to the available bandwidth weight. These two weight coefficients can be pre-set fixed values, or they can be flexibly self-corrected according to the traffic forwarding situation in actual applications. If α is greater than β, the determined forwarding weight tends to the hash calculation result. On the contrary, if α is less than β, the determined forwarding weight tends to the available bandwidth. α can also be equal to β, then the hash calculation result and the available bandwidth have the same degree of influence on the forwarding weight.
[0056] The weight coefficients can be flexibly set according to actual needs. In one application scenario, the weight coefficients can be determined based on the source IP address, destination IP address and other data flow information. The weight coefficients corresponding to different data flow information can be pre-set and stored based on a table.
[0057] In the above formula (1-1), f(h) is the hash calculation weight of the i-th forwarding port corresponding to the hash value h, and b i is the available bandwidth of forwarding port i, max(b1,..b n ) is the maximum available bandwidth among multiple forwarding ports in the network device, i.e. b1, ..b n The maximum value among these multiple items.
[0058] Through the solution provided in the embodiment of the present application, the above-mentioned hash calculation weight and available bandwidth weight are integrated in a weighted sum manner, and the weight coefficient can be flexibly adjusted in actual applications to meet different requirements for bandwidth and hash calculation results in actual applications.
[0059] Based on the solution provided in the above embodiment, optionally, in the above step S21, the hash calculation weights of the multiple forwarding ports are respectively determined based on the hash calculation results, such as Figure 3 As shown, including:
[0060] S31: Determine a target hash value range hit by the hash calculation result according to a plurality of preset hash value ranges.
[0061] In the embodiment of the present application, the preset hash range where the hash calculation result is located can be determined as the target hash value range. Among them, multiple preset hash value ranges are set in the form of a table, for example:
[0062] Hash value range H0≤h<H1 H1≤h<H2 H2≤h<H3 ...
[0063] For any hash calculation result, the target hash value range in which it is located can be determined based on the preset multiple hash value ranges.
[0064] S32: Determine a hit forwarding port corresponding to the target hash value range based on a preset mapping table, wherein the preset mapping table represents a mapping relationship between a plurality of preset hash value ranges and the plurality of forwarding ports.
[0065] The above preset mapping table is used to represent the mapping relationship between multiple preset hash value ranges and multiple forwarding ports, as shown in the following table:
[0066] Hash value range Forwarding Ports H0≤h<H1 A H1≤h<H2 B H2≤h<H3 C ... ...
[0067] In the present application example, the result of the hash calculation is mapped to a fixed range (e.g., a hash table or a hash bucket), which is associated with the forwarding path or port of the network device. For example, the network device may have 4 paths or 4 ports (numbered 0 to 3), then the hash calculation result can be mapped to one of the 4 paths or ports. The port mapped to is the hit forwarding port pointed to by the hash calculation result.
[0068] S33: Determine the hash weight of the hit forwarding port as a first weight value, and determine the hash weight of the missed forwarding port as a second weight value, wherein the missed forwarding port is a forwarding port other than the hit forwarding port in the network device, and the first weight value is greater than the second weight value.
[0069] In the example of the present application, the specific values of the first weight value and the second weight value can be preset, but the first weight value needs to be greater than the second weight value to clearly express the directionality of the hash calculation result to the above-mentioned hit forwarding port. For example, the first weight value is 1 and the second weight value is 0. Then, f(h)=1 for the hit forwarding port, and f(h)=0 for other forwarding ports in the network device other than the hit forwarding port.
[0070] The present invention is further described below with reference to an example.
[0071] For the information of the data flow to be forwarded, a five-tuple hash value is obtained through a preset hash algorithm, and the hit forwarding port corresponding to the five-tuple hash value is port A.
[0072] For the available bandwidth of each forwarding port, the available bandwidth of each port is obtained according to real-time traffic monitoring, and the available bandwidth weight of each forwarding port is determined respectively. For example, the network device is ECMP, which includes port A and port B. The ratio of port A to the maximum available bandwidth of the port in ECMP is 20%, and the ratio of port B to the maximum available bandwidth of the port in ECMP is 60%.
[0073] Then, the comprehensive forwarding weight is determined based on the available bandwidth weight and the hash calculation weight. In this example, the forwarding weight = the five-tuple hash value weight + the port available bandwidth weight. Assume that the port available bandwidth weight is 0.75. Then, it can be determined that the forwarding weight of port A is 0.25*1+0.75*0.2=0.4, and the forwarding weight of port B is 0.25*0+0.75*0.6=0.45.
[0074] Finally, since 0.45>0.4, port B with the largest forwarding weight is selected to forward the data flow, thereby achieving the purpose of balanced forwarding according to the available bandwidth of the network device port.
[0075] Based on the solution provided in the above embodiment, optionally, Figure 4 As shown, in the above step S13, the forwarding weights of the multiple forwarding ports are determined based on the hash calculation result and the available bandwidth of each forwarding port, including:
[0076] S41: Determine the forwarding weights of the multiple forwarding ports by multiplying the hash calculation result by the available bandwidth ratio of each forwarding port, wherein the available bandwidth ratio is the ratio of the available bandwidth of the corresponding forwarding port to the sum of the available bandwidths of the multiple forwarding ports.
[0077] In the example of the present application, the above hash calculation result and the available bandwidth are integrated by proportional multiplication to obtain a forwarding weight that comprehensively expresses the available bandwidth and the hash calculation result.
[0078] Among them, the available bandwidth ratio of forwarding port i can be expressed as b i / ∑ n b i , where b i is the available bandwidth of forwarding port i. n b i Indicates the total available bandwidth of multiple forwarding ports in a network port.
[0079] For forwarding port i, multiply the hash calculation result h by the available bandwidth ratio of the forwarding port i to obtain the forwarding weight WH in the form of a weighted hash value. i =h*(b i / ∑ n b i )
[0080] The present solution is described below with reference to an example.
[0081] For the available bandwidth of each forwarding port, a five-tuple hash value is obtained through a preset hash algorithm, and the hit forwarding port corresponding to the five-tuple hash value is port A.
[0082] The available bandwidth of each forwarding port is obtained according to real-time traffic monitoring. For example, the available bandwidth of port A is 20M, and the available bandwidth of port B is 60M.
[0083] Then, calculate the forwarding weight in the form of weighted hash value, weighted hash value = five-tuple hash value * port available bandwidth ratio. The forwarding weight of port A is: 0.2*20 / (20+60)=0.05, and the forwarding weight of port B is: 0.2*60 / (20+60)=0.15
[0084] Finally, since 0.15>0.05, port B with the largest forwarding weight is selected to forward the data flow, thereby achieving the purpose of balanced forwarding according to the available bandwidth of the network device port.
[0085] Based on the solution provided in the above embodiment, optionally, Figure 5As shown, in the above step S11, obtaining information of the data flow to be forwarded by the network device and the available bandwidth of multiple forwarding ports in the network device includes:
[0086] S51: Determine the occupied bandwidth of the plurality of forwarding ports respectively according to the flow data of each forwarding port.
[0087] In practical applications, the occupied bandwidth of the forwarding port can be obtained by monitoring. Specifically, the SNMP protocol or NetFlow protocol can be configured on the network device that needs to be monitored, the configuration of the SNMP protocol or NetFlow protocol can be optimized, the data packet collection interval can be reduced, and the data update frequency can be increased. The flow data processing technology is also used to ensure that the monitoring system can obtain flow data from the device with high-precision time stamp timing or in real time, such as the inflow and outflow flow of each port, bandwidth utilization and other information. Then, the occupied bandwidth of multiple forwarding ports can be determined based on the obtained flow data.
[0088] S52: Determine the available bandwidths of the plurality of forwarding ports respectively according to the difference between the preset bandwidth and the occupied bandwidth of each forwarding port.
[0089] In a network device, in an idle state, the preset bandwidths of different forwarding ports can be the same or different. For any forwarding port, the preset bandwidth of the forwarding port minus the occupied bandwidth of the forwarding port is used to obtain the available bandwidth of the forwarding port. For forwarding port i, the available bandwidth can be calculated by the following formula:
[0090] Available bandwidth i = port preset bandwidth - current traffic
[0091] For the convenience of statistics and maintenance, the preset bandwidth, current traffic, occupied bandwidth, and available bandwidth of each forwarding port can be stored in a table corresponding to the forwarding port identifier. In actual applications, the monitored traffic of each port can be updated periodically, and then based on the association in the table, the occupied bandwidth, available bandwidth and other parameters of each port can be updated accordingly. Based on the various parameters recorded in the table, they can be searched and called conveniently and quickly, thereby improving the efficiency of determining the forwarding port and efficiently realizing hash traffic forwarding.
[0092] Based on the solution provided in the above embodiment, optionally, the information of the data stream includes multiple items of the source Internet Protocol IP address, the destination IP address, the source port number, the destination port number, and the protocol type.
[0093] The above embodiments of the present application are described by taking five-tuple information to perform hash calculation as an example. In practical applications, four-tuple, seven-tuple and other information can also be selected to perform hash calculation according to the characteristics of the actual data stream, and can be flexibly set according to actual needs.
[0094] Below, this scheme is further explained with an example. Figure 6 shown.
[0095] First, for each forwarding port of the network device, real-time traffic information is obtained. The obtained real-time traffic information can be stored in a table corresponding to the forwarding port identifier, so as to be flexibly queried and called in subsequent steps.
[0096] For the acquired real-time traffic information, the remaining available bandwidth of each port is calculated according to the preset bandwidth of each forwarding port, and the remaining available bandwidth can be used to perform data flow forwarding.
[0097] Then, for the data stream to be sent, a five-tuple hash calculation is performed according to the data stream information. The hash calculation is performed based on a preset hash algorithm to obtain a hash calculation result.
[0098] Next, based on the hash calculation result and the remaining traffic bandwidth of the elder brother forwarding port, the comprehensive weight of the ECMP port is calculated. The comprehensive weight is the forwarding weight, which can be implemented in the manner described in any of the above embodiments.
[0099] According to the calculated comprehensive weight, the forwarding port with the largest comprehensive weight value is selected to forward the data flow. The data flow is mapped to the selected forwarding port to achieve forwarding.
[0100] After forwarding is performed, the remaining available bandwidth of the forwarding port is updated to ensure the real-time accuracy of the available bandwidth.
[0101] Optionally, in an embodiment of the present application, the forwarding weight can be determined by weighted summation based on the hash calculation weight and the available bandwidth weight, wherein the hash calculation weight and the available bandwidth weight can correspond to weight coefficients respectively. For the weight coefficient, a model can be constructed through machine learning and deep learning technology to perform predictive adjustment on the weight coefficient according to real-time load conditions and historical data, improve the rationality of the weight coefficient, and achieve flexible self-adjustment.
[0102] Optionally, in terms of data flow forwarding, application layer awareness can be introduced to optimize the data flow forwarding path. Customize and adjust the routing strategy according to the needs and performance indicators of specific applications. For example, for applications with high latency requirements, the path with lower latency is preferred for forwarding.
[0103] Through the scheme provided by the embodiment of the present application, the real-time utilization rate of the forwarding port is used as one of the weights of port selection to realize dynamic weight adjustment, so that the load balancing strategy can be adjusted in real time according to the network traffic situation. In this scheme, the forwarding weight is comprehensively determined by combining the five-tuple information and the real-time utilization rate of the export of the forwarding port to improve the rationality of load balancing scheduling. By adjusting the weight coefficient, the comprehensive weight calculation can be adapted to different network environments and requirements, and the flexibility and applicability of the algorithm can be improved.
[0104] In terms of performance optimization, the solution provided in this application can adjust weights in real time according to network load conditions, thereby more effectively balancing network traffic, improving network performance and throughput, and reducing latency, thereby optimizing user-side service perception.
[0105] In terms of resource utilization, taking the real-time utilization rate of the network device's forwarding port as one of the weights can more intelligently distribute network traffic, avoid resource waste and congestion, and thus make full use of physical resources and improve resource utilization efficiency.
[0106] In terms of stability, the dynamic weight adjustment strategy of the present application scheme can adjust the distribution in real time according to the actual network status, improve the stability and reliability of the network, and reduce failures and interruptions caused by overload of a single node.
[0107] In order to solve the problems existing in the prior art, the embodiment of the present application also provides a hash traffic forwarding device 70, such as Figure 7 As shown, including:
[0108] An acquisition module 71 is configured to acquire information about a data flow to be forwarded by a network device and available bandwidths of multiple forwarding ports in the network device;
[0109] A calculation module 72, performing hash calculation on the information of the data stream based on a preset hash algorithm;
[0110] A determination module 73, which determines the forwarding weights of the plurality of forwarding ports respectively based on the hash calculation result and the available bandwidth of each forwarding port;
[0111] The forwarding module 74 forwards the data flow through the forwarding port with the largest forwarding weight.
[0112] Through the device provided by the embodiment of the present application, first, the information of the data stream to be forwarded by the network device and the available bandwidth of multiple forwarding ports in the network device are obtained; then, the information of the data stream is hashed based on the preset hash algorithm; then, the forwarding weights of multiple forwarding ports are determined based on the hash calculation results and the available bandwidth of each forwarding port; finally, the data stream is forwarded through the forwarding port with the largest forwarding weight. Through the scheme provided by the embodiment of the present application, the forwarding weight is jointly determined according to the hash calculation results of the information of the data stream to be forwarded and the available bandwidth of multiple forwarding ports of the network device. The forwarding weight thus determined can express the bandwidth availability of the forwarding port to a certain extent, and can effectively realize balanced forwarding of data streams in a network device containing multiple forwarding ports. Avoid the situation where the bandwidth of some forwarding ports in the network device is too high while the other forwarding ports are idle, thereby improving the load balancing of hash traffic forwarding.
[0113] Among them, the above modules in the device provided by the embodiment of the present application can also implement the method steps provided by the above method embodiment. Alternatively, the device provided by the embodiment of the present application can also include other modules in addition to the above modules to implement the method steps provided by the above method embodiment. And the device provided by the embodiment of the present application can achieve the technical effects that can be achieved by the above method embodiment.
[0114] Preferably, an embodiment of the present application also provides an electronic device, including a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the various processes of the above-mentioned hash traffic forwarding method embodiment are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.
[0115] The embodiment of the present application also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the above-mentioned hash traffic forwarding method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. Among them, the computer-readable storage medium is such as a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.
[0116] An embodiment of the present application also provides a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program. The computer program can be operated to enable a computer to execute part or all of the steps of the above-mentioned hash traffic forwarding method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.
[0117] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0118] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes 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 generate 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.
[0119] 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.
[0120] 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. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0121] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.
[0122] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.
[0123] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.
[0124] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity 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, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.
[0125] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment or an embodiment in combination with software and hardware. Moreover, the present application may adopt 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.) that contain computer-usable program code.
[0126] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.
Claims
1. A hash traffic forwarding method, characterized in that: include: Acquire information of data streams to be forwarded by a network device and available bandwidths of multiple forwarding ports in the network device; Performing hash calculation on the information of the data stream based on a preset hash algorithm; Determine the forwarding weights of the multiple forwarding ports respectively based on the hash calculation result and the available bandwidth of each forwarding port; The data flow is forwarded through the forwarding port with the largest forwarding weight.
2. The method according to claim 1, characterized in that Determining the forwarding weights of the plurality of forwarding ports based on the hash calculation result and the available bandwidth of each forwarding port respectively includes: Determine hash calculation weights of the multiple forwarding ports based on the hash calculation results; Determine the available bandwidth weights of the multiple forwarding ports based on the available bandwidth of each forwarding port, wherein the available bandwidth weight of the target forwarding port is the ratio of the available bandwidth of the target forwarding port to the maximum available bandwidth of the multiple forwarding ports, wherein the target forwarding port is any one of the multiple forwarding ports; The forwarding weights of the multiple forwarding ports are determined based on the hash calculation weight and the available bandwidth weight of each forwarding port, wherein the forwarding weight of the target forwarding port is the weighted sum of the hash calculation weight and the available bandwidth weight corresponding to the target forwarding port.
3. The method according to claim 2, characterized in that Determining hash calculation weights of the multiple forwarding ports based on the hash calculation results respectively includes: Determining a target hash value range hit by the hash calculation result according to a plurality of preset hash value ranges; Determine a hit forwarding port corresponding to the target hash value range based on a preset mapping table, wherein the preset mapping table represents a mapping relationship between a plurality of preset hash value ranges and the plurality of forwarding ports; The hash weight of the hit forwarding port is determined as a first weight value, and the hash weight of the missed forwarding port is determined as a second weight value, wherein the missed forwarding port is a forwarding port other than the hit forwarding port in the network device, and the first weight value is greater than the second weight value.
4. The method according to claim 1, characterized in that Determining the forwarding weights of the plurality of forwarding ports based on the hash calculation result and the available bandwidth of each forwarding port respectively includes: The product of the hash calculation result and the available bandwidth ratio of each forwarding port is respectively determined as the forwarding weights of the multiple forwarding ports, wherein the available bandwidth ratio is the ratio of the available bandwidth of the corresponding forwarding port to the total available bandwidth of the multiple forwarding ports.
5. The method according to any one of claims 1 to 4, characterized in that: Acquiring information about a data flow to be forwarded by a network device and available bandwidths of multiple forwarding ports in the network device, including: Determine the occupied bandwidth of the plurality of forwarding ports respectively according to the flow data of each forwarding port; The available bandwidths of the multiple forwarding ports are determined respectively according to the difference between the preset bandwidth and the occupied bandwidth of each forwarding port.
6. The method according to any one of claims 1 to 4, characterized in that: The information of the data flow includes multiple items of the source Internet Protocol IP address, the destination IP address, the source port number, the destination port number, and the protocol type.
7. A hash traffic forwarding device, characterized in that: include: An acquisition module, for acquiring information of a data stream to be forwarded by a network device and available bandwidths of a plurality of forwarding ports in the network device; A calculation module, performing hash calculation on the information of the data stream based on a preset hash algorithm; A determination module, which determines the forwarding weights of the plurality of forwarding ports respectively based on the hash calculation result and the available bandwidth of each forwarding port; The forwarding module forwards the data flow through a forwarding port with the largest forwarding weight.
8. An electronic device, characterized in that: include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the method according to any one of claims 1 to 6 when executed by the processor.
9. 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 method according to any one of claims 1 to 6 are implemented.
10. A computer program product, characterized in that The computer program product comprises a non-transitory computer-readable storage medium storing a computer program, wherein the computer program is operable to cause a computer to execute part or all of the steps of the method according to any one of claims 1 to 6.
