Message transmission method, system and device and network equipment
By determining the processing core based on the address and port information of the request and response packets in the load balancing device, the problem that messages cannot be allocated to the same core for processing in different transmission directions of the same data stream, and the packet processing performance is improved.
Patent Information
- Application Number
- CN202510369538.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-25
- Publication Date
- 2025-06-10
AI Technical Summary
In the load balancing network architecture, packets in different transmission directions of the same data stream cannot be allocated to the same core processing of the load balancing device, affecting the transmission performance of the packet.
In the load balancing device, the processing core is determined based on the source address, source port and transmission protocol of the request message, and when processing the response message, the processing core is determined based on the destination address, destination port and transmission protocol of the response message, so as to ensure that the request message and the response message are allocated to the same processing core.
It realizes the allocation of request messages and response messages from the same data stream to the same processing core for processing, which improves the processing performance of packets by load balancing devices.
Smart Images

Figure CN120128530A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure belongs to the field of communication technologies, and particularly relates to a message transmission method, system, device, and network device. Background Art
[0002] Load Balancing (LB) technology is a technology for reasonably distributing client traffic or computing tasks to multiple servers in a server cluster in a scenario where the server cluster provides services. In a load-balanced network architecture, client request messages are usually sent to physical servers in the server cluster via an LB device, and response messages from the physical servers are sent to the client. When the LB device is implemented as a physical device, the LB device can be a multi-core device. To improve processing efficiency and simplify the process of message synchronization, it should be ensured that messages belonging to the same data stream are processed by the same core of the LB device.
[0003] The conventional message core distribution technology is implemented such that the LB device determines the processing core by performing a hash operation on the five-tuple of the message (the five-tuple includes the source address, source port, destination address, destination port, and transport protocol). However, for the response message of the same data stream relative to the request message, Network Address Translation (NAT) processing needs to be performed. Therefore, the five-tuples of messages in different transmission directions of the same data stream are different. As a result, messages in different transmission directions of the same data stream cannot be assigned to the same core of the LB device for processing, affecting the message transmission performance. Summary of the Invention
[0004] The present disclosure provides a message transmission method, system, device, and network device, which can solve the problem that messages in different transmission directions of the same data stream cannot be assigned to the same core of the LB device for processing.
[0005] A first aspect embodiment of the present disclosure proposes a message transmission method applied to an LB device, where the LB device includes multiple processing cores, and the method includes:
[0006] After receiving a request message from a client, determining a first processing core according to the source address, source port, and transport protocol of the request message, where the first processing core belongs to the multiple processing cores;
[0007] Invoking the first processing core to forward the request message to a target server;
[0008] After receiving the response message corresponding to the request message, determine the first processing core according to the destination address, destination port of the response message, and the transport protocol; the destination address of the response message corresponds to the source address of the request message; the destination port of the response message corresponds to the source port of the request message;
[0009] Call the first processing core to forward the response message to the client.
[0010] In an embodiment of the present disclosure, the calling the first processing core to forward the request message to the target server includes:
[0011] Call the first processing core to convert the address and port of the request message;
[0012] In an embodiment of the present disclosure, the calling the first processing core to convert the address and port of the request message includes:
[0013] Determine the target server;
[0014] Convert the destination address of the request message to the address of the target server, and convert the destination port of the request message to the port of the target server.
[0015] In an embodiment of the present disclosure, if the network segment to which the address of the LB device belongs is different from the network segment to which the address of the target server belongs, the calling the first processing core to convert the address and port of the request message includes:
[0016] Select a candidate address and a candidate port that match the first processing core from a preset candidate address set and a candidate port set; any candidate address in the candidate address set belongs to the same network segment as the address of the target server;
[0017] Convert the source address of the request message to the candidate address, and convert the source port of the request message to the candidate port.
[0018] In an embodiment of the present disclosure, the selecting a candidate address and a candidate port that match the first processing core from a preset candidate address set and a candidate port set includes:
[0019] Traverse each candidate address in the candidate address set;
[0020] For each traversed candidate address, traverse the ports corresponding to the traversed candidate address;
[0021] Determine a second processing core according to the traversed candidate address, the traversed port, and the transport protocol;
[0022] If the second processing core is the same as the first processing core, determine the traversed candidate address as the candidate address matching the first processing core, and determine the traversed port as the candidate port matching the first processing core.
[0023] In an embodiment of the present disclosure, the destination address of the response message is the candidate address, and the destination port of the response message is the candidate port.
[0024] In an embodiment of the present disclosure, the calling the first processing core to forward the response message to the client includes:
[0025] Call the first processing core to convert the destination address of the response message into the address of the client, and convert the destination port of the response message into the port of the client;
[0026] Forward the response message with the converted address to the client.
[0027] An embodiment of the second aspect of the present disclosure provides a message transmission system, where the message transmission system includes a client, an LB device, and at least one server connected through a network. The LB device includes multiple processing cores, where,
[0028] The client is configured to send a request message to the LB device, and is further configured to receive a response message corresponding to the request message from the LB device;
[0029] The LB device is configured to, after receiving a request message from the client, determine a first processing core according to the source address, source port, and transmission protocol of the request message. The first processing core belongs to the multiple processing cores; call the first processing core to forward the request message to a target server among the at least one server;
[0030] The LB device is further configured to, after receiving the response message corresponding to the request message, determine the first processing core according to the destination address, destination port, and the transmission protocol of the response message; the destination address of the response message corresponds to the source address of the request message; the destination port of the response message corresponds to the source port of the request message; call the first processing core to forward the response message to the client.
[0031] An embodiment of the third aspect of the present disclosure provides a message transmission device, which is applied to an LB device. The LB device includes multiple processing cores, and the device includes:
[0032] A core separation module, configured to, after receiving a request message from the client, determine a first processing core according to the source address, source port, and transmission protocol of the request message. The first processing core belongs to the multiple processing cores;
[0033] A forwarding module, configured to call the first processing core to forward the request message to a target server;
[0034] The core splitting module is further configured to, after receiving a response message corresponding to the request message, determine the first processing core according to the destination address, destination port, and the transport protocol of the response message; the destination address of the response message corresponds to the source address of the request message; the destination port of the response message corresponds to the source port of the request message;
[0035] The forwarding module is further configured to call the first processing core to forward the response message to the client.
[0036] An embodiment of the fourth aspect of the present disclosure provides a network device, including a memory, a processor, and a computer program stored on the memory and executable on the processor. The processor includes a plurality of processing cores, and the processor runs the computer program to implement the method described in the first aspect above.
[0037] An embodiment of the fifth aspect of the present disclosure provides a computer-readable storage medium, on which a computer program is stored, and the program is executed by a processor to implement the method described in the first aspect above.
[0038] The technical solution provided by the embodiments of the present disclosure has at least the following technical effects or advantages:
[0039] After receiving a request message from a client, instead of determining the processing core of the request message according to the five-tuple of the request message, the processing core of the request message is determined according to the source address, source port, and transport protocol of the request message. For the response message corresponding to the request message, since the destination address of the response message corresponds to the source address of the request message, and the destination port of the response message corresponds to the source port of the request message, after receiving the response message corresponding to the request message, the processing core of the response message determined according to the destination address, destination port, and transport protocol of the response message is the same as the processing core of the request message. In this way, even if the five-tuples of the request message and the response message are different, the request message and the response message can still be allocated to the same core of the LB device for processing, which is beneficial to improving the processing performance of the LB device for messages.
[0040] The additional aspects and advantages of the present disclosure will be given in part in the following description, will become apparent in part from the following description, or will be understood through the practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] By reading the following detailed description of the preferred embodiments, various other advantages and benefits will become clear to those of ordinary skill in the art. The drawings are only for the purpose of showing the preferred embodiments and are not considered a limitation of the present disclosure. Moreover, throughout the drawings, the same reference numerals are used to represent the same components.
[0042] In the drawings:
[0043] Figure 1 An exemplary scenario schematic diagram showing a typical load balancing service scenario is shown;
[0044] Figure 2 An exemplary method flowchart showing the message transmission method provided by an embodiment of the present disclosure is shown;
[0045] Figure 3 A schematic structural diagram of a network system provided by an embodiment of the present disclosure is shown;
[0046] Figure 4A An exemplary signaling interaction of the message transmission method provided by an embodiment of the present disclosure is shown Figure 1 ;
[0047] Figure 4B An exemplary signaling interaction of the message transmission method provided by an embodiment of the present disclosure is shown Figure 2 ;
[0048] Figure 5 A schematic composition diagram of a message transmission device provided by an embodiment of the present disclosure is shown;
[0049] Figure 6 A schematic structural diagram of a network device provided by an embodiment of the present disclosure is shown;
[0050] Figure 7 A schematic diagram of a storage medium provided by an embodiment of the present disclosure is shown. Detailed Embodiments
[0051] The exemplary embodiments of the present disclosure will be described in more detail below with reference to the drawings. Although the exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided so that the present disclosure can be more thoroughly understood and the scope of the present disclosure can be completely conveyed to those skilled in the art.
[0052] It should be noted that unless otherwise specified, the technical terms or scientific terms used in the present disclosure should have the ordinary meaning understood by those skilled in the art to which the present disclosure belongs.
[0053] The implementation scenarios and related technologies involved in the embodiments of the present disclosure will be introduced below.
[0054] The technical solution of the present disclosure relates to the message transmission service in the load balancing technology. The load balancing technology can be applied to the service scenarios of big data centers. By distributing the traffic of clients among multiple servers in a server cluster, it is ensured that no single server becomes a performance bottleneck, so that the throughput and response speed of the load balancing system are maintained at a relatively high level.
[0055] A typical load balancing service scenario is as Figure 1 shown. The client is connected to the server cluster network via the LB device. It should be noted that, for the convenience of managing multiple servers in the server cluster and reducing the complexity of the network system, multiple servers are usually configured as a virtual server, and the network address of the virtual server (for example, the virtual server IP (Virtual server's Internet Protocol, VSIP) address) is configured. In the scenario where the client accesses the server cluster, the destination address in the request message from the client is the VSIP address. After the LB device determines the server to which the client traffic is allocated, the destination address in the request message should be converted from the VSIP address to the address of the determined server, and then the request message with the converted address is forwarded to the corresponding server. In the scenario where the corresponding server sends a response message to the client, since the response message comes from the server, based on this, the source address of the response message is the address of the server, rather than the VSIP address. The LB device should convert the source address of the response message from the address of the server to the VSIP address, and then forward the response message with the converted address to the corresponding client.
[0056] The LB device can be implemented as a hardware load balancer, a software load balancer, a cloud load balancer, etc. When the LB device is implemented as a hardware load balancer, the LB device is usually a device with a multi-core processor. To improve the processing efficiency and simplify the process of message synchronization, it should be ensured that messages belonging to the same data stream are processed by the same core of the LB device. The LB device usually determines the processing core of the message by performing a hash operation on the five-tuple of the message. The five-tuple includes the source address, source port, destination address, destination port, and transport protocol.
[0057] However, in combination with Figure 1As can be seen from the illustrative embodiments, due to the existence of virtual servers, the LB device should perform destination network address translation (DNAT) on the request packets and source network address translation (SNAT) on the response packets. As a result, even packets in different transmission directions of the same data stream cannot be assigned to the same core of the LB device for processing. In this way, the session packets belonging to the same data stream need to be synchronized among multiple cores, increasing processing procedures such as inter-core communication, thereby affecting the packet transmission performance of the LB device.
[0058] In view of this, the embodiments of the present disclosure propose a technical solution. Instead of determining the processing core of a packet according to the five-tuple of the packet, based on the correspondence between the destination address of the response packet and the source address of the request packet, and the correspondence between the destination port of the response packet and the source port of the request packet, for the request packet, perform core partitioning according to the source address, source port, and transport protocol, and for the response packet, perform core partitioning according to the destination address, destination port, and transport protocol, so as to be able to assign the request packet and the response packet to the same core of the LB device for processing, thereby facilitating the improvement of the packet processing performance of the LB device.
[0059] The following describes the packet transmission method, system, device, and network device proposed according to the embodiments of the present disclosure. The technical solution of the present disclosure will be described in detail below with specific embodiments. These specific embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. The embodiments of the present disclosure will be described below with reference to the drawings.
[0060] See Figure 2 , Figure 2 FIG. shows the packet transmission method provided by an embodiment of the present disclosure. This method is applied to an LB device, and the LB device includes multiple processing cores. The method includes:
[0061] In step S11, after receiving a request packet from a client, determine a first processing core according to the source address, source port, and transport protocol of the request packet.
[0062] Wherein, the first processing core belongs to the multiple processing cores.
[0063] It should be noted that the client's access to the server usually involves not only the interaction of a single message, but a continuous data stream. To improve the processing efficiency of the data stream, after receiving the first message of the data stream, the LB device can create a session to record the network data of the messages belonging to the data stream. Based on this, if the request message is the first message of the access initiated by the client, the LB device can create a session for the data stream of this access.
[0064] The request message includes a source address, a source port, a destination address, a destination port, and a transport protocol. Exemplarily, the source address of the request message is, for example, the client IP (Client IP, CIP) address, the source port of the request message is, for example, the client port (Client Port, CPort), the destination address of the request message is, for example, the VSIP address, the destination port of the request message is, for example, the virtual server port, and the transport protocol is, for example, the Transmission Control Protocol (TCP) or the User Datagram Protocol (UDP).
[0065] It should be understood that the transport protocol can be configured according to the actual implementation scenario, and the embodiments of the present application do not limit this.
[0066] In some embodiments, the LB device can perform core distribution for the request message through hash calculation according to the source address, source port, and transport protocol of the request message.
[0067] For example, the source address of the request message is 2.2.2.2, the port number of the source port is 2000, and the transport protocol number is 6. The LB device includes 4 processing cores, and the numbers of these 4 processing cores are sequentially 0, 1, 2, and 3. The core distribution calculation process includes: 2 + 2 + 2 + 2 + 2000 + 6 = 2014; 2014 % 4 = 2, that is, the processing core numbered 2 is selected. In this example, the processing core numbered 2 is the above-mentioned first processing core.
[0068] In step S12, the first processing core is called to forward the request message to the target server.
[0069] Among them, the target server can be any physical server in the server cluster.
[0070] In an actual implementation scenario, after determining the first processing core, the LB device can call the first processing core to calculate the number of the server allocated to the request message based on the health detection results, load balancing policies, and scheduling algorithms of each server, and use the server identified by the number as the target server. Furthermore, the first processing core can be called to convert the address and port of the request message and forward the converted request message to the target server.
[0071] It should be noted that during the networking process, the LB device and the server cluster can be deployed in the internal network or the public network, or the LB device can be deployed in the public network while the server cluster is deployed in the internal network. If the LB device and the server cluster are in the same network, then the network segment to which the address of the LB device belongs is the same as the network segment to which the address of the target server belongs, and the first processing core only needs to convert the destination address and destination port of the request message. If the LB device and the server cluster are in different networks, then the network segment to which the address of the LB device belongs is different from the network segment to which the address of the target server belongs, and the first processing core not only needs to convert the destination address and destination port of the request message, but also needs to convert the source address and source port of the request message to ensure that the response message of the target server can reach the LB device.
[0072] Based on this, in any implementation scenario, the first processing core can determine the target server, convert the destination address of the request message to the address of the target server, and convert the destination port of the request message to the port of the target server. Combining Figure 1 with the description of the illustrated embodiment, the destination address of the request message is VSIP, and the destination port of the request message is the port of VS. Exemplarily, the address of the target server is, for example, the target server IP (Server IP, SIP) address.
[0073] In the scenario where the network segment to which the address of the LB device belongs is different from the network segment to which the address of the target server belongs, the LB device should also call the first processing core to select a candidate address and a candidate port that match the first processing core from a preset candidate address set and candidate port set, convert the source address of the request message to the candidate address, and convert the source port of the request message to the candidate port.
[0074] Among them, the candidate address set can be preset according to the network segment where the server cluster is located during the networking stage, and any candidate address in the candidate address set belongs to the same network segment as the address of the target server. Optionally, any candidate address can include multiple ports.
[0075] It should be understood that the source address after the request message is converted is used as the destination address of the response message, and the source port after the request message is converted is used as the destination port of the response message. The response message determines the processing core based on the destination address and the destination port. To ensure that the processing core of the response message and the processing core of the request message are the same processing core, the candidate address and candidate port with the hash calculation result being the first processing core can be used as the candidate address and candidate port that match the first processing core.
[0076] Selecting the candidate address and candidate port that match the first processing core in the preset candidate address set and candidate port set can be achieved by: traversing each candidate address in the candidate address set; for each traversed candidate address, traversing the ports corresponding to the traversed candidate address; determining the second processing core according to the traversed candidate address, the traversed port, and the transport protocol; if the second processing core is the same as the first processing core, determining the traversed candidate address as the candidate address that matches the first processing core, and determining the traversed port as the candidate port that matches the first processing core.
[0077] For example, the preset candidate address set is the IP address pool from 192.168.0.1 to 192.168.0.2, and the available port range for each IP address is from 2000 to 4000. The source address of the request message is 2.2.2.2, the port number of the source port is 2000, and the first processing core is the processing core numbered 2. Further, starting from IP 192.168.0.1 and port 2000 for traversal and search, 192 + 168 + 0 + 1 + 2000 + 6 = 4267, 4267 % 4 = 3, that is, the processing core number calculated for the IP address 192.168.0.1 and port number 2000 is 3, which is different from the number 2 of the first processing core, and continue the calculation. 192 + 168 + 0 + 1 + 2001 + 6 = 4268, 4268 % 4 = 0, that is, the processing core number calculated for the IP address 192.168.0.1 and port number 2001 is 0, which is different from the number 2 of the first processing core, and continue the calculation. Until 192 + 168 + 0 + 1 + 2003 + 6 = 4270, 4270 % 4 = 2, which is the same as the number 2 of the first processing core, the traversal can be stopped, and the IP address 192.168.0.1 is used as the candidate address, and the port number 2003 is used as the candidate port.
[0078] In step S13, after receiving the response message corresponding to the request message, determine the first processing core according to the destination address, the destination port, and the transport protocol of the response message.
[0079] Wherein, the destination address of the response message corresponds to the source address of the request message; the destination port of the response message corresponds to the source port of the request message.
[0080] The response message includes a source address, a source port, a destination address, a destination port, and a transport protocol. Since the response message comes from the target server, the source address of the response message is, for example, the IP address of the target server, the source port of the response message is, for example, the port of the target server, the destination address is the IP address that enables the LB device to receive the response message, and the destination port is the port that enables the LB device to receive the response message. The transport protocol of the response message is the same as the transport protocol included in the above-mentioned request message. In some embodiments, if the transport protocol included in the above-mentioned request message is TCP, the transport protocol of the response message is TCP. In other embodiments, if the transport protocol included in the above-mentioned request message is UDP, the transport protocol of the response message is UDP.
[0081] Combined with the foregoing description of the address conversion of the request message, it can be seen that in the scenario where the network segment of the address of the LB device is the same as the network segment of the address of the target server, the network segment of the CIP address is the same as the network segment of the IP address of the target server. Based on this, the LB device does not need to convert the source address and source port of the request message, and the destination address of the response message is the CIP address. Correspondingly, in this implementation scenario, the destination port of the response message is the port of the client. In the scenario where the network segment of the address of the LB device is different from the network segment of the address of the target server, the network segment of the CIP address is different from the network segment of the IP address of the target server. If the response message uses the CIP address as the destination address, the LB device will not be able to receive the response message. Based on this, the LB device should convert the source address of the request message into a candidate address and convert the source port of the request message into a candidate port. Correspondingly, in this implementation scenario, the destination address of the response message is the candidate address, and the destination port of the response message is the candidate port.
[0082] In some embodiments, the LB device can perform a hash calculation on the destination address, destination port, and transport protocol of the response message to perform core partitioning for the response message. The algorithm process of performing hash core partitioning on the triple can refer to the description of the above example and will not be elaborated here.
[0083] It can be seen that by adopting this implementation method, the destination address of the response message is the same as the source address of the request message or the converted candidate address, and the destination port of the response message is the same as the source port of the request message or the converted candidate port. Based on this, performing core partitioning for the response message based on the destination address, destination port, and transport protocol of the response message can ensure that the allocated processing core is the same as the processing core of the request message. Even if the five-tuples of the request message and the response message are different, the request message and the response message can still be allocated to the same core of the LB device for processing, which is beneficial to improving the processing performance of the LB device for messages.
[0084] In step S14, the first processing core is called to forward the response message to the client.
[0085] Combined with Figure 1 With reference to the description of the illustrated embodiments, after the first processing core is determined, the LB device may call the first processing core to convert the source address of the response message into the VSIP address and convert the source port of the response message into the port of the virtual server.
[0086] Furthermore, combined with the description of converting the address of the foregoing conversion request message, in a scenario where the network segment to which the address of the LB device belongs is the same as the network segment to which the address of the target server belongs, the LB device does not need to convert the destination address and destination port of the response message. In a scenario where the network segment to which the address of the LB device belongs is different from the network segment to which the address of the target server belongs, the LB device should call the first processing core to convert the destination address of the response message into the address of the client and convert the destination port of the response message into the port of the client, and then forward the response message with the converted address to the client.
[0087] Adopting this implementation method is beneficial to ensuring that the request message and response message of the same data stream are assigned to the same processing core. In this way, the messages in two transmission directions are processed by the same processing core, which can not only reduce the inter-core communication overhead of the LB device and the frequency of context switching in the same session, improve the processing speed, but also be beneficial to reducing the synchronization complexity between threads or processes, optimizing the dynamic allocation and management of resources, and improving the resource utilization rate of the load balancing system.
[0088] The above is an explanation of the technical solution of the embodiments of the present disclosure from the perspective of the LB device. Next, the message transmission method of the present disclosure will be described from the perspective of an exemplary implementation scenario in combination with a network system.
[0089] See Figure 3 , Figure 3 shows a schematic structural diagram of a network system provided by an embodiment of the present disclosure, Figure 3 The illustrated network system is a load balancing network system. Figure 3The schematic network system may include a client 31, a Server Load Balancing (SLB) device 32, and a physical server cluster 33. The physical server cluster 33 may include, for example, Server A (Service A), Server B (Service B), Server C (Service C), etc. Service A, Service B, and Service C may correspond to the numbers 0, 1, and 2 in sequence one by one. There are network connections between the client 31, the SLB device 32, and the physical server cluster 33. The physical server cluster 33 is network-connected to the SLB device 32 through a virtual server.
[0090] It should be understood that Figure 3 This is only a schematic description and does not constitute a limitation to the network system architecture of the embodiments of the present disclosure. In some other embodiments, the physical server cluster 33 may further include more or fewer servers. In some other embodiments, the network system may further include more clients. In still some other embodiments, the SLB device in the network system may also be replaced with other types of LB devices. The embodiments of the present disclosure do not limit this.
[0091] For example, Figure 3 the IP address (i.e., CIP) of the client 31 is 2.2.2.2, the port number is 2000, the IP address (i.e., SIP) of the SLB device 32 is 1.1.1.1, and the Port number of the SLB device 32 is 80. Between the client 31 and the SLB device 32, and between the SLB device 32 and Server A, Server B, and Server C respectively, for example, TCP is used to transmit packets, and TCP is 6 according to the RFC regulations.
[0092] The following will describe the packet transmission method of the embodiments of the present disclosure from the perspective of different implementation scenarios.
[0093] In the scenario where the SLB device 32 and the physical server cluster 33 are in the same network, the IP address of Server A is 1.1.1.11, the Port is 80, the IP address of Server B is 1.1.1.12, the Port is 80, and the IP address of Server C is 1.1.1.13, the Port is 80. The VSIP is 1.1.1.1, and the VSPort is 90. The SLB device 32 only needs to perform DNAT on the request packet. The packet transmission between the client 31, the SLB device 32, and the physical server cluster 33 in this scenario can be as Figure 4A shown.
[0094] Figure 4AAn exemplary signaling interaction process of the packet transmission method provided by an embodiment of the present disclosure is shown, including steps S411 to S419.
[0095] Step S411, the client 31 sends a request packet to the SLB device 32.
[0096] Among them, the five-tuple of the request packet can be expressed as (CIP, CPort, VSIP, VSPort, Proto). In this example, the five-tuple of the request packet can be specifically implemented as (2.2.2.2, 2000, 1.1.1.1, 90, 6).
[0097] Step S412, the SLB device 32 performs core partitioning according to the source IP, source Port, and Proto in the five-tuple of the request packet.
[0098] Exemplarily, taking the SLB device having 4 processing cores, and the numbers of the 4 processing cores corresponding to 0, 1, 2, and 3 respectively as an example, then the core is partitioned according to the source IP as CIP (i.e., 2.2.2.2), source Port as CPort (i.e., 2000), and Proto (6) by using the hash algorithm:
[0099] 2 + 2 + 2 + 2 + 2000 + 6 = 2014, 2014 % 4 = 2, that is, the processing core numbered 2 is used as the processing core for processing this request packet.
[0100] Step S413, the SLB device 32 selects a target physical server.
[0101] The target physical server refers to the physical server used to process the client traffic.
[0102] For example, using the source IP hash to select the target physical server can satisfy: 2 + 2 + 2 + 2 = 8, 8 % 3 = 2. Then, according to the numbers of each physical server in the physical server cluster 33, Server C can be selected to process the request packet.
[0103] Step S414, call the processing core numbered 2 to convert the VSIP in the five-tuple of the request packet into the IP address of Server C, and convert the VSPort in the five-tuple of the request packet into the Port of Server C.
[0104] For example, convert 1.1.1.1 into 1.1.1.13, and convert 90 into 80. The converted five-tuple is expressed as: (2.2.2.2, 2000, 1.1.1.13, 80, 6) for example.
[0105] Step S415, the SLB device 32 sends the request packet after converting the address to Server C.
[0106] Step S416, the SLB device 32 receives a response message from Server C.
[0107] Among them, the response message is sent by Server C after processing the request message.
[0108] The five-tuple of the response message is: (SIP, SPort, CIP, CPort, Proto), where SIP is the IP address of Server C and SPort is the port number of Server C.
[0109] The five-tuple of the response message is implemented as, for example: (1.1.1.13, 80, 2.2.2.2, 2000, 6).
[0110] Step S417, the SLB device 32 performs core splitting according to the destination IP, destination Port, and Proto in the five-tuple of the response message.
[0111] Combined with the above, the destination IP in the five-tuple of the response message is CIP: 2.2.2.2, the destination Port in the five-tuple of the response message is CPort: 2000, and the Proto in the five-tuple of the response message is 6. The implementation process of determining the processing core using the hash algorithm is as follows: 2 + 2 + 2 + 2 + 2000 + 6 = 2014, 2014 % 4 = 2, that is, the processing core numbered 2 is used as the processing core for processing this request message.
[0112] It can be seen that even if the SLB needs to convert the five-tuple of the response message, however, the destination IP included in the response message is the same as the source IP in the corresponding request message, the destination Port included in the response message is the same as the source Port in the request message, and Proto remains unchanged. Based on this, performing core splitting according to the destination IP, destination Port, and Proto in the five-tuple of the response message can ensure that the processing core allocated for the response message is the same as the processing core of the request message, thereby facilitating improving the processing performance of the LB device for messages.
[0113] Step S418, call the processing core numbered 2 to convert the SIP in the five-tuple of the response message to VSIP, and convert the SPort in the five-tuple of the response message to VSPort.
[0114] For example, the five-tuple of the response message is changed from (1.1.1.13, 80, 2.2.2.2, 2000, 6) to (1.1.1.1, 90, 2.2.2.2, 2000, 6).
[0115] Step S419, send the response message with the converted address to the client.
[0116] In a scenario where the SLB device 32 and the physical server cluster 33 are in different networks, the IP address of Server A is 192.168.0.11, the Port is 80, the IP address of Server B is 192.168.0.12, the Port is 80, and the IP address of Server C is 192.168.0.13, the Port is 80. The VSIP is 1.1.1.1, and the Port of the VS is 90. The SLB device 32 only needs to perform SNAT and DNAT on the request message. The message transmission between the client 31, the SLB device 32 and the physical server cluster 33 in this scenario can be as Figure 4B shown.
[0117] Figure 4B It shows an exemplary signaling interaction process of the message transmission method provided by an embodiment of the present disclosure, including steps S421 to S429.
[0118] Step S421, the client 31 sends a request message to the SLB device 32.
[0119] Step S422, the SLB device 32 performs nuclear separation according to the source IP, source Port and Proto in the five-tuple of the request message, and selects the target physical server.
[0120] In this example, for the specific implementation process of steps S421 to S422, reference can be made to Figure 4A the specific implementation process of steps S411 to S413. This example still continues to use the Figure 4A example in. Details are not described here.
[0121] Step S423, the SLB device 32 calls processing core numbered 2 to select candidate IP addresses and candidate Ports.
[0122] Among them, the candidate IP address is used to convert the source IP in the request message, and the candidate Port is used to convert the source Port in the request message.
[0123] For example, the preset candidate address set is an IP address pool from 192.168.0.1 to 192.168.0.2, and the available port range for each IP address is from 2000 to 4000. Starting from 192.168.0.1, port 2000 for traversal and search, 192 + 168 + 0 + 1 + 2000 + 6 = 4267, 4267 % 4 = 3, which is different from number 2, so continue the calculation. 192 + 168 + 0 + 1 + 2001 + 6 = 4268, 4268 % 4 = 0, which is different from number 2, so continue the calculation. 192 + 168 + 0 + 1 + 2002 + 6 = 4269, 4269 % 4 = 1, which is different from number 2, so continue the calculation. 192 + 168 + 0 + 1 + 2003 + 6 = 4270, 4270 % 4 = 2, which is the same as number 2, so the traversal can be stopped, the IP address 192.168.0.1 is used as the candidate address, and Port 2003 is used as the candidate Port.
[0124] Step S424, call the processing with number 2 to check the request message for address conversion.
[0125] Specifically, use the candidate IP to replace the source address of the request message, use the candidate Port to replace the source Port of the request message, and replace the destination IP and destination Port of the request message with the IP and Port of Server C. For the exemplary implementation of converting the destination IP and destination Port of the request message, refer to the description in step S414, which will not be elaborated here.
[0126] Exemplarily, the candidate IP is represented as SNAT IP for example, and the candidate Port is represented as SNAT Port for example. The initial five-tuple of the request message is (CIP, CPort, VSIP, VSPort, Proto), and the five-tuple after address conversion is (SNAT IP, SNATPort, SIP, SPort, Proto). For example, (CIP, CPort, VSIP, VSPort, Proto) is specifically implemented as (2.2.2.2, 2000, 1.1.1.1, 90, 6), and (SNAT IP, SNAT Port, SIP, SPort, Proto) can be specifically implemented as (192.168.0.1, 2003, 192.168.0.13, 80, 6).
[0127] Step S425, the SLB device 32 sends the request message with the converted address to Server C.
[0128] Step S426, the SLB device 32 receives the response message from Server C.
[0129] In this example, the five-tuple of the response message is: (SIP, SPort, SNAT IP, SNAT Port, Proto), and this five-tuple is implemented as (192.168.0.13, 80, 192.168.0.1, 2003, 6) for example.
[0130] Step S427, the SLB device 32 performs core separation according to the destination IP, destination Port, and Proto in the five-tuple of the response message.
[0131] In this example, the destination IP of the response message is the SNAT IP, the destination Port is the SNAT Port, and the SNAT IP and SNAT Port are determined according to the number of the processing core. Correspondingly, the number of the processing core determined by performing hash core separation on the SNAT Port, SNAT Port, and Proto is also 2. The process of hash core separation will not be elaborated here.
[0132] Step S428, call the processing core numbered 2 to convert the address in the five-tuple of the response message.
[0133] Specifically, the processing core converts the SIP in the five-tuple of the response message to VSIP, converts the SPort in the five-tuple of the response message to VSPort, converts the SNAT IP in the five-tuple of the response message to CIP, and converts the SNAT Port in the five-tuple of the response message to CPort. Combining the foregoing description, the converted five-tuple can be implemented as (1.1.1.1, 90, 2.2.2.2, 2000, 6).
[0134] Step S429, send the response message with the converted address to the client.
[0135] In summary, after receiving the request message from the client, instead of determining the processing core of the request message according to the five-tuple of the request message, the processing core of the request message is determined according to the source address, source port, and transport protocol of the request message. For the response message corresponding to the request message, since the destination address of the response message corresponds to the source address of the request message, and the destination port of the response message corresponds to the source port of the request message, after receiving the response message corresponding to the request message, the processing core of the response message determined according to the destination address, destination port, and transport protocol of the response message is the same processing core as that of the request message. In this way, even if the five-tuples of the request message and the response message are different, the request message and the response message can still be assigned to the same core of the LB device for processing, which is beneficial to improving the processing performance of the LB device for messages.
[0136] Corresponding to the message transmission method illustrated in the above embodiments, the embodiments of the present disclosure also provide a message transmission device. AsFigure 5 As shown, a message transmission device is provided. This device can be deployed in the above-mentioned LB device and is used to execute the above-mentioned Figure 2 and Figure 4B operations performed by the LB device in Figure 5 As shown, the message transmission device includes:
[0137] A core division module 501, which is used to determine a first processing core according to the source address, source port and transmission protocol of the request message after receiving the request message from the client. The first processing core belongs to the multiple processing cores;
[0138] A forwarding module 502, which is used to call the first processing core to forward the request message to the target server;
[0139] The core division module 501 is further used to determine the first processing core according to the destination address, destination port and the transmission protocol of the response message after receiving the response message corresponding to the request message; the destination address of the response message corresponds to the source address of the request message; the destination port of the response message corresponds to the source port of the request message;
[0140] The forwarding module 502 is further used to call the first processing core to forward the response message to the client.
[0141] Optionally, the forwarding module 502 is further used to call the first processing core to convert the address and port of the request message; and forward the converted request message to the target server.
[0142] Optionally, the forwarding module 502 is further used to determine the target server; convert the destination address of the request message to the address of the target server, and convert the destination port of the request message to the port of the target server.
[0143] Optionally, if the network segment to which the address of the LB device belongs is different from the network segment to which the address of the target server belongs, the forwarding module 502 is further used to select a candidate address and a candidate port that match the first processing core from a preset candidate address set and a candidate port set; any candidate address in the candidate address set belongs to the same network segment as the address of the target server; convert the source address of the request message to the candidate address, and convert the source port of the request message to the candidate port.
[0144] Optionally, the forwarding module 502 is further configured to traverse each candidate address in the candidate address set; for each traversed candidate address, traverse the ports corresponding to the traversed candidate address; determine a second processing core according to the traversed candidate address, the traversed port, and the transport protocol; if the second processing core is the same as the first processing core, determine the traversed candidate address as the candidate address matching the first processing core, and determine the traversed port as the candidate port matching the first processing core.
[0145] Optionally, the destination address of the response message is the candidate address, and the destination port of the response message is the candidate port.
[0146] Optionally, the forwarding module 502 is further configured to call the first processing core to convert the destination address of the response message into the address of the client, and convert the destination port of the response message into the port of the client; forward the response message with the converted address to the client.
[0147] The message transmission device provided in the above embodiments of the present disclosure and the message transmission method provided in the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run, or implemented by the application programs stored therein.
[0148] The present disclosure also provides a network device, which can be implemented as Figure 1 and Figure 3 the LB device shown in Figure 2 、 Figure 4A and Figure 4B to execute the message transmission method shown in Figure 6 . Please refer to Figure 6 , which shows a schematic diagram of a network device provided in some embodiments of the present disclosure. As
[0149] Among them, the memory 601 may include high-speed random access memory (RAM), and may also include non-volatile memory, such as at least one disk memory. The communication connection between the system virtual devices is realized through at least one communication interface 603 (which can be wired or wireless), and the Internet, wide area network, local area network, metropolitan area network, etc. can be used.
[0150] The bus 602 can be an ISA bus, a PCI bus, an EISA bus, etc. The bus can be divided into an address bus, a data bus, a control bus, etc. Among them, the memory 601 is used to store programs. After receiving the execution instruction, the processor 600 executes the program. Any of the message transmission methods disclosed in the foregoing embodiments of the present disclosure can be applied to or implemented by the processor 600.
[0151] The processor 600 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by the integrated logic circuit in the hardware of the processor 600 or the instructions in software form. The above-mentioned processor 600 can be a general-purpose processor, including a central processing unit (CPU for short), a network processor (NP for short), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. It can implement or execute the various methods, steps and logic block diagrams disclosed in the embodiments of the present disclosure. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in combination with the embodiments of the present disclosure can be directly embodied as being executed and completed by the hardware decoding processor, or executed and completed by the combination of the hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the art such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register, etc. This storage medium is located in the memory 601, and the processor 600 reads the content in the memory 601 and combines its hardware to complete the steps of the above method.
[0152] The electronic device provided by the embodiments of the present disclosure and the message transmission method provided by the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run or implemented by it.
[0153] The embodiments of the present disclosure also provide a computer-readable storage medium corresponding to the message transmission method provided by the foregoing embodiments. Please refer to Figure 1, which shows that the computer-readable storage medium is an optical disc 30, on which a computer program (i.e., program product) is stored. When the computer program is run by a processor, it will execute the message transmission method provided in any of the foregoing embodiments.
[0154] It should be noted that examples of the computer-readable storage medium may further include, but are not limited to, phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory, or other optical and magnetic storage media, which will not be elaborated here one by one.
[0155] The computer-readable storage medium provided in the above embodiments of the present disclosure and the message transmission method provided in the embodiments of the present disclosure are based on the same inventive concept and have the same beneficial effects as the methods adopted, run, or implemented by the application programs stored therein.
[0156] Although the optional embodiments of the present disclosure have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concept. Therefore, the appended claims are intended to be construed to include the preferred embodiments as well as all changes and modifications falling within the scope of the present disclosure.
[0157] The above specific embodiments have further elaborated the purpose, technical solution, and beneficial effects of the present disclosure. It should be understood that the above is only the specific embodiment of the present disclosure and is not used to limit the protection scope of the present disclosure. Any modification, equivalent replacement, improvement, etc. made on the basis of the technical solution of the present disclosure shall be included in the protection scope of the present invention.
Claims
1. A message transmission method, characterized in that: Applied to a load balancing LB device, the LB device includes multiple processing cores, and the method includes: After receiving a request message from a client, determining a first processing core according to a source address, a source port, and a transmission protocol of the request message, where the first processing core belongs to the multiple processing cores; Invoke the first processing core to forward the request message to a target server; After receiving a response message corresponding to the request message, determining the first processing core according to the destination address, destination port and the transmission protocol of the response message; the destination address of the response message corresponds to the source address of the request message; the destination port of the response message corresponds to the source port of the request message; Invoke the first processing core to forward the response message to the client.
2. The method according to claim 1, characterized in that The calling the first processing core to forward the request message to the target server includes: Calling the first processing core to convert the address and port of the request message; The converted request message is forwarded to the target server.
3. The method according to claim 2, characterized in that The calling the first processing core to convert the address and port of the request message includes: Determining the target server; The destination address of the request message is converted into the address of the target server, and the destination port of the request message is converted into the port of the target server.
4. The method according to claim 2 or 3, characterized in that: If the network segment to which the address of the LB device belongs is different from the network segment to which the address of the target server belongs, calling the first processing core to convert the address and port of the request message includes: Selecting a candidate address and a candidate port that match the first processing core from a preset candidate address set and a preset candidate port set; the network segment to which any candidate address in the candidate address set belongs is the same as the network segment to which the address of the target server belongs; The source address of the request message is converted into the candidate address, and the source port of the request message is converted into the candidate port.
5. The method according to claim 4, characterized in that The selecting a candidate address and a candidate port that match the first processing core from a preset candidate address set and a preset candidate port set includes: Traversing each candidate address in the candidate address set; For each traversed candidate address, traverse the port corresponding to the traversed candidate address; Determining a second processing core according to the traversed candidate address, the traversed port and the transmission protocol; If the second processing core is the same as the first processing core, the traversed candidate address is determined as a candidate address matching the first processing core, and the traversed port is determined as a candidate port matching the first processing core.
6. The method according to claim 4, characterized in that The destination address of the response message is the candidate address, and the destination port of the response message is the candidate port.
7. The method according to claim 6, characterized in that The calling the first processing core to forward the response message to the client includes: Invoking the first processing core to convert the destination address of the response message into the address of the client, and converting the destination port of the response message into the port of the client; The response message of the converted address is forwarded to the client.
8. A message transmission system, characterized in that: The message transmission system includes a network-connected client, a load balancing LB device and at least one server, wherein the LB device includes multiple processing cores, The client is used to send a request message to the LB device, and is also used to receive a response message corresponding to the request message from the LB device; The LB device is used to determine a first processing core according to a source address, a source port and a transmission protocol of the request message after receiving the request message from the client, wherein the first processing core belongs to the multiple processing cores; and call the first processing core to forward the request message to a target server among the at least one server; The LB device is also used to determine the first processing core according to the destination address, destination port and transmission protocol of the response message after receiving the response message corresponding to the request message; the destination address of the response message corresponds to the source address of the request message; the destination port of the response message corresponds to the source port of the request message; and call the first processing core to forward the response message to the client.
9. A message transmission device, characterized in that: Applied to a load balancing LB device, the LB device includes multiple processing cores, and the device includes: A core division module, configured to determine a first processing core according to a source address, a source port and a transmission protocol of a request message after receiving the request message from a client, wherein the first processing core belongs to the plurality of processing cores; A forwarding module, used for calling the first processing core to forward the request message to a target server; The core division module is further used to determine the first processing core according to the destination address, destination port and transmission protocol of the response message after receiving the response message corresponding to the request message; the destination address of the response message corresponds to the source address of the request message; the destination port of the response message corresponds to the source port of the request message; The forwarding module is further used to call the first processing core to forward the response message to the client.
10. A network device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor comprises a plurality of processing cores, and the processor executes the computer program to implement the method according to any one of claims 1 to 7.