Message processing method, operating system, storage medium and computer equipment

By building a TCP manager in the user space and diverting TCP messages, the problem of high complexity of the TCP proxy system in the existing technology is solved, the flexibility and controllability are improved, and the construction of intermediate proxy nodes is avoided.

CN118540390APending Publication Date: 2024-08-23PURPLE MOUNTAIN LAB
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410653816.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-23
Publication Date
2024-08-23

AI Technical Summary

Technical Problem

In the existing technology, the TCP proxy is implemented by constructing an intermediate proxy node, which results in high system complexity, large limitations in application scenarios, and insufficient flexibility and controllability in the application method.

Method used

Build a TCP manager in the user space of the system. By offloading TCP packets to the TCP manager for processing and offloading non-TCP packets to the kernel protocol stack for processing, TCP proxy services between the local application layer and the network card are implemented to avoid Build intermediate agent nodes.

Benefits of technology

It simplifies the system complexity, improves the flexibility and controllability of application scenarios, and achieves the technical effect of TCP proxy without building an intermediate proxy node.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118540390A
    Figure CN118540390A
Patent Text Reader

Abstract

The invention discloses a message processing method, an operating system, a storage medium and computer equipment. The method comprises the steps that a sending message transmitted by an application program is received, and the application program is located in a local application layer; the sending message is processed, the message type of the sending message is obtained, and the message type comprises a transmission control protocol message or a non-transmission control protocol message; under the condition that the message type of the sending message is a transmission control protocol message, a transmission control protocol manager is adopted to process the sending message to obtain a first proxy message corresponding to the sending message, and the transmission control protocol manager is arranged in a user space; the first proxy message is transmitted to a network card, and the network card is used for sending the first proxy message to the target device. According to the invention, the technical problem of high system complexity caused by the need of constructing an intermediate agent node to realize TCP proxy in the prior art is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communications, and in particular to a message processing method, an operating system, a storage medium and a computer device. Background Art

[0002] Transmission Control Protocol proxy is also called TCP proxy or TCP port forwarding. It is generally implemented by building a middleman node to forward data between the TCP server and the TCP client. It is widely used in network security fields such as privacy protection, content filtering, and security penetration testing, providing basic services for network security control and management systems. Implementing TCP proxy by building a middleman node greatly increases the complexity of the system, has large application scenarios, and is not flexible and controllable enough.

[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention

[0004] The embodiments of the present invention provide a message processing method, an operating system, a storage medium and a computer device, so as to at least solve the technical problem in the prior art that an intermediate proxy node needs to be constructed to implement a TCP proxy, resulting in high system complexity.

[0005] According to one aspect of an embodiment of the present invention, a message processing method is provided, comprising: receiving a send message transmitted by an application, wherein the application is located at a local application layer; processing the send message to obtain a message type of the send message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message; in a case where the message type of the send message is a transmission control protocol message, using a transmission control protocol manager to process the send message to obtain a first proxy message corresponding to the send message, wherein the transmission control protocol manager is set in a user space; and transmitting the first proxy message to a network card, wherein the network card is used to send the first proxy message to a target device.

[0006] Optionally, the transmission control protocol manager is used to process the sending message to obtain a first proxy message corresponding to the sending message, including: processing the sending message according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection status in the transmission control protocol manager; controlling the transmission control protocol manager to update the connection mapping map manager according to the sending message, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; performing message processing on the sending message according to the connection mapping map manager and the five-tuple information of the sending message to obtain the first proxy message.

[0007] Optionally, controlling the transmission control protocol manager to update the connection mapping map manager according to the sent message includes: determining whether there is a corresponding entry for the sent message in the connection mapping map manager according to the five-tuple information of the sent message; in the case where the sent message is a link establishment message, if the corresponding entry does not exist in the connection mapping map manager, creating the corresponding entry in the connection mapping map manager; if the corresponding entry exists in the connection mapping map manager, updating the value of the corresponding entry according to the sent message; or, in the case where the sent message is a link break message, if the connection If the corresponding entry does not exist in the connection mapping map manager, the processing of the sending message is skipped; if the corresponding entry exists in the connection mapping map manager, the corresponding entry is deleted when the transmission control protocol connection state is closed, and the value of the corresponding entry is updated when the transmission control protocol connection state is other than closed; or, in the case that the sending message is a data message, if the corresponding entry does not exist in the connection mapping map manager, the processing of the sending message is skipped; if the corresponding entry exists in the connection mapping map manager, the value of the corresponding entry is updated according to the sending message.

[0008] Optionally, the receiving of the sending message transmitted by the application includes: determining whether the application is a preset takeover application, wherein the preset takeover application is an application requesting a transmission control protocol proxy service; when the application is a preset takeover application, using a POSIX socket interface module to receive the sending message, wherein the POSIX socket interface module is used to transmit messages between the local application layer and the transmission control protocol manager.

[0009] Optionally, the method also includes: when the message type of the sending message is a non-transmission control protocol message, distributing the sending message to the kernel protocol stack; processing the sending message based on the kernel protocol stack, and passing the processed sending message to the network card, wherein the network card is used to send the processed sending message to the target device.

[0010] According to another aspect of an embodiment of the present invention, a message processing method is also provided, including: receiving a network message transmitted by a network card; processing the network message to obtain a message type of the network message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message; when the message type of the network message is a transmission control protocol message, distributing the network message to a transmission control protocol manager, wherein the transmission control protocol manager is set in the user space; using the transmission control protocol manager to process the network message to obtain a second proxy message corresponding to the network message; and delivering the second proxy message to an application in a local application layer.

[0011] Optionally, the use of the transmission control protocol manager to process the network message to obtain a second proxy message corresponding to the network message includes: processing the network message according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection status in the transmission control protocol manager; controlling the transmission control protocol manager to update the connection mapping map manager according to the network message and the transmission control protocol connection status, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; performing message processing on the network message according to the connection mapping map manager and the five-tuple information of the network message to obtain the second proxy message.

[0012] Optionally, according to the network message and the transmission control protocol connection status, controlling the transmission control protocol manager to update the connection mapping map manager includes: determining whether there is a corresponding entry for the network message in the connection mapping map manager according to the five-tuple information of the network message; in the case where the network message is a link establishment message, if the corresponding entry does not exist in the connection mapping map manager, creating the corresponding entry in the connection mapping map manager; if the corresponding entry exists in the connection mapping map manager, updating the value of the corresponding entry according to the network message; in the case where the network message is a link breaking message, In the case where the corresponding entry does not exist in the connection mapping map manager, the processing of the network message is skipped; if the corresponding entry exists in the connection mapping map manager, the corresponding entry is deleted when the transmission control protocol connection state is closed, and the value of the corresponding entry is updated when the transmission control protocol connection state is other than closed; in the case where the network message is a data message, if the corresponding entry does not exist in the connection mapping map manager, the processing of the network message is skipped; if the corresponding entry exists in the connection mapping map manager, the value of the corresponding entry is updated according to the network message.

[0013] Optionally, delivering the second proxy message to an application program in a local application layer includes: delivering the second proxy message to a POSIX socket interface module, and the POSIX socket interface module delivering the second proxy message to the application program.

[0014] Optionally, the method further includes: when the message type of the network message is a non-transmission control protocol message, distributing the network message to a kernel protocol stack; processing the network message based on the kernel protocol stack, and passing the processed network message to the application.

[0015] According to another aspect of an embodiment of the present invention, an operating system is also provided, including: an interface module, used to receive a send message transmitted by an application, and pass the send message to a send message splitter, and also used to pass a proxy message obtained by processing a network message to the application; the send message splitter is used to distribute the send message to a transmission control protocol manager when the send message is a transmission control protocol message; the transmission control protocol manager is used to process the send message to obtain a proxy message corresponding to the send message, and is also used to process the network message to obtain a proxy message corresponding to the network message; a fast data plane module, including a receive message splitter; wherein the receive message splitter is used to distribute the network message to the transmission control protocol manager when the network message is a transmission control protocol message.

[0016] According to another aspect of an embodiment of the present invention, a non-volatile storage medium is provided, wherein the non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute any one of the above-mentioned message processing methods.

[0017] According to another aspect of an embodiment of the present invention, a computer device is provided, comprising a memory and a processor, wherein the memory is used to store programs, and the processor is used to run the programs stored in the memory, wherein when the program is run, any one of the above-mentioned message processing methods is executed.

[0018] According to another aspect of the embodiments of the present application, a computer program product is also provided, including a computer program, and when the computer program is executed by a processor, the message processing method in each embodiment of the present application is implemented.

[0019] In the embodiment of the present invention, a method of building a TCP manager in the user space of the system to perform TCP proxy service is adopted. By diverting TCP packets to the TCP manager for processing, and diverting non-TCP packets to the kernel protocol stack for processing, the purpose of realizing TCP proxy service between the local application layer and the network card is achieved, thereby achieving the technical effect of realizing TCP without building an intermediate proxy node, and further solving the technical problem in the prior art that the construction of an intermediate proxy node is required to realize TCP proxy, resulting in high system complexity. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:

[0021] Figure 1 A hardware structure block diagram of a computer terminal for implementing a message processing method is shown;

[0022] Figure 2 is a flow chart of a message processing method 1 provided according to an embodiment of the present invention;

[0023] Figure 3 is a flow chart of a second message processing method according to an embodiment of the present invention;

[0024] Figure 4 is a schematic diagram of the structure of an operating system provided according to an optional embodiment of the present invention;

[0025] Figure 5 is a structural block diagram of a message processing device 1 provided according to an embodiment of the present invention;

[0026] Figure 6 It is a structural block diagram of a second message processing device provided according to an embodiment of the present invention. DETAILED DESCRIPTION

[0027] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.

[0028] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0029] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following interpretations:

