Transmission control protocol packet processing method, system, device, medium and product

By determining the processing strategy based on control flags or payload in the TCP protocol, the storage of 5-tuples and sequence numbers is avoided, thus solving the resource consumption problem of the TCP protocol in high-concurrency scenarios and achieving more efficient DNS server processing.

CN122640486APending Publication Date: 2026-08-25ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510207359.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-24
Publication Date
2026-08-25

AI Technical Summary

Technical Problem

The existing TCP protocol needs to maintain connection state when processing requests, which leads to excessive consumption of CPU and memory resources, especially affecting the continuity and stability of services in high-concurrency scenarios.

Method used

By receiving stateless TCP packets sent by the client, the processing strategy is determined based on the control flags or payload of the packets, avoiding the need to store information such as 5-tuples and sequence numbers, and simplifying connection state maintenance.

Benefits of technology

It reduces the consumption of CPU and memory resources, improves service continuity and stability, lowers resource consumption, and enhances the processing capacity and response speed of the DNS server.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122640486A_ABST
    Figure CN122640486A_ABST
Patent Text Reader

Abstract

The application provides a transmission control protocol message processing method, system, device, medium and product, and relates to the technical field of networks.The method comprises the following steps: a server receives a stateless service transmission control protocol (TCP) message sent by a client, determines a processing strategy corresponding to the TCP message according to a control flag bit or a payload of the TCP message, and processes the TCP message according to the processing strategy corresponding to the TCP message.In this embodiment, for the TCP message of the stateless service, the processing strategy corresponding to the TCP message is determined according to the control flag bit or the payload of the TCP message, and then the TCP message is processed, so that the connection state is maintained without the need of checking and maintaining the connection state by storing five-tuple information, sequence number and the like, the consumption of CPU computing resources and memory resources is reduced, and the continuity and stability of the service can be effectively maintained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network technology, and in particular to a method, system, device, medium and product for processing Transmission Control Protocol (TCP) messages. Background Technology

[0002] Transmission Control Protocol (TCP) is a connection-oriented, reliable, byte-stream-based transport layer communication protocol designed to provide error-free transmission of data packets from a source host to a destination host. TCP establishes a connection through a three-way handshake, ensuring the sequential delivery and integrity verification of data, and securely closes the connection through a four-way handshake. It also provides flow control and congestion control mechanisms to avoid network congestion and data loss, and is widely used in network applications requiring high reliability and data integrity, such as web browsing, email, and file transfer.

[0003] As a connection-oriented protocol, TCP involves a three-way handshake to establish a connection, data transmission acknowledgment and retransmission mechanisms, flow control, and congestion control. While these features ensure the reliability of data transmission, they also incur significant resource overhead. When processing TCP requests, the server needs to maintain connection state, such as storing 5-tuples and sequence numbers for verification, which consumes CPU and memory resources. This resource consumption is particularly pronounced in high-concurrency scenarios, hindering the maintenance of service continuity and stability. Summary of the Invention

[0004] This application provides a method, system, device, medium, and product for processing Transmission Control Protocol (TCP) messages, in order to reduce the consumption of CPU computing resources and memory resources, and effectively maintain the continuity and stability of services.

[0005] In a first aspect, embodiments of this application provide a Transmission Control Protocol (TCP) message processing method. This method is applied to a server and includes: receiving a stateless TCP message sent by a client; determining a processing strategy corresponding to the TCP message based on the control flags or payload of the TCP message; and processing the TCP message according to the processing strategy corresponding to the TCP message.

[0006] Secondly, embodiments of this application provide a Transmission Control Protocol (TCP) message processing system, including a client and a server; the client is used to: send stateless TCP messages to the server; the server is used to: receive TCP messages sent by the client, determine the processing strategy corresponding to the TCP message based on the control flags or payload of the TCP message, and process the TCP message according to the processing strategy corresponding to the TCP message.

[0007] Thirdly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory, wherein the processor implements any of the methods described above when executing the computer program.

[0008] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements any of the methods described above.

[0009] Fifthly, embodiments of this application provide a computer program product, which includes a computer program that, when executed by a processor, implements any of the methods described above.

[0010] Compared with the prior art, this application has the following advantages:

[0011] This application provides a method, system, device, medium, and product for processing Transmission Control Protocol (TCP) messages. The server receives TCP messages for stateless services sent by the client, determines the corresponding processing strategy based on the control flags or payload of the TCP message, and processes the TCP message according to the corresponding processing strategy. In this embodiment, for stateless service TCP messages, the processing strategy is determined based on the control flags or payload of the TCP message, and then the TCP message is processed. This eliminates the need to maintain connection state by storing information such as 5-tuples and sequence numbers, reducing the consumption of CPU and memory resources and effectively maintaining service continuity and stability.

[0012] The above description is only an overview of the technical solution of this application. In order to better understand the technical means of this application, it can be implemented according to the contents of the specification. In order to make the above and other objects, features and advantages of this application more obvious and understandable, specific embodiments of this application are given below. Attached Figure Description

[0013] In the accompanying drawings, unless otherwise specified, the same reference numerals throughout the various drawings denote the same or similar parts or elements. These drawings are not necessarily drawn to scale. It should be understood that these drawings depict only some embodiments according to this application and should not be construed as limiting the scope of this application.

[0014] Figure 1 This is a signaling diagram illustrating the interaction between the server and client in a TCP packet processing method according to an embodiment of this application.

[0015] Figure 2 This is a flowchart illustrating a Transmission Control Protocol (TCP) message processing method according to an embodiment of this application.

