Data processing method, gateway and terminal equipment
By assigning a service identifier when the terminal device establishes a connection with the gateway and carrying the identifier in the data packet, the problem of erroneous routing during the gateway iteration process is solved, stateless routing is realized, and the continuity and zero interruption of data transmission are ensured. It is suitable for gateway iteration scenarios where dynamic balancing strategies of the transport layer are used for routing.
Patent Information
- Application Number
- CN202511179435.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-21
- Publication Date
- 2025-10-31
AI Technical Summary
Errors and system disturbances caused during gateway iteration can affect the delivery of data packets to the target service node that was originally responsible for handling connection requests, thus impacting business continuity, especially during continuous iterations where losses can be significant.
When a terminal device establishes a connection with the gateway, a service identifier is assigned and carried in the data packet. The gateway forwards the data packet directly to the corresponding service node based on the service identifier, thereby achieving stateless routing and avoiding incorrect routing and interruption of data packets during gateway iteration.
It ensures the continuity of data transmission, achieves zero interruption in the connection between terminal devices and service nodes during gateway iteration, reduces system disturbance, and is suitable for gateway iteration scenarios where dynamic balancing strategies at the transport layer are used for routing.
Smart Images

Figure CN120881069A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to a data processing method, a gateway, and a terminal device. Background Technology
[0002] As a crucial component connecting clients and backend service clusters, the gateway undertakes the core functions of data forwarding and protocol conversion. The gateway receives request data packets from clients, and through parsing and routing decisions, distributes the packets to the appropriate backend service nodes to achieve data communication and resource allocation between different devices. To improve data transmission flexibility and system stability, gateways typically employ dynamic routing strategies based on load balancing to dynamically adjust the forwarding paths of data packets. During gateway iterations (gateway upgrades, changes in routing strategies, dynamic changes in the network service cluster, etc.), load balancing is triggered, causing connection redistribution. This can disrupt data communication on terminal devices that have already established connections and are communicating normally. It becomes difficult to ensure that data packets are accurately delivered to the target service node originally responsible for handling the connection request; data packets may be assigned to new service nodes with no associated historical records, impacting business continuity and causing significant system losses, especially during continuous iterations, where this approach incurs certain overhead. Summary of the Invention
[0003] This application provides a data processing method, a gateway, and a terminal device to solve the technical problems of system disturbance and loss caused by erroneous routing during gateway iteration in related technologies.
[0004] The technical solution adopted in this application is as follows.
[0005] In a first aspect, this application provides a data processing method applied to a gateway, which is used for data interaction between a terminal device and a service cluster, the service cluster including multiple service nodes. The method includes: in response to receiving a data packet from a terminal device, detecting whether the data packet carries a service identifier; if a service identifier is detected, forwarding the data packet to the service node corresponding to the service identifier; wherein, the service identifier is assigned by the terminal device when establishing a connection with the gateway.
[0006] Thus, the data processing method of this application can solve the routing problem of data interaction between terminal devices and service clusters, i.e., multiple service nodes. Moreover, compared with existing technologies, this solution can achieve stateless routing during gateway iteration, reducing system disturbances and losses, and realizing a smooth gateway iteration scheme. Specifically, the terminal device only needs to obtain the service identifier of the assigned service node when establishing a connection with the gateway. After the connection is established, the terminal device carries the service identifier in the data packet. The gateway will then directly forward the data packet to the service node corresponding to the service identifier, ensuring that the data packet is always delivered to the service node originally responsible for handling the connection request. This prevents the current terminal device from needing to re-route or causing incorrect data packet routing due to gateway iteration, thereby ensuring the continuity of data transmission. This is equivalent to achieving stateless routing, realizing zero interruption of the connection between the terminal device and the service node during gateway iteration, and avoiding routing failures, incorrect forwarding, or forwarding failures caused by the gateway during iteration. Gateway iteration will not affect data transmission under the existing connection of the current terminal device, because for the current terminal device with an established connection, the gateway will forward data packets according to the service identifier. Therefore, the data transmission of the current terminal device continues as before and is not affected. In summary, this application can achieve stateless routing, and is particularly suitable for gateway iteration scenarios based on dynamic balancing strategies for routing at the transport layer (layer 4).
[0007] In conjunction with the first aspect, in one possible implementation, the service identifier is obtained based on connection processing operations. These operations include: responding to a connection request packet received from a terminal device requesting the establishment of a connection; selecting a service node from the service cluster for allocation to the terminal device according to a preset routing policy; determining the service identifier of the allocated service node; sending the connection request packet to the allocated service node; receiving a connection response packet from the allocated service node in response to the connection request packet; and sending a connection response packet to the terminal device. The connection response packet received by the terminal device carries the service identifier, enabling the terminal device to obtain the service identifier for subsequent data packet transmission. The service identifier is written into the connection response packet through a gateway or the allocated service node.
[0008] In this way, by cleverly using the response packet during the connection establishment phase to pass the service identifier to the terminal device, for the same terminal device, the gateway only needs to execute the routing policy once to allocate a service node during the connection establishment phase. There is no need to execute the routing policy again afterwards. The gateway can directly forward the data packet to the corresponding service node based on the service identifier in the data packet sent by the terminal device.
[0009] In conjunction with the first aspect, in one possible implementation, the gateway is a transport layer device; the service identifier is carried in the connection response packet by being written into the transport layer header of the connection response packet by the gateway or the assigned service node during the connection processing operation; detecting whether the data packet carries the service identifier includes: detecting whether the transport layer header of the data packet carries the service identifier.
[0010] For transport layer gateways, since they operate at OSI (Open Systems Interconnection) Layer 4, they only parse the transport layer header and are unaware of application layer content (such as the HTTP protocol). They cannot participate in connection state management and mainly forward data packets for user backend services. They can only decide how to forward data packets based on routing policies. Therefore, related technologies cannot resolve the contradiction between the statelessness (no connection table maintenance) of Layer 4 gateways and the requirement for accurate routing. However, this application cleverly passes the service identifier to the terminal device during the connection establishment phase. Subsequently, the terminal device only needs to write the service identifier into the transport layer header. According to the scheme of this application, the gateway determines the service identifier by detecting the transport layer header and then forwards the data packet to the corresponding service node. In this way, the contradiction between the statelessness (no connection table maintenance) of Layer 4 gateways and the requirement for accurate routing can be resolved.
[0011] In conjunction with the first aspect, in one possible implementation, the gateway is a transport layer device, and both data packets and connection request packets are TCP packets. The connection request packet is a transport layer handshake message in the three-way handshake phase, and the service identifier is written in the extended field of the transport layer header of the TCP packet.
[0012] Thus, this application achieves dynamic route injection into the terminal device through a three-way handshake TCP response packet, enabling the terminal device to transmit data tables based on the injected service identifier. Consequently, the gateway can obtain the service identifier from the extended field of the transport layer header of the TCP packet and directly forward data packets to the service node based on the service identifier, thereby achieving stateless routing during the transmission phase.
[0013] In conjunction with the first aspect, in one possible implementation, the service identifier includes the network location information of the service node; forwarding the data packet to the service node corresponding to the service identifier includes: extracting the network location information from the data packet, determining the network address of the service node based on the network location information, and sending the data packet to the service node based on the network address.
[0014] In conjunction with the first aspect, in one possible implementation, each service node within the service cluster belongs to the same local area network (LAN). The network address of a service node is composed of a first location value and a second location value. The first location value is used to represent the LAN, and the second location value is used to represent a specific service node within the LAN. The network location information is the second location value. Determining the network address of a service node based on the network location information includes concatenating the extracted network location information with the first location value corresponding to the LAN to obtain the network address representing the specific service node.
[0015] In this way, the data packet only needs to carry the differentiated information of the service node (the second location value, such as the IP suffix), reducing the overhead of identification transmission. Moreover, the gateway can directly concatenate this LAN base address (the first location value) with the service identifier (the second location value) to directly obtain the network address of the service node, thereby achieving fast address synthesis and reducing the computational complexity of the gateway.
[0016] In conjunction with the first aspect, in one possible implementation, the method further includes: when the data packet does not carry a service identifier or the service node corresponding to the service identifier it carries leaves the service cluster, selecting a service node from the service cluster to allocate to the terminal device according to a preset routing policy, and sending the data packet to the allocated service node.
[0017] Thus, when a data packet is detected to lack a service identifier, or when the service node corresponding to the service identifier has left the service cluster, the system can select or reselect a suitable service node from the currently available service clusters according to the preset routing policy, and dynamically route the data packet to the new service node. That is, when the identifier expires, it automatically switches to the traditional routing policy to ensure service continuity.
[0018] Secondly, this application also provides a data processing method applied to a terminal device. The method includes: in response to a data packet sending request, embedding a service identifier in a data packet, wherein the service identifier is assigned by the terminal device when establishing a connection with a gateway, the gateway is used for data interaction between the terminal device and a service cluster, and the service cluster includes multiple service nodes; sending a data packet carrying the service identifier to the gateway, so that the gateway forwards the data packet to the service node corresponding to the service identifier based on the service identifier in the data packet.
[0019] In conjunction with the second aspect, in one possible implementation, the service identifier is obtained based on connection processing operations, which include: in response to a connection request, sending a connection request packet to the gateway; in response to a connection response packet sent by the gateway in response to the connection request packet, extracting the service identifier embedded in the connection response packet; and saving the extracted service identifier for use in sending subsequent data packets.
[0020] In conjunction with the second aspect, in one possible implementation, the gateway is a transport layer device; the service identifier is carried in the connection response packet by being written into the transport layer header of the connection response packet by the gateway or the assigned service node during the connection processing operation; extracting the service identifier embedded in the connection response packet includes: extracting the service identifier from the transport layer header of the connection response packet.
[0021] In conjunction with the second aspect, in one possible implementation, the gateway is a transport layer device, and both data packets and connection request packets are TCP packets. The service identifier is written in an extended field of the transport layer header of the TCP packet.
[0022] In conjunction with the second aspect, in one possible implementation, the service identifier includes the network location information of the service node, so that the gateway can determine the network address of the service node based on the network location information and then send data packets to the service node.
[0023] In conjunction with the second aspect, in one possible implementation, each service node in the service cluster belongs to the same local area network (LAN). The network address of a service node is composed of a first location value and a second location value. The first location value is used to represent the LAN, and the second location value is used to represent the specific service node within the LAN. The network location information is the second location value, so that the gateway can concatenate the network location information with the first location value corresponding to the LAN to obtain the network address representing the specific service node.
[0024] Thirdly, this application also provides a gateway for data interaction between a terminal device and a service cluster, the service cluster including multiple service nodes, and the gateway including modules for executing the data processing method in the first aspect or any optional implementation of the first aspect. For example, the gateway includes: The receiving module is used to detect whether the data packet carries a service identifier in response to receiving a data packet from the terminal device; The output module is used to forward data packets to the service node corresponding to the service identifier when a service identifier is detected; the service identifier is assigned by the terminal device when establishing a connection with the gateway.
[0025] Fourthly, this application also provides a terminal device, including modules for executing the data processing method in the second aspect or any optional implementation of the second aspect. For example, the terminal device includes: The processing module is used to embed the service identifier into the data packet in response to the data packet sending request. The service identifier is assigned by the terminal device when establishing a connection with the gateway. The gateway is used for data interaction between the terminal device and the service cluster. The service cluster includes multiple service nodes. The sending module sends data packets carrying service identifiers to the gateway, so that the gateway can forward the data packets to the service node corresponding to the service identifier based on the service identifier in the data packets.
[0026] Fifthly, this application also provides a computing device, including a memory and a processor, wherein the memory is used to store computer programs or instructions; when the computer program or instructions are executed by the processor, the method in the first aspect or any possible implementation of the first aspect is implemented, or the method in the second aspect or any possible implementation of the second aspect is implemented.
[0027] Sixthly, this application also provides a computer-readable storage medium storing a computer program or instructions that, when executed by a processor, implement the method in the first aspect or any possible implementation of the first aspect, or implement the method in the second aspect or any possible implementation of the second aspect.
[0028] In a seventh aspect, this application also provides a computer program product, which includes a computer program or instructions that, when executed by a processor, implement the method in the first aspect or any possible implementation of the first aspect, or implement the method in the second aspect or any possible implementation of the second aspect.
[0029] The beneficial effects of aspects two through seven above can be referred to in aspect one or any possible implementation of aspect one, and will not be elaborated here. Based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations.
[0030] Other advantages, objectives and features of this application will be partly apparent from the description below, and partly understood by those skilled in the art through study and practice of this application. Attached Figure Description
[0031] To more clearly illustrate the technical solutions in the embodiments or related technologies of this application, the accompanying drawings used in the description of the embodiments or related technologies will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on the structures shown in these drawings without creative effort.
[0032] Figure 1a This is a schematic diagram of the implementation environment of the data processing method provided in the embodiments of this application; Figure 1b This is a timing diagram illustrating a data processing method in an exemplary embodiment of this application; Figure 2This is one of the flowcharts illustrating a data processing method in an exemplary embodiment of this application; Figure 3 This is a second flowchart illustrating a data processing method in an exemplary embodiment of this application; Figure 4 This is the third flowchart of a data processing method illustrated in an exemplary embodiment of this application; Figure 5 This is the fourth flowchart of a data processing method illustrated in an exemplary embodiment of this application; Figure 6 This is the fifth flowchart illustrating a data processing method in an exemplary embodiment of this application; Figure 7 This is the sixth flowchart illustrating a data processing method in an exemplary embodiment of this application; Figure 8 This is the seventh flowchart of a data processing method illustrated in an exemplary embodiment of this application; Figure 9 This is the eighth flowchart of a data processing method illustrated in an exemplary embodiment of this application; Figure 10 This is the ninth flowchart illustrating a data processing method in an exemplary embodiment of this application; Figure 11 This is flowchart ten of an exemplary embodiment of the data processing method shown in this application; Figure 12 This is a schematic block diagram of a gateway illustrated in an exemplary embodiment of this application; Figure 13 This is a schematic block diagram of a terminal device illustrated in an exemplary embodiment of this application; Figure 14 This is a schematic block diagram of a computing device illustrated in an exemplary embodiment of this application. Detailed Implementation
[0033] It should be noted that, in this application, the terms "exemplary" or "for example" are used to indicate that something is being described as an example, illustration, or illustration. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.
[0034] The term "and / or" as used in this application includes any and all combinations of one or more of the associated listed items. In this application, "at least one" means one or more, and "more than one" means two or more. The terms "first," "second," and other ordinal terms used in this application may be used to describe various constituent elements, but these constituent elements are not limited by these terms. The purpose of using these terms is solely to distinguish one constituent element from others and should not be construed as indicating or implying relative importance. For example, without departing from the scope of this application, a first constituent element may be named a second constituent element, and similarly, a second constituent element may be named a first constituent element.
[0035] Before introducing the embodiments of this application, the technical terms involved in this application will be introduced first.
[0036] Gateway: In a computer network, a device or system that connects different networks, protocols, or architectures is used to implement functions such as data packet forwarding, protocol conversion, and access control. It is commonly used for data communication between different networks such as local area networks (LANs) and wide area networks (WANs), and internal and external networks.
[0037] A service cluster refers to a collection of servers or nodes that provide services. A service cluster plus a gateway constitutes a local area network (LAN). The gateway is the unified service entry point for the service cluster; any data interaction between any service node within the LAN and external terminal devices must pass through the gateway. The gateway uses a load-balancing-based dynamic routing strategy to assign specific service nodes to terminal devices, thus implementing routing functionality.
[0038] Exiting the service cluster: This refers to a server or node device being removed from the service cluster or being temporarily unavailable due to reasons such as failure, maintenance, or upgrade. Nodes that have exited the service cluster no longer participate in the reception and processing of data packets.
[0039] Data interaction: refers to the process of data exchange and communication between different devices, systems or applications through network protocols, including operations such as sending, receiving and processing data.
[0040] Routing: refers to the process of determining the path that data packets take from the source address to the destination address in a network according to predetermined rules or algorithms. It is usually implemented by routers or gateway devices.
[0041] Data packets: In computer networks, data is divided into smaller units and encapsulated according to a specific network protocol (such as TCP / IP) to facilitate distribution, management, and error correction. Each data packet generally consists of two parts: a "header" containing control information such as the source address, destination address, packet sequence number, and protocol type; and a "data portion," also called the "payload," which contains the actual data to be transmitted. When a large amount of data needs to be transmitted over a network, it is usually divided into multiple data packets, each sent separately. The receiver then reassembles these packets into complete data according to their sequence numbers.
[0042] Establishing a connection refers to the process by which two communicating parties (such as a client and a server) create a data transmission channel through a specific protocol and handshake procedure, enabling them to exchange data subsequently. Taking the commonly used TCP protocol as an example, establishing a connection typically involves three steps, also known as a "three-way handshake": The client sends a "connection request packet" to the server, expressing its intention to establish a connection; after receiving the request, the server replies with a "connection response packet," indicating its agreement to establish the connection and confirming with the client; finally, the client sends a "connection confirmation packet" to the server, indicating that it has received the response, and the connection is officially established.
[0043] TCP packets are data packets encapsulated based on the Transmission Control Protocol (TCP). Each TCP packet consists of two parts: the TCP header and the data portion. The TCP header contains control and management information such as the port number, sequence number, acknowledgment number, flags, window size, and checksum, used to ensure correct data packet transmission, order control, error detection, and connection establishment and maintenance. The data portion carries the actual user data to be transmitted. The header ensures the reliability and order of data transmission, while the data portion carries the specific content exchanged between the communicating parties.
[0044] Transport layer: refers to the fourth layer in the OSI seven-layer model or the TCP / IP protocol stack. It is responsible for end-to-end data transmission management, including data segmentation, reassembly, flow control, error detection and correction.
[0045] Local Area Network (LAN): refers to a network system built within a limited geographical area (such as the same building or office area). It usually has high speed, low latency and high security, and is commonly used in corporate internal networks and home networks.
[0046] Before introducing the embodiments of this application, the relevant technologies involved in this application will be introduced first.
[0047] As a crucial component connecting clients and backend service clusters, the gateway undertakes the core functions of data forwarding and protocol conversion. The gateway receives request data packets from clients, and through parsing and routing decisions, distributes the packets to the appropriate backend service nodes to achieve data communication and resource allocation between different devices. To improve data transmission flexibility and system stability, gateways typically employ dynamic routing strategies based on load balancing to dynamically adjust the forwarding paths of data packets. During gateway iterations (gateway upgrades, changes in routing strategies, dynamic changes in the network service cluster, etc.), load balancing is triggered, causing connection redistribution. This can disrupt data communication on terminal devices that have already established connections and are communicating normally. It becomes difficult to ensure that data packets are accurately delivered to the target service node originally responsible for handling the connection request; data packets may be assigned to new service nodes with no associated historical records, impacting business continuity and causing significant system losses, especially during continuous iterations, where this approach incurs certain overhead.
[0048] Specifically, existing Layer 4 load balancing gateways typically employ methods like traffic switching and diverting when iterating service nodes. However, these methods have significant shortcomings in practical applications. Since Layer 4 load balancing primarily relies on consistent hashing for traffic distribution, changes in backend nodes, even with only a few nodes failing or having their weights adjusted, can still cause significant disturbances in the hash ring, leading to incorrect routing or connection interruptions. For TCP long-connection scenarios (such as continuous video streaming), this disturbance will cause user connection interruptions and a degraded experience. Furthermore, complete diverting of traffic is difficult and time-consuming to implement. Therefore, existing solutions struggle to meet the requirements for high availability and zero-disruption Layer 4 gateway iteration.
[0049] In summary, related technologies suffer from system disturbances and losses caused by erroneous routing during gateway iteration. To address this, this application provides a data processing method, apparatus, gateway, and terminal device that can achieve stateless routing, ensuring zero interruption of the connection between the terminal device and the service node during gateway iteration. This avoids routing failures, erroneous forwarding, or forwarding failures caused by the gateway during iteration, and is particularly suitable for gateway iteration scenarios based on dynamic balancing strategies at the transport layer (Layer 4).
[0050] The following first describes one or more exemplary operating environments to make it easier and clearer to understand the role and intent of the various implementation methods in the embodiments of this application.
[0051] Reference Figure 1aThe diagram illustrates the implementation environment of the method provided in this application embodiment. The method can be applied to the environment shown in Figure 1, which includes a terminal device 101, a gateway 102, and a service cluster. The service cluster includes multiple service nodes 103. The terminal device 101 and service nodes 103 interact via the gateway 102, and the data interaction can be wired or wireless. The terminal device 101 refers to the device initiating data interaction during network communication. Device forms include, but are not limited to, smartphones, tablets (such as iOS / Android devices), PCs (such as iMacs), and smart wearable devices. The service node 103 refers to an entity capable of responding to external requests and providing data, resources, or services, typically a server. During the process of the terminal device 101 sending data packets to the service node 103, the gateway 102 determines the path of the data packets according to predetermined rules or algorithms, ensuring that the data packets sent by the terminal device 101 are directed to a single service node 103 for processing. Typically, gateway 102 dynamically matches the load of service node 103 to ensure that each service node 103 in the service cluster maintains high service efficiency and avoids situations where some service nodes 103 are overloaded while the rest of the service nodes 103 are underloaded.
[0052] The technical solutions of this application are described below through several embodiments. It should be understood that these embodiments can be implemented in many different forms and should not be construed as being limited to the embodiments set forth herein.
[0053] Reference Figure 2 As shown, in a first aspect, this application provides a data processing method applied to a gateway 102. The gateway 102 is used for data interaction between a terminal device 101 and a service cluster, the service cluster including multiple service nodes 103. Figure 2 As shown, the method includes the following steps S201-S203: S201: In response to receiving a data packet from the terminal device, detect whether the data packet carries a service identifier, wherein the service identifier is assigned by the terminal device 101 when establishing a connection with the gateway 102.
[0054] S203: If a service identifier is detected, forward the data packet to the service node corresponding to the service identifier.
[0055] This application discloses a data processing method applicable to gateway 102, aiming to optimize the data interaction routing between terminal device 101 and the service cluster, i.e., multiple service nodes 103. When gateway 102 receives a data packet from terminal device 101, it checks whether the data packet contains a service identifier. If a service identifier is detected, gateway 102 can route the data packet to the service node 103 corresponding to the service identifier based on the service identifier. The service identifier is assigned when terminal device 101 establishes a connection with gateway 102 and is used to uniquely identify the backend service node 103 associated with that connection. Thus, by allowing terminal device 101 to obtain the service identifier of the assigned service node 103 when establishing a connection with gateway 102, and continuously carrying this identifier in subsequent data packets, gateway 102 can forward data packets based on this identifier. This effectively avoids problems such as misdelivery of data packets or service interruption that may be caused by changes in dynamic routing policies or adjustments to load balancing mechanisms. Specifically, the service identifier of this application is assigned and stored by the terminal device 101 when it initiates a connection. Therefore, each time the terminal device 101 sends a data packet to the gateway 102, it can carry the service identifier in the data packet. The gateway 102 does not need to write or maintain the service identifier in the data packet, nor does it need to store state information separately for each connection, thus realizing true stateless routing. By having the terminal device 101 store and transmit the identification information of the backend service node 103, the gateway 102 can complete the data packet forwarding based on the service identifier without being aware of the connection state during the data forwarding phase. This method eliminates the need for the gateway 102 to store and maintain the connection state, improving the system's scalability and fault tolerance. Especially during gateway 102 iterations (gateway upgrades, changes in routing strategies, dynamic changes in the network service cluster, etc.), it ensures that all data packets of the established terminal devices 101 can still be accurately and continuously forwarded to the original target service node 103, avoiding traffic disturbances and user losses caused by gateway 102 iterations, and achieving zero service interruption and smooth migration. This solution is particularly suitable for the iterative scenario of gateway 102, which uses a dynamic balancing strategy for routing at the transport layer (layer 4).
[0056] It should be understood that the gateway 102 referred to in this application is not specific, but is exemplary applied to a Layer 4 Load Balancer (L4 LB), which is a network traffic forwarding device or system that operates at Layer 4 (Transport Layer) of the OSI model. It is suitable for scenarios where traffic is scheduled and distributed via TCP / UDP protocols, and is especially suitable for scenarios with requirements such as co-location, smooth upgrades, and online iterations.
[0057] The following combination Figure 2-9 The above steps, as well as other optional steps, are explained in detail.
[0058] Regarding step S201 : In response to receiving a data packet from the terminal device, detect whether the data packet carries a service identifier; The service identifier is assigned to the terminal device 101 when it establishes a connection with the gateway 102. The service identifier is a tag used to uniquely identify each service node 103 in the service cluster. The service identifier may include device ID, service instance ID, IP address, port number, etc., and can clearly distinguish different service nodes 103, facilitating correct routing and distribution of data packets. The service identifier can be obtained through different methods and can take different forms.
[0059] Regarding the method of obtaining the service identifier, it can be obtained based on the connection processing operation; that is, a connection processing operation exists before step S201. (See reference...) Figure 3 In some embodiments, the connection processing operation specifically includes S301-S303: S301: In response to receiving a connection request packet from a terminal device requesting to establish a connection, select a service node from the service cluster to be assigned to the terminal device according to a preset routing policy, and determine the service identifier of the assigned service node. In practice, the preset routing strategy for allocating service node 103 can vary, commonly including round-robin, weighted round-robin, least-connection-based allocation, and consistent hashing. For example, round-robin can simply and effectively distribute requests evenly across all available nodes; weighted round-robin allows different weights to be assigned based on node performance differences; and consistent hashing is suitable for scenarios with frequent node additions and removals, significantly reducing data redistribution caused by node changes. Depending on actual business needs and system scale, developers can flexibly select or combine multiple strategies to adapt to different application scenarios and performance requirements.
[0060] S303: Send the connection request packet to the assigned service node; S305: Upon receiving a connection response packet from the assigned service node in response to the connection request packet, send a connection response packet to the terminal device; That is, the connection response packet received by the terminal device 101 carries a service identifier, so that the terminal device 101 can obtain the service identifier for subsequent data packet transmission.
[0061] Thus, during the connection establishment phase, a corresponding service node 103 is assigned to the terminal device 101, and the service identifier corresponding to the service node 103 is written into the connection response packet and returned to the terminal device 101. This ensures that the service identifier remains bound to all data packets sent by the terminal device 101 throughout the entire connection lifecycle, guaranteeing the continuity of data transmission. For the same terminal device 101, the gateway 102 only needs to execute the routing policy once during the connection establishment phase to assign the service node 103. Subsequent execution of the routing policy is unnecessary; data packets are directly forwarded to the corresponding service node based on the service identifier in the data packets sent by the terminal device 101. The service identifier can cover and be used for multiple subsequent routing and data forwarding operations. The service identifier allocation process can flexibly combine existing hash allocation, load balancing, and other routing algorithms without changing the basic logic of the original routing policy, ensuring the system's distributed scalability and load balancing capabilities, and further improving the compatibility of the technical solution.
[0062] It is understood that the service identifier of this application can be written into the connection response packet either through the gateway 102 or through the assigned service node 103.
[0063] refer to Figure 4 When the service identifier is written into the connection response packet through gateway 102, step S305 includes steps S401-S402: S401: When receiving a connection response packet for the connection request packet sent by the assigned service node, embed the service identifier into the connection response packet; S403: Send the connection response packet to the terminal device so that the terminal device can obtain the service identifier for subsequent data packet transmission.
[0064] Reference Figure 5 When the service identifier is written into the connection response packet through the assigned service node 103, step S305 is specified as step S501: S501: When receiving a connection response packet carrying the service identifier from the assigned service node 103 in response to the connection request packet, the terminal device 101 sends the connection response packet to the terminal device 101 so that the terminal device 101 can obtain the service identifier for subsequent data packet transmission.
[0065] Whether the service identifier is written to the connection response packet by gateway 102 or directly by the assigned service node 103, both implementation methods ensure that the terminal device 101 can obtain the service identifier in a timely and accurate manner during the connection establishment phase, thereby enabling correct routing and accurate forwarding of subsequent data packets. Specifically, the gateway 102 writing method offers greater flexibility and controllability, facilitating centralized management and unified configuration of the service identifier; while the service node 103 writing method simplifies the gateway 102 processing flow, reduces the pressure on gateway 102, and improves the system's response speed and scalability.
[0066] In one possible implementation, gateway 102 is a transport layer device; the service identifier is carried in the connection response packet by being written into the transport layer header of the connection response packet by gateway 102 or the assigned service node 103 during the connection processing operation.
[0067] The extended fields in the transport layer header should be understood as: optional fields in the transport layer protocol header used to extend protocol functionality, such as TCP Options, which can carry additional control information or metadata.
[0068] Reference Figure 6 Accordingly, step S201 is specified as including S601: S601: In response to receiving a data packet from a terminal device, detect whether the transport layer header of the data packet carries a service identifier.
[0069] In this application, the service identifier is written into the transport layer header of the connection response packet by the gateway 102 or the assigned service node 103 during the connection establishment response phase, realizing the carrying and transmission of the service identifier at the protocol layer. Since a Layer 4 gateway operates at OSI layer 4, it only parses the transport layer header (such as TCP / UDP) and does not perceive or process application layer content. Therefore, it cannot participate in connection state management like an application layer gateway, and traditional technologies struggle to meet the requirements of stateless forwarding and accurate routing. This application, however, transmits the service identifier to the terminal device in a protocol-compatible manner during the connection establishment phase. This allows the terminal device to directly write the service identifier into the transport layer header of each data packet during subsequent data transmission. The gateway only needs to detect and parse the service identifier in the transport layer header to achieve accurate data packet distribution, without needing to maintain a connection table or be aware of application layer protocol content. This ensures both the efficiency of stateless routing and meets the requirements of connection persistence and accurate data packet delivery.
[0070] On the one hand, this technical solution does not involve changes to application layer protocols, improving compatibility with various existing business systems and network protocols, and facilitating direct deployment and expansion in different scenarios. On the other hand, by carrying a service identifier in the transport layer header, complex deep packet inspection is unnecessary, ensuring that the service identifier can be quickly parsed and processed by various devices in the network path. This improves the efficiency and accuracy of data packet forwarding, reduces the risk of application layer tampering with the service identifier, and enhances the security and maintainability of data transmission. Thus, this application effectively resolves the contradiction between the statelessness of Layer 4 gateways (no connection table maintenance) and the requirement for precise routing, achieving efficient, stable, and secure service routing and data forwarding in a distributed system.
[0071] For example, gateway 102 is a transport layer device, and both data packets and connection request packets are TCP packets. The connection request packet is a transport layer handshake message in the three-way handshake phase, and the service identifier is written in the extended field of the transport layer header of the TCP packet.
[0072] This application injects dynamic routing information into terminal device 101 within the TCP three-way handshake response packet by embedding the service identifier in an extended field of the transport layer header. During subsequent data transmission, terminal device 101 encapsulates data packets based on this service identifier. Gateway 102 can then directly parse the service identifier from the TCP packet's transport layer header and accurately forward the data packet to the corresponding service node 103, thus achieving true stateless routing during the data transmission phase.
[0073] For example, to enhance the security of the solution, the service identifier carried in the extended field of the transport layer header of the TCP packet may include additional information such as magic value and checksum, which is used to verify the legality of the transport layer header content, prevent forgery or tampering, and ensure the correctness and security of data forwarding.
[0074] Regarding step S203 If a service identifier is detected, the data packet will be forwarded to the service node corresponding to the service identifier.
[0075] In terms of the form of the service identifier, in some embodiments, the service identifier includes the network location information of service node 103. Accordingly, refer to Figure 7 Step S203 includes S701-S705: S701: If a service identifier is detected, extract network location information from the data packet; Network location information refers to information used to determine the location of nodes or devices in a network. It can include IP addresses, port numbers, MAC addresses, etc., and helps to achieve accurate routing and distribution of data packets.
[0076] S703: Determine the network address of the service node based on network location information; A network address is an address information used to uniquely identify a node or device in a computer network. Common forms include IP addresses (IPv4, IPv6) and MAC addresses.
[0077] S705: Sends data packets to the service node based on the network address.
[0078] By incorporating the network location information of service node 103 as part of the service identifier, rapid addressing and accurate routing of data packets during forwarding can be achieved. In practice, gateway 102 or related network devices can directly extract network location information from data packets, easily resolving the network address of the target service node 103 without relying on additional lookup or mapping processes, effectively reducing the complexity and latency of data forwarding. This approach not only improves the overall data processing efficiency of the system but also has good scalability and flexibility, adapting to various network architectures and deployment scenarios. Furthermore, the direct carrying and parsing of network location information helps enhance the transparency and controllability of data paths, facilitating subsequent network management and maintenance.
[0079] Furthermore, refer to Figure 8 In one possible implementation, each service node 103 in the service cluster belongs to the same local area network. The network address of the service node 103 is composed of a first location value and a second location value. The first location value is used to represent the local area network, and the second location value is used to represent the specific service node 103 in the local area network. The network location information is the second location value.
[0080] The first location value can be understood as the LAN base address, which is the network segment identifier of the LAN where the service cluster resides, representing the common IP address prefix shared by all service nodes. The second location value is the IP difference value, a unique identifier for a single service node within the LAN, representing the variable portion of the node's IP address that distinguishes it from the base address. For example, suppose a service cluster is deployed within a LAN with the following network architecture: LAN base address (first location value): 192.168.1.0 / 24, meaning the last bit is the difference value, and the service node IP address is: Node A: 192.168.1.101; Node B: 192.168.1.102; Node C: 192.168.1.103; Then, the service identifier (second location value) of the service node: Node A's identifier: 101; Node B's identifier: 102; The identifier for node C is 103.
[0081] Accordingly, step S703 is specified as S801: S801: The extracted network location information is concatenated with the first location value corresponding to the local area network to obtain the network address representing the specific service node.
[0082] Continuing the example above, assuming the three-way handshake phase, if the terminal device is assigned to node B, then node B or the gateway will write node B's identifier "102" into the response packet and save it to the terminal device. When the terminal device sends a data packet, the service identifier (second location value) carried in the TCP header Options field is "102". The gateway, upon receiving this data packet, will detect the service identifier (second location value) as "102" in the TCP header Options field, and then concatenate the first location value with the second location value: "192.168.10." + "102" = "192.168.10.102". Therefore, the gateway will directly send the data packet to "192.168.10.102", that is, to the service node B.
[0083] In scenarios where all nodes within a service cluster belong to the same local area network (LAN), carrying only the second location value as network location information can significantly optimize the structure and load of data packets. Specifically, by using the known first location value of the LAN as a network prefix, only the second location value, which distinguishes service nodes within the LAN, needs to be transmitted in the data packet. During forwarding, the complete network address can be quickly reconstructed by concatenating the two values, reducing the length of location information carried in the data packet, lowering identifier transmission overhead, and improving bandwidth utilization. Furthermore, gateway 102 can directly concatenate this LAN base address (first location value) with the service identifier (second location value) to directly obtain the network address of service node 103, achieving fast address synthesis, reducing gateway computational complexity, and contributing to improved overall system forwarding efficiency and response speed.
[0084] In summary, by splitting the network address into a first location value representing the local area network and a second location value representing a specific service node 103 within the local area network, and using only the second location value as the network location information, the data communication overhead is effectively reduced while ensuring accurate node addressing, thus improving the service routing efficiency in a distributed cluster environment.
[0085] In addition, refer to Figure 9 In one possible implementation, the data processing method further includes S901: S901: When the data packet does not carry a service identifier or the service node corresponding to the service identifier leaves the service cluster, select a service node from the service cluster to allocate to the terminal device according to the preset routing policy, and send the data packet to the allocated service node.
[0086] The preset routing policy is not restrictive; the gateway allocates service nodes to terminal device 101 based on the preset routing policy during the three-way handshake phase. Thus, when a data packet is detected as not carrying a service identifier, or when the service node 103 corresponding to the service identifier has left the service cluster, the system can again select or reselect a suitable service node 103 from the currently available service cluster according to the preset routing policy, dynamically routing the data packet to a new service node. That is, when the identifier expires, it automatically switches to the traditional routing policy to ensure service continuity. Of course, the preset routing policy configured for the gateway may change during its lifecycle (e.g., algorithm updates, dynamic changes in the service cluster). In short, whenever a data packet is found to lack a service identifier, or when the service node 103 corresponding to the service identifier has left the service cluster, this application will re-allocate a service node to terminal device 101 according to the latest preset routing policy.
[0087] Reference Figure 1b The following uses a complete example to illustrate the technical solution of this application in more detail: 1) Upon receiving a new connection request packet (SYN) from terminal device 101 via a three-way handshake, gateway 102 assigns service node 103 to terminal device 101 using a preset routing strategy (e.g., hashing) and forwards the connection request packet to the corresponding service node 103. Service node 103 responds to the connection request packet by returning a connection response packet (SYN-ACK). Gateway 102 writes the service identifier of service node 103 into the connection response packet (specifically, writing the IP difference value into the option field of SYN-ACK) and forwards the connection response packet carrying the service identifier to the terminal device 101 that initiated the connection. (It is understandable that in other implementations, service node 103 could also write the service identifier into the connection response packet, with gateway 102 only responsible for forwarding.) Specifically, multiple service nodes 103 are on the same network segment. This is quite common in practice. Typically, the Layer 4 load balancer gateway 102 exposes the public IP address, while the multiple backend service nodes 103 are unified into a large internal LAN cluster. When they are on the same network segment, the network addresses of different service nodes 103 have the same prefix, with only the last part being different. This difference is written into the connection response packet as a service identifier (such as the xx value in 1.1.1.xx).
[0088] 2) Terminal device 101 stores the service identifier.
[0089] 3) In subsequent data interactions, all data packets sent by terminal device 101 to gateway 102 carry the service identifier (specifically, the second location value, i.e., the IP difference value, is written into the option field of the data packet; for example, assuming the IP difference value is xx). After receiving the data packet, gateway 102 parses the service identifier: if the parsing is successful, it concatenates the xx value in the parsed data with the IP prefix of the actual backend LAN cluster's network address (i.e., the first location value in this application, assuming it is 1.1.1 here) to obtain the corresponding 1.1.1.xx, and forwards the data packet to the service node 103 corresponding to the network address 1.1.1.xx; if the parsing fails or the service identifier is not carried, the backend service node 103 is selected for forwarding according to the normal hash logic. Here, the hit rate can be further obtained through monitoring, or, to ensure the security of the service identifier, magic pairs and some verification information can be added.
[0090] 4) After receiving the data packet carrying the service identifier forwarded by the gateway 102, the service node 103 processes it according to the business logic and returns the response data packet to the gateway 102. After receiving the response data packet, the gateway 102 forwards it to the corresponding terminal device 101 without parsing or modifying the content, thus achieving efficient data pass-through.
[0091] Through the above method, the data exchange between the terminal device 101 and the service node 103 is achieved at the gateway 102 with stateless and low-latency forwarding, which effectively improves the system's processing efficiency and stability.
[0092] Based on the same technical concept, in the second aspect, refer to... Figure 10 This application also provides a data processing method applied to a terminal device 101, the data processing method comprising S1001-S1003: S1001: In response to the data packet sending request, embed the service identifier into the data packet. The service identifier is assigned by the terminal device when establishing a connection with the gateway. The gateway is used for data interaction between the terminal device and the service cluster. The service cluster includes multiple service nodes. S1003: Send a data packet carrying a service identifier to the gateway so that the gateway can forward the data packet to the service node corresponding to the service identifier based on the service identifier in the data packet.
[0093] Corresponding to the first aspect, this application also discloses a data processing method applied to terminal device 101, which further improves the efficiency and accuracy of data interaction with service node 103 in the service cluster. Specifically, when terminal device 101 responds to a data packet sending request, terminal device 101 embeds the service identifier previously allocated during the connection establishment process with gateway 102 into the data packet. Subsequently, terminal device 101 sends the data packet carrying the service identifier to gateway 102. Gateway 102 can then accurately forward the data packet to the service node 103 corresponding to the identifier based on the service identifier in the data packet, thereby achieving end-to-end data routing.
[0094] Similar to the embodiment applied to gateway 102 described above, refer to Figure 11 In one possible implementation, the service identifier is obtained based on the connection processing operation. That is, the data processing method includes a connection processing operation before step S1001, which includes S1101-S1105: S1101: In response to a connection request, a connection request packet is sent to the gateway; S1103: In response to the connection request packet sent by the gateway, extract the service identifier embedded in the connection response packet. S1105: Save the extracted service identifier for use in sending subsequent data packets.
[0095] In one possible implementation, the gateway 102 is a transport layer device; the service identifier is carried in the connection response packet by being written into the transport layer header of the connection response packet by the gateway 102 or the assigned service node 103 during the connection processing operation; extracting the service identifier embedded in the connection response packet includes: extracting the service identifier from the transport layer header of the connection response packet.
[0096] In one possible implementation, gateway 102 is a transport layer device, and both data packets and connection request packets are TCP packets. The connection request packet is a transport layer handshake message in the three-way handshake phase, and the service identifier is written in the extended field of the transport layer header of the TCP packet.
[0097] In one possible implementation, the service identifier includes the network location information of the service node 103, so that the gateway 102 can send data packets to the service node 103 after determining the network address of the service node 103 based on the network location information.
[0098] In one possible implementation, each service node 103 in the service cluster belongs to the same local area network (LAN). The network address of the service node 103 is composed of a first location value and a second location value. The first location value is used to represent the LAN, and the second location value is used to represent the specific service node 103 within the LAN. The network location information is the second location value, so that the gateway 102 can obtain the network address representing the specific service node 103 by concatenating the network location information with the first location value corresponding to the LAN.
[0099] The methods of the embodiments of the second aspect of this application are applied to terminal device 101, and the methods provided in the first aspect are applied to gateway 102. Terminal device 101 and gateway 102 are nodes for data interaction. The methods provided in the first and second aspects are specific implementations of the same scheme on different nodes, and their implementation principles are similar. Therefore, the specific details such as writing and reading service identifiers, as well as sending and routing data packets in the methods of the embodiments of the second aspect of this application correspond to the methods of the embodiments of the first aspect of this application. For the implementation principle of the data processing method of the second aspect applied to terminal device 101, please refer to the description in the embodiments of the data processing method of the first aspect applied to gateway 102 above, which will not be repeated here.
[0100] Based on the same technical concept, in the third aspect, referring to... Figure 12 This application also provides a gateway 102 for data interaction between a terminal device 101 and a service cluster. The service cluster includes multiple service nodes 103. The gateway 102 includes modules for executing the data processing method in the first aspect or any optional implementation of the first aspect. For example, the gateway 102 includes: The receiving module 1201 is used to detect whether the data packet carries a service identifier in response to receiving a data packet from the terminal device 101; The output module 1202 is used to forward the data packet to the service node 103 corresponding to the service identifier when the service identifier is detected; wherein, the service identifier is assigned by the terminal device 101 when establishing a connection with the gateway 102.
[0101] Based on the same technical concept, the fourth aspect, referring to... Figure 13 This application also provides a terminal device 101, including modules for executing the data processing method in the second aspect or any optional implementation of the second aspect. For example, the terminal device 101 includes: The processing module 1301 is used to embed a service identifier into a data packet in response to a data packet sending request. The service identifier is assigned by the terminal device 101 when it establishes a connection with the gateway 102. The gateway 102 is used for data interaction between the terminal device 101 and the service cluster. The service cluster includes multiple service nodes 103. The sending module 1302 sends a data packet carrying a service identifier to the gateway 102, so that the gateway 102 can forward the data packet to the service node 103 corresponding to the service identifier based on the service identifier in the data packet.
[0102] The gateway 102 of the third aspect of this application can execute the method provided in the embodiment of the first aspect of this application, and the terminal device 101 of the fourth aspect of this application can execute the method provided in the embodiment of the second aspect of this application. Their implementation principles are similar. The actions performed by each module of the gateway 102 of the third aspect of this application correspond to the steps in the method of the embodiment of the first aspect of this application, and the actions performed by each module of the terminal device 101 of the fourth aspect of this application correspond to the steps in the method of the embodiment of the second aspect of this application. For detailed functional descriptions of each module of the gateway 102 and the terminal device 101, please refer to the descriptions in the method embodiments of the first and second aspects above, respectively, and they will not be repeated here.
[0103] It should be noted that the various modules described herein are divided into modules for clarity. However, in actual implementation, the boundaries between modules may be blurred. For example, any or all functional modules in this application may share various hardware and / or software elements. As another example, any and / or all functional modules in this application may be wholly or partially implemented by software instructions executed by a shared processor 1402. Furthermore, various software sub-modules executed by one or more processors 1402 may be shared among various software modules. Accordingly, unless expressly required, the scope of this application is not limited by mandatory boundaries between various hardware and / or software elements.
[0104] Based on the same technical concept, the fifth aspect, referring to... Figure 14 This application also provides a computing device 1400, including a memory 1401 and a processor 1402. The memory 1401 is used to store computer programs or instructions; when the computer program or instructions are executed by the processor 1402, they implement the method in the first aspect or any possible implementation of the first aspect, or implement the method in the second aspect or any possible implementation of the second aspect. It should be noted that... Figure 14 The structure of the computing device 1400 shown is merely illustrative and does not constitute a limitation on the computing device 1400 to which the methods provided in the embodiments of this application are applicable.
[0105] The specific entity of the computing device 1400 may be a gateway 102 device for implementing the method of any embodiment of the first aspect described above, or it may be a user terminal 101 for implementing the method of any embodiment of the second aspect described above.
[0106] The memory 1401 can be used to store operating systems and computer programs or instructions, which, when invoked by the processor 1402, implement the methods shown in the embodiments of the first or second aspect of this application. The memory 1401 can also store programs for implementing other functions or services. The memory 1401 includes at least one type of computer-readable storage medium, including flash memory, hard disk, multimedia card, random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), magnetic disk, optical disk, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computing device, such as the hard disk or memory of the computing device. In other embodiments, the computer-readable storage medium can also be an external storage device of the computing device, such as a plug-in hard disk, a secure digital card (SD card), a flash memory card, etc., provided on the computing device. Of course, the computer-readable storage medium can also include both internal storage units and external storage devices of the computing device. In this embodiment, the computer-readable storage medium is generally used to store software installed on the computing device, such as program code of the methods of the embodiments of the first or second aspect. In addition, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or will be output.
[0107] The processor 1402 is connected to the memory 1401 via a bus 1405 and performs corresponding functions by calling the application programs stored in the memory 1401. In some embodiments, it may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other chips. The processor 1402 is typically used to control the overall operation of the processing device, such as performing control and processing related to data interaction or communication with other entities. In this embodiment, the processor 1402 is used to run program code stored in the memory 1401 or process data.
[0108] The computing device 1400 can connect to a network via a communication module 1403 (which may include, but is not limited to, components such as a network interface) to communicate with other devices (such as service nodes) through the network and achieve data interaction, such as sending data to or receiving data from other devices. The communication module 1403 may include a wired network interface and / or a wireless network interface, meaning the communication module may include at least one of a wired communication module or a wireless communication module.
[0109] The computing device 1400 can connect to necessary input / output devices, such as a keyboard and display device, via the input / output interface 1404. The device 1400 itself may have a display device, and other display devices can also be connected externally via interface 1404. It is understood that the input / output interface 1404 can be a wired interface or a wireless interface. Depending on the actual application scenario, the device connected to the input / output interface 1404 can be a component of the device 1400, or it can be an external device connected to the device 1400 when needed.
[0110] The bus 1405 used to connect the components may include a pathway for transmitting information between the components. The bus 1405 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Depending on its function, the bus 1405 may be divided into an address bus, a data bus, a control bus, etc.
[0111] Based on the same technical concept, in a sixth aspect, this application also provides a computer-readable storage medium storing a computer program or instructions that, when executed by a processor, implement the method in the first aspect or any possible implementation of the first aspect, or implement the method in the second aspect or any possible implementation of the second aspect.
[0112] Further details can be found in the method embodiments, which will not be repeated here. In this embodiment, the computer-readable storage medium can be non-volatile or volatile. Computer-readable storage media include flash memory, hard disks, multimedia cards, random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), magnetic disks, optical disks, etc. In some embodiments, the computer-readable storage medium can be an internal storage unit of a computing device, such as the hard disk or memory of the computing device. In other embodiments, the computer-readable storage medium can also be an external storage device of the computing device, such as a plug-in hard disk, a secure digital card (SD card), a flash memory card, etc., provided on the computing device. Of course, the computer-readable storage medium can also include both internal storage units and external storage devices of the computing device. In this embodiment, the computer-readable storage medium is typically used to store software installed on the computing device, such as program code of the methods of the first or second aspect embodiments. Furthermore, the computer-readable storage medium can also be used to temporarily store various types of data that have been output or will be output.
[0113] Based on the same technical concept, in a seventh aspect, this application also provides a computer program product, which includes a computer program or instructions that, when executed by a processor, implement the method in the first aspect or any possible implementation of the first aspect, or implement the method in the second aspect or any possible implementation of the second aspect.
[0114] The beneficial effects of aspects two through seven above can be referred to in aspect one or any possible implementation of aspect one, and will not be elaborated here. Based on the implementations provided in the above aspects, this application can also be further combined to provide more implementations.
[0115] It should be noted that the order in which the embodiments are described in this application is not intended to limit the priority of the embodiments. The reference to "embodiment" herein means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily refer to the same embodiment, nor is it a mutually exclusive, independent, or alternative embodiment. Those skilled in the art will explicitly and implicitly understand that the embodiments described herein can be combined with other embodiments.
[0116] Unless otherwise defined, all technical and scientific terms used in this application have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used in this application and in its specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
[0117] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many forms under the guidance of this application without departing from the spirit and scope of protection of the claims. All equivalent transformations made based on the content of this application's specification and drawings, or direct / indirect applications in other related technical fields, are included within the scope of patent protection of this application.
Claims
1. A data processing method, characterized in that, Applied to a gateway, the gateway is used for data interaction between terminal devices and a service cluster, the service cluster including multiple service nodes, the method includes: In response to receiving a data packet from a terminal device, detect whether the data packet carries a service identifier; If a service identifier is detected, the data packet is forwarded to the service node corresponding to the service identifier; The service identifier is assigned by the terminal device when it establishes a connection with the gateway.
2. The method according to claim 1, characterized in that, The service identifier is obtained based on connection processing operations, which include: In response to receiving a connection request packet from a terminal device requesting to establish a connection, a service node for allocation to the terminal device is selected from the service cluster according to a preset routing policy, and the service identifier of the allocated service node is determined. Send the connection request packet to the assigned service node; Upon receiving a connection response packet from the assigned service node in response to the connection request packet, the system sends the connection response packet to the terminal device. The connection response packet received by the terminal device carries the service identifier, so that the terminal device can obtain the service identifier for subsequent data packet transmission; the service identifier is written into the connection response packet through a gateway or an assigned service node.
3. The method according to any one of claims 1-2, characterized in that, The gateway is a transport layer device; the service identifier is carried in the connection response packet by being written into the transport layer header of the connection response packet by the gateway or the assigned service node during the connection processing operation. The step of detecting whether the data packet carries a service identifier includes: detecting whether the transport layer header of the data packet carries a service identifier.
4. The method according to any one of claims 1-2, characterized in that, The gateway is a transport layer device, and the data packets and connection request packets are both TCP packets. The connection request packet is a transport layer handshake message in the three-way handshake phase, and the service identifier is written in the extended field of the transport layer header of the TCP packet.
5. The method according to any one of claims 1-4, characterized in that, The service identifier includes the network location information of the service node; forwarding the data packet to the service node corresponding to the service identifier includes: The network location information is extracted from the data packet, and the network address of the service node is determined based on the network location information; The data packet is sent to the service node based on the network address.
6. The method according to claim 5, characterized in that, Each service node in the service cluster belongs to the same local area network. The network address of the service node is composed of a first location value and a second location value. The first location value is used to represent the local area network, and the second location value is used to represent the specific service node in the local area network. The network location information is the second location value. Determining the network address of a service node based on the network location information includes: concatenating the extracted network location information with the first location value corresponding to the local area network to obtain the network address representing the specific service node.
7. The method according to claim 1, characterized in that, The method further includes: When the data packet does not carry a service identifier or the service node corresponding to the service identifier it carries leaves the service cluster, a service node for allocation to the terminal device is selected from the service cluster according to a preset routing policy, and the data packet is sent to the allocated service node.
8. A data processing method, characterized in that, Applied to a terminal device, the method includes: In response to a data packet sending request, a service identifier is embedded in the data packet, wherein the service identifier is assigned by the terminal device when establishing a connection with the gateway, the gateway is used for data interaction between the terminal device and the service cluster, and the service cluster includes multiple service nodes; A data packet carrying a service identifier is sent to the gateway so that the gateway can forward the data packet to the service node corresponding to the service identifier based on the service identifier in the data packet.
9. The method according to claim 8, characterized in that, The service identifier is obtained based on connection processing operations, which include: In response to a connection request, the connection request packet is sent to the gateway; In response to a connection response packet sent by the gateway for the connection request packet, the service identifier embedded in the connection response packet is extracted from the connection response packet; The extracted service identifier is saved for use in sending subsequent data packets.
10. The method according to claim 9, characterized in that, The gateway is a transport layer device; the service identifier is carried in the connection response packet by being written into the transport layer header of the connection response packet by the gateway or the assigned service node during the connection processing operation. Extracting the service identifier embedded in the connection response packet from the connection response packet includes: extracting the service identifier from the transport layer header of the connection response packet.
11. The method according to any one of claims 9-10, characterized in that, The gateway is a transport layer device, and the data packets and connection request packets are both TCP packets. The connection request packet is a transport layer handshake message in the three-way handshake phase, and the service identifier is written in the extended field of the transport layer header of the TCP packet.
12. The method according to any one of claims 8-11, characterized in that, The service identifier includes the network location information of the service node, so that the gateway can determine the network address of the service node based on the network location information and then send the data packet to the service node.
13. The method according to claims 8-12, characterized in that, Each service node in the service cluster belongs to the same local area network. The network address of the service node is composed of a first location value and a second location value. The first location value is used to represent the local area network, and the second location value is used to represent the specific service node in the local area network. The network location information is the second location value, so that the gateway can combine the network location information with the first location value corresponding to the local area network to obtain the network address representing the specific service node.
14. A gateway, characterized in that, The gateway is used for data interaction between terminal devices and the service cluster, the service cluster including multiple service nodes, and the gateway includes: The receiving module is configured to detect whether the data packet carries a service identifier in response to receiving a data packet from the terminal device; The output module is used to forward the data packet to the service node corresponding to the service identifier when a service identifier is detected. The service identifier is assigned by the terminal device when it establishes a connection with the gateway.
15. A terminal device, characterized in that, include: The processing module is used to embed a service identifier into the data packet in response to the data packet sending request. The service identifier is assigned by the terminal device when establishing a connection with the gateway. The gateway is used for data interaction between the terminal device and the service cluster. The service cluster includes multiple service nodes. The sending module sends a data packet carrying a service identifier to the gateway, so that the gateway forwards the data packet to the service node corresponding to the service identifier based on the service identifier in the data packet.
16. A computing device, characterized in that, It includes a memory and a processor, the memory being used to store computer programs or instructions; when the computer programs or instructions are executed by the processor, they implement the method of any one of claims 1-7, or the method of any one of claims 8-13.
17. A computer-readable storage medium, characterized in that, The storage medium stores a computer program or instructions that, when executed by a processor, implement the method of any one of claims 1-7, or the method of any one of claims 8-13.
18. A computer program product, characterized in that, The computer program product includes a computer program or instructions that, when executed by a processor, implement the method of any one of claims 1-7, or the method of any one of claims 8-13.