Load balancing method and device supporting data source-in and source-out

By defining session connection tables and hash value linked lists, packet data is processed and forwarded in real time, solving the problem of inconsistent return paths for load balancing devices in NAT Server scenarios, and improving system performance and business continuity.

CN120980027APending Publication Date: 2025-11-18TMLAKE (BEIJING) TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202511291437.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-10
Publication Date
2025-11-18

AI Technical Summary

Technical Problem

In NAT Server scenarios, slow access speeds or business interruptions caused by inconsistent return paths can affect the performance and business continuity of the load balancing system.

Method used

By defining a session connection table and a hash value linked list, the system receives packet data in real time from the load balancing device, performs traversal query processing and forwarding, and ensures that the data source is in and out, including initializing the session connection table, processing packet data forwarding, and generating new session connection data.

Benefits of technology

It resolved the issue of slow access speed or business interruption caused by inconsistent return paths, improved the access speed and equipment performance of the load balancing system, and ensured business continuity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120980027A_ABST
    Figure CN120980027A_ABST
Patent Text Reader

Abstract

The invention discloses a load balancing method and device supporting source-in and source-out of data. The method comprises the steps that a session connection table is defined, and according to a session connection table structure, a session connection table is created and initialized; receiving message data in real time through a network card based on load balancing equipment, performing traversal query processing on the message data according to the session connection table, determining a traversal query result, if the query succeeds, forwarding the message data according to the traversal query result, and if the query fails, forwarding the message data according to the traversal query result. If yes, determining a destination IP address, a data outflow network interface, a source IP address and a source port of message forwarding according to the session connection table structure and the message data, generating new session connection data, updating the session connection table, and then forwarding the message data according to the new session connection data. Through the technical scheme provided by the invention, the access speed of the load balancing system and the performance of the load balancing equipment are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of Internet technology, and more specifically, to a load balancing method and apparatus that supports data source input and output. Background Technology

[0002] Load balancing is a fundamental element of high application availability. By distributing traffic to different backend servers, it expands the service throughput of an application system, eliminates single points of failure, and improves the availability of the application system.

[0003] After receiving the TCP handshake / UDP packet from the client, the load balancer needs to generate a TCP handshake / UDP packet to send to the backend server based on the request data packet and the rules configured in the load balancer, just as if the client were communicating with the real server.

[0004] like Figure 1 As shown, in a NAT Server scenario (server mapping), if there are multiple exit points, when returning packets, the load balancer will look up the outgoing interface of the server response packet according to the routing table. This can result in the request packet entering from Internet Service Provider (ISP) ISP1, while the server response packet returns from ISP2. This inconsistent return path can cause technical problems such as slow access speeds or service interruptions.

[0005] To address the aforementioned problems in existing technologies, it is necessary to introduce a new method and apparatus. Based on a load balancing device and a created session connection table and hash value linked list, the method receives packet data in real time through a network interface card, and performs traversal query processing and forwarding of the packet data. This solves the technical problem of slow access speed or service interruption caused by inconsistent return paths in existing technologies, thereby ensuring the continuity of packet data source input and output and services, and improving the access speed of the load balancing system and the performance of the load balancing device. Summary of the Invention

[0006] To address the aforementioned technical issues, this invention provides a load balancing method and apparatus that supports data source inflow and outflow. Based on a load balancing device and a created session connection table and hash value linked list, it receives packet data in real time through a network interface card, and performs traversal query processing and forwarding of the packet data. This solves the technical problem in the prior art where inconsistent return paths cause slow access speeds or service interruptions, thereby ensuring the continuity of packet data source inflow and outflow and services, and improving the access speed of the load balancing system and the performance of the load balancing device.

[0007] This invention provides a load balancing method that supports data source input and output, the method comprising:

[0008] S1, Define and initialize the session connection table: Define the session connection table structure based on the five-tuple data of the packet, as well as the physical interface of the incoming device and the physical interface of the outgoing device, and create and initialize the session connection table according to the session connection table structure. The five-tuple data includes the protocol number, source IP address, source port, destination IP address and destination port.

[0009] S2, Packet data forwarding processing: Based on the load balancing device, packet data is received in real time through the network card, and the packet data is traversed and queried according to the session connection table to determine the traversal query result. If the query is successful, the packet data is forwarded according to the traversal query result. If the query fails, the process jumps to step S3.