[0016] Figure 3 This is a structural block diagram of a Transmission Control Protocol (TCP) message processing apparatus according to an embodiment of this application.

[0017] Figure 4 This is a structural block diagram of a Transmission Control Protocol (TCP) message processing system according to an embodiment of this application.

[0018] Figure 5 This is a block diagram of an electronic device used to implement embodiments of this application. Detailed Implementation

[0019] In the following description, only certain exemplary embodiments are briefly described. As those skilled in the art will recognize, the described embodiments can be modified in various ways without departing from the concept or scope of this application. Therefore, the drawings and description are considered to be exemplary in nature and not restrictive.

[0020] To facilitate understanding of the technical solutions of the embodiments of this application, the relevant technologies of the embodiments of this application are described below. The following relevant technologies are optional solutions and can be combined with the technical solutions of the embodiments of this application in any way, and all of them fall within the protection scope of the embodiments of this application.

[0021] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0022] Figure 1 This diagram illustrates the interaction between the server and client in the TCP packet processing method provided in this application. In this embodiment, the stateless service is a domain name resolution service, namely the Domain Name System (DNS), which translates human-readable domain names into Internet Protocol (IP) addresses that computers can understand. This allows users to access websites through easy-to-remember URLs without having to remember complex IP addresses. DNS employs a hierarchical distributed database structure, consisting of multiple layers such as root name servers, top-level name servers, authoritative name servers, and local name servers, ensuring the efficiency and reliability of domain name resolution services globally.

[0023] In related technologies, DNS primarily relies on the User Datagram Protocol (UDP) for data transmission. UDP's connectionless nature makes it highly efficient and resource-efficient in handling DNS requests, making it ideal for stateless network services like DNS. However, in specific scenarios, such as zone transfers or processing DNS responses exceeding UDP's size limit (typically 512 bytes), DNS must switch to TCP to support larger data packets and more complex data transmission needs. In these technologies, when processing TCP packets, the server needs to maintain connection state, such as storing 5-tuples and sequence numbers for verification, which consumes CPU and memory resources.

[0024] In this embodiment, the TCP packets are those used for interaction between the client and server during DNS usage. Each DNS request is independent, with one request corresponding to one response, and there is no correlation between consecutive requests. The size of the TCP packet does not exceed the Maximum Transmission Unit (MTU) limit. Because consecutive DNS requests are unrelated, this embodiment does not require maintaining the connection state by storing information such as 5-tuples and sequence numbers. Instead, it determines the corresponding processing strategy for the TCP packet based on the control flags or payload, thereby processing the TCP packet. This reduces the consumption of CPU and memory resources, effectively maintaining service continuity and stability.

[0025] like Figure 1 As shown, the server receives TCP packets sent by the client, parses the TCP packets to obtain control flags or payloads, and thus determines the packet processing strategy and performs corresponding processing. The specific content is as follows:

[0026] If the server receives a TCP packet from the client, it parses it and determines that the control flags are the Synchronize Sequence Numbers (SYN), where the sent sequence number `sent_seq` is `x`. The server determines the acknowledgment number `recv_ack` of the reply packet based on `sent_seq`, setting it to `x+1`, generates a random value as the `sent_seq` of the reply packet, and returns the reply packet to the client. The reply packet has the control flags SYN+ACK, indicating connection establishment and connection acknowledgment. The SYN control flag is used during the three-way handshake in the TCP connection establishment phase. The client sends a TCP packet with the SYN control flag to the server, indicating its desire to establish a new connection. The acknowledgment (ACK) flag is used to acknowledge received TCP packets. The sequence number is a unique number used in the TCP protocol to identify the position of each byte in the data stream, ensuring that data can be reassembled in the correct order at the receiving end. The acknowledgment number is the sequence number of the last data successfully received by the receiver plus 1, used to confirm the data reception status.

[0027] If the server receives a TCP packet from the client with the control flag set to ACK, indicating acknowledgment of the received TCP packet, then no further action is taken.

[0028] If the server receives a TCP packet from the client with the control flags set to Finish (FIN), send_seq set to x, and recv_ack set to y, it will send a reply packet back to the client with the control flags set to FIN+ACK, recv_ack set to x+1, and send_seq set to y. The FIN control flag is used during the TCP connection termination phase. Either side sends a TCP packet with the FIN flag to the other, indicating that data transmission in that direction is complete and no further data will be sent, but data can still be received. The side receiving the packet with the FIN control flag will respond with a packet with the ACK control flag, acknowledging receipt of the end signal. Subsequently, the receiving side can also send a TCP packet with the FIN control flag, indicating the end of bidirectional data transmission, ultimately completing the four-way handshake and closing the connection.

[0029] If the server receives a TCP packet from the client with the control flag set to Reset (RST), it will discard the TCP packet without further processing.

[0030] If the server receives a TCP packet from the client where the payload value is greater than zero, send_seq is x, recv_ack is y, and payload value is z, then it will process it as follows:

[0031] a. If the TCP packet itself is abnormal (e.g., the format does not conform to the standard format), reply with a packet containing the RST control flag to reset the connection. Figure 1 (Not shown in the image).

[0032] b. If the TCP message is from a preset domain name server (e.g., an authoritative domain name server), then obtain the domain name resolution result from the preset domain name server, add it to the reply message and return it to the client, where recv_ack is x+z (z is converted to a byte position number and added to x), and send_seq is y.

[0033] c. If the domain name resolution result of the TCP packet is in the local cache data, then obtain the domain name resolution result, add it to the reply packet and return it to the client, where recv_ack is x+z and send_seq is y.