[0030] Transmission Control Protocol (TCP) is a connection-oriented, reliable, byte-stream-based transport layer communication protocol. TCP is the main transport protocol in the Internet protocol suite (TCP / IP protocol suite), providing reliable data transmission services for many applications (such as web browsers and email clients).

[0031] TCP proxy, also known as TCP port forwarding, is a proxy service software on the application layer of the TCP / IP protocol. Its working principle is to forward the data of the TCP connection coming from the proxy listening port to a port listened by the superior as it is. The superior can be the TCP proxy of the proxy or a specific third-party service. If the superior is a TCP proxy, then a forwarding chain is formed. The TCP proxy interacts directly with the TCP layer, cuts off the TCP connection between the internal and external networks, divides a connection into two segments, and blocks the TCP network protocol at the transport layer, copies the data in the source data packet, and realizes data ferrying through the proxy forwarding at the application layer. The proxy is an intermediary that sends messages to the server on behalf of the client, and can be used in scenarios such as privacy protection, content filtering, censorship bypass, caching, and security penetration testing.

[0032] When implementing a TCP proxy, the intermediate node usually refers to the proxy server itself. The proxy server is located between the client and the destination server (such as a web server) in the network architecture, acting as a "middleman". The client sends a TCP connection request to the proxy server, which then forwards the request to the destination server. Similarly, the data returned from the destination server will also pass through the proxy server before being transmitted to the client.

[0033] According to an embodiment of the present invention, an embodiment of a message processing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0034] The method embodiments provided in the embodiments of the present application can be executed in a mobile terminal, a computer terminal or a similar computing device. Figure 1 FIG. 1 shows a hardware structure block diagram of a computer terminal for implementing a message processing method. Figure 1 As shown, the computer terminal 10 may include one or more processors (processors 102a, 102b, ..., 102n are used as examples in the figure) (the processors may include but are not limited to processing devices such as microprocessors MCU or programmable logic devices FPGA), and a memory 104 for storing data. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply, and / or a camera. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components as shown, or with Figure 1 Different configurations are shown.

[0035] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the computer terminal 10. As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0036] The memory 104 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the message processing method in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory 104, that is, the message processing method of the above-mentioned application is realized. The memory 104 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory 104 may further include a memory remotely arranged relative to the processor, and these remote memories may be connected to the computer terminal 10 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0037] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computer terminal 10 .

[0038] Figure 2 1 is a flow chart of a message processing method according to an embodiment of the present invention. The method can be applied to a TCP proxy system between an application layer and a network card. The method can realize sending the TCP message of an application program outward after realizing the TCP proxy. Figure 2 As shown, the method comprises the following steps:

[0039] Step S201, receiving a send message transmitted by an application, wherein the application is located at a local application layer. In this step, the send message is used to send to other ends, for example, to other clients.

[0040] As an optional embodiment, a sending message transmitted by an application can be received in the following manner: determining whether the application is a preset takeover application, wherein the preset takeover application is an application requesting a transmission control protocol proxy service; in the case where the application is a preset takeover application, using a POSIX socket interface module to receive the sending message, wherein the POSIX socket interface module is used to transmit messages between the local application layer and the transmission control protocol manager.

[0041] The socket interface in the operating system is a network programming interface for realizing network communication between application programs. It provides a set of functions and protocols so that application programs can send and receive data through the network. The POSIX Socket interface module in this optional embodiment is a part of the POSIX (Portable Operating System Interface) standard, which defines a set of functions and protocols for network programming. These functions and protocols provide a standard, cross-platform interface so that application programs can perform network communication on different operating systems. In this optional embodiment, the POSIX Socket interface module is used to realize the takeover of the operating system socket interface.

[0042] The preset takeover application is a predetermined application that uses the local TCP proxy service. For the applications at the local application layer, not all of them need the local TCP proxy, or some applications do not need the TCP proxy. Therefore, it is possible to predetermine which applications need the local TCP proxy and mark these applications as preset takeover applications. For the messages sent by these applications, the POSIX Socket interface module can be used for takeover and message ferrying processing.

[0043] Among them, the main functions of the POSIX Socket interface module include: Creating a socket: An application can use the functions provided by the POSIX Socket interface module to create a socket, which will serve as the endpoint of network communication. Binding address and port: An application can bind a socket to a specific IP address and port number so that other computers can communicate with the application through the address and port number. Listening for connection requests: For server-side applications, the POSIX Socket interface module provides functions for listening for connection requests. When a client application initiates a connection request, the server-side application can use these functions to accept the connection request and establish a connection. Sending and receiving data: Once the connection is successfully established, the application can use the functions provided by the POSIX Socket interface module to send and receive data. These functions provide synchronous and asynchronous communication methods to meet the needs of different application scenarios.

[0044] Step S202, processing the sent message to obtain the message type of the sent message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message.