[0010] S3, Generate new session connection data: Based on the session connection table structure and the packet data, determine the destination IP address, data outgoing network interface, source IP address and source port for packet forwarding, generate new session connection data, update the session connection table, and then forward the packet data based on the new session connection data.

[0011] As described above, the session connection table structure includes address family, protocol number, source IP address, source port, source MAC address, destination IP address, destination port, destination MAC address, data inflow network interface, data outflow network interface, source network address translation IP address, and source network address translation port;

[0012] The message data includes the address family and the quintuple data.

[0013] As described above, step S1, the step of creating and initializing the session connection table according to the session connection table structure, includes:

[0014] After the session connection table is created, the five-tuple data of the existing packets in the load balancing system, as well as the address family, source network address translation IP address, source network address translation port, data inflow network interface, and data outflow network interface are written into the session connection table. The hash value is calculated based on the address family, protocol number, source IP address, and source port in the session connection table. The slot number of the session connection table is determined based on the calculated hash value, and the calculated hash value is recorded in the hash value linked list, thereby completing the initialization of the session connection table.

[0015] The value of the slot number where the session connection table is located is equal to the hash value calculated based on the address family, protocol number, source IP address and source port in the session connection table.

[0016] The hash value linked list needs to be created in advance to store the hash values ​​calculated based on the address family, protocol number, source IP address, and source port.

[0017] As described above, in step S2, the step of receiving packet data in real time through the network card based on the load balancing device and performing traversal query processing on the packet data according to the session connection table further includes:

[0018] S21, based on the load balancing device, receives packet data in real time through the network card and calculates the hash value of the packet based on the address family, protocol number, source IP address and source port in the packet data;

[0019] S22, determine the slot where the session connection table is located based on the hash value of the obtained message, the hash value linked list, and the slot number of the session connection table, and traverse and query all session connection tables in the determined slot. If there is a record in the session connection table that is the same as the address family, protocol number, source IP address, source port, destination IP address, and destination port in the message data, the query is successful. Obtain and encapsulate the source network address translation IP address, source network address translation port, destination IP address, and destination port from the same record in the session connection table into the message data, and use the data in the record to flow into the network interface or flow out of the network interface to forward the message data.

[0020] If there is no record in the session connection table that matches the protocol number, source IP address, source port, destination IP address, and destination port in the message data, the query fails and proceeds to step S3.

[0021] As described above, in step S3, the step of determining the destination IP address, data outgoing network interface, source IP address, and source port of the packet forwarding based on the session connection table structure and the packet data, and generating new session connection data, includes the step of confirming the destination IP address of the packet, specifically as follows:

[0022] Based on the load balancing device, the real server is queried and determined according to the destination IP address in the packet data and the load balancing algorithm, and then the destination IP address for packet forwarding is determined based on the real server.

[0023] As described above, in step S3, the step of determining the destination IP address, data outgoing network interface, source IP address, and source port for packet forwarding based on the session connection table structure and the packet data, and generating new session connection data, includes the step of determining the data outgoing interface, specifically:

[0024] Based on the load balancer, a route lookup is performed on the routing table stored on the load balancer according to the destination IP address of the packet, and the data flow outgoing network interface of the packet is determined according to the route lookup result.

[0025] S311, according to the destination IP address of the message, check the routing table of the policy route stored on the load balancer. If there is an address in the routing table of the policy route that is the same as the destination IP address of the message, then the outgoing interface of the policy route is used as the data outgoing network interface for message forwarding, and the data outgoing network interface for message forwarding and the message data are recorded in the session record table where the slot number is equal to the hash value of the message. If there is no address in the routing table of the policy route that is the same as the destination IP address of the message, then jump to step S312.

[0026] S312, according to the destination IP address of the message, check the routing table of the directly connected routes stored on the load balancer. If there is an address in the routing table of the directly connected routes that is the same as the destination IP address of the message, then the outgoing interface of the directly connected route is used as the data outgoing network interface for message forwarding, and the data outgoing network interface for message forwarding and the message data are both recorded in the session record table where the slot number is equal to the hash value of the message. If there is no address in the routing table of the directly connected routes that is the same as the destination IP address of the message, then jump to step S313.