[0034] d. If the domain name resolution result of the TCP packet is not in the local cache data, then first reply with a packet containing the ACK control flag, where recv_ack is x+z and send_seq is y. Figure 1 (Not shown in the image). Then, the TCP packets sent by the client are stored in the buffer area, and outbound iterative queries are performed until the domain name resolution result of the TCP packets is obtained. Then, the recv_ack and send_seq of the TCP packets are retrieved from the buffer area, where recv_ack is x+z and send_seq is y. The domain name resolution result, recv_ack, and send_seq are filled into the reply packet and returned to the client.

[0035] Additionally, if the server receives a TCP packet from the client that is not for the current service but for another service, it will discard it without further processing.

[0036] In this embodiment, the server can pre-allocate a fixed-size buffer area for receiving and processing DNS TCP packets. When a TCP packet is received, there is no need for a complex connection establishment process; instead, the TCP packet is directly placed in the buffer area, parsed, and a reply packet is generated, avoiding the additional cost of maintaining the TCP connection state. During the DNS TCP request process, the client is unaware of the server's processing, and the server does not need to implement complex and complete TCP connection maintenance logic, reducing processing complexity.

[0037] This technical solution eliminates the need for additional dedicated intermediate protection equipment or any configuration changes by end users, significantly reducing the deployment threshold and complexity. This design allows for seamless integration into DNS infrastructure, enabling rapid deployment and immediate effectiveness in both enterprise and public internet environments, demonstrating exceptional flexibility and adaptability. The DNS server can reduce the resource consumption of each TCP request to a level comparable to that of a UDP request. This is because DNS queries typically involve short connections and high concurrency. In TCP packet processing in related technologies, each connection needs to maintain certain state information, which can lead to significant server resource consumption in high-concurrency environments. This solution, by avoiding the maintenance of this state information, significantly reduces the server load, allowing the DNS server to handle more requests at a lower resource cost, thereby improving overall service performance and response speed.

[0038] In related technologies, the complexity and resource-intensive nature of the TCP protocol makes it an ideal target for Distributed Denial of Service (DDoS) attacks. Attackers can exploit the characteristics of the TCP protocol to rapidly exhaust the connection resources of the DNS server by launching a large number of TCP connection requests (such as a SYN flood attack), causing legitimate users' requests to fail to receive timely responses, thereby achieving the purpose of denying service. In internet-scale DNS services, the destructive power of this attack is particularly enormous, potentially causing the entire service to crash and severely impacting network availability and user experience.

[0039] This application's technical solution simplifies the implementation of DNS servers, reduces resource consumption, and improves service performance, while ensuring a good user experience while maintaining security. This combined advantage makes this solution demonstrate enormous application potential in the DNS field, especially in the current internet environment, where it provides an efficient, flexible, and secure solution in the face of ever-increasing network traffic and complex security threats.

[0040] This application provides a method for processing Transmission Control Protocol (TCP) messages. The method in this embodiment can be applied to servers, platforms, devices, etc., that have computing and processing capabilities. The server can be a server cluster or a single server, a server deployed in the cloud, or a local server.

[0041] like Figure 2 The diagram shown is a flowchart of a Transmission Control Protocol (TCP) message processing method according to an embodiment of this application, including:

[0042] Step S201: Receive the TCP packet for stateless service sent by the client, and determine the processing strategy corresponding to the TCP packet based on the control flags or payload of the TCP packet.

[0043] Step S202: Process the TCP packet according to the processing strategy corresponding to the TCP packet.

[0044] In this embodiment, the server is used as the execution subject for example. Stateless services process a single request without depending on other requests. That is, the information needed to process a request is either contained within the request itself or can be obtained externally; the server itself does not store request-related information.

[0045] TCP packets are messages sent using the TCP protocol. The control flags of the TCP protocol are used to manage connection establishment, data transmission, flow control, and connection termination. These include, but are not limited to, SYN, ACK, FIN, and RST.

[0046] The payload refers to the actual application data portion transmitted in data communication. It is the content excluding all protocol overhead; that is, the information the sender expects the receiver to receive.

[0047] The specific type of a TCP packet can be determined by its control flags or payload. Different types of packets are handled using different strategies, including but not limited to: dropping packets and replying to packets.

[0048] The Transmission Control Protocol (TCP) message processing method provided in this application embodiment involves the server receiving TCP messages for stateless services sent by the client, determining the corresponding processing strategy for the TCP message based on its control flags or payload, and then processing the TCP message according to the corresponding processing strategy. In this embodiment, for TCP messages of stateless services, the processing strategy is determined based on the control flags or payload, and the TCP message is then processed. This eliminates the need to maintain connection state by storing information such as 5-tuples and sequence numbers, reducing the consumption of CPU and memory resources and effectively maintaining service continuity and stability.

[0049] The following describes the specific implementation process of each step above through various implementation methods:

[0050] In one implementation, step S202, processing the TCP packet according to the processing strategy corresponding to the TCP packet, includes: if the control flag indicates connection establishment, incrementing the first sending sequence number of the TCP packet by a preset value to obtain a first receiving acknowledgment number; generating a second sending sequence number; generating a first reply packet based on the first receiving acknowledgment number and the second sending sequence number, and returning the first reply packet to the client; the control flag of the first reply packet indicates connection establishment and connection acknowledgment.

