A data transmission method and apparatus
By deploying front-end devices in front of the server cluster, and using network tunneling protocols to process load balancer packets and forward them to the target server, the problem of servers not supporting network tunneling protocols is solved, enabling flexible server deployment and efficient data transmission.
Patent Information
- Application Number
- CN202310343886.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-03
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2043-04-03
AI Technical Summary
Some servers do not support network tunneling protocols and cannot use L4 load balancing technology for data transmission, resulting in their inability to respond to client requests. Furthermore, adding a network tunneling protocol processing module is costly.
A front-end device is deployed in front of the server cluster. The front-end device acts as a bridge between the server cluster and the load balancer. It uses a network tunneling protocol to process packets from the load balancer, sets the destination MAC address of the request data packet to the MAC address of the target server, and forwards it to the target server.
This solves the problem of servers not supporting network tunneling protocols, improves the flexibility of server deployment, eliminates the need to deploy the load balancer and server on the same local area network, and the target server only needs to have a standard Internet Protocol processing module to respond to requests.
Smart Images

Figure CN118784401B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of communication technology, and in particular to a data transmission method and apparatus. Background Technology
[0002] The rapid development of the Internet has led to a surge in the number of accesses to multimedia network servers. However, the limited central processing unit (CPU) and input / output (I / O) resources of a single server cannot meet the demands of a large number of concurrent accesses. Therefore, clusters of multiple servers are currently used to jointly provide services to clients. Load balancing technology refers to a technique that distributes traffic across different servers in a cluster using a balancing algorithm when dealing with high concurrency traffic from user requests to the server. Among them, Layer 4 (L4) load balancing technology is a load balancing technique based on the five-tuple of data packets (source IP address, destination IP address, source port, destination port, and transport layer protocol), operating at OSI Layer 4, the transport layer. L4 load balancing works by deploying a load balancer in front of a server cluster. The load balancer receives request packets from external clients, uses a balancing algorithm to determine which server in the cluster to forward the request to, and then encapsulates the packets using network tunneling protocols (such as IP tunneling and Virtual eXtensible Local Area Network, VXLAN) before sending them to the designated server. See also: Figure 1 A schematic diagram of a system architecture for L4 load balancing technology.
[0003] However, some servers do not support network tunneling protocols (such as servers running Windows), and therefore cannot process packets from the load balancer, thus failing to respond to client requests. Adding network tunneling protocol processing modules to all servers that do not support it would be prohibitively costly. Therefore, how to use L4 load balancing technology for data transmission on servers that do not support network tunneling protocols is a problem that urgently needs to be solved. Summary of the Invention
[0004] This application provides a data transmission method and apparatus to solve the problem that some servers do not support network tunneling protocols and therefore cannot use L4 load balancing technology for data transmission.
[0005] In a first aspect, embodiments of this application provide a data transmission method, the method being applied to a front-end device, the front-end device connecting to multiple servers in a server cluster, the method comprising:
[0006] The load balancer sends a first request data packet; the first request data packet is obtained by the load balancer encapsulating a second request data packet using a network tunneling protocol, and the second request data packet comes from the client;
[0007] The target server is determined from the plurality of servers based on the destination IP address of the first request data packet, and the first request data packet is decapsulated using a network tunneling protocol to obtain the second request data packet;
[0008] The destination MAC address in the header of the second request data packet is set to the MAC address of the target server to obtain the third request data packet;
[0009] The third request data packet is sent to the target server.
[0010] In some embodiments, the method further includes:
[0011] Based on the pre-stored IP address mapping relationship, determine the IP address of the target server corresponding to the destination IP address;
[0012] The MAC address of the target server corresponding to the IP address of the target server is determined using the Address Resolution Protocol (ARP).
[0013] In some embodiments, the target server is a server determined by the load balancer from the server cluster to receive the first request data packet using a load balancing algorithm; the destination IP address is the IP address corresponding to the target server obtained by the load balancer from multiple IP addresses of the stored front-end device when it determines that the target server does not support the network tunneling protocol.
[0014] In some embodiments, the load balancer stores a mapping relationship between multiple IP addresses of a front-end device and multiple IP addresses of servers connected to the front-end device, and the destination IP address is the IP address of the front-end device corresponding to the IP address of the target server, as determined by the load balancer based on the mapping relationship.
[0015] In some embodiments, the method further includes:
[0016] Record the correspondence between the destination IP address and the MAC address of the target server.
[0017] In some embodiments, setting the destination MAC address in the header of the second request data packet to the MAC address of the target server specifically includes:
[0018] Determine whether the header of the second request data packet includes the destination MAC address;
[0019] If the header of the second request data packet includes a destination MAC address, then the destination MAC address in the header of the second request data packet is modified to the MAC address of the target server;
[0020] If the header of the second request data packet does not include the destination MAC address, then the MAC address of the target server is added to the header of the second request data packet as the destination MAC address of the second request data packet.
[0021] In some embodiments, the method further includes:
[0022] Set the source MAC address in the header of the second request data packet to the MAC address of the front-end device.
[0023] Secondly, embodiments of this application provide a data transmission apparatus, which is a front-end device, or the apparatus is applied to a front-end device. The apparatus connects to multiple servers included in a server cluster, and the apparatus includes:
[0024] A communication unit is used to receive a first request data packet sent by the load balancer; the first request data packet is obtained by the load balancer encapsulating a second request data packet using a network tunneling protocol, and the second request data packet comes from the client;
[0025] The processing unit is configured to determine the target server from the plurality of servers based on the destination IP address of the first request data packet, and to decapsulate the first request data packet using a network tunneling protocol to obtain the second request data packet;
[0026] The processing unit is further configured to set the destination MAC address in the header of the second request data packet to the MAC address of the target server, thereby obtaining a third request data packet;
[0027] The communication unit is also used to send the third request data packet to the target server.
[0028] In some embodiments, the processing unit is further configured to:
[0029] Based on the pre-stored IP address mapping relationship, determine the IP address of the target server corresponding to the destination IP address;
[0030] The MAC address of the target server corresponding to the IP address of the target server is determined using the Address Resolution Protocol (ARP).
[0031] In some embodiments, the target server is a server determined by the load balancer from the server cluster to receive the first request data packet using a load balancing algorithm; the destination IP address is the IP address corresponding to the target server obtained by the load balancer from multiple IP addresses of the stored front-end device when it determines that the target server does not support the network tunneling protocol.
[0032] In some embodiments, the load balancer stores a mapping relationship between multiple IP addresses of a front-end device and multiple IP addresses of servers connected to the front-end device, and the destination IP address is the IP address of the front-end device corresponding to the IP address of the target server, as determined by the load balancer based on the mapping relationship.
[0033] In some embodiments, the processing unit is further configured to:
[0034] Record the correspondence between the destination IP address and the MAC address of the target server.
[0035] In some embodiments, the processing unit is specifically used for:
[0036] Determine whether the header of the second request data packet includes the destination MAC address;
[0037] If the header of the second request data packet includes a destination MAC address, then the destination MAC address in the header of the second request data packet is modified to the MAC address of the target server;
[0038] If the header of the second request data packet does not include the destination MAC address, then the MAC address of the target server is added to the header of the second request data packet as the destination MAC address of the second request data packet.
[0039] In some embodiments, the processing unit is further configured to:
[0040] Set the source MAC address in the header of the second request data packet to the MAC address of the front-end device.
[0041] Thirdly, an electronic device is provided, comprising a controller and a memory. The memory stores computer-executable instructions, and the controller executes the computer-executable instructions in the memory to perform operational steps of any possible implementation of the method of the first aspect using hardware resources in the controller.
[0042] Fourthly, a computer-readable storage medium is provided, which stores instructions that, when executed on a computer, cause the computer to perform the methods described above.
[0043] This application proposes deploying a front-end device before the server cluster. This front-end device acts as a bridge between the server cluster and the load balancer. The front-end device can process packets from the load balancer and forward them to the servers using network tunneling protocols, allowing the servers to directly process packets using standard Internet protocols. This solution addresses the issue of some existing servers not supporting network tunneling protocols and eliminates the need to deploy the load balancer and servers on the same local area network, thus improving the flexibility of server deployment. Attached Figure Description
[0044] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0045] Figure 1 A schematic diagram of a system architecture for L4 load balancing technology;
[0046] Figure 2 This is a schematic diagram of a load balancing system architecture based on direct routing.
[0047] Figure 3 This is a schematic diagram of a load balancing system architecture based on address translation.
[0048] Figure 4 This is a schematic diagram of a load balancing system architecture based on tunneling technology.
[0049] Figure 5 A schematic diagram of a communication system architecture provided in an embodiment of this application;
[0050] Figure 6 A flowchart illustrating a data transmission method provided in an embodiment of this application;
[0051] Figure 7 A schematic diagram of the architecture of a front-end device provided in an embodiment of this application;
[0052] Figure 8 A flowchart illustrating another data transmission method provided in an embodiment of this application;
[0053] Figure 9 This is a schematic diagram of the structure of a data transmission device provided in an embodiment of this application;
[0054] Figure 10 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of this application will be clearly and completely described below with reference to the accompanying drawings of the embodiments of this application. Obviously, the described embodiments are only some embodiments of the technical solutions of this application, and not all embodiments. Based on the embodiments recorded in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the technical solutions of this application.
[0056] The terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in sequences other than those illustrated or described herein.
[0057] A server cluster refers to the combined operation of multiple servers to provide services, thereby improving the overall processing performance of the server cluster. This application addresses how to perform data transmission while maintaining load balancing across multiple servers in a server cluster. Currently, there are many load balancing technologies, primarily including: Domain Name System (DNS) load balancing, Layer 7 load balancing, and L4 load balancing.
[0058] DNS-based load balancing refers to configuring the same domain name for multiple server addresses in the DNS. Therefore, clients querying this domain name will receive one of the addresses, allowing different clients to access different servers, thus achieving load balancing. DNS load balancing eliminates the need to develop and maintain load balancing equipment, making it simple and low-cost to implement, and it offloads the load balancing work to the DNS server, saving management costs. However, DNS is unaware of the actual load of each server, making on-demand allocation impossible. Furthermore, DNS supports fewer algorithms and has a simpler traffic allocation strategy, which can easily lead to uneven scheduling and coarse granularity. Additionally, the latency in synchronizing server addition, modification, or failover information to the DNS server is significant, causing user access failures. Layer 7 load balancing is based on virtual Uniform Resource Locators (URLs) or host network protocol (IP) addresses, achieving load balancing through application layer protocols. For example, Nginx load balancing technology operates at Layer 7 (the application layer) in the network hierarchy. Nginx establishes a connection with the client (handshake) and then flexibly distributes requests to different servers based on the client's request information and local configuration information. While Layer 7 load balancing can achieve load balancing between servers, it requires establishing a connection with the client, resulting in lower efficiency.
[0059] To address the aforementioned issues, L4 load balancing technology has been proposed. L4 load balancing is a load balancing technology based on network tunneling protocols. Network tunneling protocols mainly include IP tunneling and VXLAN. IP tunneling is a technology that encapsulates one IP packet into another, allowing data packets destined for one IP address to be encapsulated and forwarded to another IP address. IP tunneling technology can also be called IP encapsulation technology. VXLAN introduces an outer tunnel in User Datagram Protocol (UDP) format as the data link layer, with the original data packet content transmitted as the tunnel payload. In other words, the outer tunnel of the IP tunneling protocol is at the network layer 3—application layer, while the outer tunnel of the VXLAN protocol is at the network layer 2—data link layer. Therefore, compared to IP tunneling, VXLAN can achieve cross-regional Layer 2 interconnection. L4 load balancing mainly includes three working modes: Network Address Translation (NAT), Direct Routing (DR), and Tunneling (TUN). The following is an introduction to these three working modes.
[0060] The architecture of the DR working mode can be found in [reference]. Figure 2 In DR mode, the load balancer (LB) receives data packets by modifying the destination MAC address and configuring a server-visible loopback adaptor (LO) network interface card (NIC) address on the server. The LO NIC is a special network interface located on the server, not connected to any actual device, used for communication between processes within the same server. Multiple IP addresses can be configured on the LO NIC. The specific process in DR mode is as follows: Step 1: The client sends a request data packet to the LB. Here, the source IP address of the request data packet is defined as CIP, the destination IP address as the LB's Virtual IP (VIP), the source MAC address as CMAC, and the destination MAC address as VMAC. Step 2: The LB receives the request data packet, determines the target server to be forwarded from the server cluster according to the load balancing algorithm, modifies the destination MAC address in the packet header to the target server's MAC address (defined as RMAC), and modifies the source MAC address to the MAC address corresponding to the IP address of the LB in the same network segment as the target server (defined as DMAC). Step 3: The LB sends the request data packet with the modified MAC address to the target server. Step four: The target server receives the request data packet and determines that the destination MAC address of the packet is its own network interface card (NIC) address and the destination IP address is the VIP configured in the LO NIC. It then parses the request data packet to obtain the data and performs corresponding business processing to obtain the response data packet. Using the VIP as the source IP and the CIP as the destination IP, the response data packet is sent to the client, completing the request-response process.
[0061] DR (Direct Routing) mode forwards client request packets to the server directly, and the server returns the response information directly to the client without going through LB (Load Balancer). This is highly efficient and involves minimal modification to the packets, ensuring the integrity of the packet information. However, because LB sends request packets directly to the server at the data link layer, LB and the server must be on the same local area network (LAN). Therefore, servers in a server cluster cannot be deployed across data centers. Additionally, the server must be configured with a LO (Local Outline) network interface card (NIC).
[0062] For the system architecture of NAT working mode, please refer to Figure 3In NAT mode, client request packets are sent directly to the Load Balancer's (LB) VIP. The LB uses Network Address Translation (NAT) to modify the destination IP address of the request packet to the target server's address, thus forwarding the request packet to the target server for processing. The specific process is as follows: Step 1: The client sends a request packet to the LB. Here, the source IP address of the request packet is defined as CIP, and the destination IP address is the LB's VIP. Step 2: The LB receives the request packet, parses the IP address in the packet header, modifies the destination IP address to the target server's IP address (defined as RIP), and sends the modified request packet to the target server. The target server is determined by the LB using a load balancing algorithm. Step 3: After the target server confirms that the destination IP address of the received request packet is its own IP address, it can parse the request packet and generate a response packet. Step 4: The target server sends the response packet to the LB. Since the gateway device configured in the target server is the LB, the target server will send the response packet to the LB. Step 5: The LB forwards the response packet to the client.
[0063] NAT mode places low demands on the server, requiring only the handling of standard Internet transport layer protocols. However, because all request and response packets must pass through the load balancer (LB), and the LB also needs to perform address translation, this results in a significant load on the LB.
[0064] The system architecture for TUN operating mode can be found in [reference]. Figure 4 Similar to DR mode, TUN mode requires configuring the server with a server-only visible LO (Local Address) NIC address to receive data packets. Unlike DR mode, which modifies the MAC address, TUN mode re-encapsulates the original data packet before sending it to the target server. The specific process is as follows: Step 1, the client sends a request data packet to the LB (Load Balancer). Here, the source IP address of the request data packet is defined as CIP, and the destination IP address is the LB's VIP (Virtual IP). Step 2, the LB receives the request data packet and encapsulates it using the network tunneling protocol, adding a tunnel header (where the source IP is DIP and the destination IP is RIP), and then sends the re-encapsulated request data packet to the target server. Step 3, after receiving the request data packet, the target server first decapsulates it using the network tunneling protocol, then decapsulates it again using the standard Internet Protocol (IP), and finally generates a response data packet to return to the client.
[0065] TUN mode places less load on the load balancer, but because upper-layer applications cannot parse network tunneling protocols, all servers need to have network tunneling protocol processing modules, which places higher demands on the servers.
[0066] To address the aforementioned issues, this application proposes a data transmission scheme. Under the TUN (Transfer-Under-Task) mode of L4 load balancing technology, a front-end device is deployed before the server cluster. This front-end device uses a network tunneling protocol to initially decapsulate packets from the LB (Load Balancer), sets the destination MAC address of the request data packet to the MAC address of the target server, and finally sends the processed request data packet to the target server. Thus, the target server only needs a standard Internet Protocol (IP) processing module to respond to requests.
[0067] To facilitate understanding of the solution presented in this application, the communication system used in this application will first be described. See [link to relevant documentation]. Figure 5 This is a schematic diagram of the architecture of a communication system provided in an embodiment of this application. It should be understood that the embodiments of this application are not limited to... Figure 5 In the system shown, in addition, Figure 5 The device in the document can be hardware, software defined by function, or a combination of both. For example... Figure 5 As shown, the communication system includes clients, load balancers, front-end devices, and a server cluster. The server cluster can include two types of servers: the first type supports network tunneling protocols, such as servers running the Linux system. Figure 5 Servers A and B are categorized as the first type of server; the second type consists of servers that do not support network tunneling protocols, such as servers using the Windows operating system. Figure 5 Servers C and D are designated as the second type of servers.
[0068] For example, a client is a terminal device used by a user, which may be called a mobile station (MS), mobile terminal (MT), etc. It is a device that provides voice and / or data connectivity to the user, such as a handheld device with wireless connectivity, in-vehicle equipment, etc. Currently, some examples of terminals include: mobile phones, tablets, laptops, PDAs, mobile internet devices (MID), wearable devices, virtual reality (VR) devices, augmented reality (AR) devices, wireless terminals in industrial control, wireless terminals in self-driving, wireless terminals in remote medical surgery, wireless terminals in smart grids, wireless terminals in transportation safety, wireless terminals in smart cities, wireless terminals in smart homes, etc.
[0069] Figure 5 A load balancer can be a standalone server, processor, or processing chip, or it can be integrated into a gateway device, such as a switch. The load balancer employs load balancing algorithms to distribute client requests among the servers in the server cluster, ensuring balanced load across all servers. Figure 5 The front-end device shown can also be a standalone server, processor, or processing chip. As a bridge between the load balancer and the second type of servers in the server cluster, the front-end device processes request packets from the load balancer using a network tunneling protocol and forwards the processed request packets to the second type of servers.
[0070] It should be noted that, Figure 5 This application is merely an illustrative description and does not limit the number of servers, front-end devices, or clients included in the communication system. Optionally, a front-end device can simultaneously provide data packet processing services to multiple Type II servers.
[0071] Below, in conjunction with Figure 5 The system shown provides a detailed description of the solution in this application. See also... Figure 6 This is a schematic flowchart illustrating a data transmission method provided in an embodiment of this application. Exemplarily, Figure 6 The process shown can be... Figure 5The system shown includes front-end devices for execution. Figure 6 The multiple servers involved are Figure 5 The system shown includes the second type of server. Figure 6 The method flow shown specifically includes:
[0072] 601, Receive the first request packet from the load balancer.
[0073] In this application, the first request data packet is obtained by the load balancer decapsulating the second request data packet using a network tunneling protocol. The second request data packet originates from the client. That is, the client can generate request information and encapsulate it using a standard internet transmission protocol, such as Transmission Control Protocol / Internet Protocol (TCP / IP), to obtain the second request data packet, which is then sent to the load balancer. Upon receiving the second request data packet, the load balancer can use a load balancing algorithm to determine the target server from the server cluster. Based on the stored IP address and MAC address of the target server, it then encapsulates the second request data packet using a network tunneling protocol to obtain the first request data packet, which is then sent to the front-end device. It should be noted that in this application, since the target server is a type II server, the IP address of the target server stored by the load balancer is one of multiple IP addresses of the front-end device, and the MAC address of the target server stored is one of multiple MAC addresses of the front-end device.
[0074] 602. Determine the target server from multiple servers based on the destination IP address of the first request data packet, and use a network tunneling protocol to decapsulate the first request data packet to obtain the second request data packet.
[0075] Among them, multiple servers are the aforementioned Figure 5 The system shown includes the second type of server.
[0076] For example, after receiving the first request data packet, the front-end device can determine whether the first request data packet was sent correctly based on whether the destination IP address in the header of the first request data packet is its own IP address. For instance, if the front-end device determines that the destination IP address of the first request data packet is not the IP address configured for its own machine, the front-end device can discard the first request data packet; if it determines that the destination IP address of the first request data packet is the IP address configured for its own machine, the front-end device can parse the first request data packet.
[0077] The front-end device can have multiple local IP addresses, and the number of IP addresses corresponds to the number of servers the front-end device is connected to. For example...Figure 5 In the system shown, the front-end device connects to two Class II servers (Server C and Server D). Therefore, it can be configured with two local IP addresses. The IP addresses of Server C and Server D recorded in the load balancer are both the front-end device's local IP addresses. Thus, any data packet destined for either of these two local IP addresses will be transmitted to the front-end device. Optionally, the front-end device can also store a mapping between its local IP address and the actual IP addresses of the servers. For example, the configured local IP addresses can include "IP address C" corresponding to the actual IP address of Server C, and "IP address D" corresponding to the actual IP address of Server D. Correspondingly, the IP address of Server C stored in the load balancer is not the actual IP address of Server C, but rather the local IP address configured in the front-end device, i.e., "IP address C". Similarly, the IP address of Server D stored in the load balancer is the local IP address configured in the front-end device, i.e., "IP address D". Therefore, when the load balancer determines that the target server is Server C, it will encapsulate the second request data packet using "IP address C", which is precisely the local IP address configured in the front-end device. Thus, the encapsulated data packet will be received by the front-end device.
[0078] 603, set the destination MAC address in the header of the second request packet to the MAC address of the target server, and obtain the third request packet.
[0079] For example, after determining the actual IP address of the target server in step 604, the front-end device can determine the MAC address of the target server corresponding to the actual IP address of the target server according to the Address Resolution Protocol (ARP), thereby setting the destination MAC address in the header of the second request data packet to the MAC address of the target server.
[0080] 604 indicates that a third-party request data packet has been sent to the target server.
[0081] For example, after receiving the third request data packet, the target server can check whether the destination MAC address of the third request data packet is its own network interface card (NIC) address, and whether the destination IP address of the third request data packet is the IP address of the load balancer (i.e., the VIP, where the LO NICs of each server in the server cluster are configured with a VIP). Furthermore, the target server can also determine the corresponding upper-layer application based on the port number in the third request data packet, and use the determined application to perform the corresponding business processing to generate a response data packet, and return the response data packet to the client, completing the request-response process.
[0082] Based on the above solution, this application proposes deploying a front-end device before the server cluster. This front-end device acts as a bridge between the server cluster and the load balancer. The front-end device can process packets from the load balancer and forward them to the server using a network tunneling protocol, allowing the server to directly process packets using standard Internet protocols. This solution addresses the problem of some existing servers not supporting network tunneling protocols and eliminates the need to deploy the load balancer and servers on the same local area network, thus improving the flexibility of server deployment.
[0083] In some embodiments, the front-end device stores a mapping relationship between the server's actual IP address and the configured local IP address, and may also configure a mapping relationship between the server's actual MAC address and the configured local IP address. Therefore, when performing step 603 above, the front-end device can directly obtain the MAC address corresponding to the destination IP address of the first request data packet (i.e., the local IP address configured by the front-end device) from the storage space, and use the obtained MAC address to set the destination MAC address of the second request data packet. In one possible scenario, if the front-end device's storage space does not store the MAC address corresponding to the destination IP address of the first request data packet (i.e., the local IP address configured by the front-end device), the front-end device can also determine the target server's actual IP address based on the stored mapping relationship between the server's actual IP address and the configured local IP address, and can determine the MAC address corresponding to the target server's actual IP address based on the Address Resolution Protocol (ARP). In this case, the front-end device can also record the mapping relationship between the destination IP address of the first request data packet (i.e., the local IP address configured by the front-end device) and the determined target server's MAC address, for example, by generating a MAC address mapping table and storing it in the storage space, so that the corresponding MAC address can be directly queried based on the destination IP address of the data packet next time.
[0084] In one possible implementation, after determining the MAC address of the target server, the front-end device can set it as the destination MAC address of the second request data packet. For example, the front-end device can determine whether the header of the second request data packet includes the destination MAC address. Because the load balancer uses different network tunneling protocols when re-encapsulating the second request data packet from the client, the encapsulation results will vary. For example, if the IP tunneling protocol is used, the Layer 2 header of the second request data packet will be missing, meaning the header of the second request data packet obtained by the front-end device will not contain a MAC address. In this case, the front-end device can add the target server's MAC address as the destination MAC address to the header of the second request data packet. If the VXLAN protocol is used for encapsulation, the header of the second request data packet obtained by the front-end device will include a MAC address. In this case, the front-end device can modify the MAC address included in the header of the second request data packet to the MAC address of the target server.
[0085] As an optional approach, when setting the header of the second request data packet, the front-end device can also modify the source MAC address in the header, changing it to the front-end device's own MAC address. Specifically, the front-end device can query the MAC address corresponding to its configured IP address in the same network segment as the target server and use that as the source MAC address of the second request data packet.
[0086] For example, the solutions described in the above embodiments can be executed by a front-end device, or by a processor, processing chip, or different processing modules included in the front-end device. For instance, see [link to relevant documentation]. Figure 7 This is a schematic diagram of the architecture of a front-end device provided in an embodiment of this application. Figure 7 As shown, the front-end device may include a receiving module, a decapsulation module, a storage module, an acquisition module, a generation module, an address setting module, and a sending module.
[0087] The system comprises the following modules: a receiving module to receive packets from the load balancer; a decapsulation module to decapsulate packets from the load balancer using a network tunneling protocol; an address setting module to set the MAC address of the decapsulated packets; and a sending module to send the packets output by the address setting module to the server. A storage module stores the mapping between the local IP address configured on the front-end device (i.e., the destination IP address of the packets from the load balancer) and the actual IP address of the server. An acquisition module obtains the server's MAC address using the ARP protocol. A generation module generates the mapping between the local IP address configured on the front-end device and the MAC address of the server based on the information from the storage and acquisition modules, and can store the generated mapping in the storage module.
[0088] It should be noted that, Figure 7 The processing modules shown are only a functional division of the front-end device, and the actual structure of the front-end device is not limited to this.
[0089] The following, combined with Figure 7 The schematic diagram of the front-end device shown below provides a detailed description of the solution in this application. See also... Figure 8 The above is a flowchart illustrating a data transmission method provided in an embodiment of this application, specifically including:
[0090] 801, The receiving module receives the first request data packet from the load balancer.
[0091] Optionally, the receiving module can inspect the received first request data packet to determine that its destination IP address is one of multiple local IP addresses configured for itself.
[0092] 802, the decapsulation module uses the network tunneling protocol to decapsulate the first request data packet to obtain the second request data packet.
[0093] 803, the module determines whether the storage module stores the MAC address corresponding to the destination IP address of the first request data packet.
[0094] If so, proceed to step 807.
[0095] If not, proceed to step 804.
[0096] 804, the acquisition module determines the IP address of the target server corresponding to the destination IP address of the first request data packet based on the IP address mapping relationship stored in the storage module.
[0097] 805, the module obtains the MAC address corresponding to the IP address of the target server according to the ARP protocol.
[0098] 806, The generation module generates a mapping relationship between the destination IP address and the MAC address of the target server for the first request data packet, and stores the generated mapping relationship in the storage module.
[0099] 807, The address setting module obtains the MAC address of the target server from the storage module.
[0100] 808, the address setting module determines whether the header of the second request data packet has a MAC address.
[0101] If so, proceed to step 809.
[0102] If not, proceed to step 810.
[0103] 809, The address setting module modifies the destination MAC address in the header of the second request data packet to the MAC address of the target server.
[0104] Optionally, the address setting module can also modify the source MAC address in the header of the second request data packet to the MAC address of the front-end device, and then continue to step 811.
[0105] 810, The address setting module adds the target server's MAC address as the destination MAC address to the header of the second request data packet.
[0106] Optionally, the address setting module can also add the MAC address of the front-end device as the source MAC address to the header of the second request data packet, and then continue to step 811.
[0107] 811, the sending module sends the data packet output by the address setting module to the target server.
[0108] Based on the same concept as the method described above, see [link to relevant documentation]. Figure 9 This application provides a data transmission apparatus 900, which is used to perform the various steps in the above-described method. To avoid repetition, these steps will not be described again here. The apparatus 900 includes a communication unit 901 and a processing unit 902.
[0109] The communication unit 901 is used to receive a first request data packet sent by the load balancer; the first request data packet is obtained by the load balancer encapsulating a second request data packet using a network tunneling protocol, and the second request data packet comes from the client;
[0110] Processing unit 902 is configured to determine the target server from the plurality of servers based on the destination IP address of the first request data packet, and decapsulate the first request data packet using a network tunneling protocol to obtain the second request data packet;
[0111] The processing unit 902 is further configured to set the destination MAC address in the header of the second request data packet to the MAC address of the target server, thereby obtaining a third request data packet;
[0112] The communication unit 901 is also used to send the third request data packet to the target server.
[0113] In some embodiments, the target server is a server determined by the load balancer from the server cluster to receive the first request data packet using a load balancing algorithm; the destination IP address is the IP address corresponding to the target server obtained by the load balancer from multiple IP addresses of the stored front-end device when it determines that the target server does not support the network tunneling protocol.
[0114] In some embodiments, the processing unit 902 is further configured to:
[0115] Based on the pre-stored IP address mapping relationship, determine the IP address of the target server corresponding to the destination IP address;
[0116] The MAC address of the target server corresponding to the IP address of the target server is determined using the Address Resolution Protocol (ARP).
[0117] In some embodiments, the processing unit 902 is further configured to:
[0118] Record the correspondence between the destination IP address and the MAC address of the target server.
[0119] In some embodiments, the processing unit 902 is specifically used for:
[0120] Determine whether the header of the second request data packet includes the destination MAC address;
[0121] If the header of the second request data packet includes a destination MAC address, then the destination MAC address in the header of the second request data packet is modified to the MAC address of the target server;
[0122] If the header of the second request data packet does not include the destination MAC address, then the MAC address of the target server is added to the header of the second request data packet as the destination MAC address of the second request data packet.
[0123] In some embodiments, the processing unit 902 is further configured to:
[0124] Set the source MAC address in the header of the second request data packet to the MAC address of the front-end device.
[0125] Figure 10 A schematic diagram of the structure of an electronic device 1000 provided in an embodiment of this application is shown. The electronic device 1000 in this embodiment may further include a communication interface 1003, which is, for example, a network port. The electronic device can transmit data through the communication interface 1003. For example, the communication interface 1003 can realize the function of the communication unit 901 described in the above embodiment.
[0126] In this embodiment, the memory 1002 stores instructions that can be executed by at least one controller 1001. By executing the instructions stored in the memory 1002, the at least one controller 1001 can perform various steps in the above-described method. For example, the controller 1001 can implement the above-described... Figure 9 The function of the processing unit 902 in the middle.
[0127] The controller 1001 is the control center of the electronic device, capable of connecting various parts of the device via various interfaces and lines. It executes instructions stored in the memory 1002 and retrieves data stored in the memory 1002. Optionally, the controller 1001 may include one or more processing units. The controller 1001 may integrate an application controller and a modem controller. The application controller primarily handles the operating system and applications, while the modem controller primarily handles wireless communication. It is understood that the modem controller may not be integrated into the controller 1001. In some embodiments, the controller 1001 and the memory 1002 may be implemented on the same chip; in other embodiments, they may be implemented on separate chips.
[0128] The controller 1001 can be a general-purpose controller, such as a central processing unit (CPU), digital signal controller, application-specific integrated circuit, field-programmable gate array or other programmable logic device, discrete gate or transistor logic device, or discrete hardware component, capable of implementing or executing the methods, steps, and logic block diagrams disclosed in the embodiments of this application. The general-purpose controller can be a microcontroller or any conventional controller. The steps performed by the data statistics platform disclosed in the embodiments of this application can be directly executed by the hardware controller, or executed by a combination of hardware and software modules within the controller.
[0129] Memory 1002, as a non-volatile computer-readable storage medium, can be used to store non-volatile software programs, non-volatile computer-executable programs, and modules. Memory 1002 may include at least one type of storage medium, such as flash memory, hard disk, multimedia card, card-type memory, random access memory (RAM), static random access memory (SRAM), programmable read-only memory (PROM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), magnetic memory, magnetic disk, optical disk, etc. Memory 1002 can be any other medium capable of carrying or storing desired program code in the form of instructions or data structures that can be accessed by a computer, but is not limited thereto. In the embodiments of this application, memory 1002 can also be a circuit or any other device capable of implementing storage functions for storing program instructions and / or data.
[0130] By designing and programming the controller 1001, for example, the code corresponding to the method described in the foregoing embodiment can be embedded into the chip, so that the chip can execute the steps of the foregoing method when running. How to design and program the controller 1001 is a well-known technique to those skilled in the art, and will not be described in detail here.
[0131] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0132] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to this application. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a controller of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing device to produce a machine, such that the instructions, which execute via the controller of the computer or other programmable data processing device, generate instructions for implementing the flowchart illustrations. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0133] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0134] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0135] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0136] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A data transmission method, characterized in that, The method is applied to a front-end device, which connects to multiple servers in a server cluster, and the method includes: The load balancer sends a first request data packet; the first request data packet is obtained by the load balancer encapsulating a second request data packet using a network tunneling protocol, and the second request data packet comes from the client; The target server is determined from the plurality of servers based on the destination IP address of the first request data packet, and the first request data packet is decapsulated using a network tunneling protocol to obtain the second request data packet; The destination MAC address in the header of the second request data packet is set to the MAC address of the target server to obtain the third request data packet; The third request data packet is sent to the target server.
2. The method according to claim 1, characterized in that, The method further includes: Based on the pre-stored IP address mapping relationship, determine the IP address of the target server corresponding to the destination IP address; The MAC address of the target server corresponding to the IP address of the target server is determined using the Address Resolution Protocol (ARP).
3. The method according to claim 1 or 2, characterized in that, The target server is the server that the load balancer determines from the server cluster using a load balancing algorithm to receive the first request data packet; the destination IP address is the IP address corresponding to the target server obtained by the load balancer from multiple IP addresses of the stored front-end devices when it determines that the target server does not support the network tunneling protocol.
4. The method according to claim 1 or 2, characterized in that, Setting the destination MAC address in the header of the second request data packet to the MAC address of the target server specifically includes: Determine whether the header of the second request data packet includes the destination MAC address; If the header of the second request data packet includes a destination MAC address, then the destination MAC address in the header of the second request data packet is modified to the MAC address of the target server; If the header of the second request data packet does not include the destination MAC address, then the MAC address of the target server is added to the header of the second request data packet as the destination MAC address of the second request data packet.
5. A data transmission device, characterized in that, The device is a front-end device, or the device is applied to a front-end device, the device connects to multiple servers in a server cluster, and the device includes: A communication unit is used to receive a first request data packet sent by the load balancer; the first request data packet is obtained by the load balancer encapsulating a second request data packet using a network tunneling protocol, and the second request data packet comes from the client; The processing unit is configured to determine the target server from the plurality of servers based on the destination IP address of the first request data packet, and to decapsulate the first request data packet using a network tunneling protocol to obtain the second request data packet; The processing unit is further configured to set the destination MAC address in the header of the second request data packet to the MAC address of the target server, thereby obtaining a third request data packet; The communication unit is also used to send the third request data packet to the target server.
6. The apparatus according to claim 5, characterized in that, The processing unit is further configured to: Based on the pre-stored IP address mapping relationship, determine the IP address of the target server corresponding to the destination IP address; The MAC address of the target server corresponding to the IP address of the target server is determined using the Address Resolution Protocol (ARP).
7. The apparatus according to claim 5 or 6, characterized in that, The target server is the server that the load balancer determines from the server cluster using a load balancing algorithm to receive the first request data packet; the destination IP address is the IP address corresponding to the target server obtained by the load balancer from multiple IP addresses of the stored front-end devices when it determines that the target server does not support the network tunneling protocol.
8. The apparatus according to claim 5 or 6, characterized in that, The processing unit is specifically used for: Determine whether the header of the second request data packet includes the destination MAC address; If the header of the second request data packet includes a destination MAC address, then the destination MAC address in the header of the second request data packet is modified to the MAC address of the target server; If the header of the second request data packet does not include the destination MAC address, then the MAC address of the target server is added to the header of the second request data packet as the destination MAC address of the second request data packet.
9. An electronic device, characterized in that, The electronic device includes a controller and a memory. The memory is used to store computer programs or instructions; The controller is configured to execute a computer program or instructions in a memory, such that the method of any one of claims 1-4 is performed.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions that, when invoked by a computer, cause the computer to perform the method as described in any one of claims 1-4.
Citation Information
Patent Citations
Load balancing method and load balancing system
CN106686129A
Server cluster-based packet generation method and load balancer
CN107026890A