[0027] S313, based on the destination IP address of the message, check the routing table of the dynamic route stored on the load balancer. If there is an address in the routing table of the dynamic route that is the same as the destination IP address of the message, then the outgoing interface of the dynamic route is used as the data outgoing network interface for message forwarding, and the data outgoing network interface for message forwarding and the message data are both recorded in the session record table where the slot number is equal to the hash value of the message.

[0028] Each load balancer has a routing table, and the routing type corresponds one-to-one with the routing table type. The routing types include policy routing, static routing, and dynamic routing.

[0029] As described above, in step S3, the step of determining the destination IP address, data outgoing network interface, source IP address, and source port for packet forwarding based on the session connection table structure and the packet data, and generating new session connection data, further includes the step of determining the source address and source port, specifically:

[0030] Based on the source address translation strategy configured by the load balancer and virtual service type, a source IP address and source port are assigned to the packet. The assigned source IP address and source port are used to update the source IP address and source port of the packet forwarding in the session record table. At the same time, the assigned source IP address and source port are encapsulated with the packet data to obtain new session connection data.

[0031] The new session connection data includes address family, protocol number, destination IP address, destination port, assigned source IP address and source port, as well as data outflow network interface and data inflow network interface.

[0032] As described above, in step S3, the step of forwarding the packet data based on the new session connection data further includes:

[0033] The hash value of the message is calculated based on the address family, protocol number, source IP address, and source port in the message data and stored in the hash value linked list. The message is then forwarded using new session connection data.

[0034] Accordingly, the present invention also provides a load balancing device that supports data source input and output, the device comprising a connection table initialization unit, a packet data forwarding and processing unit, and a session connection data generation unit;

[0035] in,

[0036] The connection table initialization unit is used to define and initialize the session connection table: define the session connection table structure according to the five-tuple data of the packet, as well as the physical interface of the packet's inflow device and the physical interface of the outflow device, and create and initialize the session connection table according to the session connection table structure, wherein the five-tuple data includes the protocol number, source IP address, source port, destination IP address and destination port;

[0037] The message data forwarding processing unit is used for message data forwarding processing: based on the load balancing device, it receives message data in real time through the network card, and performs traversal query processing on the message data according to the session connection table to determine the traversal query result. If the query is successful, the message data is forwarded according to the traversal query result. If the query fails, it jumps to step S3.

[0038] The session connection data generation unit is used to generate new session connection data: based on the session connection table structure and the packet data, it determines the destination IP address, data outgoing network interface, source IP address and source port for packet forwarding, generates new session connection data, updates the session connection table, and then forwards the packet data based on the new session connection data.

[0039] By applying the above technical solutions, this invention enables the real-time reception of packet data via network interface card (NIC) based on a load balancing device, a created session connection table, and a hash value linked list. It then performs traversal, querying, processing, and forwarding of the packet data, solving the technical problem of slow access speed or service interruption caused by inconsistent return paths in existing technologies. This ensures the continuity of packet data source input and output and service continuity, improving the access speed of the load balancing system and the performance of the load balancing device. Attached Figure Description

[0040] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0041] Figure 1 This diagram illustrates a structure where the incoming and outgoing paths of messages are inconsistent in existing technologies.

[0042] Figure 2 A flowchart illustrating a load balancing method supporting data source input and output proposed in an embodiment of the present invention is shown.

[0043] Figure 3 This diagram illustrates the structure of the present invention after configuring source-in / source-out;

[0044] Figure 4 The diagram shows a structural schematic of a load balancing device that supports data source input and output according to an embodiment of the present invention. Detailed Implementation

[0045] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0046] This invention provides a load balancing method that supports both inbound and outbound data sources, such as... Figure 2 As shown, the method includes the following steps:

[0047] S1, Define and initialize the session connection table: Define the session connection table structure based on the five-tuple data of the packet, as well as the physical interface of the incoming device and the physical interface of the outgoing device, and create and initialize the session connection table according to the session connection table structure. The five-tuple data includes the protocol number, source IP address, source port, destination IP address and destination port.

[0048] In this embodiment, the session connection table structure includes address family, protocol number, source IP address, source port, source MAC address, destination IP address, destination port, destination MAC address, data inflow network interface, data outflow network interface, source network address translation IP address, and source network address translation port.