[0045] Optionally, this step can be performed using a sending splitter in the operating system. The sending splitter can be referred to as a TX splitter, which is used to determine the type of the sent message and to split the sent message to the correct place based on the message type. In the present application, when the type of the sent message is a transmission control protocol message (referred to as a TCP message), the TX splitter can split the TCP message to a transmission control protocol manager (referred to as a TCP manager), and the TCP manager executes step S203.

[0046] As an optional embodiment, when the message type of the sent message is a non-transmission control protocol message, the sent message can be distributed to the kernel protocol stack; the sent message is processed based on the kernel protocol stack, and the processed sent message is passed to the network card, wherein the network card is used to send the processed sent message to the target device. In this optional embodiment, the kernel protocol stack is used to perform conventional message processing and encapsulation on the sent message diverted to itself, and then send it normally to other clients.

[0047] Step S203, when the message type of the sent message is a transmission control protocol message, a transmission control protocol manager is used to process the sent message to obtain a first proxy message corresponding to the sent message, wherein the transmission control protocol manager is set in the user space.

[0048] In this step, the transmission control protocol manager can also be referred to as a TCP manager for short. The TCP manager is used to implement the TCP proxy service, so that TCP proxy forwarding can be achieved during the message delivery process without setting up additional intermediate server nodes.

[0049] As an optional embodiment, a transmission control protocol manager is used to process a sending message to obtain a first proxy message corresponding to the sending message, including the following steps: processing the sending message according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection status in the transmission control protocol manager; controlling the transmission control protocol manager to update the connection mapping map manager (connection mapping map manager, referred to as connection Maps) according to the sending message and the transmission control protocol connection status, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; performing message processing on the sending message according to the connection mapping map manager and the five-tuple information of the sending message to obtain a first proxy message.

[0050] Optionally, the TCP manager may include a message processor, a TCP protocol state machine, and a connection mapping map manager (referred to as the Connection Maps Manager). The message processor may perform application layer message processing according to preset rules. For example, it may be responsible for receiving and sending messages in the TCP manager, as well as parsing incoming TCP messages, extracting header information in the TCP message, such as sequence number, acknowledgment number, the above-mentioned five-tuple information, etc. The five-tuple information can be used for TCP stream matching. The TCP protocol state machine may maintain the internal TCP protocol connection state based on the TCP protocol standard, and may subsequently decide how to respond to messages received by the TCP manager based on the TCP specification and the current TCP protocol connection state of the message. The Connection Maps Manager may create, update, or delete connection Maps based on the five-tuple information in the message header of the sent message and the TCP protocol connection state corresponding to the sent message. For example, the TCP protocol connection state corresponding to the sent message may be updated to the entry corresponding to the sent message included in the Connection Maps Manager.

[0051] Optionally, when the TCP manager provided by the present invention is used to process a sending message to obtain a corresponding first proxy message, the basic processing flow may include the following steps: after the TCP manager receives a sending message of the TCP type through a message processor, the message processor parses the sending message to obtain five-tuple information of the sending message; the TCP protocol state machine reads the sending message, maintains the TCP connection state according to the message state type of the sending message, and updates the latest TCP connection state of the sending message to the connection map manager, wherein the message state type of the sending message may include any one of a link establishment message, a data message, and a link break message.

[0052] eXpress Data Path (XDP) is a programmable packet processing solution in the Linux kernel that bypasses the kernel. The core idea is to process the data packet in the kernel space before the data packet reaches the network driver, so as to quickly process the data packet and determine its further processing path. Specifically, when a data packet arrives at the Linux kernel, it would originally be sent to a network driver, such as a network interface card driver (NIC driver). However, under the XDP mechanism, the data packet will be processed by the XDP program before being passed to the network driver. The XDP program can quickly check and modify the data packet in the kernel space, thereby realizing flexible control of network traffic. The connection Maps in the present invention are XDP module components, which are used to realize data interaction between user space and kernel state, and to realize the data processing function of the TCP manager. The connection Maps in the present invention can be BPF Maps implemented based on eBPF. BPF Maps provide various types of key-value data storage methods, which allow user space programs to interact with XDP programs in kernel space to realize data sharing. The Extended Berkeley Packet Filter (eBPF) allows sandboxed programs to be run in a privileged context (such as the operating system kernel), thereby safely and efficiently extending the functionality of the kernel without having to change the kernel source code or load kernel modules. eBPF programs can be dynamically loaded into the kernel and add additional functionality to the operating system at runtime.

[0053] In the combination of XDP and eBPF, XDP provides the underlying packet processing mechanism, while eBPF provides powerful programming capabilities, enabling developers to write complex logic to process network packets. By dynamically mounting the eBPF program to XDP, the application requirements in the embodiments of the present invention can be achieved. Among them, Connection Maps plays the role of a bridge between eBPF and XDP, providing a mechanism that enables eBPF programs to access and modify user space data structures. Connection Maps can store various types of data, such as hash tables, arrays, etc., and can be shared between kernel space and user space.

[0054] The five-tuple information of the TCP message header includes [proto, src-ip, src-port, dst-ip, dst-port], where proto is the IP message type, supporting IPv4 / IPv6 dual stack, src-ip is the source IP, src-port is the source port, dst-ip is the destination IP, and dst-port is the destination port.

[0055] Maintaining the TCP connection state based on the TCP protocol standard means managing and maintaining the different states of the TCP connection according to the provisions of the TCP protocol during the TCP communication process. TCP (Transmission Control Protocol) is a connection-oriented, reliable, byte stream-based transport layer communication protocol that establishes a connection before sending and receiving data, and removes the connection after the data transmission is completed. The TCP protocol defines several different states to describe the different stages and situations of the connection, such as LISTEN, SYN_SENT, SYN_RECV, ESTABLISHED, FIN_WAIT_1, FIN_WAIT_2, TIME_WAIT, CLOSE_WAIT, LAST_ACK, and CLOSED. During the TCP connection process, these states will be converted in a specific order to complete operations such as connection establishment, data transmission, and connection removal. The main purpose of maintaining the TCP connection state is to ensure reliable data transmission and correct management of connections. By tracking the status of the connection, the TCP protocol can handle problems such as packet loss, disorder, and duplicate packets to ensure the orderly and reliable transmission of data. At the same time, when the connection is no longer needed, the TCP protocol will correctly close the connection and release resources.

[0056] As an optional embodiment, according to the sent message and the transmission control protocol connection status, the transmission control protocol manager is controlled to update the connection mapping map manager. The following method can be adopted: according to the five-tuple information of the sent message, determine whether there is a corresponding entry for the sent message in the connection mapping map manager; in the case where the sent message is a link establishment message, if the corresponding entry does not exist in the connection mapping map manager, then create a corresponding entry in the connection mapping map manager, if the corresponding entry exists in the connection mapping map manager, then update the value of the corresponding entry according to the sent message; or, in the case where the sent message is a link break message, if the corresponding entry does not exist in the connection mapping map manager, then skip the processing of the sent message, if the corresponding entry exists in the connection mapping map manager, then delete the corresponding entry when the transmission control protocol connection status is closed, and update the value of the corresponding entry when the transmission control protocol connection status is other than closed; or, in the case where the sent message is a data message, if the corresponding entry does not exist in the connection mapping map manager, then skip the processing of the sent message, if the corresponding entry exists in the connection mapping map manager, then update the value of the corresponding entry according to the sent message and the transmission control protocol connection status.