[0051] If the server receives a TCP packet sent by the client, after parsing it, the control flag is set to SYN, indicating that a connection should be established, and the send sequence number sent_seq is x. Then, the server determines that the receive acknowledgment number recv_ack of the reply packet is x+1, which is the first receive acknowledgment number. It generates a random value as the send_seq of the first reply packet, which is the second send sequence number, and returns the first reply packet to the client. The control flag of the reply packet is SYN+ACK.

[0052] In this embodiment, for TCP packets with a connection establishment flag, the receiving acknowledgment number of the reply packet is determined based on the sending sequence number of the received packet, and the reply packet is returned to the client to establish the connection. The process is simple and does not require storing the 5-tuple information used to maintain the connection state, thus saving memory resources.

[0053] In one implementation, step S202, processing the TCP packet according to the processing strategy corresponding to the TCP packet, includes: if the control flag indicates termination of the connection, incrementing the third sending sequence number of the TCP packet by a preset value to obtain a second receiving acknowledgment number; obtaining the third receiving acknowledgment number of the TCP packet and using it as the fourth sending sequence number; generating a second reply packet based on the second receiving acknowledgment number and the fourth sending sequence number, and returning the second reply packet to the client; the control flag of the second reply packet indicates termination of the connection and termination acknowledgment.

[0054] Specifically, if the server receives a TCP packet sent by the client, after parsing it, it finds that the control flag is FIN, indicating termination of the connection, and the sent sequence number is x (the third sent sequence number). Parsing the TCP packet also yields recv_ack as y (the third received acknowledgment number). The server then determines that the received acknowledgment number recv_ack of the second reply packet is x+1 (the second received acknowledgment number), uses the third received acknowledgment number y as the fourth sent sequence number, generates a second reply packet, and returns the second reply packet to the client with the control flags FIN+ACK.

[0055] In this embodiment, for TCP packets with a connection termination flag, the sending sequence number and receiving acknowledgment number of the reply packet are determined based on the sending sequence number and receiving acknowledgment number of the received packet. The reply packet is then returned to the client to terminate the connection. The process is simple, does not require storing the 5-tuple information used to maintain the connection state, and does not require connection state verification, thus saving memory and computing resources.

[0056] In one implementation, step S202 involves processing the TCP packet according to the processing strategy corresponding to the TCP packet, including: if the control flag indicates a connection reset, then discarding the TCP packet.

[0057] If the server receives a TCP packet from the client, after parsing it, the control flag is set to RST, indicating that the connection should be terminated. No further processing is needed; the packet is simply discarded. The RST control flag is typically used when an invalid TCP packet is received or a serious error is encountered.

[0058] In this embodiment, if the server receives a TCP packet with the RST control flag, it indicates that there is a problem with the connection. The connection should be closed immediately, illegal connection attempts should be rejected, or the deadlock state should be cleared.

[0059] In one implementation, step S202 involves processing the TCP packet according to the processing strategy corresponding to the TCP packet, including: if the payload is greater than zero and the TCP packet is an abnormal packet, then resetting the connection between the client and the server.

[0060] In practical applications, if the server receives and parses a TCP packet sent by the client and finds that the payload is greater than zero, it indicates that the received TCP packet is a request for data. If the TCP packet itself is abnormal (e.g., the format does not conform to the standard format, the data size exceeds the maximum allowed value, memory resource limitations, etc.), the server will reply with a packet containing the RST control flag to reset the connection and prevent unauthorized access from causing security issues.

[0061] In one implementation, the stateless service includes a domain name resolution service. Step S202 involves processing the TCP packet according to the processing strategy corresponding to the TCP packet, including: if the payload is greater than zero and the TCP packet is a packet from a preset domain name server, then obtaining the first domain name resolution result from the preset domain name server; determining the fourth receive acknowledgment number based on the fifth sending sequence number and the payload of the TCP packet; using the fifth receive acknowledgment number of the TCP packet as the sixth sending sequence number; generating a third reply packet based on the fourth receive acknowledgment number, the sixth sending sequence number, and the first domain name resolution result, and returning the third reply packet to the client.

[0062] Stateless services can include domain name resolution services. This means that if the TCP packets received by the server are DNS packets with a payload greater than zero, the TCP packets are requesting data; that is, the purpose of the packets is to obtain the domain name resolution results. DNS can translate human-readable domain names into Internet Protocol (IP) addresses that computers can understand, allowing users to access websites through easy-to-remember URLs without having to remember complex IP addresses. DNS employs a layered distributed database structure, consisting of multiple layers such as root name servers, top-level name servers, authoritative name servers, and local name servers, ensuring the efficiency and reliability of domain name resolution services globally.

[0063] In one example, the default name server can be an authoritative name server (NAME Server). An authoritative name server is a type of server in the DNS system that provides "authoritative" DNS records for a specific domain name. These servers store the latest and most accurate information about that domain name, including the IP address, mail server information, and other relevant resource records. Authoritative name servers can be managed directly by the domain registrant or by a hosting service provider or domain registrar. Each top-level domain (such as .com, .org, .net, etc.) has its own set of authoritative name servers, which are responsible for guiding queries to more specific name servers until the correct IP address is found. If the received TCP packet is a packet from an authoritative name server, the reply content, i.e., the first domain name resolution result, can be obtained from the authoritative name server. The payload value is converted into a byte position number and added to the TCP packet's sending sequence number (i.e., the fifth sending sequence number) to obtain the reply packet's receive acknowledgment number (i.e., the fourth receive acknowledgment number). This received TCP packet's receive acknowledgment number (i.e., the fifth receive acknowledgment number) is then used as the reply packet's sending sequence number (i.e., the sixth sending sequence number), and a reply packet (i.e., the third reply packet) is constructed and returned to the client. In this embodiment, for TCP packets requesting data, if the packet belongs to a preset domain name server, the domain name resolution result is directly obtained from the preset domain name server, and a reply packet is constructed and returned to the client. This eliminates the need to store the five-tuple information used to maintain the connection state and eliminates the need for connection state verification, thus saving memory and computational resources.