[0049] In this embodiment, step S1, which involves creating and initializing the session connection table based on the session connection table structure, includes:

[0050] After the session connection table is created, the five-tuple data of the existing packets in the load balancing system, as well as the address family, source network address translation IP address, source network address translation port, data inflow network interface, and data outflow network interface are written into the session connection table. The hash value is calculated based on the address family, protocol number, source IP address, and source port in the session connection table. The slot number of the session connection table is determined based on the calculated hash value, and the calculated hash value is recorded in the hash value linked list, thereby completing the initialization of the session connection table.

[0051] The value of the slot number where the session connection table is located is equal to the hash value calculated based on the address family, protocol number, source IP address and source port in the session connection table.

[0052] The hash value linked list needs to be created in advance to store the hash values ​​calculated based on the address family, protocol number, source IP address, and source port.

[0053] S2, Packet data forwarding processing: Based on the load balancing device, packet data is received in real time through the network card, and the packet data is traversed and queried according to the session connection table to determine the traversal query result. If the query is successful, the packet data is forwarded according to the traversal query result. If the query fails, the process jumps to step S3.

[0054] The message data includes the address family and the quintuple data.

[0055] In this embodiment, step S2, which involves receiving packet data in real time via a network card based on a load balancing device and performing traversal query processing on the packet data according to the session connection table, further includes:

[0056] S21, based on the load balancing device, receives packet data in real time through the network card and calculates the hash value of the packet based on the address family, protocol number, source IP address and source port in the packet data;

[0057] S22, determine the slot where the session connection table is located based on the hash value of the obtained message, the hash value linked list, and the slot number of the session connection table, and traverse and query all session connection tables in the determined slot. If there is a record in the session connection table that is the same as the address family, protocol number, source IP address, source port, destination IP address, and destination port in the message data, the query is successful. Obtain and encapsulate the source network address translation IP address, source network address translation port, destination IP address, and destination port from the same record in the session connection table into the message data, and use the data in the record to flow into the network interface or flow out of the network interface to forward the message data.

[0058] If there is no record in the session connection table that matches the protocol number, source IP address, source port, destination IP address, and destination port in the message data, the query fails and proceeds to step S3.

[0059] In this embodiment, step S3, which involves determining the destination IP address, data outgoing network interface, source IP address, and source port of the packet based on the session connection table structure and the packet data, and generating new session connection data, includes a step of confirming the destination IP address of the packet, specifically as follows:

[0060] Based on the load balancing device, the real server is queried and determined according to the destination IP address in the packet data and the load balancing algorithm, and then the destination IP address for packet forwarding is determined based on the real server.

[0061] S3, Generate new session connection data: Based on the session connection table structure and the packet data, determine the destination IP address, data outgoing network interface, source IP address and source port for packet forwarding, generate new session connection data, update the session connection table, and then forward the packet data based on the new session connection data.

[0062] In this embodiment, step S3, which involves determining the destination IP address, data outgoing network interface, source IP address, and source port for packet forwarding based on the session connection table structure and the packet data, and generating new session connection data, includes the step of determining the data outgoing interface, specifically:

[0063] Based on the load balancer, a route lookup is performed on the routing table stored on the load balancer according to the destination IP address of the packet, and the data flow outgoing network interface of the packet is determined according to the route lookup result.

[0064] S311, according to the destination IP address of the message, check the routing table of the policy route stored on the load balancer. If there is an address in the routing table of the policy route that is the same as the destination IP address of the message, then the outgoing interface of the policy route is used as the data outgoing network interface for message forwarding, and the data outgoing network interface for message forwarding and the message data are recorded in the session record table where the slot number is equal to the hash value of the message. If there is no address in the routing table of the policy route that is the same as the destination IP address of the message, then jump to step S312.

[0065] S312, according to the destination IP address of the message, check the routing table of the directly connected routes stored on the load balancer. If there is an address in the routing table of the directly connected routes that is the same as the destination IP address of the message, then the outgoing interface of the directly connected route is used as the data outgoing network interface for message forwarding, and the data outgoing network interface for message forwarding and the message data are both recorded in the session record table where the slot number is equal to the hash value of the message. If there is no address in the routing table of the directly connected routes that is the same as the destination IP address of the message, then jump to step S313.