[0057] Optionally, the connection Maps storage entries in the embodiment of the present invention are all composed of [key, value] key-value pairs. The key in the connection Maps is constructed by the TCP message five-tuple information [proto, src-ip, src-port, dst-ip, dst-port]. The value of the entry corresponding to the sent message is constructed by [pid, socket-fd, state, snd-time, rcv-time, snd-cnt, rcv-cnt]. Among them, pid is the process ID, socket-fd is the socket file descriptor, state is the current connection state, snd-time is the most recent sending timestamp, rcv-time is the most recent receiving timestamp, snd-cnt is the sending message count, and rcv-cnt is the receiving message count. Based on this optional embodiment, the maintenance and management of the connection Maps can be implemented.

[0058] Optionally, you can check the control bits field (Control Bits) of the sent message to determine whether the message is a link-building message, a link-breaking message, or a data message. For a link-building message, during the TCP three-way handshake to establish a connection, the client will send a SYN message (SYN=1) to the server to request to establish a connection. After receiving it, the server will reply with a SYN+ACK message (SYN=1, ACK=1) to indicate that it agrees to establish a connection. Finally, the client sends another ACK message (ACK=1) to confirm that the connection is successfully established. Therefore, if the SYN flag in the message is 1, then it is a link-building message. For a link-breaking message, during the TCP four-wave handshake to disconnect the connection, one party will send a FIN message (FIN=1) to the other party to indicate a request to disconnect. After receiving it, the receiver will reply with an ACK message for confirmation. After that, there may be some data transmission and confirmation messages. Finally, the sender will send another FIN message to indicate that the connection has been completely closed. Therefore, if the FIN flag in the message is 1, it is a broken link message.

[0059] Step S204: delivering the first proxy message to the network card, wherein the network card is used to send the first proxy message to the target device.

[0060] Through the above steps, a TCP manager is built in the user space of the system to perform TCP proxy services. By diverting TCP packets to the TCP manager for processing, and diverting non-TCP packets to the kernel protocol stack for processing, the purpose of realizing TCP proxy services between the local application layer and the network card is achieved, thereby achieving the technical effect of realizing TCP without building an intermediate proxy node, and further solving the technical problem in the prior art that the system complexity is high due to the need to build an intermediate proxy node to realize TCP proxy.

[0061] The above-mentioned message processing method 1 provides a method for processing sent messages. The present invention also provides a method for processing received messages, which can also be applied to the TCP proxy system between the application layer and the network card to realize TCP proxy processing of received messages. Figure 3 is a flow chart of a second message processing method according to an embodiment of the present invention. Figure 3 As shown, the method comprises the following steps:

[0062] Step S301, receiving a network message transmitted by a network card. The network message in this step is a received message, which is sent by an external client or server to an application in a local application layer through a network card. Based on this embodiment, TCP proxy processing of network messages can be implemented locally without the need to build an additional TCP proxy server intermediate node.

[0063] Step S302, process the network message to obtain the message type of the network message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message. Optionally, this step can be implemented by a receiving splitter, which can be referred to as an RX splitter.

[0064] Step S303: when the message type of the network message is a transmission control protocol message, the network message is distributed to a transmission control protocol manager, wherein the transmission control protocol manager is set in the user space.

[0065] Step S304: Use the transmission control protocol manager to process the network message to obtain a second proxy message corresponding to the network message.

[0066] As an optional embodiment, the use of the transmission control protocol manager to process the network message to obtain a second proxy message corresponding to the network message includes: processing the network message according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection status in the transmission control protocol manager; controlling the transmission control protocol manager to update the connection mapping map manager according to the network message and the transmission control protocol connection status, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; performing message processing on the network message according to the connection mapping map manager and the five-tuple information of the network message to obtain the second proxy message.

[0067] As an optional embodiment, according to the network message and the transmission control protocol connection status, the transmission control protocol manager is controlled to update the connection mapping map manager, including: according to the five-tuple information of the network message, determining whether there is a corresponding entry of the network message in the connection mapping map manager; in the case where the network message is a link establishment message, if the corresponding entry does not exist in the connection mapping map manager, then create a corresponding entry in the connection mapping map manager, if the corresponding entry exists in the connection mapping map manager, then update the value of the corresponding entry according to the network message and the transmission control protocol connection status; in the case where the network message is a link disconnection message, if the corresponding entry does not exist in the connection mapping map manager, then skip the processing of the network message, if the corresponding entry exists in the connection mapping map manager, then delete the corresponding entry when the transmission control protocol connection status is closed, and update the value of the corresponding entry when the transmission control protocol connection status is other than closed; in the case where the network message is a data message, if the corresponding entry does not exist in the connection mapping map manager, then skip the processing of the network message, if the corresponding entry exists in the connection mapping map manager, then update the value of the corresponding entry according to the network message and the transmission control protocol connection status.

[0068] Step S305: delivering the second proxy message to the application program in the local application layer.

[0069] As an optional embodiment, delivering the second proxy message to an application program in a local application layer includes: delivering the second proxy message to a POSIX socket interface module, and the POSIX socket interface module delivering the second proxy message to the application program.

[0070] As an optional embodiment, the second message processing method also includes the following steps: when the message type of the network message is a non-transmission control protocol message, distributing the network message to the kernel protocol stack; processing the network message based on the kernel protocol stack, and passing the processed network message to the application.

[0071] Based on the above-mentioned message processing method 1 and message processing method 2, the present invention discloses a TCP proxy method and system based on a splitter. Optionally, the takeover of the operating system socket interface can be realized through the POSIX socket interface module, and the takeover action is only effective for a specific application; the TX splitter splits the message sent by the application, passes the TCP message to the TCP manager, and transparently transmits the non-TCP message to the kernel protocol stack; the TCP manager first updates the connection Maps according to the TCP message five-tuple information and the TCP connection status for the TCP data message sent or received by the application, and then the corresponding message manager performs corresponding operations on the message according to predetermined rules, and the operations include but are not limited to modifying the message, discarding the message, and transparently transmitting the message; the connection Maps stores the TCP connection status information to realize the sharing and interaction of kernel space and user space data; the RX splitter directly transparently transmits the received non-TCP message to the kernel protocol stack, and for the TCP message, first queries the connection information stored in the connection Maps according to the TCP message five-tuple information, if there is a corresponding connection entry, the message is passed to the TCP manager, and if there is no corresponding connection entry, the corresponding entry can be created. The above message processing method realizes a TCP proxy method that is not perceived by the upper-layer application and has no effect on non-TCP messages. The above method can be applied to the TCP client and / or TCP server separately or simultaneously without building a middleman node, realizing the takeover of the TCP protocol of a specific application, and the application method is flexible and controllable.

[0072] Figure 4 is a schematic diagram of the structure of an operating system provided according to an optional embodiment of the present invention, such as Figure 4 As shown, the operating system may include an interface module, a sending message splitter, a transmission control protocol manager and a fast data plane module.

[0073] in,

[0074] The interface module is used to receive the sending message transmitted by the application program, and transmit the sending message to the sending message splitter, and is also used to transmit the proxy message obtained by processing the network message to the application program.