[0064] In one implementation, the stateless service includes a domain name resolution service. Step S202 involves processing the TCP packet according to the processing strategy corresponding to the TCP packet, including: if the payload is greater than zero and the second domain name resolution result of the TCP packet is in the local cache data, then obtaining the second domain name resolution result from the local cache data; determining the sixth receive acknowledgment number based on the seventh sending sequence number and the payload of the TCP packet; using the seventh receive acknowledgment number of the TCP packet as the eighth sending sequence number; generating a fourth reply packet based on the sixth receive acknowledgment number, the eighth sending sequence number, and the second domain name resolution result, and returning the fourth reply packet to the client.

[0065] In practical applications, if the TCP packet received by the server is a DNS request packet, and the requested data can be found in the local cache, then the server retrieves the response content from the local cache, i.e., the second domain name resolution result. After converting the payload value into a byte position number, it adds it to the sending sequence number of the TCP packet (i.e., the seventh sending sequence number) to obtain the receiving acknowledgment number of the response packet (i.e., the sixth receiving acknowledgment number). The receiving acknowledgment number of the received TCP packet (i.e., the seventh receiving acknowledgment number) is then used as the sending sequence number of the response packet (i.e., the eighth sending sequence number), and a response packet (i.e., the fourth response packet) is constructed and returned to the client.

[0066] In this embodiment, for TCP packets requesting data, if the request result can be found in the local cache data, the domain name resolution result is directly obtained from the local cache data, and a reply packet is constructed and returned to the client. There is no need to store the five-tuple information used to maintain the connection state, and there is no need for connection state verification, thus saving memory and computing resources.

[0067] In one implementation, the stateless service includes a domain name resolution service. Step S202 involves processing the TCP packet according to the processing strategy corresponding to the TCP packet, including: if the payload is greater than zero and the second domain name resolution result of the TCP packet is not in the local cache data, then determining the eighth receive acknowledgment number based on the ninth sending sequence number and the payload of the TCP packet; using the ninth receive acknowledgment number of the TCP packet as the tenth sending sequence number; generating a fifth reply packet based on the eighth receive acknowledgment number and the tenth sending sequence number; returning the fifth reply packet to the client; and having the control flag of the fifth reply packet indicate that acknowledgment has been received.

[0068] In practical applications, if the TCP packet received by the server is a DNS request packet and the requested data is not in the local cache, the server will send a reply packet with the control flag set to ACK to the client to indicate that the packet has been received.

[0069] The acknowledgment number (i.e., the eighth receive acknowledgment number) and the sequence number (i.e., the tenth send sequence number) of the reply message (i.e., the fifth reply message) are determined based on the send sequence number (ninth send sequence number) and receive acknowledgment number (i.e., the ninth receive acknowledgment number) of the received message and the payload. Specifically, the payload value is converted into a byte position number and then added to the send sequence number (i.e., the ninth send sequence number) of the received TCP message to obtain the acknowledgment number (i.e., the eighth receive acknowledgment number) of the reply message. The receive acknowledgment number (ninth receive acknowledgment number) of the received TCP message is used as the send sequence number (tenth send sequence number) of the reply message. After sending the reply message with the ACK control flag (i.e., the fifth reply message) to the client, the domain name resolution result corresponding to the TCP message is obtained, and then the domain name resolution result is sent to the client.

[0070] In one implementation, the Transmission Control Protocol (TCP) message processing method further includes: storing the TCP message in a buffer area, obtaining the second domain name resolution result through iterative query; obtaining the ninth receive acknowledgment number and the ninth send sequence number of the TCP message from the buffer area; generating a sixth reply message based on the ninth receive acknowledgment number, the ninth send sequence number, and the second domain name resolution result, and returning the sixth reply message to the client.

[0071] In practical applications, when the domain name resolution result of a DNS TCP packet is not in the local cache, after sending a reply packet with the ACK control flag, the domain name resolution result is obtained through iterative queries. Specifically, iterative queries are sent outwards to the root DNS server, top-level domain DNS server, or more specific name server, gradually approaching the authoritative DNS server holding the target domain name information. Each queried DNS server returns the address of the next-level DNS server closest to the queried domain name based on its knowledge, until an authoritative DNS server that can provide the accurate answer is found. After finding the correct domain name resolution result, it is passed back to the DNS server that initially issued the recursive request, which then constructs a reply packet and sends it back to the client.

[0072] In addition, when constructing the reply message, the TCP packets received from the client are retrieved from the cache area, the receive acknowledgment number, send sequence number and payload of the packets are extracted, the send sequence number and receive acknowledgment number of the reply message are determined, the domain name resolution result is obtained based on the iterative query, and the reply message is constructed and returned to the client.

[0073] This application provides a method for processing Transmission Control Protocol (TCP) messages. The method in this embodiment can be applied to terminal devices with computing and processing capabilities.

[0074] A method for processing Transmission Control Protocol (TCP) messages according to an embodiment of this application includes:

[0075] A stateless service transmission control protocol TCP message is sent to the server so that the server can determine the corresponding processing strategy for the TCP message based on the control flags or payload of the TCP message, and process the TCP message according to the corresponding processing strategy. The two requests for stateless services are unrelated.