[0066] S313, based on the destination IP address of the message, check the routing table of the dynamic route stored on the load balancer. If there is an address in the routing table of the dynamic route that is the same as the destination IP address of the message, then the outgoing interface of the dynamic route is used as the data outgoing network interface for message forwarding, and the data outgoing network interface for message forwarding and the message data are both recorded in the session record table where the slot number is equal to the hash value of the message.

[0067] Each load balancer has a routing table, and the routing type corresponds one-to-one with the routing table type. The routing types include policy routing, static routing, and dynamic routing.

[0068] In this embodiment, step S3, which involves determining the destination IP address, data outgoing network interface, source IP address, and source port for packet forwarding based on the session connection table structure and the packet data, and generating new session connection data, further includes a step of determining the source address and source port, specifically:

[0069] Based on the source address translation strategy configured by the load balancer and virtual service type, a source IP address and source port are assigned to the packet. The assigned source IP address and source port are used to update the source IP address and source port of the packet forwarding in the session record table. At the same time, the assigned source IP address and source port are encapsulated with the packet data to obtain new session connection data.

[0070] The new session connection data includes address family, protocol number, destination IP address, destination port, assigned source IP address and source port, as well as data outflow network interface and data inflow network interface.

[0071] In this embodiment, step S3, the step of forwarding the packet data according to the new session connection data, further includes:

[0072] The hash value of the message is calculated based on the address family, protocol number, source IP address, and source port in the message data and stored in the hash value linked list. The message is then forwarded using new session connection data.

[0073] To enable those skilled in the art to better understand the above-mentioned technical solutions provided by the present invention, examples are provided to supplement the explanation of the above-mentioned technical solutions, such as... Figure 3 As shown.

[0074] To achieve the above design, ensure data source inflow and outflow, and improve device performance, a session connection table mechanism was designed through experiments. As shown in Table 1, the five-tuple data of the packet (prototype, source IP, source port, destination IP, destination port) is recorded in the table. Simultaneously, the physical interfaces of the incoming and outgoing devices are also recorded in the table. When a packet returns, a fast hash lookup is performed to locate the connection table, and then the physical interface from which the packet entered is retrieved. The packet is then sent back from that interface, thus ensuring data source inflow and outflow.

[0075] Table 1

[0076]

[0077] Load balancing mainly refers to server load balancing, or SLB. Typically, a load balancer provides a virtual service (VS). Client requests to VS are routed by the load balancer to the backend real server (RS). Specific implementation methods are as follows:

[0078] 1. After receiving data from the network card, the system first calculates the hash value based on the packet's address family, protocol number, source IP address (SRC-IP), and source port (SRC-Port). This determines the slot in the connection table to be queried. The system then iterates through the connection table in that slot, checking if the packet's address family, protocol number, source IP address (SRC-IP), source port (SRC-Port), destination IP address (Destination IP Address), and destination port (Destination Destination Port) are equal to determine if an existing session connection is found. If the query is successful, the data packet is encapsulated according to the corresponding SNAT IP address (Source Network Address Translation IP Address), SNAT port (Source Network Address Translation Port), destination IP address (Destination IP Address), and destination port (Destination Port) in the session connection table. The data is then forwarded according to the device's outgoing or incoming interface recorded in the connection table. If no connection table is found, the system enters the prerouting process (pre-routing or before routing) and creates the session connection table according to the following steps.

[0079] The hash value calculated by the hash function is the slot number. The session connection table is attached to each slot number. First, the slot number where the connection table is located is determined, and then the session connection table is searched under that slot. The slot is the parent slot where the connection table is attached.

[0080] Address families are classification standards used in network programming to identify different network protocols. They are mainly divided into the following three categories:

[0081] 1) AF_INET (IPv4), based on Internet Protocol version 4 (IPv4), uses 32-bit addresses, adopts dotted decimal notation (e.g., 192.168.1.1), and supports cross-host network communication.

[0082] 2) AF_INET6 (IPv6), corresponding to Internet Protocol version 6 (IPv6), uses 128-bit addresses and adopts colon-separated hexadecimal format (e.g., 2001:db8::1). It aims to solve the IPv4 address exhaustion problem and gradually replace IPv4.