[0075] Optionally, the interface module can be a POSIX socket interface module, which fully implements the POSIX socket interface function, is compiled into a dynamic link library, and uses the Linux operating system LD_PRELOAD mechanism. Only when the upper-layer application that needs to be taken over by the TCP proxy described in this embodiment is started, the Linux operating system socket interface is taken over, and the sending message of the application is internally directed to the TX splitter, and the message is submitted to the upper-layer application when the received network message arrives. There is no impact on other upper-layer applications that do not need to be taken over by the TCP proxy described in this embodiment.

[0076] The transmission message splitter is used to distribute the transmission message to the transmission control protocol manager when the transmission message is a transmission control protocol message. Optionally, the transmission message splitter can also distribute the transmission message to the kernel protocol stack when the transmission message is a non-transmission control protocol message.

[0077] Optionally, a transmit message splitter (TX splitter) may be composed of a message filter and a message distributor. When receiving a transmit message passed from a POSIX socket interface module, the message filter classifies the message, and the message distributor distributes the message. The message filter classifies messages according to the message protocol, specifically into two categories: TCP messages and non-TCP messages, and sets the corresponding message distribution destination according to the message classification. For TCP messages, the distribution destination is set to the TCP manager; for non-TCP messages, the distribution destination is set to the kernel protocol stack. The message distributor receives the message passed from the message filter and distributes the message according to the distribution destination. The message processing flow of the TX splitter is as follows:

[0078] In the first step, the message filter classifies and processes the messages. The distribution destination of non-TCP messages is set to the kernel protocol stack, and the distribution destination of TCP messages is set to the TCP manager.

[0079] In the second step, the message distributor distributes the messages according to the distribution destination, distributes the messages whose destination is the kernel protocol stack to the kernel protocol stack, and distributes the messages whose destination is the TCP manager to the TCP manager.

[0080] The Transmission Control Protocol Manager (TCP Manager) is used to process the sent message and obtain the proxy message corresponding to the sent message. It is also used to process the network message and obtain the proxy message corresponding to the network message.

[0081] Optionally, the TCP manager includes a TCP protocol state machine, a connection Maps manager, and at least one message processor. The TCP protocol state machine maintains the TCP connection state according to the TCP message interaction. The connection Maps manager provides a management / query interface for the connection Maps in the XDP module. There may be several message processors inside the TCP manager, each of which performs TCP stream matching based on the five-tuple information, and performs application layer message processing for the matching TCP stream according to preset rules, and its processing actions include but are not limited to modifying messages, discarding messages, and transparently transmitting messages.

[0082] The TCP manager processes the message transmitted by the TX splitter in the following way:

[0083] The first step is to receive the message passed by the TX splitter, and the TCP protocol state machine processes the message and maintains the internal TCP connection state according to the TCP protocol standard. The possible states are: [LISTEN, SYN-SENT, SYN-RCVD, ESTAB, CLOSE-WAIT, LAST-ACK, FIN-WAIT1, FIN-WAIT2, CLOSING, TIME-WAIT, CLOSED].

[0084] The second step is to extract the five-tuple information to construct the key, and perform the corresponding connection Maps operation through the connection Maps manager.

[0085] For link establishment messages, when the TCP state is one of [LISTEN, SYN-SENT, SYN-RCVD], first query the connection Maps. If there is no corresponding entry, create a new entry and initialize the value field value [pid, socket-fd, state, snd-time, rcv-time, snd-cnt, rcv-cnt]. Finally, insert the entry into the connection Maps; if there is a corresponding entry, update the entry value field value [state, snd-time, snd-cnt].

[0086] For broken link messages, first query the connection Maps. If there is no corresponding entry, skip it. If there is a corresponding entry, delete the entry when the TCP state is [CLOSED]. If the TCP state is other, update the entry value field value [state, snd-time, snd-cnt].

[0087] For data packets, if there is no corresponding entry, skip it; if there is a corresponding entry, update the entry value field value [snd-time, snd-cnt].

[0088] In the third step, the message processor matches the TCP stream according to the five-tuple information, and then processes the application layer message according to the preset rules. The processing methods include but are not limited to modifying the message, discarding the message, and transparently transmitting the message.

[0089] Optionally, the TCP manager processes the message transmitted by the receiving message splitter (RX splitter) as follows:

[0090] The first step is to receive the message passed by the RX splitter, and the TCP protocol state machine processes the message and maintains the internal TCP connection state according to the TCP protocol standard. The possible states are: [LISTEN, SYN-SENT, SYN-RCVD, ESTAB, CLOSE-WAIT, LAST-ACK, FIN-WAIT1, FIN-WAIT2, CLOSING, TIME-WAIT, CLOSED].

[0091] The second step is to extract the five-tuple information to construct the key, and perform the corresponding connection Maps operation through the connection Maps manager.

[0092] For link establishment messages, when the TCP state is one of [LISTEN, SYN-SENT, SYN-RCVD], first query the connection Maps. If there is no corresponding entry, create a new entry and initialize the value field value [pid, socket-fd, state, snd-time, rcv-time, snd-cnt, rcv-cnt]. Finally, insert the entry into the connection Maps; if there is a corresponding entry, update the entry value field value [state, rcv-time, rcv-cnt].

[0093] For broken link messages, first query the connection Maps. If there is no corresponding entry, skip it. If there is a corresponding entry, delete the entry when the TCP state is [CLOSED]. If the TCP state is other, update the entry value field value [state, rcv-time, rcv-cnt].

[0094] For data packets, if there is no corresponding entry, skip it; if there is a corresponding entry, update the entry value field value [rcv-time, rcv-cnt].

[0095] In the third step, the message processor matches the TCP stream according to the five-tuple information, and then processes the application layer message according to the preset rules. The processing methods include but are not limited to modifying the message, discarding the message, and transparently transmitting the message.

[0096] The fourth step is to pass the message to the POSIX socket interface module.

[0097] The fast data plane module (XDP module) includes a received message splitter, wherein the received message splitter is used to distribute the network message to the transmission control protocol manager when the network message is a transmission control protocol message. Optionally, the received message splitter can also distribute the network message to the kernel protocol stack when the network message is a non-transmission control protocol message.

[0098] Optionally, the XDP module can be composed of a connection Maps manager and an RX splitter. The XDP module is developed based on the XDP technology and runs in the kernel state. The connection Maps manager stores TCP connection information and provides data sharing and interaction channels between the kernel state and the user state. The RX splitter consists of a connection Maps queryer, a message filter, and a message distributor. The connection Maps manager provides a query / management connection Maps interface and performs connection Maps entry query and update operations based on the five-tuple information. The message filter classifies the message according to the message protocol and sets the message distribution destination. For non-TCP messages, the distribution destination is set to the kernel protocol stack; for TCP messages, the entries in the connection Maps are matched according to the five-tuple information. If there is no corresponding entry, the distribution destination is set to the kernel protocol stack. If there is a corresponding entry, the distribution destination is set to the TCP manager. The message distributor receives the message passed by the message filter and distributes the message according to the distribution destination.

[0099] When the RX splitter receives a network message, it processes the message. The process is as follows:

[0100] In the first step, the message filter classifies the messages, sets the distribution destination of non-TCP messages to the kernel protocol stack, and processes TCP messages in the next step.