[0076] In this embodiment, the client is used as the execution subject for example. Stateless services process a single request without depending on other requests. That is, the information needed to process a request is either contained within the request itself or can be obtained externally; the server itself does not store request-related information.

[0077] TCP packets are messages sent using the TCP protocol. The control flags of the TCP protocol are used to manage connection establishment, data transmission, flow control, and connection termination. These include, but are not limited to, SYN, ACK, FIN, and RST.

[0078] The payload refers to the actual application data portion transmitted in data communication. It is the content excluding all protocol overhead; that is, the information the sender expects the receiver to receive.

[0079] The Transmission Control Protocol (TCP) message processing method provided in this application embodiment involves a client sending a stateless TCP message to a server. The server then determines the corresponding processing strategy for the TCP message based on its control flags or payload, and processes the TCP message according to that strategy. The two requests for stateless services are unrelated. In this embodiment, because the two requests for stateless services are unrelated, the processing strategy for the TCP message is determined based on its control flags or payload, and the TCP message is processed accordingly. This eliminates the need to maintain connection state by storing information such as 5-tuples and sequence numbers, reducing CPU and memory resource consumption and effectively maintaining service continuity and stability.

[0080] Corresponding to the application scenarios and methods provided in the embodiments of this application, the embodiments of this application also provide a Transmission Control Protocol (TCP) message processing apparatus. For example... Figure 3 The diagram shown is a structural block diagram of a Transmission Control Protocol (TCP) message processing apparatus according to an embodiment of this application. The apparatus includes:

[0081] The receiving module 301 is used to receive TCP packets for stateless services sent by the client, and determine the corresponding processing strategy for the TCP packets based on the control flags or payload of the TCP packets; the two requests for stateless services are unrelated.

[0082] The processing module 302 is used to process TCP packets according to the processing strategy corresponding to the TCP packets.

[0083] The Transmission Control Protocol (TCP) message processing apparatus provided in this embodiment receives TCP messages for stateless services sent by a client, determines the corresponding processing strategy for the TCP message based on the control flags or payload of the TCP message, and processes the TCP message according to the corresponding processing strategy. In this embodiment, for TCP messages for stateless services, the processing strategy for the TCP message is determined based on the control flags or payload of the TCP message, and then the TCP message is processed. This eliminates the need to maintain the connection state by storing information such as 5-tuples and sequence numbers, reducing the consumption of CPU computing resources and memory resources, and effectively maintaining the continuity and stability of the service.

[0084] In one implementation, the processing module 302 is configured to: if the control flag indicates the establishment of a connection, increment the first sending sequence number of the TCP packet by a preset value to obtain a first receiving acknowledgment number; generate a second sending sequence number; generate a first reply packet based on the first receiving acknowledgment number and the second sending sequence number, and return the first reply packet to the client; the control flag of the first reply packet indicates the establishment of a connection and connection confirmation.

[0085] In one implementation, the processing module 302 is configured to: if the control flag indicates termination of the connection, increment the third sending sequence number of the TCP packet by a preset value to obtain a second receiving acknowledgment number; obtain the third receiving acknowledgment number of the TCP packet and use the third receiving acknowledgment number as the fourth sending sequence number; generate a second reply message based on the second receiving acknowledgment number and the fourth sending sequence number, and return the second reply message to the client; the control flag of the second reply message indicates termination of the connection and termination acknowledgment.

[0086] In one implementation, the processing module 302 is configured to: discard TCP packets if the control flag indicates a connection reset.

[0087] In one implementation, the processing module 302 is configured to: reset the connection between the client and the server if the payload is greater than zero and the TCP packet is an abnormal packet.

[0088] In one implementation, the stateless service includes a domain name resolution service. A processing module 302 is configured to: if the payload is greater than zero and the TCP packet is a packet from a preset domain name server, obtain a first domain name resolution result from the preset domain name server; determine a fourth receive acknowledgment number based on the fifth sending sequence number and the payload of the TCP packet; use the fifth receive acknowledgment number of the TCP packet as a sixth sending sequence number; generate a third reply packet based on the fourth receive acknowledgment number, the sixth sending sequence number, and the first domain name resolution result; and return the third reply packet to the client.

[0089] In one implementation, the stateless service includes a domain name resolution service. A processing module 302 is configured to: if the payload is greater than zero and the second domain name resolution result of the TCP packet is in the local cache data, then retrieve the second domain name resolution result from the local cache data; determine the sixth receive acknowledgment number based on the seventh sending sequence number and the payload of the TCP packet; use the seventh receive acknowledgment number of the TCP packet as the eighth sending sequence number; generate a fourth reply packet based on the sixth receive acknowledgment number, the eighth sending sequence number, and the second domain name resolution result, and return the fourth reply packet to the client.

[0090] In one implementation, the stateless service includes a domain name resolution service and a processing module 302, configured to: if the payload is greater than zero and the second domain name resolution result of the TCP packet is not in the local cache data, determine the eighth receive acknowledgment number based on the ninth sending sequence number of the TCP packet and the payload; use the ninth receive acknowledgment number of the TCP packet as the tenth sending sequence number; generate a fifth reply packet based on the eighth receive acknowledgment number and the tenth sending sequence number; return the fifth reply packet to the client; and have the control flag of the fifth reply packet indicate that acknowledgment has been received.

[0091] In one implementation, the Transmission Control Protocol (TCP) message processing device is further configured to: store the TCP message in a buffer area, obtain the second domain name resolution result through iterative query; obtain the ninth receive acknowledgment number and the ninth send sequence number of the TCP message from the buffer area; generate a sixth reply message based on the ninth receive acknowledgment number, the ninth send sequence number, and the second domain name resolution result, and return the sixth reply message to the client.