[0083] 3) AF_UNIX (Unix domain socket) is used for inter-process communication (IPC) within the same host. It is identified by a file path (such as / tmp / my_socket) and does not require the intervention of a network protocol stack.

[0084] Other address families such as AF_APPLETALK (AppleTalk protocol) and AF_IPX (IPX protocol) are used less frequently.

[0085] 2. **[Destination IP Confirmation]** The prerouting process, before route selection, first queries the specific virtual service type (SLB, or Server Load Balancing) for the destination address of the packet. The virtual service type acts as a proxy for the backend real servers, and each virtual service type corresponds to a set of backend real servers. Based on the load balancing algorithm, the virtual service schedules traffic to the backend real servers. Once the real servers are determined according to the algorithm, the destination IP of the packet is confirmed, which is also known as DNAT. At this point, the prerouting process ends, and the route selection process begins.

[0086] Load balancing employs various scheduling algorithms, which are configured by the user, such as address round-robin, least connections, and shortest response time.

[0087] 3. **[Determining the Outgoing Network Interface for Data]** The routing process involves selecting a route. After confirming the destination IP in the previous process, this process checks if there is a route to that destination address on the device, i.e., whether the network is reachable. During route selection, policy-based routes are queried first. If no match is found, static routes are queried, then directly connected routes, and finally dynamic routes. Once the correct route is found, the outgoing interface of the route is recorded in the session connection table, and the outgoing interface of the packet data is updated to that interface, ensuring that data is forwarded from the correct interface. After completing the route lookup, the postrouting process begins.

[0088] Each device has a routing table, and routes are queried based on the stored table; different types of routes have different tables; thus, policy routes, static routes, and dynamic routes are distinguished; the previous attribute of a route is the outgoing interface.

[0089] 4. **[Source Address and Source Port Confirmation]** Postrouting is a data processing step performed after route selection. After the first two processes determine the destination address and outgoing interface of the packet, ensuring its correct forwarding, the source address and source port are still required. This process completes this step. Each virtual service type is configured with an SNAT policy, i.e., a source address translation method. Source address translation methods typically include keeping the source port, round-robin IP address translation, and least connections. The virtual service assigns a source address and port to the data stream according to the method and records the source address and port in the connection table. Simultaneously, it performs source address encapsulation of the data packet, i.e., filling in the source IP address and source port.

[0090] 5. After the above three steps are completed, the information of the session connection table has been collected. The session connection table is created with this information, and the hash value is calculated according to the address family, protocol number, src-ip, and src-port of the packet and placed into the corresponding hash chain. After that, the data is forwarded according to the connection table. When a subsequent packet comes in, it will directly hit the connection table for fast data forwarding.

[0091] By applying the above technical solutions, a session connection table structure is defined based on the five-tuple data of the packet, as well as the physical interfaces of the incoming and outgoing devices. The session connection table is then created and initialized according to this structure. Based on a load balancer, packet data is received in real-time via the network interface card (NIC). The packet data is then traversed and queried according to the session connection table to determine the query result. If the query is successful, the packet data is forwarded based on the query result. If the query fails, the destination IP address and data flow for packet forwarding are determined based on the session connection table structure and the packet data. The system identifies the network interface, source IP address, and source port, generates new session connection data, updates the session connection table, and then forwards the packet data based on the new session connection data. This system, based on a load balancing device and a created session connection table and hash value linked list, enables real-time reception of packet data via the network card, and performs traversal, querying, processing, and forwarding of the packet data. This solves the technical problem of slow access speed or service interruption caused by inconsistent return paths in existing technologies, thereby ensuring the continuity of packet data source input and output and service, and improving the access speed of the load balancing system and the performance of the load balancing device.

[0092] In addition, the technical solution of the present invention has high computational search efficiency. After the result is found, it is sent directly out from the interface without occupying extra space, and only increases the data inflow and outflow interfaces.

[0093] Corresponding to the load balancing method supporting data source input and output described in one embodiment of the present invention, the present invention also discloses a load balancing device supporting data source input and output, such as... Figure 4 As shown, the device includes a connection table initialization unit, a message data forwarding processing unit, and a session connection data generation unit;

[0094] in,

[0095] The connection table initialization unit is used to define and initialize the session connection table: define the session connection table structure according to the five-tuple data of the packet, as well as the physical interface of the packet's inflow device and the physical interface of the outflow device, and create and initialize the session connection table according to the session connection table structure, wherein the five-tuple data includes the protocol number, source IP address, source port, destination IP address and destination port;