[0101] The second step is to extract the five-tuple information of the TCP message, and query whether there is a corresponding entry in the connection map through the connection map queryer. If there is no corresponding entry, the message distribution destination is set to the kernel protocol stack; if there is a corresponding entry, the message distribution destination is set to the TCP manager, and the [rcv-time, rcv-cnt] field value in the entry is updated.

[0102] In the third step, the message distributor distributes the messages according to the message distribution purpose, distributes the messages whose destination is the kernel protocol stack to the kernel protocol stack, and distributes the messages whose destination is the TCP manager to the TCP manager.

[0103] In this embodiment, the XDP module is independently constructed and runs in the kernel space, and other modules are uniformly constructed and run in the user space. The two modules share and interact with each other through connection Maps, and finally realize the TCP proxy function.

[0104] The method and system described in this embodiment are directly applied to both ends of the TCP connection without building a middleman node, and the application mode is flexible and controllable; TCP proxy is performed for specific applications without affecting other applications in the system; the Linux socket interface is completely taken over without the upper-layer application being aware of it; only the TCP protocol stack is taken over without any impact on other protocol messages.

[0105] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0106] Through the description of the above implementation methods, those skilled in the art can clearly understand that the message processing method according to the above embodiment can be implemented by means of software plus a necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), including a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods of various embodiments of the present invention.

[0107] According to an embodiment of the present invention, there is also provided a message processing device 1 for implementing the above-mentioned message processing method 1. Figure 5 is a structural block diagram of a message processing device 1 provided according to an embodiment of the present invention, such as Figure 5 As shown, the message processing device 1 includes: a first receiving unit 51, a first processing unit 52, a second processing unit 53 and a first transmission unit 54. The message processing device 1 is described below.

[0108] The first receiving unit 51 is used to receive a sending message transmitted by an application program, wherein the application program is located in a local application layer.

[0109] The first processing unit 52 is connected to the first receiving unit 51, and is used to process the sent message to obtain the message type of the sent message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message.

[0110] The second processing unit 53 is connected to the first processing unit 52, and is used for, when the message type of the sending message is a transmission control protocol message, using a transmission control protocol manager to process the sending message to obtain a first proxy message corresponding to the sending message, wherein the transmission control protocol manager is set in the user space.

[0111] The first transmission unit 54 is connected to the second processing unit 53, and is used to transmit the first proxy message to the network card, wherein the network card is used to send the first proxy message to the target device.

[0112] It should be noted that the first receiving unit 51, the first processing unit 52, the second processing unit 53 and the first transmission unit 54 correspond to steps S201 to S204 in the embodiment, and the examples and application scenarios implemented by the multiple modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above embodiment. It should be noted that the above modules, as part of the device, can be run in the computer terminal 10 provided in the embodiment.

[0113] According to an embodiment of the present invention, a second message processing device for implementing the second message processing method is also provided. Figure 6 is a structural block diagram of a message processing device 2 provided according to an embodiment of the present invention, such as Figure 6 As shown, the message processing device 2 includes: a second receiving unit 61, a third processing unit 62, a determining unit 63, a fourth processing unit 64 and a second transmitting unit 65. The message processing device 2 is described below.

[0114] The second receiving unit 61 is used to receive the network message transmitted by the network card.

[0115] The third processing unit 62 is connected to the second receiving unit 61, and is used to process the network message to obtain the message type of the network message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message.

[0116] The determination unit 63 is connected to the third processing unit 62, and is used to distribute the network message to the transmission control protocol manager when the message type of the network message is a transmission control protocol message, wherein the transmission control protocol manager is set in the user space.

[0117] The fourth processing unit 64 is connected to the above-mentioned determination unit 63, and is used for using the transmission control protocol manager to process the network message to obtain a second proxy message corresponding to the network message.

[0118] The second transmission unit 65 is connected to the fourth processing unit 64, and is used to transmit the second proxy message to the application program in the local application layer.

[0119] It should be noted that the second receiving unit 61, the third processing unit 62, the determination unit 63, the fourth processing unit 64 and the second transmission unit 65 correspond to steps S301 to S305 in the embodiment, and the examples and application scenarios implemented by the multiple modules and the corresponding steps are the same, but are not limited to the contents disclosed in the above embodiment. It should be noted that the above modules as part of the device can be run in the computer terminal 10 provided in the embodiment.

[0120] An embodiment of the present invention may provide a computer device. Optionally, in this embodiment, the computer device may be located in at least one network device among multiple network devices of a computer network. The computer device includes a memory and a processor.

[0121] Among them, the memory can be used to store software programs and modules, such as the program instructions / modules corresponding to the message processing method and device in the embodiment of the present invention. The processor executes various functional applications and data processing by running the software programs and modules stored in the memory, that is, realizing the above-mentioned message processing method. The memory may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory may further include a memory remotely arranged relative to the processor, and these remote memories can be connected to the computer terminal via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0122] The processor can call the information and application stored in the memory through the transmission device to perform the following steps: receive a sending message transmitted by the application, wherein the application is located in the local application layer; process the sending message to obtain the message type of the sending message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message; when the message type of the sending message is a transmission control protocol message, use a transmission control protocol manager to process the sending message to obtain a first proxy message corresponding to the sending message, wherein the transmission control protocol manager is set in the user space; pass the first proxy message to the network card, wherein the network card is used to send the first proxy message to the target device.

[0123] Optionally, the processor may also execute the following program code: using a transmission control protocol manager to process a sending message to obtain a first proxy message corresponding to the sending message, including: processing the sending message according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection status in the transmission control protocol manager; controlling the transmission control protocol manager to update the connection mapping map manager according to the sending message and the transmission control protocol connection status, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; performing message processing on the sending message according to the connection mapping map manager and the five-tuple information of the sending message to obtain a first proxy message.

[0124] Optionally, the processor may also execute the following program code: according to the sent message and the transmission control protocol connection status, control the transmission control protocol manager to update the connection mapping map manager, including: according to the five-tuple information of the sent message, determine whether there is a corresponding entry for the sent message in the connection mapping map manager; in the case where the sent message is a link establishment message, if there is no corresponding entry in the connection mapping map manager, create a corresponding entry in the connection mapping map manager, if there is a corresponding entry in the connection mapping map manager, update the value of the corresponding entry according to the sent message; or, in the case where the sent message is a link break message, if there is no corresponding entry in the connection mapping map manager, skip processing the sent message, if there is a corresponding entry in the connection mapping map manager, delete the corresponding entry when the transmission control protocol connection status is closed, and update the value of the corresponding entry when the transmission control protocol connection status is other than closed; or, in the case where the sent message is a data message, if there is no corresponding entry in the connection mapping map manager, skip processing the sent message, if there is a corresponding entry in the connection mapping map manager, update the value of the corresponding entry according to the sent message.

[0125] Optionally, the processor may also execute program code for the following steps: receiving a sending message transmitted by an application, including: determining whether the application is a preset takeover application, wherein the preset takeover application is an application requesting a transmission control protocol proxy service; in the case where the application is a preset takeover application, using a POSIX socket interface module to receive the sending message, wherein the POSIX socket interface module is used to transmit messages between the local application layer and the transmission control protocol manager.