[0092] The functions of each module in the embodiments of this application can be found in the corresponding descriptions in the above methods, and they have corresponding beneficial effects, which will not be repeated here.

[0093] Corresponding to the application scenarios and methods provided in the embodiments of this application, the embodiments of this application also provide a Transmission Control Protocol (TCP) message processing apparatus. One embodiment of the TCP message processing apparatus of this application includes:

[0094] The sending module is used to send Transmission Control Protocol (TCP) packets for stateless services to the server, so that the server can determine the corresponding processing strategy for the TCP packet based on the control flags or payload of the TCP packet, and process the TCP packet according to the corresponding processing strategy. The two requests for stateless services are unrelated.

[0095] The Transmission Control Protocol (TCP) message processing apparatus provided in this application embodiment allows a client to send stateless TCP messages to a server. This enables the server to determine the corresponding processing strategy for the TCP message based on its control flags or payload, and then process the TCP message according to that strategy. In this embodiment, for stateless TCP messages, the processing strategy is determined based on the control flags or payload, eliminating the need to maintain connection state by storing 5-tuples, sequence numbers, or other information. This reduces CPU and memory resource consumption and effectively maintains service continuity and stability.

[0096] In addition, embodiments of this application provide a Transmission Control Protocol (TCP) message processing system. Figure 4 This is a structural block diagram of a Transmission Control Protocol (TCP) message processing system according to an embodiment of this application. The TCP message processing system includes a client 401 and a server 402.

[0097] Client 401 is used to: send stateless TCP packets to the server;

[0098] The server-side 402 is used to: receive TCP packets sent by the client, determine the corresponding processing strategy for the TCP packet based on the control flags or payload of the TCP packet, and process the TCP packet according to the corresponding processing strategy.

[0099] The specific processing procedures of client 401 and server 402 have been described in the above embodiments and will not be repeated here.

[0100] The Transmission Control Protocol (TCP) message processing system provided in this application embodiment receives TCP messages for stateless services sent by the client. Based on the control flags or payload of the TCP message, the server determines the corresponding processing strategy and processes the TCP message according to the processing strategy. In this embodiment, since the two requests for stateless services are unrelated, the processing strategy for the TCP message is determined based on the control flags or payload, and then the TCP message is processed. This eliminates the need to maintain connection state by storing information such as 5-tuples and sequence numbers, reducing CPU and memory resource consumption and effectively maintaining service continuity and stability.

[0101] Figure 5 This is a block diagram of an electronic device used to implement embodiments of this application. For example... Figure 5 As shown, the electronic device includes a memory 510 and a processor 520. The memory 510 stores a computer program that can run on the processor 520. When the processor 520 executes the computer program, it implements the method described in the above embodiments. The number of memories 510 and processors 520 can be one or more.

[0102] The electronic device also includes:

[0103] The communication interface 530 is used to communicate with external devices and exchange and transmit data.

[0104] If the memory 510, processor 520, and communication interface 530 are implemented independently, they can be interconnected via a bus to communicate with each other. This bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. This bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 5 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0105] Optionally, in a specific implementation, if the memory 510, processor 520, and communication interface 530 are integrated on a single chip, then the memory 510, processor 520, and communication interface 530 can communicate with each other through an internal interface.

[0106] This application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method provided in this application.

[0107] This application provides a computer program product, which includes a computer program that, when executed by a processor, implements the method provided in this application.

[0108] This application also provides a chip including a processor for calling and executing instructions stored in a memory, causing a communication device with the chip installed to perform the method provided in this application.

[0109] This application also provides a chip, including: an input interface, an output interface, a processor, and a memory. The input interface, output interface, processor, and memory are connected through an internal connection path. The processor is used to execute code in the memory. When the code is executed, the processor is used to execute the method provided in the application embodiment.

[0110] It should be understood that the aforementioned processor can be a Central Processing Unit (CPU), or other general-purpose processors, Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field-Programmable Gate Arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. General-purpose processors can be microprocessors or any conventional processor. It is worth noting that the processor can be a processor supporting Advanced Reduced Instruction Set Machines (ARM) architecture.

[0111] Further, optionally, the aforementioned memory may include read-only memory and random access memory. The memory may be volatile memory or non-volatile memory, or may include both. Non-volatile memory may include read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which serves as an external cache. By way of example, but not limitation, many forms of RAM are available. Examples include Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDR SDRAM), Enhanced Synchronous DRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), and Direct Rambus RAM (DR RAM).

[0112] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transferred from one computer-readable storage medium to another.

[0113] In the description of this specification, the references to terms such as "one embodiment," "some embodiments," "example," "specific example," or "some examples," etc., indicate that a specific feature, structure, material, or characteristic described in connection with that embodiment or example is included in at least one embodiment or example of this application. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Moreover, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of those different embodiments or examples.

[0114] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "a plurality of" means two or more, unless otherwise explicitly specified.

[0115] Any process or method described in the flowchart or otherwise herein can be understood as representing a module, segment, or portion of code comprising one or more executable instructions for implementing a particular logical function or process. Furthermore, the scope of the preferred embodiments of this application includes additional implementations in which functions may be performed not in the order shown or discussed, including substantially simultaneously or in reverse order depending on the functionality involved.

[0116] The logic and / or steps described in the flowchart or otherwise herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus or device (such as a computer-based system, a processor-included system or other system that can fetch and execute instructions from, an instruction execution system, apparatus or device).