[0096] The message data forwarding processing unit is used for message data forwarding processing: based on the load balancing device, it receives message data in real time through the network card, and performs traversal query processing on the message data according to the session connection table to determine the traversal query result. If the query is successful, the message data is forwarded according to the traversal query result. If the query fails, it jumps to step S3.

[0097] The session connection data generation unit is used to generate new session connection data: based on the session connection table structure and the packet data, it determines the destination IP address, data outgoing network interface, source IP address and source port for packet forwarding, generates new session connection data, updates the session connection table, and then forwards the packet data based on the new session connection data.

[0098] The various embodiments in this specification are described in a related manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.

[0099] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A load balancing method supporting both inbound and outbound data sources, characterized in that, The method includes: S1, Define and initialize the session connection table: Define the session connection table structure based on the five-tuple data of the packet, as well as the physical interface of the incoming device and the physical interface of the outgoing device, and create and initialize the session connection table according to the session connection table structure. The five-tuple data includes the protocol number, source IP address, source port, destination IP address and destination port. S2, Packet data forwarding processing: Based on the load balancing device, packet data is received in real time through the network card, and the packet data is traversed and queried according to the session connection table to determine the traversal query result. If the query is successful, the packet data is forwarded according to the traversal query result. If the query fails, the process jumps to step S3. S3, Generate new session connection data: Based on the session connection table structure and the packet data, determine the destination IP address, data outgoing network interface, source IP address and source port for packet forwarding, generate new session connection data, update the session connection table, and then forward the packet data based on the new session connection data.

2. The method as described in claim 1, characterized in that, The session connection table structure includes address family, protocol number, source IP address, source port, source MAC address, destination IP address, destination port, destination MAC address, data inflow network interface, data outflow network interface, source network address translation IP address, and source network address translation port; The message data includes the address family and the quintuple data.

3. The method as described in claim 1, characterized in that, In step S1, the step of creating and initializing the session connection table based on the session connection table structure includes: After the session connection table is created, the five-tuple data of the existing packets in the load balancing system, as well as the address family, source network address translation IP address, source network address translation port, data inflow network interface, and data outflow network interface are written into the session connection table. The hash value is calculated based on the address family, protocol number, source IP address, and source port in the session connection table. The slot number of the session connection table is determined based on the calculated hash value, and the calculated hash value is recorded in the hash value linked list, thereby completing the initialization of the session connection table. The value of the slot number where the session connection table is located is equal to the hash value calculated based on the address family, protocol number, source IP address and source port in the session connection table. The hash value linked list needs to be created in advance to store the hash values ​​calculated based on the address family, protocol number, source IP address, and source port.

4. The method as described in claim 1, characterized in that, In step S2, the step of receiving packet data in real time through the network card based on the load balancing device and performing traversal query processing on the packet data according to the session connection table further includes: S21, based on the load balancing device, receives packet data in real time through the network card and calculates the hash value of the packet based on the address family, protocol number, source IP address and source port in the packet data; S22, determine the slot where the session connection table is located based on the hash value of the obtained message, the hash value linked list, and the slot number of the session connection table, and traverse and query all session connection tables in the determined slot. If there is a record in the session connection table that is the same as the address family, protocol number, source IP address, source port, destination IP address, and destination port in the message data, the query is successful. Obtain and encapsulate the source network address translation IP address, source network address translation port, destination IP address, and destination port from the same record in the session connection table into the message data, and use the data in the record to flow into the network interface or flow out of the network interface to forward the message data. If there is no record in the session connection table that matches the protocol number, source IP address, source port, destination IP address, and destination port in the message data, the query fails and proceeds to step S3.

5. The method as described in claim 1, characterized in that, In step S3, the step of determining the destination IP address, data outgoing network interface, source IP address, and source port of the packet forwarding based on the session connection table structure and the packet data, and generating new session connection data, includes the step of confirming the destination IP address of the packet, specifically as follows: Based on the load balancing device, the real server is queried and determined according to the destination IP address in the packet data and the load balancing algorithm, and then the destination IP address for packet forwarding is determined based on the real server.