[0126] Optionally, the processor may also execute the following program code steps: when the message type of the sending message is a non-transmission control protocol message, distributing the sending message to the kernel protocol stack; processing the sending message based on the kernel protocol stack, and passing the processed sending message to the network card, wherein the network card is used to send the processed sending message to the target device.

[0127] The processor can also call the information and application programs stored in the memory through the transmission device to perform the following steps: receiving the network message transmitted by the network card; processing the network message to obtain the message type of the network message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message; when the message type of the network message is a transmission control protocol message, distributing the network message to a transmission control protocol manager, wherein the transmission control protocol manager is set in the user space; using the transmission control protocol manager to process the network message to obtain a second proxy message corresponding to the network message; and delivering the second proxy message to the application in the local application layer.

[0128] Optionally, the processor may also execute the following program code: using a transmission control protocol manager to process network messages to obtain a second proxy message corresponding to the network message, including: processing network messages according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection status in the transmission control protocol manager; controlling the transmission control protocol manager to update the connection mapping map manager according to the network message and the transmission control protocol connection status, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; performing message processing on the network message according to the connection mapping map manager and the five-tuple information of the network message to obtain a second proxy message.

[0129] Optionally, the processor may also execute the following program code: according to the network message and the transmission control protocol connection status, control the transmission control protocol manager to update the connection mapping map manager, including: according to the five-tuple information of the network message, determine whether there is a corresponding entry for the network message in the connection mapping map manager; in the case where the network message is a link establishment message, if there is no corresponding entry in the connection mapping map manager, create a corresponding entry in the connection mapping map manager; if there is a corresponding entry in the connection mapping map manager, update the value of the corresponding entry according to the network message and the transmission control protocol connection status; in In the case where the network message is a broken link message, if there is no corresponding entry in the connection mapping map manager, the processing of the network message is skipped; if there is a corresponding entry in the connection mapping map manager, the corresponding entry is deleted when the transmission control protocol connection status is closed, and the value of the corresponding entry is updated when the transmission control protocol connection status is other than closed; in the case where the network message is a data message, if there is no corresponding entry in the connection mapping map manager, the processing of the network message is skipped; if there is a corresponding entry in the connection mapping map manager, the value of the corresponding entry is updated according to the network message and the transmission control protocol connection status.

[0130] Optionally, the processor may also execute program code of the following steps: passing the second proxy message to an application in a local application layer, including: passing the second proxy message to a POSIX socket interface module, and the POSIX socket interface module passing the second proxy message to the application.

[0131] Optionally, the processor may also execute the following program code: when the message type of the network message is not a transmission control protocol message, distribute the network message to the kernel protocol stack; process the network message based on the kernel protocol stack, and pass the processed network message to the application.

[0132] A person of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing the hardware related to the terminal device through a program, and the program can be stored in a non-volatile storage medium, and the storage medium may include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0133] The embodiment of the present invention further provides a non-volatile storage medium. Optionally, in this embodiment, the non-volatile storage medium can be used to store the program code executed by the message processing method provided in the above embodiment.

[0134] Optionally, in this embodiment, the non-volatile storage medium may be located in any computer terminal in a computer terminal group in a computer network, or in any mobile terminal in a mobile terminal group.

[0135] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for performing the following steps: receiving a send message transmitted by an application, wherein the application is located at a local application layer; processing the send message to obtain a message type of the send message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message; in a case where the message type of the send message is a transmission control protocol message, using a transmission control protocol manager to process the send message to obtain a first proxy message corresponding to the send message, wherein the transmission control protocol manager is arranged in a user space; and passing the first proxy message to a network card, wherein the network card is used to send the first proxy message to a target device.

[0136] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: using a transmission control protocol manager to process a sending message to obtain a first proxy message corresponding to the sending message, including: processing the sending message according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection status in the transmission control protocol manager; controlling the transmission control protocol manager to update the connection mapping map manager according to the sending message and the transmission control protocol connection status, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; performing message processing on the sending message according to the connection mapping map manager and the five-tuple information of the sending message to obtain a first proxy message.

[0137] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: according to the sent message and the transmission control protocol connection status, control the transmission control protocol manager to update the connection mapping map manager, including: according to the five-tuple information of the sent message, determine whether there is a corresponding entry for the sent message in the connection mapping map manager; in the case where the sent message is a link establishment message, if there is no corresponding entry in the connection mapping map manager, create a corresponding entry in the connection mapping map manager; if there is a corresponding entry in the connection mapping map manager, update the corresponding entry according to the sent message. value; or, in the case where the sending message is a broken link message, if there is no corresponding entry in the connection mapping map manager, the processing of the sending message is skipped, if there is a corresponding entry in the connection mapping map manager, then the corresponding entry is deleted when the transmission control protocol connection state is closed, and the value of the corresponding entry is updated when the transmission control protocol connection state is other than closed; or, in the case where the sending message is a data message, if there is no corresponding entry in the connection mapping map manager, the processing of the sending message is skipped, if there is a corresponding entry in the connection mapping map manager, the value of the corresponding entry is updated according to the sending message.

[0138] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: receiving a sending message transmitted by an application, including: determining whether the application is a preset takeover application, wherein the preset takeover application is an application requesting a transmission control protocol proxy service; in the case that the application is a preset takeover application, using a POSIX socket interface module to receive the sending message, wherein the POSIX socket interface module is used to transmit messages between the local application layer and the transmission control protocol manager.

[0139] Optionally, in this embodiment, the non-volatile storage medium is configured to store program codes for executing the following steps: when the message type of the sending message is a non-transmission control protocol message, distributing the sending message to the kernel protocol stack; processing the sending message based on the kernel protocol stack, and passing the processed sending message to the network card, wherein the network card is used to send the processed sending message to the target device.

[0140] Optionally, in this embodiment, the non-volatile storage medium is configured to store program codes for executing the following steps: receiving a network message transmitted by a network card; processing the network message to obtain a message type of the network message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message; in the case where the message type of the network message is a transmission control protocol message, distributing the network message to a transmission control protocol manager, wherein the transmission control protocol manager is arranged in the user space; using the transmission control protocol manager to process the network message to obtain a second proxy message corresponding to the network message; and delivering the second proxy message to an application in the local application layer.

[0141] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: using a transmission control protocol manager to process network packets to obtain a second proxy packet corresponding to the network packet, including: processing the network packet according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection status in the transmission control protocol manager; controlling the transmission control protocol manager to update the connection mapping map manager according to the network packet and the transmission control protocol connection status, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; performing packet processing on the network packet according to the connection mapping map manager and the five-tuple information of the network packet to obtain the second proxy packet.

[0142] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: according to the network message and the transmission control protocol connection status, control the transmission control protocol manager to update the connection mapping map manager, including: according to the five-tuple information of the network message, determine whether there is a corresponding entry for the network message in the connection mapping map manager; in the case where the network message is a link establishment message, if there is no corresponding entry in the connection mapping map manager, create a corresponding entry in the connection mapping map manager; if there is a corresponding entry in the connection mapping map manager, update the corresponding entry according to the network message and the transmission control protocol connection status. the value of the corresponding entry; in the case that the network message is a broken link message, if there is no corresponding entry in the connection mapping map manager, the processing of the network message is skipped; if there is a corresponding entry in the connection mapping map manager, the corresponding entry is deleted when the transmission control protocol connection status is closed, and the value of the corresponding entry is updated when the transmission control protocol connection status is other than closed; in the case that the network message is a data message, if there is no corresponding entry in the connection mapping map manager, the processing of the network message is skipped; if there is a corresponding entry in the connection mapping map manager, the value of the corresponding entry is updated according to the network message and the transmission control protocol connection status.