[0117] It should be understood that various parts of this application can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in memory and executed by a suitable instruction execution system. All or part of the steps of the methods in the above embodiments can be implemented by a program instructing related hardware, the program being stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiments.

[0118] Furthermore, the functional units in the various embodiments of this application can be integrated into a processing module, or each unit can exist physically separately, or two or more units can be integrated into a module. The integrated module can be implemented in hardware or as a software functional module. If the integrated module is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. This storage medium can be a read-only memory, a disk, or an optical disk, etc.

[0119] The above description is merely an exemplary embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various variations or substitutions within the technical scope described in this application, and these should all be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for processing Transmission Control Protocol (TCP) messages, characterized in that, The method is applied to the server side and includes: Receive stateless service Transmission Control Protocol (TCP) packets sent by the client, and determine the processing strategy corresponding to the TCP packets based on the control flags or payload of the TCP packets; The TCP packet is processed according to the processing strategy corresponding to the TCP packet.

2. The method according to claim 1, characterized in that, The step of processing the TCP packet according to the processing strategy corresponding to the TCP packet includes: If the control flag indicates that a connection has been established, the first sending sequence number of the TCP packet is incremented by a preset value to obtain the first receiving acknowledgment number; Generate a second transmission sequence number; A first reply message is generated based on the first receipt confirmation number and the second transmission sequence number, and the first reply message is returned to the client; the control flag bit of the first reply message indicates the establishment of connection and connection confirmation.

3. The method according to claim 1, characterized in that, The step of processing the TCP packet according to the processing strategy corresponding to the TCP packet includes: If the control flag indicates termination of the connection, the third send sequence number of the TCP packet is incremented by a preset value to obtain the second receive acknowledgment number; Obtain the third receive acknowledgment number of the TCP packet, and use the third receive acknowledgment number as the fourth send sequence number; A second reply message is generated based on the second receipt confirmation number and the fourth send sequence number, and the second reply message is returned to the client; the control flag bit of the second reply message indicates the termination of connection and termination confirmation.

4. The method according to any one of claims 1-3, characterized in that, The step of processing the TCP packet according to the processing strategy corresponding to the TCP packet includes: If the control flag indicates a connection reset, the TCP packet is discarded.

5. The method according to any one of claims 1-3, characterized in that, The step of processing the TCP packet according to the processing strategy corresponding to the TCP packet includes: If the payload is greater than zero and the TCP packet is an abnormal packet, then the connection between the client and the server is reset.

6. The method according to any one of claims 1-3, characterized in that, The stateless service includes a domain name resolution service, and the processing of the TCP packet according to the processing strategy corresponding to the TCP packet includes: If the payload is greater than zero, and the TCP packet is a packet from a preset domain name server, then the first domain name resolution result is obtained from the preset domain name server. Based on the fifth transmission sequence number of the TCP packet and the payload, determine the fourth reception acknowledgment number; Use the fifth receive acknowledgment number of the TCP packet as the sixth send sequence number; A third reply message is generated based on the fourth receipt confirmation number, the sixth sending sequence number, and the first domain name resolution result, and the third reply message is returned to the client.

7. The method according to any one of claims 1-3, characterized in that, The stateless service includes a domain name resolution service, and the processing of the TCP packet according to the processing strategy corresponding to the TCP packet includes: If the payload is greater than zero, and the second domain name resolution result of the TCP packet is in the local cache data, then the second domain name resolution result is obtained from the local cache data; Based on the seventh sending sequence number of the TCP packet and the payload, determine the sixth receiving acknowledgment number; Use the seventh receive acknowledgment number of the TCP packet as the eighth send sequence number; A fourth reply message is generated based on the sixth receipt confirmation number, the eighth sending sequence number, and the second domain name resolution result, and the fourth reply message is returned to the client.

8. The method according to any one of claims 1-3, characterized in that, The stateless service includes a domain name resolution service, and the processing of the TCP packet according to the processing strategy corresponding to the TCP packet includes: If the payload is greater than zero, and the second domain name resolution result of the TCP packet is not in the local cache data, then the eighth receive acknowledgment number is determined based on the ninth sending sequence number of the TCP packet and the payload. Use the ninth receive acknowledgment number of the TCP packet as the tenth send sequence number; A fifth reply message is generated based on the eighth receipt confirmation number and the tenth transmission sequence number, and the fifth reply message is returned to the client. The control flag of the fifth reply message indicates that the confirmation has been received.

9. The method according to claim 8, characterized in that, The method further includes: The TCP packets are stored in a cache area, and the second domain name resolution result is obtained through iterative querying. Obtain the ninth receive acknowledgment number and the ninth send sequence number of the TCP packet from the buffer area; A sixth reply message is generated based on the ninth receipt confirmation number, the ninth sending sequence number, and the second domain name resolution result, and the sixth reply message is returned to the client.

10. A Transmission Control Protocol (TCP) message processing system, characterized in that, The system includes a client and a server; The client is used to: send stateless service TCP packets to the server; The server is used to: receive the TCP packets sent by the client, and determine the processing strategy corresponding to the TCP packets based on the control flags or payload of the TCP packets; The TCP packet is processed according to the processing strategy corresponding to the TCP packet.

11. An electronic device, characterized in that, The electronic device includes a memory, a processor, and a computer program stored in the memory, wherein the processor, when executing the computer program, implements the method of any one of claims 1-9.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the method of any one of claims 1-9.

13. A computer program product, characterized in that, The computer program product includes a computer program that, when executed by a processor, implements the method of any one of claims 1-9.