6. The method as described in claim 5, characterized in that, In step S3, the step of determining the destination IP address, data outgoing network interface, source IP address, and source port for packet forwarding based on the session connection table structure and the packet data, and generating new session connection data, includes the step of determining the data outgoing interface, specifically: Based on the load balancer, a route lookup is performed on the routing table stored on the load balancer according to the destination IP address of the packet, and the data flow outgoing network interface of the packet is determined according to the route lookup result. S311, according to the destination IP address of the message, check the routing table of the policy route stored on the load balancer. If there is an address in the routing table of the policy route that is the same as the destination IP address of the message, then the outgoing interface of the policy route is used as the data outgoing network interface for message forwarding, and the data outgoing network interface for message forwarding and the message data are recorded in the session record table where the slot number is equal to the hash value of the message. If there is no address in the routing table of the policy route that is the same as the destination IP address of the message, then jump to step S312. S312, according to the destination IP address of the message, check the routing table of the directly connected routes stored on the load balancer. If there is an address in the routing table of the directly connected routes that is the same as the destination IP address of the message, then the outgoing interface of the directly connected route is used as the data outgoing network interface for message forwarding, and the data outgoing network interface for message forwarding and the message data are both recorded in the session record table where the slot number is equal to the hash value of the message. If there is no address in the routing table of the directly connected routes that is the same as the destination IP address of the message, then jump to step S313. S313, based on the destination IP address of the message, check the routing table of the dynamic route stored on the load balancer. If there is an address in the routing table of the dynamic route that is the same as the destination IP address of the message, then the outgoing interface of the dynamic route is used as the data outgoing network interface for message forwarding, and the data outgoing network interface for message forwarding and the message data are both recorded in the session record table where the slot number is equal to the hash value of the message. Each load balancer has a routing table, and the routing type corresponds one-to-one with the routing table type. The routing types include policy routing, static routing, and dynamic routing.

7. The method as described in claim 6, characterized in that, In step S3, the step of determining the destination IP address, data outgoing network interface, source IP address, and source port for packet forwarding based on the session connection table structure and the packet data, and generating new session connection data, further includes the step of determining the source address and source port, specifically: Based on the source address translation strategy configured by the load balancer and virtual service type, a source IP address and source port are assigned to the packet. The assigned source IP address and source port are used to update the source IP address and source port of the packet forwarding in the session record table. At the same time, the assigned source IP address and source port are encapsulated with the packet data to obtain new session connection data. The new session connection data includes address family, protocol number, destination IP address, destination port, assigned source IP address and source port, as well as data outflow network interface and data inflow network interface.

8. The method as described in claim 7, characterized in that, In step S3, the step of forwarding the packet data based on the new session connection data further includes: The hash value of the message is calculated based on the address family, protocol number, source IP address, and source port in the message data and stored in the hash value linked list. The message is then forwarded using new session connection data.

9. An apparatus for implementing the load balancing method for supporting data source input and output as described in claim 1, characterized in that, The device includes a connection table initialization unit, a message data forwarding and processing unit, and a session connection data generation unit; in, The connection table initialization unit is used to define and initialize the session connection table: define the session connection table structure according to the five-tuple data of the packet, as well as the physical interface of the packet's inflow device and the physical interface of the outflow device, and create and initialize the session connection table according to the session connection table structure, wherein the five-tuple data includes the protocol number, source IP address, source port, destination IP address and destination port; The message data forwarding processing unit is used for message data forwarding processing: based on the load balancing device, it receives message data in real time through the network card, and performs traversal query processing on the message data according to the session connection table to determine the traversal query result. If the query is successful, the message data is forwarded according to the traversal query result. If the query fails, it jumps to step S3. The session connection data generation unit is used to generate new session connection data: based on the session connection table structure and the packet data, it determines the destination IP address, data outgoing network interface, source IP address and source port for packet forwarding, generates new session connection data, updates the session connection table, and then forwards the packet data based on the new session connection data.

Citation Information

Patent Citations

  • Load balancing method and device

    CN107864101A

  • Load balance-based message forwarding method and device, storage medium and equipment

    CN108667730A

  • Message forwarding method and device

    CN112788116A

  • Data forwarding method and device based on DPDK

    CN116170404A

  • Method and device based on gateway equipment load balancing and electronic equipment

    CN119520410A