[0143] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: passing the second proxy message to an application in the local application layer, including: passing the second proxy message to a POSIX socket interface module, and the POSIX socket interface module passing the second proxy message to the application.

[0144] Optionally, in this embodiment, the non-volatile storage medium is configured to store program code for executing the following steps: when the message type of the network message is a non-transmission control protocol message, distributing the network message to the kernel protocol stack; processing the network message based on the kernel protocol stack, and passing the processed network message to the application.

[0145] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0146] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0147] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0148] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.

[0149] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0150] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a non-volatile storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.

[0151] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.

Claims

1. A message processing method, characterized in that: include: receiving a sending message transmitted by an application program, wherein the application program is located in a local application layer; Processing the sent message to obtain a message type of the sent message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message; In the case where the message type of the sent message is a transmission control protocol message, a transmission control protocol manager is used to process the sent message to obtain a first proxy message corresponding to the sent message, wherein the transmission control protocol manager is set in a user space; The first proxy message is transmitted to a network card, wherein the network card is used to send the first proxy message to a target device.

2. The method according to claim 1, characterized in that The adopting a transmission control protocol manager to process the sending message to obtain a first proxy message corresponding to the sending message includes: Processing the transmission message according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection state in the transmission control protocol manager; According to the transmission message and the transmission control protocol connection state, control the transmission control protocol manager to update the connection mapping map manager, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; The sent message is processed according to the connection mapping map manager and the five-tuple information of the sent message to obtain the first proxy message.

3. The method according to claim 2, characterized in that The step of controlling the transmission control protocol manager to update the connection mapping map manager according to the sent message and the transmission control protocol connection state comprises: Determine, according to the five-tuple information of the sent message, whether there is a corresponding entry of the sent message in the connection mapping map manager; In the case where the sending message is a link establishment message, if the corresponding entry does not exist in the connection mapping map manager, then the corresponding entry is created in the connection mapping map manager; if the corresponding entry exists in the connection mapping map manager, then the value of the corresponding entry is updated according to the sending message and the transmission control protocol connection state; Alternatively, in the case where the sent message is a broken link message, if the corresponding entry does not exist in the connection mapping map manager, then the processing of the sent message is skipped; if the corresponding entry exists in the connection mapping map manager, then the corresponding entry is deleted when the transmission control protocol connection state is closed, and the value of the corresponding entry is updated when the transmission control protocol connection state is other than closed; Alternatively, in the case where the sending message is a data message, if the corresponding entry does not exist in the connection mapping map manager, the processing of the sending message is skipped; if the corresponding entry exists in the connection mapping map manager, the value of the corresponding entry is updated according to the sending message and the transmission control protocol connection status.

4. The method according to any one of claims 1 to 3, characterized in that The receiving application sends a message including: Determining whether the application is a preset takeover application, wherein the preset takeover application is an application requesting a transmission control protocol proxy service; In the case that the application is a preset takeover application, a POSIX socket interface module is used to receive the sent message, wherein the POSIX socket interface module is used to transfer messages between the local application layer and the transmission control protocol manager.

5. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: In the case where the message type of the sent message is a non-transmission control protocol message, distributing the sent message to a kernel protocol stack; The sending message is processed based on the kernel protocol stack, and the processed sending message is transferred to the network card, wherein the network card is used to send the processed sending message to the target device.

6. A message processing method, characterized in that: include: Receive network messages transmitted by the network card; Processing the network message to obtain a message type of the network message, wherein the message type includes a transmission control protocol message or a non-transmission control protocol message; In the case where the message type of the network message is a transmission control protocol message, the network message is distributed to a transmission control protocol manager, wherein the transmission control protocol manager is set in a user space; Processing the network message using the transmission control protocol manager to obtain a second proxy message corresponding to the network message; The second proxy message is delivered to an application program in a local application layer.

7. The method according to claim 6, characterized in that The adopting the transmission control protocol manager to process the network message to obtain a second proxy message corresponding to the network message includes: Processing the network message according to the protocol standard of the transmission control protocol, and maintaining the transmission control protocol connection state in the transmission control protocol manager; According to the network message and the transmission control protocol connection state, control the transmission control protocol manager to update the connection mapping map manager, wherein the connection mapping map manager is a fast data plane module component located in the kernel state; The network message is processed according to the connection mapping map manager and the five-tuple information of the network message to obtain the second proxy message.

8. The method according to claim 7, characterized in that According to the network message and the transmission control protocol connection state, controlling the transmission control protocol manager to update the connection mapping map manager includes: Determine, according to the five-tuple information of the network message, whether there is a corresponding entry of the network message in the connection mapping map manager; In the case where the network message is a link establishment message, if the corresponding entry does not exist in the connection mapping map manager, then create the corresponding entry in the connection mapping map manager; if the corresponding entry exists in the connection mapping map manager, then update the value of the corresponding entry according to the network message and the transmission control protocol connection state; In the case where the network message is a broken link message, if the corresponding entry does not exist in the connection mapping map manager, then the processing of the network message is skipped; if the corresponding entry exists in the connection mapping map manager, then the corresponding entry is deleted when the transmission control protocol connection state is closed, and the value of the corresponding entry is updated when the transmission control protocol connection state is other than closed; In the case that the network message is a data message, if the corresponding entry does not exist in the connection mapping map manager, the processing of the network message is skipped; if the corresponding entry exists in the connection mapping map manager, the value of the corresponding entry is updated according to the network message and the transmission control protocol connection status.

9. The method according to claim 6, characterized in that The delivering the second proxy message to the application program in the local application layer includes: The second proxy message is delivered to a POSIX socket interface module, and the POSIX socket interface module delivers the second proxy message to the application.

10. The method according to any one of claims 6 to 9, characterized in that The method further comprises: In the case where the message type of the network message is a non-transmission control protocol message, distributing the network message to a kernel protocol stack; The network message is processed based on the kernel protocol stack, and the processed network message is transmitted to the application program.

11. An operating system, characterized in that: include: An interface module, used for receiving a send message transmitted by an application program, and transmitting the send message to a send message splitter, and also used for transmitting a proxy message obtained by processing a network message to the application program; The transmission message splitter is used to distribute the transmission message to the transmission control protocol manager when the transmission message is a transmission control protocol message; A transmission control protocol manager, used to process the sent message to obtain a proxy message corresponding to the sent message, and also used to process the network message to obtain a proxy message corresponding to the network message; The fast data plane module comprises a received message splitter; wherein the received message splitter is used to distribute the network message to the transmission control protocol manager when the network message is a transmission control protocol message.

12. A non-volatile storage medium, characterized in that: The non-volatile storage medium includes a stored program, wherein when the program is running, the device where the non-volatile storage medium is located is controlled to execute the message processing method described in any one of claims 1 to 10.

13. A computer device, characterized in that: The computer device includes a memory and a processor, the memory is used to store programs, and the processor is used to run the programs stored in the memory, wherein the program executes the message processing method described in any one of claims 1 to 10 when it is run.

14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the message processing method according to any one of claims 1 to 10 are implemented.