Disclosure of Invention
An object of the embodiments of the present invention is to solve the problem that the difference of transmission efficiency caused by different links is not considered in the prior art, which results in low transmission efficiency and further affects the data forwarding efficiency of the network.
The embodiment of the invention provides a network outbound load balancing method, which comprises the following steps:
step S1, receiving a request for accessing a target server in a network sent by a user terminal;
step S2, sending test information to the target server through N links between the user terminal and the target server;
step S3, obtaining a response message returned from each link, wherein the response message carries a residual survival time value ttl;
s4, according to the residual ttl of the response message returned by each link, M links are selected from N links, wherein M is less than or equal to N;
step S5, allocating the data sent by the user terminal to the target server to the M links for forwarding.
Optionally, the step S4 specifically includes:
sequencing the N links in a sequential mode of the rest ttl from large to small, and selecting the first M links in the sequence;
or,
and sequencing the N links in a sequential manner of small to large residual ttl, and selecting the last M links in the sequence.
Optionally, the method further includes: storing the selected M links in a cache list;
accordingly, before the step S2, the method further includes:
detecting whether M links exist in the cache list, if so, executing a step S5; if not, step S2 is executed.
Optionally, the method further includes: configuring timeout time for the cache list;
accordingly, the method further comprises: if the M links exist in the cache list, updating the storage time of the M links in the cache list;
comparing the updated storage time of the M links with the timeout time; and if the storage time after the updating is longer than the overtime time, clearing the M links in the cache list.
Optionally, the step S5 specifically includes:
and distributing the data sent by the user terminal to the target server to the M links for forwarding in a mode of average distribution or in direct proportion to the residual ttl of the response message returned by the M links.
The invention also provides a network outbound load balancing device, which comprises:
the receiving module is used for receiving a request for accessing a target server in a network, which is sent by a user terminal;
a sending module, configured to send test information to the target server through an N link between the user terminal and the target server, where the test information carries an initial ttl value;
the obtaining module is used for obtaining a response message returned by each link, and the response message carries a residual survival time value ttl;
the selecting module is used for selecting M links from the N links according to the residual ttl corresponding to each link, wherein M is less than or equal to N;
and the distribution module is used for distributing the data sent to the target server by the user terminal to the M links for forwarding.
Optionally, the selecting module is specifically configured to sort the N links in a descending order of the remaining ttls, and select the first M links in the sequence; or, sorting the N links in a sequential manner of small to large residual ttl, and selecting the last M links in the sequence.
Optionally, the method further includes: the device comprises a storage module and a detection module;
the memory module is used for storing the selected M links in a cache list;
the detection module is used for detecting whether M links exist in the cache list after receiving a request for accessing a target server in a network, which is sent by a user terminal, and if so, triggering the distribution module; if not, the sending module is triggered.
Optionally, the apparatus further comprises: a configuration module;
the configuration module is used for configuring timeout time for the cache list;
correspondingly, the detection module is further configured to update the storage time of the M links in the cache list if it is detected that the cache list has M links; comparing the updated storage time of the M links with the timeout time; and if the storage time after the updating is longer than the overtime time, clearing the M links in the cache list.
Optionally, the allocating module is specifically configured to allocate, to the M links, the data sent by the user terminal to the target server for forwarding in a manner of average allocation or in proportion to the remaining ttl of the response packet returned on the M links.
According to the technical scheme, the network outbound load balancing method and the network outbound load balancing device send the test information to the target server through each link to obtain the residual survival time value of the test information forwarded on each link, and then dispatch the traffic to the link close to the target server according to the residual survival time value, so that the outbound load balancing effect is improved, and the forwarding efficiency of the network is improved.
Detailed Description
In order to make the objects, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, but not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without any inventive step based on the embodiments of the present invention, are within the scope of the present invention.
Fig. 1 is a diagram illustrating an application scenario of a network outbound load balancing method according to an embodiment of the present invention, and referring to fig. 1, the application scenario includes: user terminal 110, security gateway 120, and target server 130;
there are multiple links between security gateway 120 and target server 130;
in the process that the user terminal 110 sends data to the target server 130, the data flow is sent to the security gateway 120, and after the security gateway 120 performs relevant processing on the data, the data is allocated to a link for forwarding based on a preset allocation rule.
The preset allocation rule may be, for example: the data is distributed evenly across all links between security gateway 120 and destination server 130.
The user terminal 110 is, for example, a personal notebook computer.
Fig. 2 is a flowchart illustrating a method for balancing network outbound loads according to an embodiment of the present invention, and referring to fig. 1 and fig. 2, the method is implemented by the security gateway 120 and includes:
step S1, receiving a request for accessing the target server 130 in the network sent by the user terminal 110;
step S2, sending test information to the target server 130 through N links between the user terminal 110 and the target server 130;
it should be noted that the access request carries an IP address of the target server, and the security gateway sends the test information to the target server based on the IP address.
Step S3, obtaining a response message returned from each link, wherein the response message carries a residual survival time value ttl;
s4, according to the residual ttl of the response message returned by each link, M links are selected from N links, wherein M is less than or equal to N;
step S5, allocating the data traffic sent by the user terminal 110 to the target server 130 to the M links for forwarding.
It should be noted that, when receiving the access request sent by the user terminal 110, the security gateway 120 goes to the ping target server 130 through a different link; the target server 130 returns the response message, the time to live value ttl of the response message is a known value, and in the forwarding process of the network device in the link, such as a router, the time to live value ttl of the response message continuously decreases, and the time to live value ttl decreases by one every time the response message is forwarded, it can be known that the remaining ttl is the maximum network segment number before the response message is discarded by the network device, and the path length of each link can be known based on the corresponding remaining ttl on each link.
It can be seen that, in this embodiment, test information is sent to the target server through each link to obtain the remaining ttl of the response packet returned on each link, and then data is scheduled to the link closer to the target server according to the remaining ttl, so that the outbound load balancing effect is improved, and the forwarding efficiency of the network is improved.
In this embodiment, step S4 specifically includes:
sequencing the N links in a sequential mode of the rest ttl from large to small, and selecting the first M links in the sequence;
or, sorting the N links in a sequential manner of small to large residual ttl, and selecting the last M links in the sequence.
It should be noted that, no matter the sequential manner of the remaining ttl going from large to small or the sequential manner of the remaining ttl going from small to large is adopted, the M links selected finally are all the links that are the smallest distance from the target server.
In a possible embodiment, after step S4, the method further includes: storing the selected M links in a cache list;
accordingly, before the step S2, the method further includes:
detecting whether M links exist in the cache list, if so, executing a step S5; if not, step S2 is executed.
In this embodiment, the selected M links are associated with the IP address of the target server and then stored in the cache list, so that when a request of the user terminal to access a certain server is received next time, whether the relevant information of the server exists in the cache list is detected, and if the relevant information exists, the selected M links carried in the relevant information are directly used without selecting links again, thereby further improving the forwarding efficiency of the network.
In yet another possible embodiment, after step S4, the method further includes: configuring timeout time for the cache list;
accordingly, the method further comprises: if the M links exist in the cache list, updating the storage time of the M links in the cache list;
comparing the updated storage time of the M links with the timeout time; and if the storage time after the updating is longer than the overtime time, clearing the M links in the cache list.
It should be noted that the selected M links have a certain timeliness, and after a period of time, the M links are reused for forwarding data, and the load balancing effect may be reduced, so that after a period of time, the security gateway needs to select the N links again to obtain the updated M links, and the outbound load balancing effect is improved.
Fig. 3 is a schematic flow chart illustrating a network outbound load balancing method according to another embodiment of the present invention, and the following description refers to fig. 3 to explain the working principle of the present application in detail:
s31, when receiving the access request sent by the user terminal, the security gateway detects whether there is a destination IP related record in the cache list, where the destination IP related record includes: selecting M links; if yes, go to step S32; if not, go to step S33;
s32, updating the timeout t (t is 10min by default) corresponding to the target IP in the cache list, where the timeout is configurable in various ways, for example: the timeout time is modified in such a manner that a timeout time modification instruction is written into the security gateway by the external device, and step S37 is performed.
S33, the security gateway respectively pings the target server through the link;
s34, ranking the ttl values of the icmp response messages returned by different links, wherein the ranking mode can refer to the relevant statement in the corresponding embodiment of FIG. 2, and details are not repeated here.
It should be noted that TTL is an abbreviation for Time To Live, and this field specifies the maximum number of segments allowed To pass through before IP packets are dropped by the router. The router modifies the value of the TTL field in the entire forwarding path of the IP packet from the source to the destination, i.e., from the destination server to the security gateway, every time the router passes through the TTL field, specifically, the TTL field is decremented by 1, and then the IP packet is forwarded. Therefore, when one host pings another host, the larger the obtained answer message ttl is, the smaller the hops between the two hosts are, and the closer the distance between the two hosts is.
S35, selecting a link m before or after ranking from the sequence obtained by ranking, wherein the selection mode is determined by the ranking mode, and m is 3 as default and is configurable;
s36, the selected m links and the IP address of the target server (host) are associated, added into the cache list and configured with timeout time, wherein the timeout time is defaulted to 10min, namely within 10min, the associated data of the selected m links and the IP address of the target server are valid, and are invalid after 10 min.
Additionally, the default timeout time is configurable.
S37, dispatching the traffic to the target host to a link m bits before the ranking of the ttl value for forwarding; there are various scheduling manners, such as average allocation, proportional allocation according to the size of the ttl value, etc. proposed in the corresponding embodiment of fig. 2.
It can be seen that, in this embodiment, the distance between the security gateway and the target host is determined by comparing the ttl values of the icmp response messages of different links, so as to select several links with relatively short distances, and then schedule the data destined for the target host to these several links for forwarding. And meanwhile, the selected link information going to the target host is added into the cache list, so that the subsequent routing process of data going to the target host is omitted. In addition, the invention can dispatch the data to the link which is close to the target host, thereby effectively improving the forwarding efficiency of the network.
Method embodiments are described as a series of acts or combinations for simplicity of explanation, but it should be understood by those skilled in the art that the present invention is not limited by the order of acts or acts described, as some steps may occur in other orders or concurrently with other steps in accordance with the embodiments of the invention. Furthermore, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Fig. 4 is a schematic structural diagram illustrating a network outbound load balancing apparatus according to an embodiment of the present invention, and referring to fig. 4, the apparatus includes: a receiving module 41, a sending module 42, an obtaining module 43, a selecting module 44, and an allocating module 45, wherein;
a receiving module 41, configured to receive a request sent by a user terminal to access a target server in a network;
a sending module 42, configured to send test information to the target server through an N link between the user terminal and the target server, where the test information carries an initial ttl value;
an obtaining module 43, configured to obtain a response packet returned on each link, where the response packet carries a remaining lifetime value ttl;
a selecting module 44, configured to select M links from the N links according to the remaining ttl of the response packet returned by each link, where M is less than or equal to N;
and an allocating module 45, configured to allocate, to the M links, data sent by the user terminal to the target server for forwarding.
It should be noted that, after receiving a request sent by a user terminal to access a target server in a network, the receiving module 41 forwards the access request to the sending module 42, and the sending module 42 pings the target server according to an IP address of the target server in the access request; the obtaining module 43 obtains the response packet returned on each link, and forwards the obtained response packet to the selecting module 44, the selecting module 44 selects M links from the N links according to the remaining ttl of the test information carried in the response packet, and informs the information of the selected M links to the allocating module 45, and the allocating module 45 may adopt an average allocation or a manner proportional to the remaining ttl of the M links to allocate the data sent by the user terminal to the target server to the M links for forwarding.
In the embodiment, the test information is sent to the target server through each link, so that the residual ttl of the response message returned on each link is acquired, and then the data is dispatched to the link closer to the target server according to the residual ttl, so that the outbound load balancing effect is improved, and the forwarding efficiency of the network is improved.
In this embodiment, the selecting module is specifically configured to sort the N links in a descending order of the remaining ttl, and select the first M links in the sequence; or, sorting the N links in a sequential manner of small to large residual ttl, and selecting the last M links in the sequence.
Fig. 5 is a schematic structural diagram of a network outbound load balancing apparatus according to another embodiment of the present invention, and referring to fig. 5, the apparatus includes: the system comprises a receiving module 51, a detecting module 52, a sending module 53, an obtaining module 54, a selecting module 55, a storing module 56 and a distributing module 57, wherein;
the receiving module 51, the sending module 53, the obtaining module 54, the selecting module 55, and the allocating module 57 are respectively the same as the receiving module 41, the sending module 42, the obtaining module 43, the selecting module 44, and the allocating module 45 in the embodiment corresponding to fig. 4, and their working principles are the same, so that they are not described herein again, and please refer to the relevant statements in the embodiment corresponding to fig. 4 specifically.
The storage module 56 is configured to store the selected M links in a cache list;
the detecting module 52 is configured to detect whether M links exist in the cache list after receiving a request sent by a user terminal to access a target server in a network, and if yes, trigger the allocating module; if not, the sending module is triggered.
In this embodiment, the selected M links are associated with the IP address of the target server and then stored in the cache list, so that when a request of the user terminal to access a certain server is received next time, whether the relevant information of the server exists in the cache list is detected, and if the relevant information exists, the selected M links carried in the relevant information are directly used without selecting links again, thereby further improving the forwarding efficiency of the network.
Fig. 6 is a schematic structural diagram illustrating a network outbound load balancing apparatus according to another embodiment of the present invention, and referring to fig. 6, the apparatus includes: the system comprises a receiving module 61, a detecting module 62, a sending module 63, an obtaining module 64, a selecting module 65, a storing module 66, a configuring module 67 and a distributing module 68, wherein the receiving module 61, the detecting module 62, the sending module 63, the obtaining module 64, the selecting module 65, the storing module 66, the configuring module 67 and the distributing module 68 are arranged in;
the receiving module 61, the detecting module 62, the sending module 63, the obtaining module 64, the selecting module 65, the storing module 66, and the allocating module 68 are respectively the same as the receiving module 51, the detecting module 52, the sending module 53, the obtaining module 54, the selecting module 55, the storing module 56, and the allocating module 5 in the corresponding embodiment of fig. 6, and the working principle thereof is the same, so that the details are not repeated herein, and please refer to the relevant statements in the corresponding embodiment of fig. 6.
The configuration module 67 is configured to configure a timeout time for the cache list;
correspondingly, the detecting module 62 is further configured to update the storage time of the M links in the cache list if it is detected that M links exist in the cache list; comparing the updated storage time of the M links with the timeout time; and if the storage time after the updating is longer than the overtime time, clearing the M links in the cache list.
It should be noted that the selected M links have a certain timeliness, and after a period of time, the M links are reused for forwarding data, and the load balancing effect may be reduced, so that after a period of time, the security gateway needs to select the N links again to obtain the updated M links, and the outbound load balancing effect is improved.
As for the apparatus embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
It should be noted that, in the respective components of the apparatus of the present invention, the components therein are logically divided according to the functions to be implemented thereof, but the present invention is not limited thereto, and the respective components may be newly divided or combined as necessary.
Various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. In the device, the PC remotely controls the equipment or the device through the Internet, and accurately controls each operation step of the equipment or the device. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. The program for realizing the invention can be stored on a computer readable medium, and the file or document generated by the program has statistics, generates a data report and a cpk report, and the like, and can carry out batch test and statistics on the power amplifier. It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations fall within the scope defined by the appended claims.