CN107547428B - Message sending method and device, load balancing LB device and gateway device - Google Patents

Message sending method and device, load balancing LB device and gateway device Download PDF

Info

Publication number
CN107547428B
CN107547428B CN201710542175.9A CN201710542175A CN107547428B CN 107547428 B CN107547428 B CN 107547428B CN 201710542175 A CN201710542175 A CN 201710542175A CN 107547428 B CN107547428 B CN 107547428B
Authority
CN
China
Prior art keywords
address
message
terminal
server
intranet
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710542175.9A
Other languages
Chinese (zh)
Other versions
CN107547428A (en
Inventor
于洪强
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New H3C Security Technologies Co Ltd
Original Assignee
New H3C Security Technologies Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by New H3C Security Technologies Co Ltd filed Critical New H3C Security Technologies Co Ltd
Priority to CN201710542175.9A priority Critical patent/CN107547428B/en
Publication of CN107547428A publication Critical patent/CN107547428A/en
Application granted granted Critical
Publication of CN107547428B publication Critical patent/CN107547428B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Data Exchanges In Wide-Area Networks (AREA)
  • Computer And Data Communications (AREA)

Abstract

The embodiment of the invention provides a message sending method, a message sending device, LB equipment, gateway equipment and a machine readable storage medium. The method is used for LB equipment and comprises the following steps: receiving a first message sent by gateway equipment, wherein a first designated position of the message carries an intranet IP address of a terminal; determining whether the intranet IP address hits any corresponding relation in the continuity table; the persistence table is used for storing the corresponding relation between the intranet IP address and the IP address of the server; if so, replacing the target IP address of the first message by the IP address of the server in the hit corresponding relation; if not, a server is allocated to the terminal, the destination IP address of the first message is replaced by the IP address of the allocated server, and the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server is stored in a continuous table; and sending the first message after the destination IP address is replaced. The scheme can enable the traffic to be sent more uniformly, so that the load of each server is more balanced.

Description

Message sending method and device, load balancing LB device and gateway device
Technical Field
The present invention relates to the field of communications technologies, and in particular, to a packet sending method and apparatus, a load balancing LB device, a gateway device, and a machine-readable storage medium.
Background
LB (Load Balance) is a clustering technique, which can share a specific service to multiple servers or multiple links, thereby improving service processing capability and ensuring high reliability of the service.
Specifically, as shown in fig. 1, the entire network includes two terminals (client a and client B, respectively), a gateway device, an LB device, and three servers (Srv 1, Srv2, and Srv3, respectively). When receiving a message from client a or client B, the gateway device performs source IP address translation on the message, and then sends the message after source IP address translation to the LB device. The gateway device may allocate the same external network IP address (but different port) to the client a and the client B, so that the messages sent by the client a and the client B have the same source IP address after being converted by the source IP address.
And the LB device receives the message from the client A or the client B sent by the gateway device and allocates the server based on the source IP address of the message. That is, the LB device may send the message from client a or client B to the same one of Srv1, Srv2, and Srv3, which may cause uneven load on each server.
Disclosure of Invention
Embodiments of the present invention provide a packet sending method, an apparatus, an LB device, a gateway device, and a machine-readable storage medium, so as to make traffic sending more uniform and make loads of servers more balanced.
In a first aspect, an embodiment of the present invention provides a packet sending method, which is applied to a load balancing LB device, and the method includes:
receiving a first message sent by gateway equipment, wherein the first message is generated after source IP address conversion is carried out on a second message sent by a received terminal by the gateway equipment, and a first designated position of the first message carries an intranet IP address of the terminal;
determining whether the intranet IP address of the terminal carried by the first designated position of the first message hits any corresponding relation in a persistence table; the continuity table is used for storing the corresponding relation between the intranet IP address and the IP address of the server;
if so, replacing the target IP address of the first message with the IP address of the server in the hit corresponding relation;
if not, a server is allocated to the terminal, the destination IP address of the first message is replaced by the IP address of the allocated server, and the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server is stored in the persistence table;
and sending the first message with the replaced destination IP address.
In a second aspect, an embodiment of the present invention provides a packet sending method, which is applied to a gateway device, and the method includes:
receiving a second message sent by a terminal to a load balancing LB device, converting a source IP address of the second message to generate a first message, and adding an intranet IP address of the terminal at a first designated position of the first message;
sending the first message to the LB device, so that the LB device determines whether the intranet IP address of the terminal carried at a first designated position of the first message hits any corresponding relation in a persistence table, if so, replacing the destination IP address of the first message with the IP address of a server in the hit corresponding relation, if not, allocating a server to the terminal, replacing the destination IP address of the first message with the IP address of the allocated server, storing the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server in the persistence table, and sending the first message after the destination IP address is replaced;
the persistent table is used for storing the corresponding relation between the intranet IP address and the IP address of the server.
In a third aspect, an embodiment of the present invention provides a packet sending apparatus, which is applied to a load balancing LB device, where the apparatus includes:
the receiving module is used for receiving a first message sent by gateway equipment, wherein the first message is generated after source IP address conversion is carried out on a second message sent by a received terminal by the gateway equipment, and a first designated position of the first message carries an intranet IP address of the terminal;
a determining module, configured to determine whether an intranet IP address of the terminal carried in a first specified location of the first packet hits any corresponding relationship in a persistence table; the continuity table is used for storing the corresponding relation between the intranet IP address and the IP address of the server;
the first processing module is used for replacing the target IP address of the first message with the IP address of the server in the hit corresponding relation under the condition that the determination result of the determination module is positive; under the condition that the determination result of the determination module is negative, a server is allocated to the terminal, the destination IP address of the first message is replaced by the IP address of the allocated server, and the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server is stored in the persistence table;
and the first sending module is used for sending the first message after the destination IP address is replaced.
In a fourth aspect, an embodiment of the present invention provides a packet sending apparatus, which is applied to a gateway device, where the apparatus includes:
the processing module is used for receiving a second message sent by the terminal to the load balancing LB equipment, performing source IP address conversion on the second message to generate a first message, and adding the intranet IP address of the terminal at a first designated position of the first message;
a second sending module, configured to send the first packet to the LB device, so that the LB device determines whether an intranet IP address of the terminal carried in a first specified location of the first packet hits any corresponding relationship in a persistence table, if so, replace a destination IP address of the first packet with an IP address of a server in the hit corresponding relationship, if not, allocate a server to the terminal, replace the destination IP address of the first packet with an IP address of the allocated server, store the corresponding relationship between the intranet IP address of the terminal and the IP address of the allocated server in the persistence table, and send the first packet after the destination IP address is replaced;
the persistent table is used for storing the corresponding relation between the intranet IP address and the IP address of the server.
In a fifth aspect, an embodiment of the present invention provides a load balancing LB device, including a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to: the above-described method steps applied to the LB device are implemented.
In a sixth aspect, an embodiment of the present invention further provides a gateway device, including a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to: the method steps applied to the gateway device are realized.
In a seventh aspect, an embodiment of the present invention further provides a machine-readable storage medium storing machine-executable instructions, which when invoked and executed by a processor, cause the processor to: the method steps applied to the load balancing LB device or the gateway device are realized.
In this scheme, when receiving a first message sent by a gateway device, an LB device determines whether an intranet IP address of a terminal carried at a first designated location of the first message hits any entry in a persistence table. If the result is hit, which indicates that the LB device has previously allocated a server to the terminal, the LB device performs destination IP address translation on the first packet to send the first packet to the server previously allocated to the terminal. If the message is not hit, which indicates that the LB device has not previously allocated the server to the terminal, the LB device allocates the server to the terminal and performs destination IP address translation on the first message, so as to send the first message to the server allocated to the terminal. In addition, in case of miss, the LB device may further store a corresponding relationship between the intranet IP address of the terminal and the IP address of the server allocated thereto, so that, when the LB device subsequently receives a message from the terminal, the LB device may send the subsequently received message sent by the terminal to the server allocated to the terminal previously according to the persistence table.
It is easy to see that, in the present solution, the LB device distinguishes the messages from different terminals according to the intranet IP addresses in the received messages, so as to send the messages from different terminals to the server allocated to the terminal. Therefore, the LB device does not take all messages from the gateway device as the same user flow, thereby ensuring that the load on each server is more balanced.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a schematic diagram of a networking structure of a terminal, a gateway device, an LB device, and a server;
fig. 2 is a flowchart of a message sending method provided from the perspective of an LB device in an embodiment of the present invention;
FIG. 3 is a diagram illustrating a format of a TCP header;
fig. 4 is a schematic diagram of the operation of the gateway device and the LB device;
fig. 5 is a flowchart of a message sending method provided from the perspective of a gateway device in an embodiment of the present invention;
fig. 6 is a block diagram of a structure of a message sending apparatus provided from the perspective of an LB device in an embodiment of the present invention;
fig. 7 is a block diagram of a message sending apparatus provided from the perspective of a gateway device in an embodiment of the present invention;
fig. 8 is a schematic structural diagram of an LB apparatus according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a gateway device according to an embodiment of the present invention.
Detailed Description
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 only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In order to solve the problems in the prior art, embodiments of the present invention provide a packet sending method, an apparatus, an LB device, a gateway device, and a machine-readable storage medium.
First, a message sending method provided from the perspective of the LB device in the embodiment of the present invention is described below.
Referring to fig. 2, a flowchart of a message sending method according to an embodiment of the present invention is shown in the diagram. As shown in fig. 2, the method is applied to an LB device, and may include the following steps:
s201, receiving a first message sent by a gateway device, wherein the first message is generated after the gateway device performs source IP address conversion on a second message sent by a received terminal, and a first designated position of the first message carries an intranet IP address of the terminal.
It should be noted that the terminal may be a mobile phone or a tablet computer, and the gateway device may be an egress router, and of course, the types of the terminal and the gateway device are not limited thereto, and may be determined specifically according to actual situations, and are not described herein any more.
After receiving the second message from the terminal, the gateway device may perform source IP address conversion on the second message to generate the first message. Next, the gateway device may add the intranet IP address of the terminal at the first designated location of the first packet. Specifically, the first packet may be a TCP packet, and in a preferred embodiment, the first designated location of the first packet may be a location for filling an acknowledgement number in a TCP packet header shown in fig. 3. Of course, the first designated location of the first packet may also be the location for the padding option in the TCP packet header shown in fig. 3.
Then, the gateway device may send, by using the IP network shown in fig. 1, the first packet with the intranet IP address of the terminal added to the first designated location to the LB device, so that the LB device performs subsequent S202 according to the received first packet.
S202, determining whether the intranet IP address of the terminal carried by the first designated position of the first message hits any corresponding relation in the continuity table; the continuity table is used for storing the corresponding relation between the intranet IP address and the IP address of the server; if yes, go to S203, otherwise go to S204.
S203, replacing the target IP address of the first message with the IP address of the server in the hit corresponding relation.
S204, a server is allocated to the terminal, the destination IP address of the first message is replaced by the IP address of the allocated server, and the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server is stored in a persistence table.
In performing S204, the LB device may allocate a server to the terminal using a preset load balancing policy. Specifically, the preset load balancing policy may be a hash algorithm.
S205, the first message with the replaced destination IP address is sent.
For the LB device, when receiving the first packet sent by the gateway device, the LB device may perform traversal search on the persistence table to determine whether the persistence table has a corresponding relationship of the intranet IP address carried in the first designated location that includes the first packet.
If the determination result is that the terminal has the intranet IP address carried by the first designated position of the first message, the corresponding relation of the intranet IP address carried by the first designated position of the first message recorded in the persistent table is the corresponding relation hit by the intranet IP address carried by the first designated position of the first message, and the IP address of the server in the corresponding relation is the IP address of the server distributed by the LB device to the terminal having the intranet IP address carried by the first designated position of the first message before the first message is obtained. That is, the LB device has already allocated a server to the terminal sending the second packet before obtaining the first packet. Therefore, the LB device may directly replace the destination IP address of the first packet with the IP address of the server in the correspondence, and send the first packet with the destination IP address replaced. It is easy to see that the first message with the replaced destination IP address is finally sent to the server allocated to the terminal sending the second message before the LB device.
If the determination result is that the corresponding relation does not exist, that is, the intranet IP address carried by the first designated position of the first message does not hit any corresponding relation in the persistence table, the LB device cannot obtain the IP address of the server corresponding to the intranet IP address carried by the first designated position of the first message according to the persistence table. At this time, the LB device may allocate a server to the terminal that sends the second packet by using a preset load balancing policy.
After the server is allocated, on one hand, the LB device may replace the destination IP address of the first packet with the IP address of the allocated server, and send the first packet with the destination IP address replaced. In this way, the first message with the destination IP address replaced is finally sent to the server allocated by the LB device for the terminal sending the second message. On the other hand, the LB device may further store, in the persistence table, a correspondence between the intranet IP address carried in the first designated location of the first packet and the IP address of the allocated server. In this way, when the gateway device receives the message sent by the terminal sending the second message again and forwards the corresponding message to the LB device, the intranet IP address carried by the first designated location of the message received by the LB device can hit a corresponding relationship in the persistence table. Then, the LB device only needs to replace the destination IP address in the received message with the IP address in the hit correspondence, and sends the message with the destination IP address replaced, and the message is sent by the LB device to the server previously allocated to the terminal that sent the second message.
In this scheme, when receiving a first message sent by a gateway device, an LB device determines whether an intranet IP address of a terminal carried at a first designated location of the first message hits any entry in a persistence table. If the result is hit, which indicates that the LB device has previously allocated a server to the terminal, the LB device performs destination IP address translation on the first packet to send the first packet to the server previously allocated to the terminal. If the message is not hit, which indicates that the LB device has not previously allocated a server to the terminal, the LB device allocates a server to the terminal and performs destination IP address translation on the first message, so as to send the first message to the server allocated to the terminal. In addition, in case of miss, the LB device may further store a corresponding relationship between the intranet IP address of the terminal and the IP address of the server allocated thereto, so that, when the LB device subsequently receives a message from the terminal, the LB device may send the subsequently received message sent by the terminal to the server allocated to the terminal previously according to the persistence table.
It is easy to see that, in the present solution, the LB device distinguishes the messages from different terminals according to the intranet IP addresses in the received messages, so as to send the messages from different terminals to the server allocated to the terminal. Therefore, the LB device does not take all messages from the gateway device as the same user flow, thereby ensuring that the load on each server is more balanced.
In a specific implementation manner of the embodiment of the present invention, the first packet includes: the message in the TCP connection establishment process and the service message sent by the client after the TCP connection is successfully established.
In another specific implementation manner of the embodiment of the present invention, the first message may be a SYN message in a TCP connection establishment process.
The method may further comprise:
recording the corresponding relation between the session information of the session established by the SYN message and the IP address of the server corresponding to the intranet IP address of the terminal;
when receiving other messages sent by the gateway equipment based on the session, replacing the target IP addresses of the other messages with the IP addresses of the servers in the recorded corresponding relation according to the recorded corresponding relation; and sending other messages after the destination IP address is replaced.
The following describes a specific implementation process of the present embodiment by using a specific example.
After receiving the SYN message from the gateway device, the LB device determines whether the intranet IP address of the terminal carried at the first designated location of the SYN message corresponds to any one of the correspondence tables. If the result is yes, the LB device can replace the destination IP address of the SYN message with the IP address in the corresponding relation of the hit persistence table; if the determination result is negative, the LB can allocate a server for the terminal and store the corresponding relation between the IP address of the allocated server and the intranet IP address of the terminal in the persistence table.
In addition, the LB device may record a correspondence relationship between session information (denoted as session information H) of a session (denoted as session a) established using the SYN message and an IP address of a server assigned to the terminal. Specifically, the session information H may include five-tuple information extracted from the SYN packet, that is, the source IP address, the destination IP address, the source port, the destination port, and the protocol extracted from the SYN packet.
Then, when the LB device receives another message sent by the gateway device based on the session a except the SYN message (that is, the quintuple information extracted from the another message is completely the same as the quintuple information in the session information H, and at this time, the another message is a subsequent message with respect to the SYN message), the LB device can determine the IP address of the server previously allocated to the terminal according to the correspondence between the previously recorded session information and the IP address of the corresponding server without depending on a persistence table. In this way, after the destination IP address is converted for the other message sent based on the session a, the LB device can also send the other message to the server previously allocated to the terminal.
In this embodiment, the LB device may send the packet to the server previously allocated to the terminal by using the correspondence between the session information recorded previously and the IP address of the corresponding server, and the gateway device does not need to add the intranet IP address of the terminal to the first designated location of the other packet except the SYN packet, so that the operating pressure on the gateway device may be effectively reduced.
In a specific implementation manner of the embodiment of the present invention, determining whether an intranet IP address of a terminal carried at a first designated location of a first packet hits any corresponding relationship in a persistence table may include:
judging whether a second appointed position of the first message has a first mark;
if so, determining whether the intranet IP address of the terminal carried by the first designated position of the first message hits any corresponding relation in the persistence table.
The first packet may be a TCP packet, and the second designated location of the first packet may be a location for filling the reserved flag in the TCP packet header shown in fig. 3. Specifically, the first flag may be 1.
For the gateway device, after receiving the second packet from the terminal and performing source IP address translation on the second packet to generate the first packet, it may determine whether the first packet is a SYN packet. If the first message is a SYN message, the gateway device may add the intranet IP address of the terminal to the first specified location of the first message, and add the first mark to the second specified location of the first message. It can be seen that the first flag can be used to characterize the first message as a SYN message.
Thus, when the terminal receives the first message sent by the gateway device, it may first determine whether the second designated location of the first message has the first flag. If yes, this indicates that the first message is a SYN message, and at this time, the LB device may perform a step of determining whether the intranet IP address of the terminal carried at the first specified location of the first message hits any corresponding relationship in the persistence table. If not, this indicates that the first message is not a SYN message, then the LB device does not need to perform the step of determining whether the intranet IP address of the terminal carried at the first specified location of the first message hits any corresponding relationship in the persistence table, and the LB device may directly check the corresponding relationship between the session information and the IP address of the corresponding server to determine the IP address of the server previously allocated to the terminal by the LB device, so that system resources on the LB device may be effectively saved.
In a specific implementation of the embodiment of the present invention, any correspondence stored in the persistence table is provided with an aging time.
It should be noted that the aging time of each corresponding relationship setting stored in the persistence table may be the same or different, which is all feasible.
In this embodiment, the LB device may record the time when each corresponding relationship in the persistence table was hit last time, and may further calculate a time interval between the current time and each recorded time. If the time interval between the current time and the time when any one of the correspondence relations in the persistence table was last hit is greater than the aging duration set for the correspondence relation, the LB device may delete the correspondence relation from the persistence table to release the storage space in the persistence table.
In a specific implementation manner of the embodiment of the present invention, before sending the first packet after the destination IP address is replaced, the method may further include:
after the target IP address of the first message is replaced, based on a preset verification algorithm, verification data corresponding to the first message after the target IP address is replaced is determined.
The predetermined Check algorithm may be a Cyclic Redundancy Check (CRC) algorithm.
Replacing the verification data in the first message after the replacement of the destination IP address with the determined verification data;
sending the first packet after the destination IP address is replaced may include:
and sending the first message after the target IP address and the verification data are replaced.
The following describes a specific implementation process of this embodiment with reference to fig. 4.
As shown in fig. 4, it is assumed that the gateway device receives a packet P (which may be considered as the second packet in the foregoing) from the terminal, where the packet P is a SYN packet. At this time, the gateway device may add a first mark, i.e. 1, to a position used for filling the reservation mark in the TCP header of the packet P; adding the intranet IP address of the terminal to the position used for filling the confirmation number in the TCP message header of the message P; and carrying out source IP address conversion on the message P.
It should be noted that the three processing operations of adding the first flag, adding the intranet IP address of the terminal, and performing source IP address conversion by the gateway device may be performed simultaneously or separately (the order of the three processing operations may be set arbitrarily according to actual situations).
The gateway device can perform data adjustment and verification operations on the message P after the three processing. Specifically, the gateway device may determine, according to the check data in the message P received from the terminal, a part of the message P that changes before and after the three processing items are performed, and a CRC algorithm, the check data corresponding to the message P after the three processing items are performed. Then, the gateway device may replace the check data in the packet P after the three processing items with the determined check data to obtain a packet P '(which may be considered as the first packet in the foregoing), and send the obtained packet P' to the LB device.
After the LB device receives the packet P ', it determines whether the position in the TCP header of the packet P' used for filling the reservation label has the first label, i.e. 1. If the judgment result is yes, the LB device judges whether the intranet IP address of the position used for filling the confirmation number in the TCP message header of the message P' hits any corresponding relation in the continuity table. If the message is hit, the LB device replaces the target IP address of the message P' with the IP address in the hit corresponding relation; if not, the LB device will allocate a server for the terminal having the intranet IP address of the TCP message header of the message P 'for filling the position of the confirmation number, store the corresponding relation between the intranet IP address and the IP address of the allocated server, and replace the destination IP address of the message P' with the IP address of the allocated server.
Whether the message is hit or not, after the target IP address of the message P ' is replaced by the corresponding IP address, the LB device can also determine the check data corresponding to the message P ' after the target IP address is replaced according to the check data in the message P ' before the target IP address is replaced, the part of the message P ' before and after the target IP address is replaced, and the CRC algorithm, and replace the check data in the message P ' after the target IP address is replaced by the determined check data. Finally, the LB device may send a packet P' in which both the destination IP address and the check data are replaced.
For the server that receives the packet P 'in which the destination IP address and the verification data are both replaced, the server may obtain the corresponding verification data by using the remaining data in the received packet P' except the verification data. Then, the server may determine whether the obtained check data is the same as the check data in the received packet P'. If the two messages are the same, the server can perform subsequent processing on the received message P ', which indicates that the received message P' is correct; if not, this indicates that the received message P 'is inaccurate, the server may discard the received message P', and may send an error notification message to the LB device.
It is easy to see that, the embodiment can better ensure the correctness of the check data in the message received by the server, so that the server can accurately judge whether the message received by the server has errors.
In summary, in this embodiment, traffic is sent more uniformly, the load of each server is more balanced, and a situation that a service is unavailable due to too much pressure does not occur on a single server, so that better user experience can be brought.
A message sending method provided in an embodiment of the present invention from the perspective of a gateway device is described below.
Referring to fig. 5, a flowchart of a message sending method according to an embodiment of the present invention is shown in the diagram. As shown in fig. 5, the method is applied to a gateway device, and the method may include:
s501, receiving a second message sent by the terminal to the LB device, performing source IP address conversion on the second message to generate a first message, and adding an intranet IP address of the terminal at a first designated position of the first message;
s502, sending a first message to an LB device, so that the LB device determines whether an intranet IP address of a terminal carried at a first designated position of the first message hits any corresponding relation in a persistence table, and if so, replacing a target IP address of the first message with an IP address of a server in the hit corresponding relation; if not, a server is allocated to the terminal, the destination IP address of the first message is replaced by the IP address of the allocated server, the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server is stored in a continuous table, and the first message after the destination IP address is replaced is sent;
the persistence table is used for storing the corresponding relation between the intranet IP address and the IP address of the server.
In a specific implementation manner of the embodiment of the present invention, adding an intranet IP address of a terminal to a first specified location of a first packet includes:
and when the first message is a SYN message, adding the intranet IP address of the terminal at the first designated position of the first message.
In a specific implementation manner of the embodiment of the present invention, the method further includes:
and adding a first mark at a second appointed position of the first message, so that when the LB device determines that the second appointed position of the first message carries the first mark, the LB device determines whether the intranet IP address of the terminal carried by the first appointed position of the first message hits any corresponding relation in the persistence table.
In this scheme, when receiving a first message sent by a gateway device, an LB device determines whether an intranet IP address of a terminal carried at a first designated location of the first message hits any entry in a persistence table. If the result is hit, which indicates that the LB device has previously allocated a server to the terminal, the LB device performs destination IP address translation on the first packet to send the first packet to the server previously allocated to the terminal. If the message is not hit, which indicates that the LB device has not previously allocated the server to the terminal, the LB device allocates the server to the terminal and performs destination IP address translation on the first message, so as to send the first message to the server allocated to the terminal. In addition, in case of miss, the LB device may further store a corresponding relationship between the intranet IP address of the terminal and the IP address of the server allocated thereto, so that, when the LB device subsequently receives a message from the terminal, the LB device may send the subsequently received message sent by the terminal to the server allocated to the terminal previously according to the persistence table.
It is easy to see that, in the present solution, the LB device distinguishes the messages from different terminals according to the intranet IP addresses in the received messages, so as to send the messages from different terminals to the server allocated to the terminal. Therefore, the LB device does not take all messages from the gateway device as the same user flow, thereby ensuring that the load on each server is more balanced.
The following describes a message sending apparatus provided in an embodiment of the present invention from the perspective of an LB device.
Referring to fig. 6, a block diagram of a structure of a message sending apparatus according to an embodiment of the present invention is shown. As shown in fig. 6, the apparatus is applied to an LB device, and may include:
the receiving module 61 is configured to receive a first message sent by the gateway device, where the first message is a message generated by the gateway device after performing source IP address conversion on a second message sent by a received terminal, and a first specified location of the first message carries an intranet IP address of the terminal;
a determining module 62, configured to determine whether an intranet IP address of a terminal carried in a first specified location of the first packet hits any corresponding relationship in the persistence table; the continuity table is used for storing the corresponding relation between the intranet IP address and the IP address of the server;
a first processing module 63, configured to, if the determination result of the determining module 62 is yes, replace the destination IP address of the first packet with the IP address of the server in the hit corresponding relationship; under the condition that the determination result of the determination module 62 is negative, a server is allocated to the terminal, the destination IP address of the first message is replaced by the IP address of the allocated server, and the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server is stored in a persistence table;
and a first sending module 64, configured to send the first packet after the destination IP address is replaced.
In a specific implementation manner of the embodiment of the present invention, the first message is a SYN message;
the apparatus may further include:
the recording module is used for recording the corresponding relation between the session information of the session established by using the SYN message and the IP address of the server corresponding to the intranet IP address of the terminal;
the second processing module is used for replacing the target IP address of other messages with the IP address of the server in the recorded corresponding relation according to the recorded corresponding relation when receiving other messages sent by the gateway equipment based on the session; and sending other messages after the destination IP address is replaced.
In a specific implementation manner of the embodiment of the present invention, the determining module includes:
the judging submodule is used for judging whether a second appointed position of the first message has a first mark or not;
and the determining submodule is used for determining whether the intranet IP address of the terminal carried by the first specified position of the first message hits any corresponding relation in the continuity table or not under the condition that the judgment result of the judging submodule is yes.
In a specific implementation of the embodiment of the present invention, any correspondence stored in the persistence table is provided with an aging time.
In this scheme, when receiving a first message sent by a gateway device, an LB device determines whether an intranet IP address of a terminal carried at a first designated location of the first message hits any entry in a persistence table. If the result is hit, which indicates that the LB device has previously allocated a server to the terminal, the LB device performs destination IP address translation on the first packet to send the first packet to the server previously allocated to the terminal. If the message is not hit, which indicates that the LB device has not previously allocated a server to the terminal, the LB device allocates a server to the terminal and performs destination IP address translation on the first message, so as to send the first message to the server allocated to the terminal. In addition, in case of miss, the LB device may further store a corresponding relationship between the intranet IP address of the terminal and the IP address of the server allocated thereto, so that, when the LB device subsequently receives a message from the terminal, the LB device may send the subsequently received message sent by the terminal to the server allocated to the terminal previously according to the persistence table.
It is easy to see that, in the present solution, the LB device distinguishes the messages from different terminals according to the intranet IP addresses in the received messages, so as to send the messages from different terminals to the server allocated to the terminal. Therefore, the LB device does not take all messages from the gateway device as the same user flow, thereby ensuring that the load on each server is more balanced.
A message sending apparatus provided in an embodiment of the present invention from the perspective of a gateway device is described below.
Referring to fig. 7, a block diagram of a structure of a message sending apparatus according to an embodiment of the present invention is shown. As shown in fig. 7, the apparatus is applied to a gateway device, and may include:
the processing module 71 is configured to receive a second message sent by the terminal to the LB device, perform source IP address conversion on the second message to generate a first message, and add an intranet IP address of the terminal to a first designated location of the first message;
a second sending module 72, configured to send the first packet to the LB device, so that the LB device determines whether an intranet IP address of a terminal carried in a first specified location of the first packet hits any corresponding relationship in the persistence table, and if so, replaces a destination IP address of the first packet with an IP address of a server in the hit corresponding relationship; if not, a server is allocated to the terminal, the destination IP address of the first message is replaced by the IP address of the allocated server, the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server is stored in a continuous table, and the first message after the destination IP address is replaced is sent;
the persistence table is used for storing the corresponding relation between the intranet IP address and the IP address of the server.
In a specific implementation manner of the embodiment of the present invention, the processing module is specifically configured to:
and when the first message is a SYN message, adding the intranet IP address of the terminal at the first designated position of the first message.
In a specific implementation manner of the embodiment of the present invention, the apparatus further includes:
and the adding module is used for adding a first mark at the second appointed position of the first message, so that when the LB device determines that the second appointed position of the first message carries the first mark, whether the intranet IP address of the terminal carried by the first appointed position of the first message hits any corresponding relation in the persistence table is determined.
In this scheme, when receiving a first message sent by a gateway device, an LB device determines whether an intranet IP address of a terminal carried at a first designated location of the first message hits any entry in a persistence table. If the result is hit, which indicates that the LB device has previously allocated a server to the terminal, the LB device performs destination IP address translation on the first packet to send the first packet to the server previously allocated to the terminal. If the message is not hit, which indicates that the LB device has not previously allocated a server to the terminal, the LB device allocates a server to the terminal and performs destination IP address translation on the first message, so as to send the first message to the server allocated to the terminal. In addition, in case of miss, the LB device may further store a corresponding relationship between the intranet IP address of the terminal and the IP address of the server allocated thereto, so that, when the LB device subsequently receives a message from the terminal, the LB device may send the subsequently received message sent by the terminal to the server allocated to the terminal previously according to the persistence table.
It is easy to see that, in the present solution, the LB device distinguishes the messages from different terminals according to the intranet IP addresses in the received messages, so as to send the messages from different terminals to the server allocated to the terminal. Therefore, the LB device does not take all messages from the gateway device as the same user flow, thereby ensuring that the load on each server is more balanced.
An LB apparatus according to an embodiment of the present invention is described below.
Referring to fig. 8, a schematic structural diagram of an LB apparatus according to an embodiment of the present invention is shown. As shown in fig. 8, the LB apparatus may include: a processor 81, and a machine-readable storage medium 82 having stored thereon machine-executable instructions. The processor 81 and the machine-readable storage medium 82 may communicate via a system bus 83. Also, the processor 81 may perform the method steps described above as applied to the LB device by reading and executing machine-executable instructions in the machine-readable storage medium 82 corresponding to the messaging control logic.
A gateway device provided in an embodiment of the present invention is described below.
Referring to fig. 9, a gateway device according to an embodiment of the present invention is shown. As shown in fig. 9, the gateway apparatus may include: a processor 91, a machine-readable storage medium 92 storing machine-executable instructions. The processor 91 and the machine-readable storage medium 92 may communicate via a system bus 93. Also, the processor 91 may perform the method steps described above as applied to the gateway device by reading and executing machine-executable instructions in the machine-readable storage medium 92 corresponding to messaging control logic.
A machine-readable storage medium provided by an embodiment of the present invention is described below.
The embodiment of the invention also provides a machine-readable storage medium. Wherein the machine-readable storage medium stores machine-executable instructions that, when invoked and executed by a processor, cause the processor to: the method steps applied to the LB device or the gateway device are realized.
It should be noted that the machine-readable storage medium referred to herein may be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, and the like. For example, the machine-readable storage medium may be: RAM (random access Memory), volatile Memory, flash Memory, a storage drive (e.g., a hard drive), a solid state drive, any type of storage disk (e.g., an optical disk, dvd, etc.), or similar storage medium, or a combination thereof.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. Especially, for the embodiments of the apparatus, the LB device, the gateway device, and the machine-readable storage medium, since they are substantially similar to the embodiments of the method, the description is simple, and for the relevant points, reference may be made to the partial description of the embodiments of the method.
The above description is only for the preferred embodiment of the present invention, and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention shall fall within the protection scope of the present invention.

Claims (13)

1. A message sending method is applied to a load balancing LB device, and comprises the following steps:
receiving a first message sent by gateway equipment, wherein the first message is generated after source IP address conversion is carried out on a second message sent by a received terminal by the gateway equipment, and a first designated position of the first message carries an intranet IP address of the terminal;
determining whether the intranet IP address of the terminal carried by the first designated position of the first message hits any corresponding relation in a persistence table; the continuity table is used for storing the corresponding relation between the intranet IP address and the IP address of the server;
if so, replacing the target IP address of the first message with the IP address of the server in the hit corresponding relation;
if not, a server is allocated to the terminal, the destination IP address of the first message is replaced by the IP address of the allocated server, and the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server is stored in the persistence table;
sending the first message with the replaced destination IP address;
the first message is a SYN message;
the method further comprises the following steps:
recording the corresponding relation between the session information of the session established by the SYN message and the IP address of the server corresponding to the intranet IP address of the terminal;
when receiving other messages sent by the gateway equipment based on the session, replacing the target IP addresses of the other messages with the IP addresses of the servers in the recorded corresponding relation according to the recorded corresponding relation;
sending the other messages after the target IP address is replaced;
before the sending the first packet after the destination IP address is replaced, the method further includes:
after the target IP address of the first message is replaced, determining verification data corresponding to the first message after the target IP address is replaced based on a preset verification algorithm;
replacing the verification data corresponding to the first message after the target IP address is replaced with the determined verification data;
and sending the first message after the target IP address and the verification data are replaced.
2. The method according to claim 1, wherein the determining whether the intranet IP address of the terminal carried by the first specified location of the first packet hits any corresponding relationship in a persistence table comprises:
judging whether a second appointed position of the first message has a first mark;
if so, determining whether the intranet IP address of the terminal carried by the first designated position of the first message hits any corresponding relation in the persistence table.
3. The method of claim 1, wherein any correspondence stored in the persistence table is provided with an aging time.
4. A message sending method is applied to gateway equipment, and the method comprises the following steps:
receiving a second message sent by a terminal to a load balancing LB device, converting a source IP address of the second message to generate a first message, and adding an intranet IP address of the terminal at a first designated position of the first message;
sending the first message to the LB device, so that the LB device determines whether the intranet IP address of the terminal carried at a first designated position of the first message hits any corresponding relation in a persistence table, if so, replacing the destination IP address of the first message with the IP address of a server in the hit corresponding relation, if not, allocating a server to the terminal, replacing the destination IP address of the first message with the IP address of the allocated server, storing the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server in the persistence table, and sending the first message after the destination IP address is replaced;
the continuity table is used for storing the corresponding relation between the intranet IP address and the IP address of the server;
the adding the intranet IP address of the terminal to the first designated position of the first message includes:
when the first message is a SYN message, adding an intranet IP address of the terminal at a first designated position of the first message;
before the sending the first packet after the destination IP address is replaced, the method further includes:
after the target IP address of the first message is replaced, determining verification data corresponding to the first message after the target IP address is replaced based on a preset verification algorithm;
replacing the verification data corresponding to the first message after the target IP address is replaced with the determined verification data;
and sending the first message after the target IP address and the verification data are replaced.
5. The method of claim 4, further comprising:
and adding a first mark at a second appointed position of the first message, so that the LB device determines whether the intranet IP address of the terminal carried at the first appointed position of the first message hits any corresponding relation in a persistence table when determining that the second appointed position of the first message carries the first mark.
6. A message sending apparatus, applied to a load balancing LB device, the apparatus comprising:
the receiving module is used for receiving a first message sent by gateway equipment, wherein the first message is generated after source IP address conversion is carried out on a second message sent by a received terminal by the gateway equipment, and a first designated position of the first message carries an intranet IP address of the terminal;
a determining module, configured to determine whether an intranet IP address of the terminal carried in a first specified location of the first packet hits any corresponding relationship in a persistence table; the continuity table is used for storing the corresponding relation between the intranet IP address and the IP address of the server;
the first processing module is used for replacing the target IP address of the first message with the IP address of the server in the hit corresponding relation under the condition that the determination result of the determination module is positive; under the condition that the determination result of the determination module is negative, a server is allocated to the terminal, the destination IP address of the first message is replaced by the IP address of the allocated server, and the corresponding relation between the intranet IP address of the terminal and the IP address of the allocated server is stored in the persistence table;
the first sending module is used for sending the first message after the destination IP address is replaced;
the first message is a SYN message;
the device further comprises:
a recording module, configured to record a correspondence between session information of a session established using the SYN packet and an IP address of a server corresponding to an intranet IP address of the terminal;
a second processing module, configured to replace, when receiving another packet sent by the gateway device based on the session, a destination IP address of the other packet with an IP address of a server in the recorded correspondence according to the recorded correspondence; sending the other messages after the target IP address is replaced;
before sending the first message with the replaced destination IP address, the device is further used for,
after the target IP address of the first message is replaced, determining verification data corresponding to the first message after the target IP address is replaced based on a preset verification algorithm;
replacing the verification data corresponding to the first message after the target IP address is replaced with the determined verification data;
and sending the first message after the target IP address and the verification data are replaced.
7. The apparatus of claim 6, wherein the determining module comprises:
the judging submodule is used for judging whether a second appointed position of the first message has a first mark or not;
and the determining submodule is used for determining whether the intranet IP address of the terminal carried by the first specified position of the first message hits any corresponding relation in the continuity table or not under the condition that the judgment result of the judging submodule is yes.
8. The apparatus of claim 6, wherein any correspondence stored in the persistence table is provided with an aging time.
9. A message sending apparatus, applied to a gateway device, the apparatus comprising:
the processing module is used for receiving a second message sent by the terminal to the load balancing LB equipment, performing source IP address conversion on the second message to generate a first message, and adding the intranet IP address of the terminal at a first designated position of the first message;
a second sending module, configured to send the first packet to the LB device, so that the LB device determines whether an intranet IP address of the terminal carried in a first specified location of the first packet hits any corresponding relationship in a persistence table, if so, replace a destination IP address of the first packet with an IP address of a server in the hit corresponding relationship, if not, allocate a server to the terminal, replace the destination IP address of the first packet with an IP address of the allocated server, store the corresponding relationship between the intranet IP address of the terminal and the IP address of the allocated server in the persistence table, and send the first packet after the destination IP address is replaced;
the continuity table is used for storing the corresponding relation between the intranet IP address and the IP address of the server;
the processing module is specifically configured to:
when the first message is a SYN message, adding an intranet IP address of the terminal at a first designated position of the first message;
before sending the first message with the replaced destination IP address, the device is further used for,
after the target IP address of the first message is replaced, determining verification data corresponding to the first message after the target IP address is replaced based on a preset verification algorithm;
replacing the verification data corresponding to the first message after the target IP address is replaced with the determined verification data;
and sending the first message after the target IP address and the verification data are replaced.
10. The apparatus of claim 9, further comprising:
and the adding module is used for adding a first mark at the second appointed position of the first message, so that when the LB device determines that the second appointed position of the first message carries the first mark, whether the intranet IP address of the terminal carried by the first appointed position of the first message hits any corresponding relation in the persistence table is determined.
11. A load balancing LB device comprising a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to: carrying out the method steps of any one of claims 1 to 3.
12. A gateway device comprising a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to: implementing the method steps of any of claims 4-5.
13. A machine-readable storage medium having stored thereon machine-executable instructions that, when invoked and executed by a processor, cause the processor to: carrying out the method steps of any one of claims 1 to 5.
CN201710542175.9A 2017-07-05 2017-07-05 Message sending method and device, load balancing LB device and gateway device Active CN107547428B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710542175.9A CN107547428B (en) 2017-07-05 2017-07-05 Message sending method and device, load balancing LB device and gateway device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710542175.9A CN107547428B (en) 2017-07-05 2017-07-05 Message sending method and device, load balancing LB device and gateway device

Publications (2)

Publication Number Publication Date
CN107547428A CN107547428A (en) 2018-01-05
CN107547428B true CN107547428B (en) 2022-03-22

Family

ID=60971101

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710542175.9A Active CN107547428B (en) 2017-07-05 2017-07-05 Message sending method and device, load balancing LB device and gateway device

Country Status (1)

Country Link
CN (1) CN107547428B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109587087B (en) * 2018-12-10 2020-12-29 杭州迪普科技股份有限公司 Message processing method and system

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101783771A (en) * 2010-03-24 2010-07-21 杭州华三通信技术有限公司 Method and equipment for realizing load balance continuity
CN102209019A (en) * 2010-03-30 2011-10-05 杭州华三通信技术有限公司 Load balancing method and load balancing equipment based on message payload
CN103001966A (en) * 2012-12-11 2013-03-27 杭州迪普科技有限公司 Processing and identifying method and device for private network IP
CN106790675A (en) * 2017-01-23 2017-05-31 天地融科技股份有限公司 Load-balancing method, equipment and system in a kind of cluster

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102075445B (en) * 2011-02-28 2013-12-25 杭州华三通信技术有限公司 Load balancing method and device
US9800653B2 (en) * 2015-03-06 2017-10-24 Microsoft Technology Licensing, Llc Measuring responsiveness of a load balancing system

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101783771A (en) * 2010-03-24 2010-07-21 杭州华三通信技术有限公司 Method and equipment for realizing load balance continuity
CN102209019A (en) * 2010-03-30 2011-10-05 杭州华三通信技术有限公司 Load balancing method and load balancing equipment based on message payload
CN103001966A (en) * 2012-12-11 2013-03-27 杭州迪普科技有限公司 Processing and identifying method and device for private network IP
CN106790675A (en) * 2017-01-23 2017-05-31 天地融科技股份有限公司 Load-balancing method, equipment and system in a kind of cluster

Also Published As

Publication number Publication date
CN107547428A (en) 2018-01-05

Similar Documents

Publication Publication Date Title
EP2666263B1 (en) Methods, systems, and computer readable media for screening diameter messages within a diameter signaling router (dsr) having a distributed message processor architecture
US12015971B2 (en) Methods for processing encrypted domain name server, DNS, queries received from user equipment in a telecommunication network
EP2681937B1 (en) Method, system, and computer readable medium for hybrid session based diameter routing
JP6059336B2 (en) Method, system and computer readable medium for performing Diameter overload control
JP5758508B2 (en) Method, system and computer-readable medium for dynamically learning diameter binding information
US10305942B2 (en) SIP server with multiple identifiers
EP2533492A2 (en) A node device and method to prevent overvlow of pending interest table in name based network system
CN110166570B (en) Service session management method and device, and electronic device
CN108712516B (en) Method, device, equipment and storage medium for acquiring SIP server address
CN109120746B (en) Network address translation method and device and address translation equipment
CN105991660B (en) System for resource sharing among multiple cloud storage systems
CN112367257B (en) Route notification method and device
CN112104568B (en) Data transmission control method and gateway
US20160248789A1 (en) Call control device, call control method, and call control system
CN110913010B (en) SIP service cluster system and implementation method
US8805943B2 (en) Optimized routing for proxy use
CN113810349A (en) Data transmission method and device and computer equipment
CN107547428B (en) Message sending method and device, load balancing LB device and gateway device
CN113315848B (en) Access control method, device and equipment
CN110035134B (en) Network address translation method, device and access equipment
EP2887620A1 (en) Session Initiation Protocol Messaging
CN107547295B (en) Aging method and device for domain name cache table entries
CN107682271B (en) Method and device for generating routing line
CN110809033B (en) Message forwarding method and device and switching server
US10277421B2 (en) Route lookup resolution

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant