Data transmission method and device, storage medium and four-layer load balancer
By carrying server address information in the data packet, the fourth-layer load balancer directly sends the packet, solving the problem of excessive hash table occupation and realizing resource conservation and packet routing accuracy.
Patent Information
- Application Number
- CN202310581506.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-22
- Publication Date
- 2024-11-22
AI Technical Summary
The fourth-layer load balancer needs to store a large hash table to manage the connection identification information between the client and the server, resulting in excessive storage resources.
By carrying the server's address information in the data packet, the fourth-layer load balancer can parse and directly send the data packet to the corresponding server, avoiding the storage requirement of the hash table.
It effectively reduces the storage resource usage of the four-layer load balancer, ensuring that different data packets on the same connection are sent to the same server without storing a large number of hash tables.
Smart Images

Figure CN119011582A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of electronic technology, and in particular, relates to a data transmission method, device, computer-readable storage medium and a four-layer load balancer. Background Art
[0002] After establishing a connection between the client and the server, the client can send a data packet to the server connected to it through the four-layer load balancer. In the related art, the four-layer load balancer needs to store a large hash table, which stores the connection identification information of all clients and servers connected through the four-layer load balancer and their corresponding hash values. The hash value corresponding to the same connection is determined based on the hash table, and the same server is selected to send data packets for the same hash value, so as to ensure that different data packets of the same connection are sent to the same server. However, in the related art, since the four-layer load balancer needs to store a large hash table, it occupies more storage resources of the four-layer load balancer. Summary of the invention
[0003] The embodiments of the present application provide a data transmission method, device, storage medium and a four-layer load balancer, which can avoid occupying more storage resources of the four-layer load balancer.
[0004] In a first aspect, an embodiment of the present application provides a data transmission method, which is applied to a four-layer load balancer, comprising:
[0005] Receive a data packet sent by a client, the data packet carrying connection identification information of a server connected to the client, the connection identification information including address information of the server;
[0006] Parsing the address information from the data packet;
[0007] The data packet is sent to the server based on the address information.
[0008] In a second aspect, an embodiment of the present application provides a data transmission device, applied to a four-layer load balancer, comprising:
[0009] A data receiving module, used to receive a data packet sent by a client, the data packet carrying connection identification information of a server connected to the client, the connection identification information including address information of the server;
[0010] An information parsing module, used for parsing the address information from the data packet;
[0011] A data sending module is used to send the data packet to the server based on the address information.
[0012] In a third aspect, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed on a computer, the computer executes the data transmission method provided by the embodiment of the present application.
[0013] In a fourth aspect, an embodiment of the present application further provides a four-layer load balancer, comprising a memory and a processor, wherein the processor is used to execute the data transmission method provided in the embodiment of the present application by calling a computer program stored in the memory.
[0014] In an embodiment of the present application, a data packet sent by a client is received, the data packet carries connection identification information of a server connected to the client, and the connection identification information includes address information of the server; the address information is parsed from the data packet; and the data packet is sent to the server based on the address information. Therefore, since the connection identification information of the server connected to the client carried by the data packet sent by the client includes the address information of the server, the four-layer load balancer only needs to parse the received data packet to obtain the address information of the server, and send the data packet to the server based on the address information, so that the four-layer load balancer can send different data packets of the same connection to the same server without storing a large hash table, thereby avoiding occupying more storage resources of the four-layer load balancer. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] The technical solution and beneficial effects of the present application will be made apparent by describing in detail the specific implementation methods of the present application in conjunction with the accompanying drawings.
[0016] Figure 1 It is a schematic diagram of a data transmission system provided in an embodiment of the present application.
[0017] Figure 2 This is a first flow chart of the data transmission method provided in an embodiment of the present application.
[0018] Figure 3 This is a first schematic diagram of the connection identification information of the server provided in an embodiment of the present application.
[0019] Figure 4 This is a second schematic diagram of the connection identification information of the server provided in an embodiment of the present application.
[0020] Figure 5 This is a third schematic diagram of the connection identification information of the server provided in an embodiment of the present application.
[0021] Figure 6 This is a fourth schematic diagram of the connection identification information of the server provided in an embodiment of the present application.
[0022] Figure 7This is a fifth schematic diagram of the connection identification information of the server provided in an embodiment of the present application.
[0023] Figure 8 This is the sixth schematic diagram of the connection identification information of the server provided in the embodiment of the present application.
[0024] Fig. 9 This is the seventh schematic diagram of the connection identification information of the server provided in the embodiment of the present application.
[0025] Fig.10 This is a second flow chart of the data transmission method provided in an embodiment of the present application.
[0026] Fig.11 It is a structural diagram of the data transmission device provided in an embodiment of the present application.
[0027] Fig.12 It is a schematic diagram of the structure of the four-layer load balancer provided in the embodiment of the present application. DETAILED DESCRIPTION
[0028] It should be noted that the terms "first", "second" and "third" in this application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or modules is not limited to the listed steps or modules, but some embodiments also include steps or modules that are not listed, or some embodiments also include other steps or modules inherent to these processes, methods, products or devices.
[0029] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0030] The embodiments of the present application provide a data transmission method, a data transmission device, a computer-readable storage medium and a four-layer load balancer, wherein the execution subject of the data transmission method can be the data transmission device provided in the embodiments of the present application, or a four-layer load balancer integrating the data transmission device, wherein the data transmission device can be implemented in hardware or software.
[0031] See also Figure 1 , Figure 1 It is a schematic diagram of a data transmission system provided in an embodiment of the present application.
[0032] The data transmission system 100 includes a client 11, a client 12, a four-layer load balancer 20, a server 31, and a server 32. The client 11 has established a connection with the server 31. The client 12 has established a connection with the server 32. The client 11 needs to send a data packet to the server 31 through the four-layer load balancer 20. The client 12 needs to send a data packet to the server 32 through the four-layer load balancer 20.
[0033] The server can exist in the form of a single server or in the form of a server cluster. The server can also be called a seven-layer gateway, a seven-layer load balancer or a seven-layer switch.
[0034] When the client 11 and the server 31 establish a connection based on the QUIC protocol, the client 11 and the server 31 will both generate a connection identification information. When the client 12 and the server 32 establish a connection based on the QUIC protocol, the client 12 and the server 32 will also generate a connection identification information.
[0035] Among them, for the client, the connection identification information generated by the client can also be called source connection identification information, source connection ID or SCID, and the connection identification information generated by the server can also be called destination connection identification information, destination connection ID or DCID.
[0036] For the server, the connection identification information generated by the client can also be called source connection identification information, source connection ID or SCID, and the connection identification information generated by the server can also be called destination connection identification information, destination connection ID or DCID.
[0037] In this embodiment, for the convenience of distinction, the connection identification information generated by the client can be regarded as the connection identification information of the client, and the connection identification information generated by the server can be regarded as the connection identification information of the server.
[0038] When generating the connection identification information of the server 31, the server 31 obtains the address information of the server 31, and generates the connection identification information of the server 31 based on the address information and the corresponding random number. When generating the connection identification information of the server 32, the server 32 obtains the address information of the server 32, and generates the connection identification information of the server 32 based on the address information and the corresponding random number.
[0039] It should be noted that the address information of a server is used to uniquely identify the server.
[0040] After the client 11 and the server 31 establish a connection based on the QUIC protocol, when the client 11 generates a data packet, it will add the connection identification information of the server 31 to the data packet, and then send the data packet to the four-layer load balancer 20.
[0041] Since the connection identification information of the server 31 includes the address information of the server 31, after the four-layer load balancer 20 receives the data packet sent by the client 11, it can parse the address information of the server 31 from the data packet. After parsing the address information of the server 31, the four-layer load balancer 20 can send the data packet sent by the client 11 to the server 31 based on the address information of the server 31.
[0042] After the client 12 establishes a connection with the server 32 based on the QUIC protocol, the client 12 will add the connection identification information of the server 32 to the data packet when generating the data packet, and then send the data packet to the four-layer load balancer 20.
[0043] Since the connection identification information of the server 32 includes the address information of the server 32, after the four-layer load balancer 20 receives the data packet sent by the client 12, it can parse the address information of the server 32 from the data packet. After parsing the address information of the server 32, the four-layer load balancer 20 can send the data packet sent by the client 12 to the server 32 based on the address information of the server 32.
[0044] Among them, QUIC (Quick UDP Internet Connections) is a new transport layer network protocol that has emerged in recent years and is designed to replace the TCP protocol. It provides security comparable to TLS / SSL, while having lower connection and transmission delays. QUIC is based on UDP, so it has excellent weak network performance and can still provide available services in the case of severe packet loss and network delay.
[0045] It should be noted that the above is only an example of the data transmission system 100 and is not intended to limit the present application. In actual applications, the data transmission system 100 may also include more clients, servers, and four-layer load balancers, as well as more other devices, such as backend service clusters, cloud servers, routers, etc., which are not specifically limited here and are subject to actual needs.
[0046] See also Figure 2 , Figure 2 1 is a schematic diagram of a first flow chart of a data transmission method provided in an embodiment of the present application. The data transmission method can be applied to a four-layer load balancer. The flow may include:
[0047] In 101, a data packet sent by a client is received, the data packet carries connection identification information of a server connected to the client, and the connection identification information includes address information of the server.
[0048] When establishing a QUIC connection between the client and the server, both the client and the server will generate a 20-byte connection identification information.
[0049] Among them, from the client's point of view, the connection identification information generated by the client is called source connection identification information, source connection ID or SCID, and the connection identification information generated by the server is called destination connection identification information, destination connection ID or DCID. From the server's point of view, the connection identification information generated by the server is called source connection identification information, source connection ID or SCID, and the connection identification information generated by the client is called destination connection identification information, destination connection ID or DCID.
[0050] In this embodiment, for the convenience of distinction, the connection identification information generated by the client can be regarded as the connection identification information of the client, and the connection identification information generated by the server can be regarded as the connection identification information of the server.
[0051] In the related art, the connection identification information generated by the client and the server is a 20-byte random number. The random numbers generated by different clients are different. The random numbers generated by different servers are also different. After receiving a data packet that a client needs to send to the server connected to it, the four-layer load balancer will hash the connection identification information of the client and the connection identification information of the server connected to the client based on its stored hash table to obtain a corresponding hash value. After obtaining the corresponding hash value, the four-layer load balancer can send the data packet to the server corresponding to the hash value. Among them, the same hash value corresponds to the same server.
[0052] In the related art, since the hash table stored in the four-layer load balancer stores the connection identification information of all clients and servers connected through the four-layer load balancer and their corresponding hash values, the four-layer load balancer needs to store a larger hash table, thus occupying more storage resources of the four-layer load balancer.
[0053] For example, assuming that client 13 needs to send a data packet to server 33 through layer-4 load balancer 21, and client 14 needs to send a data packet to server 34 through layer-4 load balancer 21, the hash table stored in layer-4 load balancer 21 stores the connection identification information of client 13 and server 33 and its corresponding hash value, as well as the connection identification information of client 14 and server 14 and its corresponding hash value. When there are more connections passing through layer-4 load balancer 21, that is, when more clients need to send data packets to more servers, the hash table stored in layer-4 load balancer 21 will need to store more connection identification information of clients and servers and their corresponding hash values, resulting in the hash table stored in layer-4 load balancer 21 becoming larger and larger, which in turn occupies more storage resources of layer-4 load balancer 21.
[0054] Since the address information of each server uniquely refers to each server, the four-layer load balancer can accurately send data packets to each server through the address information of each server. Based on this, in this embodiment, when the client and the server establish a connection based on the QUIC protocol, the server will obtain its own address information and generate the connection identification information of the server based on the address information and the corresponding random number. Among them, the number of bytes occupied by the connection identification information of the server is 20. After the connection identification information of the server is generated, the server can send the connection identification information of the server to the client.
[0055] For example, when the client 11 and the server 31 establish a connection based on the QUIC protocol, the server 31 obtains its own address information, generates 20-byte connection identification information based on the address information and the corresponding random number as the connection identification information of the server 31, and sends the connection identification information of the server 31 to the client 11.
[0056] For another example, when the client 12 and the server 32 establish a connection based on the QUIC protocol, the server 32 obtains its own address information, generates 20-byte connection identification information based on the address information and the corresponding random number as the connection identification information of the server 32, and sends the connection identification information of the server 32 to the client 12.
[0057] In this embodiment, when the client needs to send a data packet to the server connected to it through the four-layer load balancer, the client will add the connection identification information of the server connected to it in the generated data packet and send the data packet to the four-layer load balancer. The four-layer load balancer receives the data packet sent by the client.
[0058] For example, when the client 11 needs to send a data packet to the server 31 connected to it through the four-layer load balancer 20, the client 11 will add the connection identification information of the server 31 connected to it to the generated data packet, and send the data packet to the four-layer load balancer 20. The four-layer load balancer 20 receives the data packet sent by the client 11.
[0059] For another example, when the client 12 needs to send a data packet to the server 32 connected thereto through the layer-4 load balancer 20, the client 12 will add the connection identification information of the server 32 connected thereto into the generated data packet, and send the data packet to the layer-4 load balancer 20. The layer-4 load balancer 20 will receive the data packet sent by the client 12.
[0060] It should be noted that the data packet mentioned in the embodiments of the present application may be a QUIC data packet.
[0061] In 102, the address information is parsed from the data packet.
[0062] Since the data packet sent by the client carries the connection identification information of the server connected to it, and the connection identification information includes the address information of the server connected to it, in this embodiment, by parsing the data packet sent by the client, the four-layer load balancer can parse out the connection identification information of the server connected to the client from the data packet, and then by parsing the connection identification information, the four-layer load balancer can parse out the connection identification information of the server connected to the client from the connection identification information.
[0063] For example, when the four-layer load balancer 20 receives a data packet sent by the client 11, the four-layer load balancer 20 can parse the data packet to obtain the connection identification information of the server 31; the four-layer load balancer 20 then parses the connection identification information of the server 31 to obtain the address information of the server 31.
[0064] For another example, when the four-layer load balancer 20 receives a data packet sent by the client 12, the four-layer load balancer 20 can parse the data packet to obtain the connection identification information of the server 32; the four-layer load balancer 20 can then parse the connection identification information of the server 32 to obtain the address information of the server 32.
[0065] In 103, the data packet is sent to the server based on the address information.
[0066] Since the data packet can be accurately sent to the corresponding server through the address information of the server, based on this, in this embodiment, after the address information of the server is parsed from the data packet, the four-layer load balancer can send the data packet to the server based on the address information.
[0067] For example, after the four-layer load balancer 20 parses the address information of the server 31 from the data packet D111 sent by the client 11, the four-layer load balancer 20 can send the data packet D111 sent by the client 11 to the server 31 based on the address information of the server 31. After the four-layer load balancer 20 parses the address information of the server 31 from the data packet D112 sent by the client 11, the four-layer load balancer 20 can send the data packet D112 sent by the client 11 to the server 31 based on the address information of the server 31.
[0068] For another example, after the four-layer load balancer 20 parses the address information of the server 32 from the data packet D121 sent by the client 12, the four-layer load balancer 20 can send the data packet D121 sent by the client 12 to the server 32 based on the address information of the server 32. After the four-layer load balancer 20 parses the address information of the server 32 from the data packet D122 sent by the client 12, the four-layer load balancer 20 can send the data packet D122 sent by the client 12 to the server 32 based on the address information of the server 32.
[0069] In this embodiment, a data packet sent by a client is received, the data packet carries connection identification information of a server connected to the client, and the connection identification information includes address information of the server; the address information is parsed from the data packet; and the data packet is sent to the server based on the address information. Therefore, since the connection identification information of the server connected to the client carried in the data packet sent by the client includes the address information of the server, the four-layer load balancer only needs to parse the received data packet to obtain the address information of the server, and send the data packet to the server based on the address information, so that the four-layer load balancer can send different data packets of the same connection to the same server without storing a large hash table, thereby avoiding occupying more storage resources of the four-layer load balancer.
[0070] In an optional embodiment, the connection identification information is generated by the server based on the address information of the server and a corresponding random number.
[0071] The corresponding random number may be a number, letter, symbol, etc. randomly generated by the server. The corresponding random numbers corresponding to different servers may be the same or different.
[0072] For example, the connection identification information of the server can be as follows Figure 3 The connection identification information of the server can also be as follows Figure 4 shown.
[0073] The address information may include an IP (Internet Protocol) address and a port number.
[0074] In an optional embodiment, the connection identification information is obtained by the server rewriting the random numbers generated by it except the corresponding random number into the address information of the target server.
[0075] For example, the server may first generate a 20-byte random number, and then rewrite part of the random number into the address information of the server, and use the other part of the random number as the corresponding random number to obtain the connection identification information of the server.
[0076] In an optional embodiment, the server may rewrite part of the random numbers into the address information of the server by referring to the following code.
[0077] / / Generate a random number of 20 bytes;
[0078] RAND_bytes(id, NGX_QUIC_SERVER_CID_LEN);
[0079] / / Get the local IP address and port number and put them in sin;
[0080] sin=(struct sockaddr_in)c->local_sockaddr;
[0081] / / Get the IP address from sin;
[0082] addr=sin->sin_addr.s_addr;
[0083] / / Rewrite the first, second, third and fourth bytes into the IP address;
[0084] id[0] = (addr>>24) & 0xff;
[0085] id[1] = (addr>>16) & 0xff;
[0086] id[2] = (addr>>8) & 0xff;
[0087] id[3] = addr&0xff;
[0088] / / Rewrite the 5th and 6th bytes as the port number;
[0089] id[4]=(sin->sin_port>>8)&0xff;
[0090] id[5]=(sin->sin_port8)&0xff;
[0091] In an optional embodiment, the number of bytes occupied by the IP address is 4, the number of bytes occupied by the port number is 2, and the number of bytes occupied by the corresponding random number is 14.
[0092] For example, the connection identification information of the server can be as follows Figure 5 shown.
[0093] In an optional embodiment, the format of the connection identification information is: the port number is located between the IP address and the target random number.
[0094] For example, the connection identification information can be Figure 6 shown.
[0095] In an optional embodiment, the format of the connection identification information is: the IP address is located before the port number, and the target random number is located after the port number.
[0096] For example, the connection identification information can be Figure 7 shown.
[0097] In an optional embodiment, the connection identification information may be as follows: Figure 8 shown.
[0098] In an optional embodiment, the connection identification information may be as follows: Fig. 9 shown.
[0099] It should be noted that Figures 3 to 9 This is only an example of the format of the connection identification information and is not intended to limit the present application. In practical applications, the format of the connection identification information may also be in other forms based on the address information of the server and the corresponding random number.
[0100] See also Fig.10 , Fig.10 1 is a second flow diagram of a data transmission method provided in an embodiment of the present application. The data transmission method is applied to a four-layer load balancer. The flow may include:
[0101] In 201, a data packet sent by a client is received, and the data packet carries connection identification information of a server connected to the client. The connection identification information is obtained by rewriting a random number generated by the server except the corresponding random number into its IP address and port number. The number of bytes occupied by the IP address is 4, the number of bytes occupied by the port number is 2, and the number of bytes occupied by the corresponding random number is 14.
[0102] For example, when the client 11 establishes a QUIC connection with the server 31, the server 31 can obtain the IP address and port number of the server 31, and based on the IP address and port number of the server 31 and the corresponding random number, generate 20 bytes of connection identification information as the connection identification information of the server 31. After obtaining the connection identification information of the server 31, the server 31 can send the connection identification information of the server 31 to the client 11.
[0103] Among them, in the connection identification information of the server 31, the IP address of the server 31 occupies 4 bytes, the port number of the server 31 occupies 2 bytes, and the corresponding random number occupies 4 bytes.
[0104] When generating data packet D111, client 11 adds connection identification information of server 31 into data packet D111 and sends generated data packet D111 to layer-4 load balancer 20. Layer-4 load balancer 20 receives data packet D111 sent by client 11.
[0105] When generating data packet D112, client 11 adds connection identification information of server 31 into data packet D112 and sends generated data packet D112 to layer-4 load balancer 20. Layer-4 load balancer 20 receives data packet D112 sent by client 11.
[0106] In 202, the IP address and the port number are parsed from the data packet.
[0107] For example, when the layer-4 load balancer 20 receives the data packet D111, the layer-4 load balancer can parse the connection identification information of the server 31 from the data packet D111, and then parse the IP address and port number of the server 31 from the connection identification information.
[0108] For another example, when the four-layer load balancer 20 receives the data packet D112, the four-layer load balancer can parse the connection identification information of the server 31 from the data packet D112, and then parse the IP address and port number of the server 31 from the connection identification information.
[0109] In 203, the data packet is sent to the server based on the IP address and the port number.
[0110] For example, after the layer-4 load balancer 20 parses the IP address and port number of the server 31 from the data packet D111 , the layer-4 load balancer 20 may send the data packet D111 to the server 31 based on the IP address and port number of the server 31 .
[0111] For another example, after the layer-4 load balancer 20 parses the IP address and port number of the server 31 from the data packet D112 , the layer-4 load balancer 20 may send the data packet D112 to the server 31 based on the IP address and port number of the server 31 .
[0112] In this embodiment, a data packet sent by a client is received, the data packet carries connection identification information of a server connected to the client, the connection identification information is obtained by rewriting a random number generated by the server except the corresponding random number into its IP address and port number, the number of bytes occupied by the IP address is 4, the number of bytes occupied by the port number is 2, and the number of bytes occupied by the corresponding random number is 14; the IP address and the port number are parsed from the data packet; the data packet is sent to the server based on the IP address and the port number, thus, since the connection identification information of the server connected to the client carried by the data packet sent by the client includes the IP address and port number of the server, the four-layer load balancer only needs to parse the received data packet to obtain the IP address and port number of the server, and sends the data packet to the server based on the IP address and port number, so that the four-layer load balancer can send different data packets of the same connection to the same server without storing a large hash table, thereby avoiding occupying more storage resources of the four-layer load balancer.
[0113] See also Fig.11 , Fig.11 The data transmission device 300 includes a data receiving module 301 , an information parsing module 302 , and a data sending module 303 .
[0114] The data receiving module 301 is used to receive a data packet sent by a client, wherein the data packet carries connection identification information of a server connected to the client, and the connection identification information includes address information of the server.
[0115] The information parsing module 302 is used to parse the address information from the data packet.
[0116] The data sending module 303 is used to send the data packet to the server based on the address information.
[0117] In an optional embodiment, the connection identification information is generated by the server based on its address information and a corresponding random number.
[0118] In an optional embodiment, the connection identification information is obtained by the server rewriting a random number generated by the server except the corresponding random number into its address information.
[0119] In an optional embodiment, the address information includes an IP address and a port number.
[0120] In an optional embodiment, the number of bytes occupied by the IP address is 4, the number of bytes occupied by the port number is 2, and the number of bytes occupied by the corresponding random number is 14.
[0121] In an optional embodiment, the format of the connection identification information is: the port number is located between the IP address and the corresponding random number.
[0122] In an optional embodiment, the format of the connection identification information is: the IP address is located before the port number, and the corresponding random number is located after the port number.
[0123] In this embodiment, a data packet sent by a client is received by a data receiving module 301, the data packet carries connection identification information of a server connected to the client, and the connection identification information includes address information of the server; the address information is parsed from the data packet by an information parsing module 302; the data packet is sent to the server based on the address information by a data sending module 303. Thus, since the connection identification information of the server connected to the client carried by the data packet sent by the client includes the address information of the server, the four-layer load balancer only needs to parse the received data packet to obtain the address information of the server, and send the data packet to the server based on the address information, so that the four-layer load balancer can send different data packets of the same connection to the same server without storing a large hash table, thereby avoiding occupying more storage resources of the four-layer load balancer.
[0124] An embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed on a computer, the computer executes the data transmission method provided in the embodiment.
[0125] The embodiment of the present application also provides a four-layer load balancer, including a memory and a processor, wherein the processor is used to execute the data transmission method provided in the embodiment by calling a computer program stored in the memory.
[0126] For example, the above four-layer load balancer can be a mobile terminal such as a tablet or a smart phone. Fig.12 , Fig.12 A schematic diagram of the structure of a four-layer load balancer provided in an embodiment of the present application.
[0127] The four-layer load balancer 400 may include components such as a processor 401 and a memory 402. Those skilled in the art will appreciate that Fig.12 The four-layer load balancer structure shown in the figure does not constitute a limitation on the four-layer load balancer, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.
[0128] Processor 401 is the control center of the four-layer load balancer. It uses various interfaces and lines to connect various parts of the entire four-layer load balancer. It executes various functions of the four-layer load balancer and processes data by running or executing applications stored in memory 402 and calling data stored in memory 402, thereby monitoring the four-layer load balancer as a whole.
[0129] The memory 402 may be used to store applications and data. The applications stored in the memory 402 include executable codes. The applications may be composed of various functional modules. The processor 401 executes various functional applications and data processing by running the applications stored in the memory 402.
[0130] In this embodiment, the processor 401 in the four-layer load balancer will load the executable code corresponding to the process of one or more application programs into the memory 402 according to the following instructions, and the processor 401 will run the application program stored in the memory 402, thereby achieving:
[0131] Receive a data packet sent by a client, the data packet carrying connection identification information of a server connected to the client, the connection identification information including address information of the server;
[0132] Parsing the address information from the data packet;
[0133] The data packet is sent to the server based on the address information.
[0134] In an optional embodiment, the connection identification information is generated by the server based on its address information and a corresponding random number.
[0135] In an optional embodiment, the connection identification information is obtained by the server rewriting a random number generated by the server except the corresponding random number into its address information.
[0136] In an optional embodiment, the address information includes an IP address and a port number.
[0137] In an optional embodiment, the number of bytes occupied by the IP address is 4, the number of bytes occupied by the port number is 2, and the number of bytes occupied by the corresponding random number is 14.
[0138] In an optional embodiment, the format of the connection identification information is: the port number is located between the IP address and the corresponding random number.
[0139] In an optional embodiment, the format of the connection identification information is: the IP address is located before the port number, and the corresponding random number is located after the port number.
[0140] The four-layer load balancer 400 provided in the embodiment of the present application receives a data packet sent by a client, wherein the data packet carries connection identification information of a server connected to the client, and the connection identification information includes address information of the server; parses the address information from the data packet; and sends the data packet to the server based on the address information. Therefore, since the connection identification information of the server connected to the client carried in the data packet sent by the client includes the address information of the server, the four-layer load balancer only needs to parse the received data packet to obtain the address information of the server, and sends the data packet to the server based on the address information, so that the four-layer load balancer can send different data packets of the same connection to the same server without storing a large hash table, thereby avoiding occupying more storage resources of the four-layer load balancer.
[0141] In the above embodiments, the description of each embodiment has its own focus. For the part that is not described in detail in a certain embodiment, please refer to the detailed description of the data transmission method above, and will not be repeated here.
[0142] The data transmission device provided in the embodiment of the present application belongs to the same concept as the data transmission method in the above embodiment. Any method provided in the data transmission method embodiment can be run on the data transmission device. The specific implementation process is detailed in the data transmission method embodiment, which will not be repeated here.
[0143] It should be noted that, for the data transmission method of the embodiment of the present application, a person of ordinary skill in the art can understand that all or part of the process of implementing the data transmission method of the embodiment of the present application can be completed by controlling the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, such as a memory, and executed by at least one processor, and the execution process may include the process of the embodiment of the data transmission method. Among them, the computer-readable storage medium can be a disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), etc.
[0144] For the data transmission device of the embodiment of the present application, each functional module can be integrated into a processing chip, or each module can exist physically separately, or two or more modules can be integrated into one module. The above-mentioned integrated module can be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium, such as a read-only memory, a disk or an optical disk.
[0145] It is understandable that in the specific implementation of this application, user information is involved, such as application usage behavior data, logs and other related data. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0146] The above is a detailed introduction to a data transmission method, device, storage medium and four-layer load balancer provided in the embodiments of the present application. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea; at the same time, for technical personnel in this field, according to the ideas of the present application, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.
Claims
1. A data transmission method, applied to a four-layer load balancer, characterized in that: include: Receive a data packet sent by a client, the data packet carrying connection identification information of a server connected to the client, the connection identification information including address information of the server; Parsing the address information from the data packet; The data packet is sent to the server based on the address information.
2. The data transmission method according to claim 1, characterized in that: The connection identification information is generated by the server based on its address information and a corresponding random number.
3. The data transmission method according to claim 2, characterized in that: The connection identification information is obtained by the server rewriting random numbers generated by the server except the corresponding random number into its address information.
4. The data transmission method according to any one of claims 1 to 3, characterized in that: The address information includes an IP address and a port number.
5. The data transmission method according to claim 4, characterized in that: The number of bytes occupied by the IP address is 4, the number of bytes occupied by the port number is 2, and the number of bytes occupied by the corresponding random number is 14.
6. The data transmission method according to claim 4, characterized in that: The format of the connection identification information is: the port number is located between the IP address and the corresponding random number.
7. The data transmission method according to claim 6, characterized in that: The format of the connection identification information is: the IP address is located before the port number, and the corresponding random number is located after the port number.
8. A data transmission device, applied to a four-layer load balancer, characterized in that: include: A data receiving module, used to receive a data packet sent by a client, the data packet carrying connection identification information of a server connected to the client, the connection identification information including address information of the server; An information parsing module, used for parsing the address information from the data packet; A data sending module is used to send the data packet to the server based on the address information.
9. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed on a computer, the computer is enabled to execute the data transmission method according to any one of claims 1 to 7.
10. A four-layer load balancer, characterized in that: The four-layer load balancer includes a processor and a memory, wherein a computer program is stored in the memory, and the processor is used to execute the data transmission method according to any one of claims 1 to 7 by calling the computer program stored in the memory.
